VTK  9.3.20240328
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 "vtkInteractorObserver.h"
39 #include "vtkRenderingCoreModule.h" // For export macro
40 
41 VTK_ABI_NAMESPACE_BEGIN
42 class vtkStringArray;
43 
44 // The superclass that all commands should be subclasses of
45 class VTKRENDERINGCORE_EXPORT vtkInteractorEventRecorder : public vtkInteractorObserver
46 {
47 public:
50  void PrintSelf(ostream& os, vtkIndent indent) override;
51 
52  // enumeration of data type
53  enum class vtkEventDataType : int
54  {
55  None = 0,
56  StringArray
57  };
58 
59  // Satisfy the superclass API. Enable/disable listening for events.
60  void SetEnabled(int) override;
62 
64 
71 
77  void Record();
78 
84  void Play();
85 
89  void Stop();
90 
95  void Clear();
96 
100  void Rewind();
101 
103 
107  vtkSetMacro(ReadFromInputString, vtkTypeBool);
108  vtkGetMacro(ReadFromInputString, vtkTypeBool);
109  vtkBooleanMacro(ReadFromInputString, vtkTypeBool);
111 
113 
116  vtkSetStringMacro(InputString);
117  vtkGetStringMacro(InputString);
119 
120 protected:
123 
124  // file to read/write from
125  char* FileName;
126 
127  // listens to delete events
129 
130  // control whether to read from string
132  char* InputString;
133 
134  // for reading and writing
135  istream* InputStream;
136  ostream* OutputStream;
137 
138  // methods for processing events
139  static void ProcessCharEvent(
140  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
141  static void ProcessDeleteEvent(
142  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
143  static void ProcessEvents(
144  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
145 
146  virtual void WriteEvent(const char* event, int pos[2], int modifiers, int keyCode,
147  int repeatCount, char* keySym, void* callData = nullptr);
148 
152  virtual void ReadEvent(const std::string& line);
153 
154  // Manage the state of the recorder
155  int State;
157  {
158  Start = 0,
160  Recording
161  };
162 
163  // Associate a modifier with a bit
165  {
166  ShiftKey = 1,
167  ControlKey = 2,
168  AltKey = 4
169  };
170 
171  static float StreamVersion;
173 
174 private:
176  void operator=(const vtkInteractorEventRecorder&) = delete;
177 };
178 
179 VTK_ABI_NAMESPACE_END
180 #endif /* vtkInteractorEventRecorder_h */
supports function callbacks
a simple class to control print indentation
Definition: vtkIndent.h:108
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:161
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