00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00052 #ifndef __vtkRenderWindowInteractor_h
00053 #define __vtkRenderWindowInteractor_h
00054
00055 #include "vtkObject.h"
00056
00057 class vtkTimerIdMap;
00058
00059
00060
00061 #define VTKI_TIMER_FIRST 0
00062 #define VTKI_TIMER_UPDATE 1
00063
00064 class vtkAbstractPicker;
00065 class vtkAbstractPropPicker;
00066 class vtkInteractorObserver;
00067 class vtkRenderWindow;
00068 class vtkRenderer;
00069 class vtkObserverMediator;
00070 class vtkInteractorEventRecorder;
00071
00072 class VTK_RENDERING_EXPORT vtkRenderWindowInteractor : public vtkObject
00073 {
00074
00075 friend class vtkInteractorEventRecorder;
00076
00077 public:
00078 static vtkRenderWindowInteractor *New();
00079 vtkTypeRevisionMacro(vtkRenderWindowInteractor,vtkObject);
00080 void PrintSelf(ostream& os, vtkIndent indent);
00081
00083
00085 virtual void Initialize();
00086 void ReInitialize() { this->Initialized = 0; this->Enabled = 0;
00087 this->Initialize(); }
00089
00092 virtual void UnRegister(vtkObjectBase *o);
00093
00097 virtual void Start() {}
00098
00100
00107 virtual void Enable() { this->Enabled = 1; this->Modified();}
00108 virtual void Disable() { this->Enabled = 0; this->Modified();}
00109 vtkGetMacro(Enabled, int);
00111
00113
00114 void SetRenderWindow(vtkRenderWindow *aren);
00115 vtkGetObjectMacro(RenderWindow,vtkRenderWindow);
00117
00120 virtual void UpdateSize(int x,int y);
00121
00123
00138 virtual int CreateTimer(int timerType);
00139 virtual int DestroyTimer();
00140 int CreateRepeatingTimer(unsigned long duration);
00141 int CreateOneShotTimer(unsigned long duration);
00142 int IsOneShotTimer(int timerId);
00143 unsigned long GetTimerDuration(int timerId);
00144 int ResetTimer(int timerId);
00145 int DestroyTimer(int timerId);
00146 virtual int GetVTKTimerId(int platformTimerId);
00148
00149
00150
00151
00152 enum {OneShotTimer=1,RepeatingTimer};
00153
00154
00156
00163 vtkSetClampMacro(TimerDuration,unsigned long,1,100000);
00164 vtkGetMacro(TimerDuration,unsigned long);
00166
00168
00178 vtkSetMacro(TimerEventId, int);
00179 vtkGetMacro(TimerEventId, int);
00180 vtkSetMacro(TimerEventType, int);
00181 vtkGetMacro(TimerEventType, int);
00182 vtkSetMacro(TimerEventDuration, int);
00183 vtkGetMacro(TimerEventDuration, int);
00184 vtkSetMacro(TimerEventPlatformId, int);
00185 vtkGetMacro(TimerEventPlatformId, int);
00187
00191 virtual void TerminateApp(void) {}
00192
00194
00196 virtual void SetInteractorStyle(vtkInteractorObserver *);
00197 vtkGetObjectMacro(InteractorStyle,vtkInteractorObserver);
00199
00201
00203 vtkSetMacro(LightFollowCamera,int);
00204 vtkGetMacro(LightFollowCamera,int);
00205 vtkBooleanMacro(LightFollowCamera,int);
00207
00209
00213 vtkSetClampMacro(DesiredUpdateRate,double,0.0001,VTK_LARGE_FLOAT);
00214 vtkGetMacro(DesiredUpdateRate,double);
00216
00218
00220 vtkSetClampMacro(StillUpdateRate,double,0.0001,VTK_LARGE_FLOAT);
00221 vtkGetMacro(StillUpdateRate,double);
00223
00225
00226 vtkGetMacro(Initialized,int);
00228
00230
00234 virtual void SetPicker(vtkAbstractPicker*);
00235 vtkGetObjectMacro(Picker,vtkAbstractPicker);
00237
00240 virtual vtkAbstractPropPicker *CreateDefaultPicker();
00241
00243
00245 virtual void ExitCallback();
00246 virtual void UserCallback();
00247 virtual void StartPickCallback();
00248 virtual void EndPickCallback();
00250
00252 virtual void GetMousePosition(int *x, int *y) { *x = 0 ; *y = 0; }
00253
00255
00257 void HideCursor();
00258 void ShowCursor();
00260
00263 virtual void Render();
00264
00266
00269 void FlyTo(vtkRenderer *ren, double x, double y, double z);
00270 void FlyTo(vtkRenderer *ren, double *x)
00271 {this->FlyTo(ren, x[0], x[1], x[2]);}
00272 void FlyToImage(vtkRenderer *ren, double x, double y);
00273 void FlyToImage(vtkRenderer *ren, double *x)
00274 {this->FlyToImage(ren, x[0], x[1]);}
00276
00278
00279 vtkSetClampMacro(NumberOfFlyFrames,int,1,VTK_LARGE_INTEGER);
00280 vtkGetMacro(NumberOfFlyFrames,int);
00282
00284
00286 vtkSetMacro(Dolly,double);
00287 vtkGetMacro(Dolly,double);
00289
00291
00296 vtkGetVector2Macro(EventPosition,int);
00297 vtkGetVector2Macro(LastEventPosition,int);
00298 vtkSetVector2Macro(LastEventPosition,int);
00299 virtual void SetEventPosition(int x, int y)
00300 {
00301 vtkDebugMacro(<< this->GetClassName() << " (" << this
00302 << "): setting EventPosition to (" << x << "," << y << ")");
00303 if (this->EventPosition[0] != x || this->EventPosition[1] != y)
00304 {
00305 this->LastEventPosition[0] = this->EventPosition[0];
00306 this->LastEventPosition[1] = this->EventPosition[1];
00307 this->EventPosition[0] = x;
00308 this->EventPosition[1] = y;
00309 this->Modified();
00310 }
00311 }
00312 virtual void SetEventPosition(int pos[2])
00313 {
00314 this->SetEventPosition(pos[0], pos[1]);
00315 }
00316 virtual void SetEventPositionFlipY(int x, int y)
00317 {
00318 this->SetEventPosition(x, this->Size[1] - y - 1);
00319 }
00320 virtual void SetEventPositionFlipY(int pos[2])
00321 {
00322 this->SetEventPositionFlipY(pos[0], pos[1]);
00323 }
00324 vtkSetMacro(AltKey, int);
00325 vtkGetMacro(AltKey, int);
00326 vtkSetMacro(ControlKey, int);
00327 vtkGetMacro(ControlKey, int);
00328 vtkSetMacro(ShiftKey, int);
00329 vtkGetMacro(ShiftKey, int);
00330 vtkSetMacro(KeyCode, char);
00331 vtkGetMacro(KeyCode, char);
00332 vtkSetMacro(RepeatCount, int);
00333 vtkGetMacro(RepeatCount, int);
00334 vtkSetStringMacro(KeySym);
00335 vtkGetStringMacro(KeySym);
00337
00339
00340 void SetEventInformation(int x,
00341 int y,
00342 int ctrl=0,
00343 int shift=0,
00344 char keycode=0,
00345 int repeatcount=0,
00346 const char* keysym=0)
00347 {
00348 this->LastEventPosition[0] = this->EventPosition[0];
00349 this->LastEventPosition[1] = this->EventPosition[1];
00350 this->EventPosition[0] = x;
00351 this->EventPosition[1] = y;
00352 this->ControlKey = ctrl;
00353 this->ShiftKey = shift;
00354 this->KeyCode = keycode;
00355 this->RepeatCount = repeatcount;
00356 if(keysym)
00357 {
00358 this->SetKeySym(keysym);
00359 }
00360 this->Modified();
00361 }
00363
00365
00367 void SetEventInformationFlipY(int x,
00368 int y,
00369 int ctrl=0,
00370 int shift=0,
00371 char keycode=0,
00372 int repeatcount=0,
00373 const char* keysym=0)
00374 {
00375 this->SetEventInformation(x,
00376 this->Size[1] - y - 1,
00377 ctrl,
00378 shift,
00379 keycode,
00380 repeatcount,
00381 keysym);
00382 }
00384
00386
00387 void SetKeyEventInformation(int ctrl=0,
00388 int shift=0,
00389 char keycode=0,
00390 int repeatcount=0,
00391 const char* keysym=0)
00392 {
00393 this->ControlKey = ctrl;
00394 this->ShiftKey = shift;
00395 this->KeyCode = keycode;
00396 this->RepeatCount = repeatcount;
00397 if(keysym)
00398 {
00399 this->SetKeySym(keysym);
00400 }
00401 this->Modified();
00402 }
00404
00406
00413 vtkSetVector2Macro(Size,int);
00414 vtkGetVector2Macro(Size,int);
00415 vtkSetVector2Macro(EventSize,int);
00416 vtkGetVector2Macro(EventSize,int);
00418
00422 virtual vtkRenderer *FindPokedRenderer(int,int);
00423
00430 vtkObserverMediator *GetObserverMediator();
00431
00432 protected:
00433 vtkRenderWindowInteractor();
00434 ~vtkRenderWindowInteractor();
00435
00436 vtkRenderWindow *RenderWindow;
00437 vtkInteractorObserver *InteractorStyle;
00438
00439
00440 vtkAbstractPicker *Picker;
00441
00442 int Initialized;
00443 int Enabled;
00444 int Style;
00445 int LightFollowCamera;
00446 int ActorMode;
00447 double DesiredUpdateRate;
00448 double StillUpdateRate;
00449
00450
00451 int AltKey;
00452 int ControlKey;
00453 int ShiftKey;
00454 char KeyCode;
00455 int RepeatCount;
00456 char* KeySym;
00457 int EventPosition[2];
00458 int LastEventPosition[2];
00459 int EventSize[2];
00460 int Size[2];
00461 int TimerEventId;
00462 int TimerEventType;
00463 int TimerEventDuration;
00464 int TimerEventPlatformId;
00465
00466
00467 int NumberOfFlyFrames;
00468 double Dolly;
00469
00471
00478 friend class vtkInteractorObserver;
00479 void GrabFocus(vtkCommand *mouseEvents, vtkCommand *keypressEvents=NULL)
00480 {this->Superclass::InternalGrabFocus(mouseEvents,keypressEvents);}
00481 void ReleaseFocus()
00482 {this->Superclass::InternalReleaseFocus();}
00483
00485
00488 vtkObserverMediator *ObserverMediator;
00489
00490
00491
00492 friend struct vtkTimerStruct;
00493 vtkTimerIdMap *TimerMap;
00494 unsigned long TimerDuration;
00496
00500 virtual int InternalCreateTimer(int timerId, int timerType, unsigned long duration);
00501 virtual int InternalDestroyTimer(int platformTimerId);
00502 int GetCurrentTimerId();
00503
00505
00506
00507
00508
00509 int HandleEventLoop;
00510
00511 private:
00512 vtkRenderWindowInteractor(const vtkRenderWindowInteractor&);
00513 void operator=(const vtkRenderWindowInteractor&);
00514 };
00515
00516 #endif