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

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 =========================================================================*/
00057 #ifndef __vtkRenderWindowInteractor_h
00058 #define __vtkRenderWindowInteractor_h
00059 
00060 #include "vtkObject.h"
00061 
00062 // Timer flags for win32/X compatibility
00063 #define VTKI_TIMER_FIRST  0
00064 #define VTKI_TIMER_UPDATE 1
00065 
00066 class vtkAbstractPicker;
00067 class vtkAbstractPropPicker;
00068 class vtkInteractorObserver;
00069 class vtkInteractorObserver;
00070 class vtkRenderWindow;
00071 class vtkRenderer;
00072 
00073 class VTK_RENDERING_EXPORT vtkRenderWindowInteractor : public vtkObject
00074 {
00075 public:
00076   static vtkRenderWindowInteractor *New();
00077   vtkTypeRevisionMacro(vtkRenderWindowInteractor,vtkObject);
00078   void PrintSelf(ostream& os, vtkIndent indent);
00079 
00081 
00083   virtual void Initialize();
00084   void ReInitialize() {  this->Initialized = 0; this->Enabled = 0;
00085                         this->Initialize(); } 
00087 
00090   virtual void UnRegister(vtkObjectBase *o);
00091 
00095   virtual void Start() {};
00096 
00098 
00105   virtual void Enable() { this->Enabled = 1; this->Modified();};
00106   virtual void Disable() { this->Enabled = 0; this->Modified();};
00107   vtkGetMacro(Enabled, int);
00109 
00111 
00112   void SetRenderWindow(vtkRenderWindow *aren);
00113   vtkGetObjectMacro(RenderWindow,vtkRenderWindow);
00115 
00117   virtual void UpdateSize(int x,int y);
00118 
00120 
00125   virtual int CreateTimer(int )  { return 1; };
00126   virtual int DestroyTimer()    { return 1; };
00128 
00132   virtual void TerminateApp(void) {};
00133 
00135 
00136   virtual void SetInteractorStyle(vtkInteractorObserver *);
00137   vtkGetObjectMacro(InteractorStyle,vtkInteractorObserver);
00139 
00141 
00143   vtkSetMacro(LightFollowCamera,int);
00144   vtkGetMacro(LightFollowCamera,int);
00145   vtkBooleanMacro(LightFollowCamera,int);
00147 
00149 
00153   vtkSetClampMacro(DesiredUpdateRate,double,0.0001,VTK_LARGE_FLOAT);
00154   vtkGetMacro(DesiredUpdateRate,double);
00156 
00158 
00160   vtkSetClampMacro(StillUpdateRate,double,0.0001,VTK_LARGE_FLOAT);
00161   vtkGetMacro(StillUpdateRate,double);
00163 
00165 
00166   vtkGetMacro(Initialized,int);
00168 
00170 
00174   virtual void SetPicker(vtkAbstractPicker*);
00175   vtkGetObjectMacro(Picker,vtkAbstractPicker);
00177 
00180   virtual vtkAbstractPropPicker *CreateDefaultPicker();
00181 
00183 
00185   virtual void ExitCallback();
00186   virtual void UserCallback();
00187   virtual void StartPickCallback();
00188   virtual void EndPickCallback();
00190   
00192   virtual void GetMousePosition(int *x, int *y) { *x = 0 ; *y = 0; }
00193 
00195 
00197   void HideCursor();
00198   void ShowCursor();
00200 
00203   virtual void Render();
00204 
00206 
00209   void FlyTo(vtkRenderer *ren, double x, double y, double z);
00210   void FlyTo(vtkRenderer *ren, double *x)
00211     {this->FlyTo(ren, x[0], x[1], x[2]);}
00212   void FlyToImage(vtkRenderer *ren, double x, double y);
00213   void FlyToImage(vtkRenderer *ren, double *x)
00214     {this->FlyToImage(ren, x[0], x[1]);}
00216 
00218 
00219   vtkSetClampMacro(NumberOfFlyFrames,int,1,VTK_LARGE_INTEGER);
00220   vtkGetMacro(NumberOfFlyFrames,int);
00222 
00224 
00226   vtkSetMacro(Dolly,double);
00227   vtkGetMacro(Dolly,double);
00229 
00231 
00236   vtkGetVector2Macro(EventPosition,int);
00237   vtkGetVector2Macro(LastEventPosition,int);
00238   virtual void SetEventPosition(int x, int y)
00239   {
00240     vtkDebugMacro(<< this->GetClassName() << " (" << this 
00241                   << "): setting EventPosition to (" << x << "," << y << ")");
00242     if (this->EventPosition[0] != x || this->EventPosition[1] != y)
00243       {
00244       this->LastEventPosition[0] = this->EventPosition[0];
00245       this->LastEventPosition[1] = this->EventPosition[1];
00246       this->EventPosition[0] = x;
00247       this->EventPosition[1] = y;
00248       this->Modified();
00249       }
00250   };
00251   virtual void SetEventPosition(int pos[2])
00252   {
00253     this->SetEventPosition(pos[0], pos[1]);
00254   } 
00255   virtual void SetEventPositionFlipY(int x, int y)
00256   {
00257     this->SetEventPosition(x, this->Size[1] - y - 1);
00258   }
00259   virtual void SetEventPositionFlipY(int pos[2])
00260   {
00261     this->SetEventPositionFlipY(pos[0], pos[1]);
00262   } 
00263   vtkSetMacro(ControlKey, int);
00264   vtkGetMacro(ControlKey, int);
00265   vtkSetMacro(ShiftKey, int);
00266   vtkGetMacro(ShiftKey, int);
00267   vtkSetMacro(KeyCode, char);
00268   vtkGetMacro(KeyCode, char);
00269   vtkSetMacro(RepeatCount, int);
00270   vtkGetMacro(RepeatCount, int);
00271   vtkSetStringMacro(KeySym);
00272   vtkGetStringMacro(KeySym);
00274 
00276 
00277   void SetEventInformation(int x, 
00278                            int y, 
00279                            int ctrl=0, 
00280                            int shift=0, 
00281                            char keycode=0, 
00282                            int repeatcount=0,
00283                            const char* keysym=0)
00284     {
00285       this->LastEventPosition[0] = this->EventPosition[0];
00286       this->LastEventPosition[1] = this->EventPosition[1];
00287       this->EventPosition[0] = x;
00288       this->EventPosition[1] = y;
00289       this->ControlKey = ctrl;
00290       this->ShiftKey = shift;
00291       this->KeyCode = keycode;
00292       this->RepeatCount = repeatcount;
00293       if(keysym)
00294         {
00295         this->SetKeySym(keysym);
00296         }
00297       this->Modified();
00298     }
00300 
00302 
00304   void SetEventInformationFlipY(int x, 
00305                                 int y, 
00306                                 int ctrl=0, 
00307                                 int shift=0, 
00308                                 char keycode=0, 
00309                                 int repeatcount=0,
00310                                 const char* keysym=0)
00311     {
00312       this->SetEventInformation(x, 
00313                                 this->Size[1] - y - 1, 
00314                                 ctrl, 
00315                                 shift, 
00316                                 keycode, 
00317                                 repeatcount, 
00318                                 keysym);
00319     }
00321 
00323 
00324   void SetKeyEventInformation(int ctrl=0, 
00325                               int shift=0, 
00326                               char keycode=0, 
00327                               int repeatcount=0,
00328                               const char* keysym=0)
00329     {
00330       this->ControlKey = ctrl;
00331       this->ShiftKey = shift;
00332       this->KeyCode = keycode;
00333       this->RepeatCount = repeatcount;
00334       if(keysym)
00335         {
00336         this->SetKeySym(keysym);
00337         }
00338       this->Modified();
00339     }
00341 
00343 
00349   vtkSetVector2Macro(Size,int);
00350   vtkGetVector2Macro(Size,int);
00351   vtkSetVector2Macro(EventSize,int);
00352   vtkGetVector2Macro(EventSize,int);
00354 
00358   virtual vtkRenderer *FindPokedRenderer(int,int);
00359 
00360 protected:
00361   vtkRenderWindowInteractor();
00362   ~vtkRenderWindowInteractor();
00363 
00364   vtkRenderWindow    *RenderWindow;
00365   vtkInteractorObserver *InteractorStyle;
00366 
00367   // Used as a helper object to pick instances of vtkProp
00368   vtkAbstractPicker          *Picker;
00369 
00370   int   Initialized;
00371   int   Enabled;
00372   int   Style;
00373   int   LightFollowCamera;
00374   int   ActorMode;
00375   double DesiredUpdateRate;
00376   double StillUpdateRate;  
00377 
00378   // Event information
00379   int   ControlKey;
00380   int   ShiftKey;
00381   char  KeyCode;
00382   int   RepeatCount;
00383   char* KeySym; 
00384   int   EventPosition[2];
00385   int   LastEventPosition[2];
00386   int   EventSize[2];
00387   int   Size[2];
00388   
00389   // control the fly to
00390   int NumberOfFlyFrames;
00391   double Dolly;
00392   
00393 private:
00394   vtkRenderWindowInteractor(const vtkRenderWindowInteractor&);  // Not implemented.
00395   void operator=(const vtkRenderWindowInteractor&);  // Not implemented.
00396 };
00397 
00398 #endif