VTK  9.7.1
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 #include "vtkNew.h" // vtkNew
42 
43 VTK_ABI_NAMESPACE_BEGIN
44 
45 class vtkActor2D;
46 class vtkStringArray;
47 
48 // The superclass that all commands should be subclasses of
49 class VTKRENDERINGCORE_EXPORT vtkInteractorEventRecorder : public vtkInteractorObserver
50 {
51 public:
54  void PrintSelf(ostream& os, vtkIndent indent) override;
55 
56  // enumeration of data type
57  enum class vtkEventDataType : int
58  {
59  None = 0,
60  StringArray
61  };
62 
63  // Satisfy the superclass API. Enable/disable listening for events.
64  void SetEnabled(int) override;
65  void SetInteractor(vtkRenderWindowInteractor* iren) override;
66 
68 
72  vtkSetFilePathMacro(FileName);
73  vtkGetFilePathMacro(FileName);
75 
81  void Record();
82 
88  void Play();
89 
93  void Stop();
94 
99  void Clear();
100 
104  void Rewind();
105 
107 
111  vtkSetMacro(ReadFromInputString, vtkTypeBool);
112  vtkGetMacro(ReadFromInputString, vtkTypeBool);
113  vtkBooleanMacro(ReadFromInputString, vtkTypeBool);
115 
117 
120  vtkSetStringMacro(InputString);
121  vtkGetStringMacro(InputString);
123 
125 
132  vtkSetMacro(ShowCursor, bool);
133  vtkGetMacro(ShowCursor, bool);
134  vtkBooleanMacro(ShowCursor, bool);
136 
137 protected:
139  ~vtkInteractorEventRecorder() override;
140 
141  // file to read/write from
142  char* FileName;
143 
144  // listens to delete events
146 
147  // control whether to read from string
149  char* InputString;
150 
151  // for reading and writing
152  istream* InputStream;
153  ostream* OutputStream;
154 
155  // methods for processing events
156  static void ProcessCharEvent(
157  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
158  static void ProcessDeleteEvent(
159  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
160  static void ProcessEvents(
161  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
162 
163  virtual void WriteEvent(const char* event, int pos[2], int modifiers, int keyCode,
164  int repeatCount, char* keySym, void* callData = nullptr);
165 
169  virtual void ReadEvent(const std::string& line);
170 
171  // Manage the state of the recorder
172  int State;
174  {
175  Start = 0,
177  Recording
178  };
179 
180  // Associate a modifier with a bit
182  {
183  ShiftKey = 1,
184  ControlKey = 2,
185  AltKey = 4
186  };
187 
188  static float StreamVersion;
190 
191 private:
193  void operator=(const vtkInteractorEventRecorder&) = delete;
194 
195  bool ShowCursor = false;
196  vtkNew<vtkActor2D> CursorActor;
197 };
198 
199 VTK_ABI_NAMESPACE_END
200 #endif /* vtkInteractorEventRecorder_h */
virtual void SetInteractor(vtkRenderWindowInteractor *iren)
This method is used to associate the widget with the render window interactor.
abstract base class for most VTK objects
Definition: vtkObject.h:52
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Handles the char widget activation event.
a actor that draws 2D data
Definition: vtkActor2D.h:35
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
a vtkAbstractArray subclass for strings
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
an abstract superclass for classes observing events invoked by vtkRenderWindowInteractor ...
int vtkTypeBool
Definition: vtkABI.h:64
platform-independent render window interaction including picking and frame rate control.
supports function callbacks
a simple class to control print indentation
Definition: vtkIndent.h:28
!< For HCURL
vtkCallbackCommand * DeleteEventCallbackCommand
record and play VTK events passing through a vtkRenderWindowInteractor
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...