VTK  9.0.1
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 =========================================================================*/
34 #ifndef vtkInteractorEventRecorder_h
35 #define vtkInteractorEventRecorder_h
36 
37 #include "vtkInteractorObserver.h"
38 #include "vtkRenderingCoreModule.h" // For export macro
39 
40 // The superclass that all commands should be subclasses of
41 class VTKRENDERINGCORE_EXPORT vtkInteractorEventRecorder : public vtkInteractorObserver
42 {
43 public:
46  void PrintSelf(ostream& os, vtkIndent indent) override;
47 
48  // Satisfy the superclass API. Enable/disable listening for events.
49  void SetEnabled(int) override;
51 
53 
56  vtkSetStringMacro(FileName);
57  vtkGetStringMacro(FileName);
59 
64  void Record();
65 
70  void Play();
71 
75  void Stop();
76 
80  void Rewind();
81 
83 
87  vtkSetMacro(ReadFromInputString, vtkTypeBool);
88  vtkGetMacro(ReadFromInputString, vtkTypeBool);
89  vtkBooleanMacro(ReadFromInputString, vtkTypeBool);
91 
93 
96  vtkSetStringMacro(InputString);
97  vtkGetStringMacro(InputString);
99 
100 protected:
103 
104  // file to read/write from
105  char* FileName;
106 
107  // listens to delete events
109 
110  // control whether to read from string
112  char* InputString;
113 
114  // for reading and writing
115  istream* InputStream;
116  ostream* OutputStream;
117 
118  // methods for processing events
119  static void ProcessCharEvent(
120  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
121  static void ProcessDeleteEvent(
122  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
123  static void ProcessEvents(
124  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
125 
126  virtual void WriteEvent(
127  const char* event, int pos[2], int modifiers, int keyCode, int repeatCount, char* keySym);
128 
129  virtual void ReadEvent();
130 
131  // Manage the state of the recorder
132  int State;
134  {
135  Start = 0,
137  Recording
138  };
139 
140  // Associate a modifier with a bit
142  {
143  ShiftKey = 1,
144  ControlKey = 2,
145  AltKey = 4
146  };
147 
148  static float StreamVersion;
149 
150 private:
152  void operator=(const vtkInteractorEventRecorder&) = delete;
153 };
154 
155 #endif /* vtkInteractorEventRecorder_h */
supports function callbacks
a simple class to control print indentation
Definition: vtkIndent.h:34
record and play VTK events passing through a vtkRenderWindowInteractor
void Record()
Invoke this method to begin recording events.
virtual void WriteEvent(const char *event, int pos[2], int modifiers, int keyCode, int repeatCount, char *keySym)
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 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.
~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)
static void ProcessDeleteEvent(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
vtkCallbackCommand * DeleteEventCallbackCommand
an abstract superclass for classes observing events invoked by vtkRenderWindowInteractor
abstract base class for most VTK objects
Definition: vtkObject.h:54
platform-independent render window interaction including picking and frame rate control.
int vtkTypeBool
Definition: vtkABI.h:69