Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

dox/Rendering/vtkRenderWindowInteractor.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkRenderWindowInteractor.h,v $ 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00043 #ifndef __vtkRenderWindowInteractor_h 00044 #define __vtkRenderWindowInteractor_h 00045 00046 #include "vtkObject.h" 00047 00048 // Timer flags for win32/X compatibility 00049 #define VTKI_TIMER_FIRST 0 00050 #define VTKI_TIMER_UPDATE 1 00051 00052 class vtkAbstractPicker; 00053 class vtkAbstractPropPicker; 00054 class vtkInteractorObserver; 00055 class vtkInteractorObserver; 00056 class vtkRenderWindow; 00057 class vtkRenderer; 00058 00059 class VTK_RENDERING_EXPORT vtkRenderWindowInteractor : public vtkObject 00060 { 00061 public: 00062 static vtkRenderWindowInteractor *New(); 00063 vtkTypeRevisionMacro(vtkRenderWindowInteractor,vtkObject); 00064 void PrintSelf(ostream& os, vtkIndent indent); 00065 00067 00069 virtual void Initialize(); 00070 void ReInitialize() { this->Initialized = 0; this->Enabled = 0; 00071 this->Initialize(); } 00073 00076 virtual void UnRegister(vtkObjectBase *o); 00077 00081 virtual void Start() {}; 00082 00084 00091 virtual void Enable() { this->Enabled = 1; this->Modified();}; 00092 virtual void Disable() { this->Enabled = 0; this->Modified();}; 00093 vtkGetMacro(Enabled, int); 00095 00097 00098 void SetRenderWindow(vtkRenderWindow *aren); 00099 vtkGetObjectMacro(RenderWindow,vtkRenderWindow); 00101 00103 virtual void UpdateSize(int x,int y); 00104 00106 00111 virtual int CreateTimer(int ) { return 1; }; 00112 virtual int DestroyTimer() { return 1; }; 00114 00118 virtual void TerminateApp(void) {}; 00119 00121 00122 virtual void SetInteractorStyle(vtkInteractorObserver *); 00123 vtkGetObjectMacro(InteractorStyle,vtkInteractorObserver); 00125 00127 00129 vtkSetMacro(LightFollowCamera,int); 00130 vtkGetMacro(LightFollowCamera,int); 00131 vtkBooleanMacro(LightFollowCamera,int); 00133 00135 00139 vtkSetClampMacro(DesiredUpdateRate,double,0.0001,VTK_LARGE_FLOAT); 00140 vtkGetMacro(DesiredUpdateRate,double); 00142 00144 00146 vtkSetClampMacro(StillUpdateRate,double,0.0001,VTK_LARGE_FLOAT); 00147 vtkGetMacro(StillUpdateRate,double); 00149 00151 00152 vtkGetMacro(Initialized,int); 00154 00156 00160 virtual void SetPicker(vtkAbstractPicker*); 00161 vtkGetObjectMacro(Picker,vtkAbstractPicker); 00163 00166 virtual vtkAbstractPropPicker *CreateDefaultPicker(); 00167 00169 00171 virtual void ExitCallback(); 00172 virtual void UserCallback(); 00173 virtual void StartPickCallback(); 00174 virtual void EndPickCallback(); 00176 00178 virtual void GetMousePosition(int *x, int *y) { *x = 0 ; *y = 0; } 00179 00181 00183 void HideCursor(); 00184 void ShowCursor(); 00186 00189 virtual void Render(); 00190 00192 00195 void FlyTo(vtkRenderer *ren, double x, double y, double z); 00196 void FlyTo(vtkRenderer *ren, double *x) 00197 {this->FlyTo(ren, x[0], x[1], x[2]);} 00198 void FlyToImage(vtkRenderer *ren, double x, double y); 00199 void FlyToImage(vtkRenderer *ren, double *x) 00200 {this->FlyToImage(ren, x[0], x[1]);} 00202 00204 00205 vtkSetClampMacro(NumberOfFlyFrames,int,1,VTK_LARGE_INTEGER); 00206 vtkGetMacro(NumberOfFlyFrames,int); 00208 00210 00212 vtkSetMacro(Dolly,double); 00213 vtkGetMacro(Dolly,double); 00215 00217 00222 vtkGetVector2Macro(EventPosition,int); 00223 vtkGetVector2Macro(LastEventPosition,int); 00224 virtual void SetEventPosition(int x, int y) 00225 { 00226 vtkDebugMacro(<< this->GetClassName() << " (" << this 00227 << "): setting EventPosition to (" << x << "," << y << ")"); 00228 if (this->EventPosition[0] != x || this->EventPosition[1] != y) 00229 { 00230 this->LastEventPosition[0] = this->EventPosition[0]; 00231 this->LastEventPosition[1] = this->EventPosition[1]; 00232 this->EventPosition[0] = x; 00233 this->EventPosition[1] = y; 00234 this->Modified(); 00235 } 00236 }; 00237 virtual void SetEventPosition(int pos[2]) 00238 { 00239 this->SetEventPosition(pos[0], pos[1]); 00240 } 00241 virtual void SetEventPositionFlipY(int x, int y) 00242 { 00243 this->SetEventPosition(x, this->Size[1] - y - 1); 00244 } 00245 virtual void SetEventPositionFlipY(int pos[2]) 00246 { 00247 this->SetEventPositionFlipY(pos[0], pos[1]); 00248 } 00249 vtkSetMacro(ControlKey, int); 00250 vtkGetMacro(ControlKey, int); 00251 vtkSetMacro(ShiftKey, int); 00252 vtkGetMacro(ShiftKey, int); 00253 vtkSetMacro(KeyCode, char); 00254 vtkGetMacro(KeyCode, char); 00255 vtkSetMacro(RepeatCount, int); 00256 vtkGetMacro(RepeatCount, int); 00257 vtkSetStringMacro(KeySym); 00258 vtkGetStringMacro(KeySym); 00260 00262 00263 void SetEventInformation(int x, 00264 int y, 00265 int ctrl=0, 00266 int shift=0, 00267 char keycode=0, 00268 int repeatcount=0, 00269 const char* keysym=0) 00270 { 00271 this->LastEventPosition[0] = this->EventPosition[0]; 00272 this->LastEventPosition[1] = this->EventPosition[1]; 00273 this->EventPosition[0] = x; 00274 this->EventPosition[1] = y; 00275 this->ControlKey = ctrl; 00276 this->ShiftKey = shift; 00277 this->KeyCode = keycode; 00278 this->RepeatCount = repeatcount; 00279 if(keysym) 00280 { 00281 this->SetKeySym(keysym); 00282 } 00283 this->Modified(); 00284 } 00286 00288 00290 void SetEventInformationFlipY(int x, 00291 int y, 00292 int ctrl=0, 00293 int shift=0, 00294 char keycode=0, 00295 int repeatcount=0, 00296 const char* keysym=0) 00297 { 00298 this->SetEventInformation(x, 00299 this->Size[1] - y - 1, 00300 ctrl, 00301 shift, 00302 keycode, 00303 repeatcount, 00304 keysym); 00305 } 00307 00309 00310 void SetKeyEventInformation(int ctrl=0, 00311 int shift=0, 00312 char keycode=0, 00313 int repeatcount=0, 00314 const char* keysym=0) 00315 { 00316 this->ControlKey = ctrl; 00317 this->ShiftKey = shift; 00318 this->KeyCode = keycode; 00319 this->RepeatCount = repeatcount; 00320 if(keysym) 00321 { 00322 this->SetKeySym(keysym); 00323 } 00324 this->Modified(); 00325 } 00327 00329 00335 vtkSetVector2Macro(Size,int); 00336 vtkGetVector2Macro(Size,int); 00337 vtkSetVector2Macro(EventSize,int); 00338 vtkGetVector2Macro(EventSize,int); 00340 00344 vtkRenderer *FindPokedRenderer(int,int); 00345 00346 protected: 00347 vtkRenderWindowInteractor(); 00348 ~vtkRenderWindowInteractor(); 00349 00350 vtkRenderWindow *RenderWindow; 00351 vtkInteractorObserver *InteractorStyle; 00352 00353 // Used as a helper object to pick instances of vtkProp 00354 vtkAbstractPicker *Picker; 00355 00356 int Initialized; 00357 int Enabled; 00358 int Style; 00359 int LightFollowCamera; 00360 int ActorMode; 00361 double DesiredUpdateRate; 00362 double StillUpdateRate; 00363 00364 // Event information 00365 int ControlKey; 00366 int ShiftKey; 00367 char KeyCode; 00368 int RepeatCount; 00369 char* KeySym; 00370 int EventPosition[2]; 00371 int LastEventPosition[2]; 00372 int EventSize[2]; 00373 int Size[2]; 00374 00375 // control the fly to 00376 int NumberOfFlyFrames; 00377 double Dolly; 00378 00379 private: 00380 vtkRenderWindowInteractor(const vtkRenderWindowInteractor&); // Not implemented. 00381 void operator=(const vtkRenderWindowInteractor&); // Not implemented. 00382 }; 00383 00384 #endif