VTK  9.3.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 "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;
62  void SetInteractor(vtkRenderWindowInteractor* iren) override;
63 
65 
69  vtkSetFilePathMacro(FileName);
70  vtkGetFilePathMacro(FileName);
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:
123  ~vtkInteractorEventRecorder() override;
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 */
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:51
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Handles the char widget activation event.
#define VTK_DEPRECATED_IN_9_2_0(reason)
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
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...