00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00049 #ifndef __vtkRenderWindowInteractor_h
00050 #define __vtkRenderWindowInteractor_h
00051
00052 #include "vtkObject.h"
00053
00054 class vtkTimerIdMap;
00055
00056
00057
00058 #define VTKI_TIMER_FIRST 0
00059 #define VTKI_TIMER_UPDATE 1
00060
00061 class vtkAbstractPicker;
00062 class vtkAbstractPropPicker;
00063 class vtkInteractorObserver;
00064 class vtkRenderWindow;
00065 class vtkRenderer;
00066 class vtkObserverMediator;
00067 class vtkInteractorEventRecorder;
00068
00069 class VTK_RENDERING_EXPORT vtkRenderWindowInteractor : public vtkObject
00070 {
00071
00072 friend class vtkInteractorEventRecorder;
00073
00074 public:
00075 static vtkRenderWindowInteractor *New();
00076 vtkTypeRevisionMacro(vtkRenderWindowInteractor,vtkObject);
00077 void PrintSelf(ostream& os, vtkIndent indent);
00078
00080
00082 virtual void Initialize();
00083 void ReInitialize() { this->Initialized = 0; this->Enabled = 0;
00084 this->Initialize(); }
00086
00089 virtual void UnRegister(vtkObjectBase *o);
00090
00094 virtual void Start() {}
00095
00097
00104 virtual void Enable() { this->Enabled = 1; this->Modified();}
00105 virtual void Disable() { this->Enabled = 0; this->Modified();}
00106 vtkGetMacro(Enabled, int);
00108
00110
00112 vtkBooleanMacro(EnableRender, bool);
00113 vtkSetMacro(EnableRender, bool);
00114 vtkGetMacro(EnableRender, bool);
00116
00118
00119 void SetRenderWindow(vtkRenderWindow *aren);
00120 vtkGetObjectMacro(RenderWindow,vtkRenderWindow);
00122
00125 virtual void UpdateSize(int x,int y);
00126
00128
00143 virtual int CreateTimer(int timerType);
00144 virtual int DestroyTimer();
00145 int CreateRepeatingTimer(unsigned long duration);
00146 int CreateOneShotTimer(unsigned long duration);
00147 int IsOneShotTimer(int timerId);
00148 unsigned long GetTimerDuration(int timerId);
00149 int ResetTimer(int timerId);
00150 int DestroyTimer(int timerId);
00151 virtual int GetVTKTimerId(int platformTimerId);
00153
00154
00155
00156
00157 enum {OneShotTimer=1,RepeatingTimer};
00158
00159
00161
00168 vtkSetClampMacro(TimerDuration,unsigned long,1,100000);
00169 vtkGetMacro(TimerDuration,unsigned long);
00171
00173
00183 vtkSetMacro(TimerEventId, int);
00184 vtkGetMacro(TimerEventId, int);
00185 vtkSetMacro(TimerEventType, int);
00186 vtkGetMacro(TimerEventType, int);
00187 vtkSetMacro(TimerEventDuration, int);
00188 vtkGetMacro(TimerEventDuration, int);
00189 vtkSetMacro(TimerEventPlatformId, int);
00190 vtkGetMacro(TimerEventPlatformId, int);
00192
00196 virtual void TerminateApp(void) {}
00197
00199
00201 virtual void SetInteractorStyle(vtkInteractorObserver *);
00202 vtkGetObjectMacro(InteractorStyle,vtkInteractorObserver);
00204
00206
00208 vtkSetMacro(LightFollowCamera,int);
00209 vtkGetMacro(LightFollowCamera,int);
00210 vtkBooleanMacro(LightFollowCamera,int);
00212
00214
00219 vtkSetClampMacro(DesiredUpdateRate,double,0.0001,VTK_LARGE_FLOAT);
00220 vtkGetMacro(DesiredUpdateRate,double);
00222
00224
00227 vtkSetClampMacro(StillUpdateRate,double,0.0001,VTK_LARGE_FLOAT);
00228 vtkGetMacro(StillUpdateRate,double);
00230
00232
00233 vtkGetMacro(Initialized,int);
00235
00237
00241 virtual void SetPicker(vtkAbstractPicker*);
00242 vtkGetObjectMacro(Picker,vtkAbstractPicker);
00244
00247 virtual vtkAbstractPropPicker *CreateDefaultPicker();
00248
00250
00252 virtual void ExitCallback();
00253 virtual void UserCallback();
00254 virtual void StartPickCallback();
00255 virtual void EndPickCallback();
00257
00259 virtual void GetMousePosition(int *x, int *y) { *x = 0 ; *y = 0; }
00260
00262
00264 void HideCursor();
00265 void ShowCursor();
00267
00270 virtual void Render();
00271
00273
00276 void FlyTo(vtkRenderer *ren, double x, double y, double z);
00277 void FlyTo(vtkRenderer *ren, double *x)
00278 {this->FlyTo(ren, x[0], x[1], x[2]);}
00279 void FlyToImage(vtkRenderer *ren, double x, double y);
00280 void FlyToImage(vtkRenderer *ren, double *x)
00281 {this->FlyToImage(ren, x[0], x[1]);}
00283
00285
00286 vtkSetClampMacro(NumberOfFlyFrames,int,1,VTK_LARGE_INTEGER);
00287 vtkGetMacro(NumberOfFlyFrames,int);
00289
00291
00293 vtkSetMacro(Dolly,double);
00294 vtkGetMacro(Dolly,double);
00296
00298
00303 vtkGetVector2Macro(EventPosition,int);
00304 vtkGetVector2Macro(LastEventPosition,int);
00305 vtkSetVector2Macro(LastEventPosition,int);
00306 virtual void SetEventPosition(int x, int y)
00307 {
00308 vtkDebugMacro(<< this->GetClassName() << " (" << this
00309 << "): setting EventPosition to (" << x << "," << y << ")");
00310 if (this->EventPosition[0] != x || this->EventPosition[1] != y ||
00311 this->LastEventPosition[0] != x || this->LastEventPosition[1] != y)
00312 {
00313 this->LastEventPosition[0] = this->EventPosition[0];
00314 this->LastEventPosition[1] = this->EventPosition[1];
00315 this->EventPosition[0] = x;
00316 this->EventPosition[1] = y;
00317 this->Modified();
00318 }
00319 }
00320 virtual void SetEventPosition(int pos[2])
00321 {
00322 this->SetEventPosition(pos[0], pos[1]);
00323 }
00324 virtual void SetEventPositionFlipY(int x, int y)
00325 {
00326 this->SetEventPosition(x, this->Size[1] - y - 1);
00327 }
00328 virtual void SetEventPositionFlipY(int pos[2])
00329 {
00330 this->SetEventPositionFlipY(pos[0], pos[1]);
00331 }
00332 vtkSetMacro(AltKey, int);
00333 vtkGetMacro(AltKey, int);
00334 vtkSetMacro(ControlKey, int);
00335 vtkGetMacro(ControlKey, int);
00336 vtkSetMacro(ShiftKey, int);
00337 vtkGetMacro(ShiftKey, int);
00338 vtkSetMacro(KeyCode, char);
00339 vtkGetMacro(KeyCode, char);
00340 vtkSetMacro(RepeatCount, int);
00341 vtkGetMacro(RepeatCount, int);
00342 vtkSetStringMacro(KeySym);
00343 vtkGetStringMacro(KeySym);
00345
00347
00348 void SetEventInformation(int x,
00349 int y,
00350 int ctrl=0,
00351 int shift=0,
00352 char keycode=0,
00353 int repeatcount=0,
00354 const char* keysym=0)
00355 {
00356 this->LastEventPosition[0] = this->EventPosition[0];
00357 this->LastEventPosition[1] = this->EventPosition[1];
00358 this->EventPosition[0] = x;
00359 this->EventPosition[1] = y;
00360 this->ControlKey = ctrl;
00361 this->ShiftKey = shift;
00362 this->KeyCode = keycode;
00363 this->RepeatCount = repeatcount;
00364 if(keysym)
00365 {
00366 this->SetKeySym(keysym);
00367 }
00368 this->Modified();
00369 }
00371
00373
00375 void SetEventInformationFlipY(int x,
00376 int y,
00377 int ctrl=0,
00378 int shift=0,
00379 char keycode=0,
00380 int repeatcount=0,
00381 const char* keysym=0)
00382 {
00383 this->SetEventInformation(x,
00384 this->Size[1] - y - 1,
00385 ctrl,
00386 shift,
00387 keycode,
00388 repeatcount,
00389 keysym);
00390 }
00392
00394
00395 void SetKeyEventInformation(int ctrl=0,
00396 int shift=0,
00397 char keycode=0,
00398 int repeatcount=0,
00399 const char* keysym=0)
00400 {
00401 this->ControlKey = ctrl;
00402 this->ShiftKey = shift;
00403 this->KeyCode = keycode;
00404 this->RepeatCount = repeatcount;
00405 if(keysym)
00406 {
00407 this->SetKeySym(keysym);
00408 }
00409 this->Modified();
00410 }
00412
00414
00421 vtkSetVector2Macro(Size,int);
00422 vtkGetVector2Macro(Size,int);
00423 vtkSetVector2Macro(EventSize,int);
00424 vtkGetVector2Macro(EventSize,int);
00426
00430 virtual vtkRenderer *FindPokedRenderer(int,int);
00431
00438 vtkObserverMediator *GetObserverMediator();
00439
00441
00446 vtkSetMacro(UseTDx,bool);
00447 vtkGetMacro(UseTDx,bool);
00449
00450 protected:
00451 vtkRenderWindowInteractor();
00452 ~vtkRenderWindowInteractor();
00453
00454 vtkRenderWindow *RenderWindow;
00455 vtkInteractorObserver *InteractorStyle;
00456
00457
00458 vtkAbstractPicker *Picker;
00459
00460 int Initialized;
00461 int Enabled;
00462 bool EnableRender;
00463 int Style;
00464 int LightFollowCamera;
00465 int ActorMode;
00466 double DesiredUpdateRate;
00467 double StillUpdateRate;
00468
00469
00470 int AltKey;
00471 int ControlKey;
00472 int ShiftKey;
00473 char KeyCode;
00474 int RepeatCount;
00475 char* KeySym;
00476 int EventPosition[2];
00477 int LastEventPosition[2];
00478 int EventSize[2];
00479 int Size[2];
00480 int TimerEventId;
00481 int TimerEventType;
00482 int TimerEventDuration;
00483 int TimerEventPlatformId;
00484
00485
00486 int NumberOfFlyFrames;
00487 double Dolly;
00488
00490
00497 friend class vtkInteractorObserver;
00498 void GrabFocus(vtkCommand *mouseEvents, vtkCommand *keypressEvents=NULL)
00499 {this->Superclass::InternalGrabFocus(mouseEvents,keypressEvents);}
00500 void ReleaseFocus()
00501 {this->Superclass::InternalReleaseFocus();}
00502
00504
00507 vtkObserverMediator *ObserverMediator;
00508
00509
00510
00511 friend struct vtkTimerStruct;
00512 vtkTimerIdMap *TimerMap;
00513 unsigned long TimerDuration;
00515
00519 virtual int InternalCreateTimer(int timerId, int timerType, unsigned long duration);
00520 virtual int InternalDestroyTimer(int platformTimerId);
00521 int GetCurrentTimerId();
00522
00524
00525
00526
00527
00528 int HandleEventLoop;
00529
00530 bool UseTDx;
00531
00532 private:
00533 vtkRenderWindowInteractor(const vtkRenderWindowInteractor&);
00534 void operator=(const vtkRenderWindowInteractor&);
00535 };
00536
00537 #endif