VTK  9.3.0
vtkInteractorEventRecorder.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
35 #ifndef vtkInteractorEventRecorder_h
36 #define vtkInteractorEventRecorder_h
37 
38 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
39 #include "vtkInteractorObserver.h"
40 #include "vtkRenderingCoreModule.h" // For export macro
41 
42 VTK_ABI_NAMESPACE_BEGIN
43 class vtkStringArray;
44 
45 // The superclass that all commands should be subclasses of
46 class VTKRENDERINGCORE_EXPORT vtkInteractorEventRecorder : public vtkInteractorObserver
47 {
48 public:
51  void PrintSelf(ostream& os, vtkIndent indent) override;
52 
53  // enumeration of data type
54  enum class vtkEventDataType : int
55  {
56  None = 0,
57  StringArray
58  };
59 
60  // Satisfy the superclass API. Enable/disable listening for events.
61  void SetEnabled(int) override;
63 
65 
72 
78  void Record();
79 
85  void Play();
86 
90  void Stop();
91 
96  void Clear();
97 
101  void Rewind();
102 
104 
108  vtkSetMacro(ReadFromInputString, vtkTypeBool);
109  vtkGetMacro(ReadFromInputString, vtkTypeBool);
110  vtkBooleanMacro(ReadFromInputString, vtkTypeBool);
112 
114 
117  vtkSetStringMacro(InputString);
118  vtkGetStringMacro(InputString);
120 
121 protected:
124 
125  // file to read/write from
126  char* FileName;
127 
128  // listens to delete events
130 
131  // control whether to read from string
133  char* InputString;
134 
135  // for reading and writing
136  istream* InputStream;
137  ostream* OutputStream;
138 
139  // methods for processing events
140  static void ProcessCharEvent(
141  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
142  static void ProcessDeleteEvent(
143  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
144  static void ProcessEvents(
145  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
146 
147  virtual void WriteEvent(const char* event, int pos[2], int modifiers, int keyCode,
148  int repeatCount, char* keySym, void* callData = nullptr);
149 
151  "This method was not used at all and has been replaced by ReadEvent(const std::string&)")
152  virtual void ReadEvent(){};
153 
157  virtual void ReadEvent(const std::string& line);
158 
159  // Manage the state of the recorder
160  int State;
162  {
163  Start = 0,
165  Recording
166  };
167 
168  // Associate a modifier with a bit
170  {
171  ShiftKey = 1,
172  ControlKey = 2,
173  AltKey = 4
174  };
175 
176  static float StreamVersion;
178 
179 private:
181  void operator=(const vtkInteractorEventRecorder&) = delete;
182 };
183 
184 VTK_ABI_NAMESPACE_END
185 #endif /* vtkInteractorEventRecorder_h */
supports function callbacks
a simple class to control print indentation
Definition: vtkIndent.h:38
record and play VTK events passing through a vtkRenderWindowInteractor
virtual void ReadEvent(const std::string &line)
A method that parse a event line and invoke the corresponding event.
void Record()
Invoke this method to begin recording events.
vtkGetFilePathMacro(FileName)
Set/Get the name of a file events should be written to/from.
static void ProcessCharEvent(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
void SetEnabled(int) override
Methods for turning the interactor observer on and off, and determining its state.
void Rewind()
Rewind the play stream to the beginning of the file.
void Play()
Invoke this method to begin playing events from the current position.
void SetInteractor(vtkRenderWindowInteractor *iren) override
This method is used to associate the widget with the render window interactor.
virtual void WriteEvent(const char *event, int pos[2], int modifiers, int keyCode, int repeatCount, char *keySym, void *callData=nullptr)
~vtkInteractorEventRecorder() override
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static vtkInteractorEventRecorder * New()
void Stop()
Invoke this method to stop recording/playing events.
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
vtkSetFilePathMacro(FileName)
Set/Get the name of a file events should be written to/from.
static void ProcessDeleteEvent(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
void Clear()
Invoke this method to clear recording/playing stream and be able to open another file using the same ...
vtkCallbackCommand * DeleteEventCallbackCommand
an abstract superclass for classes observing events invoked by vtkRenderWindowInteractor
abstract base class for most VTK objects
Definition: vtkObject.h:61
platform-independent render window interaction including picking and frame rate control.
a vtkAbstractArray subclass for strings
@ string
Definition: vtkX3D.h:490
int vtkTypeBool
Definition: vtkABI.h:64
#define VTK_DEPRECATED_IN_9_2_0(reason)