Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | 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 =========================================================================*/
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   vtkSetVector2Macro(LastEventPosition,int);
00225   virtual void SetEventPosition(int x, int y)
00226   {
00227     vtkDebugMacro(<< this->GetClassName() << " (" << this 
00228                   << "): setting EventPosition to (" << x << "," << y << ")");
00229     if (this->EventPosition[0] != x || this->EventPosition[1] != y)
00230       {
00231       this->LastEventPosition[0] = this->EventPosition[0];
00232       this->LastEventPosition[1] = this->EventPosition[1];
00233       this->EventPosition[0] = x;
00234       this->EventPosition[1] = y;
00235       this->Modified();
00236       }
00237   };
00238   virtual void SetEventPosition(int pos[2])
00239   {
00240     this->SetEventPosition(pos[0], pos[1]);
00241   } 
00242   virtual void SetEventPositionFlipY(int x, int y)
00243   {
00244     this->SetEventPosition(x, this->Size[1] - y - 1);
00245   }
00246   virtual void SetEventPositionFlipY(int pos[2])
00247   {
00248     this->SetEventPositionFlipY(pos[0], pos[1]);
00249   } 
00250   vtkSetMacro(ControlKey, int);
00251   vtkGetMacro(ControlKey, int);
00252   vtkSetMacro(ShiftKey, int);
00253   vtkGetMacro(ShiftKey, int);
00254   vtkSetMacro(KeyCode, char);
00255   vtkGetMacro(KeyCode, char);
00256   vtkSetMacro(RepeatCount, int);
00257   vtkGetMacro(RepeatCount, int);
00258   vtkSetStringMacro(KeySym);
00259   vtkGetStringMacro(KeySym);
00261 
00263 
00264   void SetEventInformation(int x, 
00265                            int y, 
00266                            int ctrl=0, 
00267                            int shift=0, 
00268                            char keycode=0, 
00269                            int repeatcount=0,
00270                            const char* keysym=0)
00271     {
00272       this->LastEventPosition[0] = this->EventPosition[0];
00273       this->LastEventPosition[1] = this->EventPosition[1];
00274       this->EventPosition[0] = x;
00275       this->EventPosition[1] = y;
00276       this->ControlKey = ctrl;
00277       this->ShiftKey = shift;
00278       this->KeyCode = keycode;
00279       this->RepeatCount = repeatcount;
00280       if(keysym)
00281         {
00282         this->SetKeySym(keysym);
00283         }
00284       this->Modified();
00285     }
00287 
00289 
00291   void SetEventInformationFlipY(int x, 
00292                                 int y, 
00293                                 int ctrl=0, 
00294                                 int shift=0, 
00295                                 char keycode=0, 
00296                                 int repeatcount=0,
00297                                 const char* keysym=0)
00298     {
00299       this->SetEventInformation(x, 
00300                                 this->Size[1] - y - 1, 
00301                                 ctrl, 
00302                                 shift, 
00303                                 keycode, 
00304                                 repeatcount, 
00305                                 keysym);
00306     }
00308 
00310 
00311   void SetKeyEventInformation(int ctrl=0, 
00312                               int shift=0, 
00313                               char keycode=0, 
00314                               int repeatcount=0,
00315                               const char* keysym=0)
00316     {
00317       this->ControlKey = ctrl;
00318       this->ShiftKey = shift;
00319       this->KeyCode = keycode;
00320       this->RepeatCount = repeatcount;
00321       if(keysym)
00322         {
00323         this->SetKeySym(keysym);
00324         }
00325       this->Modified();
00326     }
00328 
00330 
00336   vtkSetVector2Macro(Size,int);
00337   vtkGetVector2Macro(Size,int);
00338   vtkSetVector2Macro(EventSize,int);
00339   vtkGetVector2Macro(EventSize,int);
00341 
00345   virtual vtkRenderer *FindPokedRenderer(int,int);
00346 
00347 protected:
00348   vtkRenderWindowInteractor();
00349   ~vtkRenderWindowInteractor();
00350 
00351   vtkRenderWindow    *RenderWindow;
00352   vtkInteractorObserver *InteractorStyle;
00353 
00354   // Used as a helper object to pick instances of vtkProp
00355   vtkAbstractPicker          *Picker;
00356 
00357   int   Initialized;
00358   int   Enabled;
00359   int   Style;
00360   int   LightFollowCamera;
00361   int   ActorMode;
00362   double DesiredUpdateRate;
00363   double StillUpdateRate;  
00364 
00365   // Event information
00366   int   ControlKey;
00367   int   ShiftKey;
00368   char  KeyCode;
00369   int   RepeatCount;
00370   char* KeySym; 
00371   int   EventPosition[2];
00372   int   LastEventPosition[2];
00373   int   EventSize[2];
00374   int   Size[2];
00375   
00376   // control the fly to
00377   int NumberOfFlyFrames;
00378   double Dolly;
00379   
00380 private:
00381   vtkRenderWindowInteractor(const vtkRenderWindowInteractor&);  // Not implemented.
00382   void operator=(const vtkRenderWindowInteractor&);  // Not implemented.
00383 };
00384 
00385 #endif

Generated on Mon Jan 21 23:07:36 2008 for VTK by  doxygen 1.4.3-20050530