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 vtkTypeMacro(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
00115 vtkBooleanMacro(EnableRender, bool);
00116 vtkSetMacro(EnableRender, bool);
00117 vtkGetMacro(EnableRender, bool);
00119
00121
00122 void SetRenderWindow(vtkRenderWindow *aren);
00123 vtkGetObjectMacro(RenderWindow,vtkRenderWindow);
00125
00128 virtual void UpdateSize(int x,int y);
00129
00131
00146 virtual int CreateTimer(int timerType);
00147 virtual int DestroyTimer();
00148 int CreateRepeatingTimer(unsigned long duration);
00149 int CreateOneShotTimer(unsigned long duration);
00150 int IsOneShotTimer(int timerId);
00151 unsigned long GetTimerDuration(int timerId);
00152 int ResetTimer(int timerId);
00153 int DestroyTimer(int timerId);
00154 virtual int GetVTKTimerId(int platformTimerId);
00156
00157
00158
00159
00160 enum {OneShotTimer=1,RepeatingTimer};
00161
00162
00164
00171 vtkSetClampMacro(TimerDuration,unsigned long,1,100000);
00172 vtkGetMacro(TimerDuration,unsigned long);
00174
00176
00186 vtkSetMacro(TimerEventId, int);
00187 vtkGetMacro(TimerEventId, int);
00188 vtkSetMacro(TimerEventType, int);
00189 vtkGetMacro(TimerEventType, int);
00190 vtkSetMacro(TimerEventDuration, int);
00191 vtkGetMacro(TimerEventDuration, int);
00192 vtkSetMacro(TimerEventPlatformId, int);
00193 vtkGetMacro(TimerEventPlatformId, int);
00195
00199 virtual void TerminateApp(void) {}
00200
00202
00204 virtual void SetInteractorStyle(vtkInteractorObserver *);
00205 vtkGetObjectMacro(InteractorStyle,vtkInteractorObserver);
00207
00209
00211 vtkSetMacro(LightFollowCamera,int);
00212 vtkGetMacro(LightFollowCamera,int);
00213 vtkBooleanMacro(LightFollowCamera,int);
00215
00217
00222 vtkSetClampMacro(DesiredUpdateRate,double,0.0001,VTK_LARGE_FLOAT);
00223 vtkGetMacro(DesiredUpdateRate,double);
00225
00227
00230 vtkSetClampMacro(StillUpdateRate,double,0.0001,VTK_LARGE_FLOAT);
00231 vtkGetMacro(StillUpdateRate,double);
00233
00235
00236 vtkGetMacro(Initialized,int);
00238
00240
00244 virtual void SetPicker(vtkAbstractPicker*);
00245 vtkGetObjectMacro(Picker,vtkAbstractPicker);
00247
00250 virtual vtkAbstractPropPicker *CreateDefaultPicker();
00251
00253
00255 virtual void ExitCallback();
00256 virtual void UserCallback();
00257 virtual void StartPickCallback();
00258 virtual void EndPickCallback();
00260
00262 virtual void GetMousePosition(int *x, int *y) { *x = 0 ; *y = 0; }
00263
00265
00267 void HideCursor();
00268 void ShowCursor();
00270
00273 virtual void Render();
00274
00276
00279 void FlyTo(vtkRenderer *ren, double x, double y, double z);
00280 void FlyTo(vtkRenderer *ren, double *x)
00281 {this->FlyTo(ren, x[0], x[1], x[2]);}
00282 void FlyToImage(vtkRenderer *ren, double x, double y);
00283 void FlyToImage(vtkRenderer *ren, double *x)
00284 {this->FlyToImage(ren, x[0], x[1]);}
00286
00288
00289 vtkSetClampMacro(NumberOfFlyFrames,int,1,VTK_LARGE_INTEGER);
00290 vtkGetMacro(NumberOfFlyFrames,int);
00292
00294
00296 vtkSetMacro(Dolly,double);
00297 vtkGetMacro(Dolly,double);
00299
00301
00306 vtkGetVector2Macro(EventPosition,int);
00307 vtkGetVector2Macro(LastEventPosition,int);
00308 vtkSetVector2Macro(LastEventPosition,int);
00309 virtual void SetEventPosition(int x, int y)
00310 {
00311 vtkDebugMacro(<< this->GetClassName() << " (" << this
00312 << "): setting EventPosition to (" << x << "," << y << ")");
00313 if (this->EventPosition[0] != x || this->EventPosition[1] != y ||
00314 this->LastEventPosition[0] != x || this->LastEventPosition[1] != y)
00315 {
00316 this->LastEventPosition[0] = this->EventPosition[0];
00317 this->LastEventPosition[1] = this->EventPosition[1];
00318 this->EventPosition[0] = x;
00319 this->EventPosition[1] = y;
00320 this->Modified();
00321 }
00322 }
00323 virtual void SetEventPosition(int pos[2])
00324 {
00325 this->SetEventPosition(pos[0], pos[1]);
00326 }
00327 virtual void SetEventPositionFlipY(int x, int y)
00328 {
00329 this->SetEventPosition(x, this->Size[1] - y - 1);
00330 }
00331 virtual void SetEventPositionFlipY(int pos[2])
00332 {
00333 this->SetEventPositionFlipY(pos[0], pos[1]);
00334 }
00335 vtkSetMacro(AltKey, int);
00336 vtkGetMacro(AltKey, int);
00337 vtkSetMacro(ControlKey, int);
00338 vtkGetMacro(ControlKey, int);
00339 vtkSetMacro(ShiftKey, int);
00340 vtkGetMacro(ShiftKey, int);
00341 vtkSetMacro(KeyCode, char);
00342 vtkGetMacro(KeyCode, char);
00343 vtkSetMacro(RepeatCount, int);
00344 vtkGetMacro(RepeatCount, int);
00345 vtkSetStringMacro(KeySym);
00346 vtkGetStringMacro(KeySym);
00348
00350
00351 void SetEventInformation(int x,
00352 int y,
00353 int ctrl=0,
00354 int shift=0,
00355 char keycode=0,
00356 int repeatcount=0,
00357 const char* keysym=0)
00358 {
00359 this->LastEventPosition[0] = this->EventPosition[0];
00360 this->LastEventPosition[1] = this->EventPosition[1];
00361 this->EventPosition[0] = x;
00362 this->EventPosition[1] = y;
00363 this->ControlKey = ctrl;
00364 this->ShiftKey = shift;
00365 this->KeyCode = keycode;
00366 this->RepeatCount = repeatcount;
00367 if(keysym)
00368 {
00369 this->SetKeySym(keysym);
00370 }
00371 this->Modified();
00372 }
00374
00376
00378 void SetEventInformationFlipY(int x,
00379 int y,
00380 int ctrl=0,
00381 int shift=0,
00382 char keycode=0,
00383 int repeatcount=0,
00384 const char* keysym=0)
00385 {
00386 this->SetEventInformation(x,
00387 this->Size[1] - y - 1,
00388 ctrl,
00389 shift,
00390 keycode,
00391 repeatcount,
00392 keysym);
00393 }
00395
00397
00398 void SetKeyEventInformation(int ctrl=0,
00399 int shift=0,
00400 char keycode=0,
00401 int repeatcount=0,
00402 const char* keysym=0)
00403 {
00404 this->ControlKey = ctrl;
00405 this->ShiftKey = shift;
00406 this->KeyCode = keycode;
00407 this->RepeatCount = repeatcount;
00408 if(keysym)
00409 {
00410 this->SetKeySym(keysym);
00411 }
00412 this->Modified();
00413 }
00415
00417
00424 vtkSetVector2Macro(Size,int);
00425 vtkGetVector2Macro(Size,int);
00426 vtkSetVector2Macro(EventSize,int);
00427 vtkGetVector2Macro(EventSize,int);
00429
00433 virtual vtkRenderer *FindPokedRenderer(int,int);
00434
00441 vtkObserverMediator *GetObserverMediator();
00442
00444
00449 vtkSetMacro(UseTDx,bool);
00450 vtkGetMacro(UseTDx,bool);
00452
00453 protected:
00454 vtkRenderWindowInteractor();
00455 ~vtkRenderWindowInteractor();
00456
00457 vtkRenderWindow *RenderWindow;
00458 vtkInteractorObserver *InteractorStyle;
00459
00460
00461 vtkAbstractPicker *Picker;
00462
00463 int Initialized;
00464 int Enabled;
00465 bool EnableRender;
00466 int Style;
00467 int LightFollowCamera;
00468 int ActorMode;
00469 double DesiredUpdateRate;
00470 double StillUpdateRate;
00471
00472
00473 int AltKey;
00474 int ControlKey;
00475 int ShiftKey;
00476 char KeyCode;
00477 int RepeatCount;
00478 char* KeySym;
00479 int EventPosition[2];
00480 int LastEventPosition[2];
00481 int EventSize[2];
00482 int Size[2];
00483 int TimerEventId;
00484 int TimerEventType;
00485 int TimerEventDuration;
00486 int TimerEventPlatformId;
00487
00488
00489 int NumberOfFlyFrames;
00490 double Dolly;
00491
00493
00500 friend class vtkInteractorObserver;
00501 void GrabFocus(vtkCommand *mouseEvents, vtkCommand *keypressEvents=NULL)
00502 {this->Superclass::InternalGrabFocus(mouseEvents,keypressEvents);}
00503 void ReleaseFocus()
00504 {this->Superclass::InternalReleaseFocus();}
00505
00507
00510 vtkObserverMediator *ObserverMediator;
00511
00512
00513
00514 friend struct vtkTimerStruct;
00515 vtkTimerIdMap *TimerMap;
00516 unsigned long TimerDuration;
00518
00522 virtual int InternalCreateTimer(int timerId, int timerType, unsigned long duration);
00523 virtual int InternalDestroyTimer(int platformTimerId);
00524 int GetCurrentTimerId();
00525
00527
00528
00529
00530
00531 int HandleEventLoop;
00532
00533 bool UseTDx;
00534
00535 private:
00536 vtkRenderWindowInteractor(const vtkRenderWindowInteractor&);
00537 void operator=(const vtkRenderWindowInteractor&);
00538 };
00539
00540 #endif