00001
00002
00003
00004
00005
00006
00007
00008
00010
00011 #ifndef WXVTKINTERACTOREVENTRECORDER_H
00012 #define WXVTKINTERACTOREVENTRECORDER_H
00013
00014 #ifdef __GNUG__
00015 #pragma interface "VtkInteractorEventRecorder.h"
00016 #endif
00017
00018 #include <wxGuiTest/Common.h>
00019
00020 #include <list>
00021 #include <map>
00022
00023 #include <vtkInteractorObserver.h>
00024
00025 class wxVTKRenderWindowInteractor;
00026 class vtkCamera;
00027
00028 namespace wxTst {
00029
00030
00047 class WxVtkInteractorEventRecorder : public vtkInteractorObserver
00048 {
00049 public:
00050
00051 typedef std::list< wxSize > SizeList;
00052 struct WxVtkStruct {
00053
00054 wxPoint position;
00055 SizeList sizeList;
00056 vtkCamera *camera;
00057 wxVTKRenderWindowInteractor *wxVtkRwi;
00058
00059 };
00060 typedef WxVtkStruct WxVtk;
00061
00062 typedef std::map < wxString, WxVtk * > WxVtkMap;
00063
00064 public:
00065 static WxVtkInteractorEventRecorder * New ();
00066 vtkTypeRevisionMacro (WxVtkInteractorEventRecorder, vtkInteractorObserver);
00067 void PrintSelf (ostream &os, vtkIndent indent);
00068
00069
00070 virtual void SetEnabled (int);
00071 virtual void SetInteractor (vtkRenderWindowInteractor *iren);
00072
00073 virtual void AddInteractor (const wxString &wxVtkId,
00074 wxVTKRenderWindowInteractor *wxVtkRwi);
00075
00076
00077
00078 vtkSetStringMacro (FileName);
00079 vtkGetStringMacro (FileName);
00080
00081
00082
00083
00084 void Record ();
00085
00086
00087
00088
00089 void Play ();
00090
00091
00092
00093 void Stop ();
00094
00095
00096
00097 void Rewind ();
00098
00099 bool HasInputStream () const;
00100
00101
00102 bool IsEmptyRecording () const;
00103
00104 wxString GetRecordingAsEmitString (const wxString &tab) const;
00105
00106 void ResetRecording ();
00107
00108
00109 virtual wxVTKRenderWindowInteractor * GetInteractor (
00110 const wxString &wxVtkId) const;
00111
00112
00113 void RestoreWxVtkSettings ();
00114
00115
00116 const WxVtkMap & GetWxVtkMap () const;
00117
00118
00119
00120
00121 vtkSetMacro (ReadFromInputString, int);
00122 vtkGetMacro (ReadFromInputString, int);
00123 vtkBooleanMacro (ReadFromInputString, int);
00124
00125
00126
00127 vtkSetStringMacro (InputString);
00128 vtkGetStringMacro (InputString);
00129
00130 protected:
00134 WxVtkInteractorEventRecorder ();
00135
00136
00140 virtual ~WxVtkInteractorEventRecorder ();
00141
00142
00143 static void ProcessCharEvent (vtkObject *object, unsigned long event,
00144 void *clientdata, void *calldata);
00145 static void ProcessEvents (vtkObject *object, unsigned long event,
00146 void *clientdata, void *calldata);
00147
00148 virtual void WriteEvent (const char *event, int pos[2], int ctrlKey,
00149 int shiftKey, int keyCode, int repeatCount, char *keySym,
00150 const char *wxVtkId);
00151
00152 virtual void ReadEvent();
00153
00154
00155 char *FileName;
00156
00157
00158 int ReadFromInputString;
00159 char *InputString;
00160
00161
00162 istream *InputStream;
00163 ostream *OutputStream;
00164
00165
00166 int State;
00167 enum WidgetState {
00168 Start=0,
00169 Playing,
00170 Recording
00171 };
00172
00173
00174 static float StreamVersion;
00175
00176
00177 virtual wxString GetInteractorId (
00178 wxVTKRenderWindowInteractor *wxVtkRwi) const;
00179
00180 virtual void ClearInteractors ();
00181
00182 WxVtkMap m_wxVtkMap;
00183
00184 private:
00185
00186 WxVtkInteractorEventRecorder (const WxVtkInteractorEventRecorder &rhs);
00187 WxVtkInteractorEventRecorder & operator= (const WxVtkInteractorEventRecorder &rhs);
00188 };
00189
00190 }
00191
00192 #endif // WXVTKINTERACTOREVENTRECORDER_H