OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / I386LINUX / util / I386LINUX / include / vtk / vtkInteractorEventRecorder.h
1 /*=========================================================================
2
3   Program:   Visualization Toolkit
4   Module:    $RCSfile: vtkInteractorEventRecorder.h,v $
5   Language:  C++
6   Date:      $Date: 2002/08/15 15:38:34 $
7   Version:   $Revision: 1.4 $
8
9   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
10   All rights reserved.
11   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
12
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notice for more information.
16
17 =========================================================================*/
18 // .NAME vtkInteractorEventRecorder - record and play VTK events passing through a vtkRenderWindowInteractor
19
20 // .SECTION Description
21 // vtkInteractorEventRecorder records all VTK events invoked from a
22 // vtkRenderWindowInteractor. The events are recorded to a
23 // file. vtkInteractorEventRecorder can also be used to play those events
24 // back and invoke them on an vtkRenderWindowInteractor. (Note: the events
25 // can also be played back from a file or string.)
26 //
27 // The format of the event file is simple. It is:
28 //  EventName X Y ctrl shift keycode repeatCount keySym
29 // The format also allows "#" comments.
30
31 // .SECTION See Also
32 // vtkInteractorObserver vtkCallback
33
34 #ifndef __vtkInteractorEventRecorder_h
35 #define __vtkInteractorEventRecorder_h
36
37 #include "vtkInteractorObserver.h"
38
39 // The superclass that all commands should be subclasses of
40 class VTK_RENDERING_EXPORT vtkInteractorEventRecorder : public vtkInteractorObserver
41 {
42 public:
43   static vtkInteractorEventRecorder *New();
44   vtkTypeRevisionMacro(vtkInteractorEventRecorder,vtkInteractorObserver);
45   void PrintSelf(ostream& os, vtkIndent indent);
46
47   // Satisfy the superclass API. Enable/disable listening for events.
48   virtual void SetEnabled(int);
49   virtual void SetInteractor(vtkRenderWindowInteractor* iren);
50
51   // Description:
52   // Set/Get the name of a file events should be written to/from.
53   vtkSetStringMacro(FileName);
54   vtkGetStringMacro(FileName);
55
56   // Description:
57   // Invoke this method to begin recording events. The events will be
58   // recorded to the filename indicated.
59   void Record();
60
61   // Description:
62   // Invoke this method to begin playing events from the current position.
63   // The events will be played back from the filename indicated.
64   void Play();
65
66   // Description:
67   // Invoke this method to stop recording/playing events.
68   void Stop();
69
70   // Description:
71   // Rewind to the beginning of the file.
72   void Rewind();
73
74   // Description:
75   // Enable reading from an InputString as compared to the default
76   // behavior, which is to read from a file.
77   vtkSetMacro(ReadFromInputString,int);
78   vtkGetMacro(ReadFromInputString,int);
79   vtkBooleanMacro(ReadFromInputString,int);
80
81   // Description:
82   // Set/Get the string to read from.
83   vtkSetStringMacro(InputString);
84   vtkGetStringMacro(InputString);
85
86 protected:
87   vtkInteractorEventRecorder();
88   ~vtkInteractorEventRecorder();
89
90   // file to read/write from
91   char *FileName;
92   
93   // control whether to read from string
94   int ReadFromInputString;
95   char *InputString;
96
97   // for reading and writing
98   istream *InputStream;
99   ostream *OutputStream;
100
101   //methods for processing events
102   static void ProcessCharEvent(vtkObject* object, unsigned long event,
103                                void* clientdata, void* calldata);
104   static void ProcessEvents(vtkObject* object, unsigned long event,
105                             void* clientdata, void* calldata);
106
107   virtual void WriteEvent(const char* event, int pos[2], int ctrlKey,
108                           int shiftKey, int keyCode, int repeatCount,
109                           char* keySym);
110   
111   virtual void ReadEvent();
112
113 //BTX - manage the state of the recorder
114   int State;
115   enum WidgetState
116   {
117     Start=0,
118     Playing,
119     Recording
120   };
121 //ETX
122
123   static float StreamVersion;
124
125 private:
126   vtkInteractorEventRecorder(const vtkInteractorEventRecorder&);  // Not implemented.
127   void operator=(const vtkInteractorEventRecorder&);  // Not implemented.
128   
129 };
130
131 #endif /* __vtkInteractorEventRecorder_h */
132