VTK  9.4.20250206
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
39#include "vtkRenderingCoreModule.h" // For export macro
40
41#include "vtkNew.h" // vtkNew
42
43VTK_ABI_NAMESPACE_BEGIN
44
45class vtkActor2D;
46class vtkStringArray;
47
48// The superclass that all commands should be subclasses of
49class VTKRENDERINGCORE_EXPORT vtkInteractorEventRecorder : public vtkInteractorObserver
50{
51public:
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;
66
68
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
137protected:
140
141 // file to read/write from
142 char* FileName;
143
144 // listens to delete events
146
147 // control whether to read from string
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);
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
191private:
193 void operator=(const vtkInteractorEventRecorder&) = delete;
194
195 bool ShowCursor = false;
196 vtkNew<vtkActor2D> CursorActor;
197};
198
199VTK_ABI_NAMESPACE_END
200#endif /* vtkInteractorEventRecorder_h */
a actor that draws 2D data
Definition vtkActor2D.h:145
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.
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
static vtkInteractorEventRecorder * New()
an abstract superclass for classes observing events invoked by vtkRenderWindowInteractor
Allocate and hold a VTK object.
Definition vtkNew.h:167
abstract base class for most VTK objects
Definition vtkObject.h:162
platform-independent render window interaction including picking and frame rate control.
a vtkAbstractArray subclass for strings
int vtkTypeBool
Definition vtkABI.h:64
@ None
!< For HCURL