1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: vtkInteractorEventRecorder.h,v $
6 Date: $Date: 2002/08/15 15:38:34 $
7 Version: $Revision: 1.4 $
9 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
11 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notice for more information.
17 =========================================================================*/
18 // .NAME vtkInteractorEventRecorder - record and play VTK events passing through a vtkRenderWindowInteractor
20 // .SECTION Description
21 // vtkInteractorEventRecorder records all VTK events invoked from a
22 // vtkRenderWindowInteractor. The events are recorded to a
23 // file. vtkInteractorEventRecorder can also be used to play those events
24 // back and invoke them on an vtkRenderWindowInteractor. (Note: the events
25 // can also be played back from a file or string.)
27 // The format of the event file is simple. It is:
28 // EventName X Y ctrl shift keycode repeatCount keySym
29 // The format also allows "#" comments.
32 // vtkInteractorObserver vtkCallback
34 #ifndef __vtkInteractorEventRecorder_h
35 #define __vtkInteractorEventRecorder_h
37 #include "vtkInteractorObserver.h"
39 // The superclass that all commands should be subclasses of
40 class VTK_RENDERING_EXPORT vtkInteractorEventRecorder : public vtkInteractorObserver
43 static vtkInteractorEventRecorder *New();
44 vtkTypeRevisionMacro(vtkInteractorEventRecorder,vtkInteractorObserver);
45 void PrintSelf(ostream& os, vtkIndent indent);
47 // Satisfy the superclass API. Enable/disable listening for events.
48 virtual void SetEnabled(int);
49 virtual void SetInteractor(vtkRenderWindowInteractor* iren);
52 // Set/Get the name of a file events should be written to/from.
53 vtkSetStringMacro(FileName);
54 vtkGetStringMacro(FileName);
57 // Invoke this method to begin recording events. The events will be
58 // recorded to the filename indicated.
62 // Invoke this method to begin playing events from the current position.
63 // The events will be played back from the filename indicated.
67 // Invoke this method to stop recording/playing events.
71 // Rewind to the beginning of the file.
75 // Enable reading from an InputString as compared to the default
76 // behavior, which is to read from a file.
77 vtkSetMacro(ReadFromInputString,int);
78 vtkGetMacro(ReadFromInputString,int);
79 vtkBooleanMacro(ReadFromInputString,int);
82 // Set/Get the string to read from.
83 vtkSetStringMacro(InputString);
84 vtkGetStringMacro(InputString);
87 vtkInteractorEventRecorder();
88 ~vtkInteractorEventRecorder();
90 // file to read/write from
93 // control whether to read from string
94 int ReadFromInputString;
97 // for reading and writing
99 ostream *OutputStream;
101 //methods for processing events
102 static void ProcessCharEvent(vtkObject* object, unsigned long event,
103 void* clientdata, void* calldata);
104 static void ProcessEvents(vtkObject* object, unsigned long event,
105 void* clientdata, void* calldata);
107 virtual void WriteEvent(const char* event, int pos[2], int ctrlKey,
108 int shiftKey, int keyCode, int repeatCount,
111 virtual void ReadEvent();
113 //BTX - manage the state of the recorder
123 static float StreamVersion;
126 vtkInteractorEventRecorder(const vtkInteractorEventRecorder&); // Not implemented.
127 void operator=(const vtkInteractorEventRecorder&); // Not implemented.
131 #endif /* __vtkInteractorEventRecorder_h */