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

# Rendering/vtkRenderWindowInteractor.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program:   Visualization Toolkit
    00004   Module:    $RCSfile: vtkRenderWindowInteractor.h,v $
    00005   Language:  C++
    00006
    00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
    00008   All rights reserved.
    00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
    00010
    00011      This software is distributed WITHOUT ANY WARRANTY; without even
    00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    00013      PURPOSE.  See the above copyright notice for more information.
    00014
    00015 =========================================================================*/
    00061 #ifndef __vtkRenderWindowInteractor_h
    00062 #define __vtkRenderWindowInteractor_h
    00063
    00064 #include "vtkObject.h"
    00065
    00066 // Timer flags for win32/X compatibility
    00067 #define VTKI_TIMER_FIRST  0
    00068 #define VTKI_TIMER_UPDATE 1
    00069
    00070 class vtkAbstractPicker;
    00071 class vtkAbstractPropPicker;
    00072 class vtkInteractorObserver;
    00073 class vtkInteractorObserver;
    00074 class vtkRenderWindow;
    00075 class vtkRenderer;
    00076
    00077 class VTK_RENDERING_EXPORT vtkRenderWindowInteractor : public vtkObject
    00078 {
    00079 public:
    00080   static vtkRenderWindowInteractor *New();
    00081   vtkTypeRevisionMacro(vtkRenderWindowInteractor,vtkObject);
    00082   void PrintSelf(ostream& os, vtkIndent indent);
    00083
    00085
    00087   virtual void Initialize();
    00088   void ReInitialize() {  this->Initialized = 0; this->Enabled = 0;
    00089                         this->Initialize(); }
    00091
    00094   virtual void UnRegister(vtkObjectBase *o);
    00095
    00099   virtual void Start() {};
    00100
    00102
    00109   virtual void Enable() { this->Enabled = 1; this->Modified();};
    00110   virtual void Disable() { this->Enabled = 0; this->Modified();};
    00111   vtkGetMacro(Enabled, int);
    00113
    00115
    00116   void SetRenderWindow(vtkRenderWindow *aren);
    00117   vtkGetObjectMacro(RenderWindow,vtkRenderWindow);
    00119
    00121   virtual void UpdateSize(int x,int y);
    00122
    00124
    00129   virtual int CreateTimer(int )  { return 1; };
    00130   virtual int DestroyTimer()    { return 1; };
    00132
    00136   virtual void TerminateApp(void) {};
    00137
    00139
    00140   virtual void SetInteractorStyle(vtkInteractorObserver *);
    00141   vtkGetObjectMacro(InteractorStyle,vtkInteractorObserver);
    00143
    00145
    00147   vtkSetMacro(LightFollowCamera,int);
    00148   vtkGetMacro(LightFollowCamera,int);
    00149   vtkBooleanMacro(LightFollowCamera,int);
    00151
    00153
    00157   vtkSetClampMacro(DesiredUpdateRate,float,0.0001f,VTK_LARGE_FLOAT);
    00158   vtkGetMacro(DesiredUpdateRate,float);
    00160
    00162
    00164   vtkSetClampMacro(StillUpdateRate,float,0.0001f,VTK_LARGE_FLOAT);
    00165   vtkGetMacro(StillUpdateRate,float);
    00167
    00169
    00170   vtkGetMacro(Initialized,int);
    00172
    00174
    00178   virtual void SetPicker(vtkAbstractPicker*);
    00179   vtkGetObjectMacro(Picker,vtkAbstractPicker);
    00181
    00184   virtual vtkAbstractPropPicker *CreateDefaultPicker();
    00185
    00186 #ifndef VTK_REMOVE_LEGACY_CODE
    00187
    00188
    00189   void SetStartPickMethod(void (*f)(void *), void *arg);
    00190   void SetStartPickMethodArgDelete(void (*f)(void *));
    00191   void SetEndPickMethod(void (*f)(void *), void *arg);
    00192   void SetEndPickMethodArgDelete(void (*f)(void *));
    00193   void SetUserMethod(void (*f)(void *), void *arg);
    00194   void SetUserMethodArgDelete(void (*f)(void *));
    00195   void SetExitMethod(void (*f)(void *), void *arg);
    00196   void SetExitMethodArgDelete(void (*f)(void *));
    00198 #endif
    00199
    00201
    00203   virtual void ExitCallback();
    00204   virtual void UserCallback();
    00205   virtual void StartPickCallback();
    00206   virtual void EndPickCallback();
    00208
    00210   virtual void GetMousePosition(int *x, int *y) { *x = 0 ; *y = 0; }
    00211
    00213
    00215   void HideCursor();
    00216   void ShowCursor();
    00218
    00221   virtual void Render();
    00222
    00224
    00227   void FlyTo(vtkRenderer *ren, float x, float y, float z);
    00228   void FlyTo(vtkRenderer *ren, float *x)
    00229     {this->FlyTo(ren, x[0], x[1], x[2]);}
    00230   void FlyToImage(vtkRenderer *ren, float x, float y);
    00231   void FlyToImage(vtkRenderer *ren, float *x)
    00232     {this->FlyToImage(ren, x[0], x[1]);}
    00234
    00236
    00237   vtkSetClampMacro(NumberOfFlyFrames,int,1,VTK_LARGE_INTEGER);
    00238   vtkGetMacro(NumberOfFlyFrames,int);
    00240
    00242
    00244   vtkSetMacro(Dolly,float);
    00245   vtkGetMacro(Dolly,float);
    00247
    00249
    00254   vtkGetVector2Macro(EventPosition,int);
    00255   vtkGetVector2Macro(LastEventPosition,int);
    00256   virtual void SetEventPosition(int x, int y)
    00257   {
    00258     vtkDebugMacro(<< this->GetClassName() << " (" << this
    00259                   << "): setting EventPosition to (" << x << "," << y << ")");
    00260     if (this->EventPosition[0] != x || this->EventPosition[1] != y)
    00261       {
    00262       this->LastEventPosition[0] = this->EventPosition[0];
    00263       this->LastEventPosition[1] = this->EventPosition[1];
    00264       this->EventPosition[0] = x;
    00265       this->EventPosition[1] = y;
    00266       this->Modified();
    00267       }
    00268   };
    00269   virtual void SetEventPosition(int pos[2])
    00270   {
    00271     this->SetEventPosition(pos[0], pos[1]);
    00272   }
    00273   virtual void SetEventPositionFlipY(int x, int y)
    00274   {
    00275     this->SetEventPosition(x, this->Size[1] - y - 1);
    00276   }
    00277   virtual void SetEventPositionFlipY(int pos[2])
    00278   {
    00279     this->SetEventPositionFlipY(pos[0], pos[1]);
    00280   }
    00281   vtkSetMacro(ControlKey, int);
    00282   vtkGetMacro(ControlKey, int);
    00283   vtkSetMacro(ShiftKey, int);
    00284   vtkGetMacro(ShiftKey, int);
    00285   vtkSetMacro(KeyCode, char);
    00286   vtkGetMacro(KeyCode, char);
    00287   vtkSetMacro(RepeatCount, int);
    00288   vtkGetMacro(RepeatCount, int);
    00289   vtkSetStringMacro(KeySym);
    00290   vtkGetStringMacro(KeySym);
    00292
    00294
    00295   void SetEventInformation(int x,
    00296                            int y,
    00297                            int ctrl=0,
    00298                            int shift=0,
    00299                            char keycode=0,
    00300                            int repeatcount=0,
    00301                            const char* keysym=0)
    00302     {
    00303       this->LastEventPosition[0] = this->EventPosition[0];
    00304       this->LastEventPosition[1] = this->EventPosition[1];
    00305       this->EventPosition[0] = x;
    00306       this->EventPosition[1] = y;
    00307       this->ControlKey = ctrl;
    00308       this->ShiftKey = shift;
    00309       this->KeyCode = keycode;
    00310       this->RepeatCount = repeatcount;
    00311       if(keysym)
    00312         {
    00313         this->SetKeySym(keysym);
    00314         }
    00315       this->Modified();
    00316     }
    00318
    00320
    00322   void SetEventInformationFlipY(int x,
    00323                                 int y,
    00324                                 int ctrl=0,
    00325                                 int shift=0,
    00326                                 char keycode=0,
    00327                                 int repeatcount=0,
    00328                                 const char* keysym=0)
    00329     {
    00330       this->SetEventInformation(x,
    00331                                 this->Size[1] - y - 1,
    00332                                 ctrl,
    00333                                 shift,
    00334                                 keycode,
    00335                                 repeatcount,
    00336                                 keysym);
    00337     }
    00339
    00341
    00342   void SetKeyEventInformation(int ctrl=0,
    00343                               int shift=0,
    00344                               char keycode=0,
    00345                               int repeatcount=0,
    00346                               const char* keysym=0)
    00347     {
    00348       this->ControlKey = ctrl;
    00349       this->ShiftKey = shift;
    00350       this->KeyCode = keycode;
    00351       this->RepeatCount = repeatcount;
    00352       if(keysym)
    00353         {
    00354         this->SetKeySym(keysym);
    00355         }
    00356       this->Modified();
    00357     }
    00359
    00361
    00367   vtkSetVector2Macro(Size,int);
    00368   vtkGetVector2Macro(Size,int);
    00369   vtkSetVector2Macro(EventSize,int);
    00370   vtkGetVector2Macro(EventSize,int);
    00372
    00376   vtkRenderer *FindPokedRenderer(int,int);
    00377
    00378 protected:
    00379   vtkRenderWindowInteractor();
    00380   ~vtkRenderWindowInteractor();
    00381
    00382   vtkRenderWindow    *RenderWindow;
    00383   vtkInteractorObserver *InteractorStyle;
    00384
    00385   // Used as a helper object to pick instances of vtkProp
    00386   vtkAbstractPicker          *Picker;
    00387
    00388   int   Initialized;
    00389   int   Enabled;
    00390   int   Style;
    00391   int   LightFollowCamera;
    00392   int   ActorMode;
    00393   float DesiredUpdateRate;
    00394   float StillUpdateRate;
    00395
    00396   // Event information
    00397   int   ControlKey;
    00398   int   ShiftKey;
    00399   char  KeyCode;
    00400   int   RepeatCount;
    00401   char* KeySym;
    00402   int   EventPosition[2];
    00403   int   LastEventPosition[2];
    00404   int   EventSize[2];
    00405   int   Size[2];
    00406
    00407   // These should be removed when the Set*Method methods that are
    00408   // deprecated above are removed.  We don't want these inside the
    00409   // check for VTK_REMOVE_LEGACY_CODE because it will change the size
    00410   // of the object.
    00411   unsigned long StartPickTag;
    00412   unsigned long EndPickTag;
    00413   unsigned long UserTag;
    00414   unsigned long ExitTag;
    00415
    00416   // control the fly to
    00417   int NumberOfFlyFrames;
    00418   float Dolly;
    00419
    00420 private:
    00421   vtkRenderWindowInteractor(const vtkRenderWindowInteractor&);  // Not implemented.
    00422   void operator=(const vtkRenderWindowInteractor&);  // Not implemented.
    00423 };
    00424
    00425 #endif