VTK  9.2.5
vtkInteractorEventRecorder.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkInteractorEventRecorder.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
47 #ifndef vtkInteractorEventRecorder_h
48 #define vtkInteractorEventRecorder_h
49 
50 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
51 #include "vtkInteractorObserver.h"
52 #include "vtkRenderingCoreModule.h" // For export macro
53 
54 class vtkStringArray;
55 
56 // The superclass that all commands should be subclasses of
57 class VTKRENDERINGCORE_EXPORT vtkInteractorEventRecorder : public vtkInteractorObserver
58 {
59 public:
62  void PrintSelf(ostream& os, vtkIndent indent) override;
63 
64  // enumeration of data type
65  enum class vtkEventDataType : int
66  {
67  None = 0,
68  StringArray
69  };
70 
71  // Satisfy the superclass API. Enable/disable listening for events.
72  void SetEnabled(int) override;
74 
76 
83 
89  void Record();
90 
96  void Play();
97 
101  void Stop();
102 
107  void Clear();
108 
112  void Rewind();
113 
115 
119  vtkSetMacro(ReadFromInputString, vtkTypeBool);
120  vtkGetMacro(ReadFromInputString, vtkTypeBool);
121  vtkBooleanMacro(ReadFromInputString, vtkTypeBool);
123 
125 
128  vtkSetStringMacro(InputString);
129  vtkGetStringMacro(InputString);
131 
132 protected:
135 
136  // file to read/write from
137  char* FileName;
138 
139  // listens to delete events
141 
142  // control whether to read from string
144  char* InputString;
145 
146  // for reading and writing
147  istream* InputStream;
148  ostream* OutputStream;
149 
150  // methods for processing events
151  static void ProcessCharEvent(
152  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
153  static void ProcessDeleteEvent(
154  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
155  static void ProcessEvents(
156  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
157 
158  virtual void WriteEvent(const char* event, int pos[2], int modifiers, int keyCode,
159  int repeatCount, char* keySym, void* callData = nullptr);
160 
162  "This method was not used at all and has been replaced by ReadEvent(const std::string&)")
163  virtual void ReadEvent(){};
164 
168  virtual void ReadEvent(const std::string& line);
169 
170  // Manage the state of the recorder
171  int State;
173  {
174  Start = 0,
176  Recording
177  };
178 
179  // Associate a modifier with a bit
181  {
182  ShiftKey = 1,
183  ControlKey = 2,
184  AltKey = 4
185  };
186 
187  static float StreamVersion;
189 
190 private:
192  void operator=(const vtkInteractorEventRecorder&) = delete;
193 };
194 
195 #endif /* vtkInteractorEventRecorder_h */
supports function callbacks
a simple class to control print indentation
Definition: vtkIndent.h:119
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:82
platform-independent render window interaction including picking and frame rate control.
a vtkAbstractArray subclass for strings
@ string
Definition: vtkX3D.h:496
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_DEPRECATED_IN_9_2_0(reason)