File: vtkInteractorEventRecorder.h

package info (click to toggle)
vtk 5.0.4-1.1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 51,084 kB
  • ctags: 70,426
  • sloc: cpp: 524,166; ansic: 220,276; tcl: 43,377; python: 14,037; perl: 3,102; java: 1,436; yacc: 1,033; sh: 339; lex: 248; makefile: 197; asm: 154
file content (129 lines) | stat: -rw-r--r-- 4,097 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    $RCSfile: vtkInteractorEventRecorder.h,v $

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
// .NAME vtkInteractorEventRecorder - record and play VTK events passing through a vtkRenderWindowInteractor

// .SECTION Description
// vtkInteractorEventRecorder records all VTK events invoked from a
// vtkRenderWindowInteractor. The events are recorded to a
// file. vtkInteractorEventRecorder can also be used to play those events
// back and invoke them on an vtkRenderWindowInteractor. (Note: the events
// can also be played back from a file or string.)
//
// The format of the event file is simple. It is:
//  EventName X Y ctrl shift keycode repeatCount keySym
// The format also allows "#" comments.

// .SECTION See Also
// vtkInteractorObserver vtkCallback

#ifndef __vtkInteractorEventRecorder_h
#define __vtkInteractorEventRecorder_h

#include "vtkInteractorObserver.h"

// The superclass that all commands should be subclasses of
class VTK_RENDERING_EXPORT vtkInteractorEventRecorder : public vtkInteractorObserver
{
public:
  static vtkInteractorEventRecorder *New();
  vtkTypeRevisionMacro(vtkInteractorEventRecorder,vtkInteractorObserver);
  void PrintSelf(ostream& os, vtkIndent indent);

  // Satisfy the superclass API. Enable/disable listening for events.
  virtual void SetEnabled(int);
  virtual void SetInteractor(vtkRenderWindowInteractor* iren);

  // Description:
  // Set/Get the name of a file events should be written to/from.
  vtkSetStringMacro(FileName);
  vtkGetStringMacro(FileName);

  // Description:
  // Invoke this method to begin recording events. The events will be
  // recorded to the filename indicated.
  void Record();

  // Description:
  // Invoke this method to begin playing events from the current position.
  // The events will be played back from the filename indicated.
  void Play();

  // Description:
  // Invoke this method to stop recording/playing events.
  void Stop();

  // Description:
  // Rewind to the beginning of the file.
  void Rewind();

  // Description:
  // Enable reading from an InputString as compared to the default
  // behavior, which is to read from a file.
  vtkSetMacro(ReadFromInputString,int);
  vtkGetMacro(ReadFromInputString,int);
  vtkBooleanMacro(ReadFromInputString,int);

  // Description:
  // Set/Get the string to read from.
  vtkSetStringMacro(InputString);
  vtkGetStringMacro(InputString);

protected:
  vtkInteractorEventRecorder();
  ~vtkInteractorEventRecorder();

  // file to read/write from
  char *FileName;
  
  // control whether to read from string
  int ReadFromInputString;
  char *InputString;

  // for reading and writing
  istream *InputStream;
  ostream *OutputStream;

  //methods for processing events
  static void ProcessCharEvent(vtkObject* object, unsigned long event,
                               void* clientdata, void* calldata);
  static void ProcessEvents(vtkObject* object, unsigned long event,
                            void* clientdata, void* calldata);

  virtual void WriteEvent(const char* event, int pos[2], int ctrlKey,
                          int shiftKey, int keyCode, int repeatCount,
                          char* keySym);
  
  virtual void ReadEvent();

//BTX - manage the state of the recorder
  int State;
  enum WidgetState
  {
    Start=0,
    Playing,
    Recording
  };
//ETX

  static float StreamVersion;

private:
  vtkInteractorEventRecorder(const vtkInteractorEventRecorder&);  // Not implemented.
  void operator=(const vtkInteractorEventRecorder&);  // Not implemented.
  
};

#endif /* __vtkInteractorEventRecorder_h */