VTK
dox/Rendering/vtkInteractorStyle.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkInteractorStyle.h
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 =========================================================================*/
00100 #ifndef __vtkInteractorStyle_h
00101 #define __vtkInteractorStyle_h
00102 
00103 #include "vtkInteractorObserver.h"
00104 
00105 // Motion flags
00106 
00107 #define VTKIS_START        0
00108 #define VTKIS_NONE         0
00109 
00110 #define VTKIS_ROTATE       1
00111 #define VTKIS_PAN          2
00112 #define VTKIS_SPIN         3
00113 #define VTKIS_DOLLY        4
00114 #define VTKIS_ZOOM         5
00115 #define VTKIS_USCALE       6
00116 #define VTKIS_TIMER        7
00117 #define VTKIS_FORWARDFLY   8
00118 #define VTKIS_REVERSEFLY   9
00119 
00120 #define VTKIS_ANIM_OFF 0
00121 #define VTKIS_ANIM_ON  1
00122 
00123 class vtkActor2D;
00124 class vtkActor;
00125 class vtkCallbackCommand;
00126 class vtkEventForwarderCommand;
00127 class vtkOutlineSource;
00128 class vtkPolyDataMapper;
00129 class vtkProp3D;
00130 class vtkProp;
00131 class vtkTDxInteractorStyle;
00132 
00133 class VTK_RENDERING_EXPORT vtkInteractorStyle : public vtkInteractorObserver
00134 {
00135 public:
00139   static vtkInteractorStyle *New();
00140 
00141   vtkTypeMacro(vtkInteractorStyle,vtkInteractorObserver);
00142   void PrintSelf(ostream& os, vtkIndent indent);
00143 
00146   virtual void SetInteractor(vtkRenderWindowInteractor *interactor);
00147 
00153   virtual void SetEnabled(int);
00154 
00156 
00162   vtkSetClampMacro(AutoAdjustCameraClippingRange, int, 0, 1 );
00163   vtkGetMacro(AutoAdjustCameraClippingRange, int );
00164   vtkBooleanMacro(AutoAdjustCameraClippingRange, int );
00166   
00170   void FindPokedRenderer(int,int);
00171 
00173 
00174   vtkGetMacro(State,int);
00176 
00178 
00179   vtkGetMacro(UseTimers,int);
00180   vtkSetMacro(UseTimers,int);
00181   vtkBooleanMacro(UseTimers,int);
00183 
00185 
00189   vtkSetClampMacro(TimerDuration,unsigned long,1,100000);
00190   vtkGetMacro(TimerDuration,unsigned long);
00192 
00194 
00195   vtkSetMacro(HandleObservers,int);
00196   vtkGetMacro(HandleObservers,int);
00197   vtkBooleanMacro(HandleObservers,int);
00199 
00201 
00202   virtual void OnMouseMove() {};
00203   virtual void OnLeftButtonDown() {};
00204   virtual void OnLeftButtonUp() {};
00205   virtual void OnMiddleButtonDown() {};
00206   virtual void OnMiddleButtonUp() {};
00207   virtual void OnRightButtonDown() {};
00208   virtual void OnRightButtonUp() {};
00209   virtual void OnMouseWheelForward() {};
00210   virtual void OnMouseWheelBackward() {};
00212 
00215   virtual void OnChar();
00216 
00217   // OnKeyDown is triggered by pressing any key (identical to OnKeyPress()).
00218   // An empty implementation is provided. The behavior of this function should
00219   // be specified in the subclass.
00220   virtual void OnKeyDown() {};
00221 
00222   // OnKeyUp is triggered by releaseing any key (identical to OnKeyRelease()).
00223   // An empty implementation is provided. The behavior of this function should
00224   // be specified in the subclass.
00225   virtual void OnKeyUp() {};
00226 
00227   // OnKeyPress is triggered by pressing any key (identical to OnKeyDown()).
00228   // An empty implementation is provided. The behavior of this function should
00229   // be specified in the subclass.
00230   virtual void OnKeyPress() {};
00231 
00232   // OnKeyRelease is triggered by pressing any key (identical to OnKeyUp()).
00233   // An empty implementation is provided. The behavior of this function should
00234   // be specified in the subclass.
00235   virtual void OnKeyRelease() {};
00236 
00238 
00239   virtual void OnExpose() {};
00240   virtual void OnConfigure() {};
00241   virtual void OnEnter() {};
00242   virtual void OnLeave() {};
00244 
00247   virtual void OnTimer();
00248 
00250 
00254   virtual void Rotate() {};
00255   virtual void Spin() {};
00256   virtual void Pan() {};
00257   virtual void Dolly() {};
00258   virtual void Zoom() {};
00259   virtual void UniformScale() {};
00261 
00263 
00264   virtual void StartState(int newstate);
00265   virtual void StopState();
00267 
00269 
00270   virtual void StartAnimate();  
00271   virtual void StopAnimate();  
00272   virtual void StartRotate();
00273   virtual void EndRotate();
00274   virtual void StartZoom();
00275   virtual void EndZoom();
00276   virtual void StartPan();
00277   virtual void EndPan();
00278   virtual void StartSpin();
00279   virtual void EndSpin();
00280   virtual void StartDolly();
00281   virtual void EndDolly();
00282   virtual void StartUniformScale();
00283   virtual void EndUniformScale();
00284   virtual void StartTimer();
00285   virtual void EndTimer();
00287 
00289 
00293   virtual void HighlightProp(vtkProp *prop);
00294   virtual void HighlightActor2D(vtkActor2D *actor2D);
00295   virtual void HighlightProp3D(vtkProp3D *prop3D);
00297 
00299 
00301   vtkSetVector3Macro(PickColor,double);
00302   vtkGetVectorMacro(PickColor, double, 3);
00304 
00306 
00309   vtkSetMacro(MouseWheelMotionFactor, double);
00310   vtkGetMacro(MouseWheelMotionFactor, double);
00312 
00314 
00316   vtkGetObjectMacro(TDxStyle,vtkTDxInteractorStyle);
00317   virtual void SetTDxStyle(vtkTDxInteractorStyle *tdxStyle);
00319   
00321 
00322   void DelegateTDxEvent(unsigned long event,
00323                         void *calldata);
00325   
00326 protected:
00327   vtkInteractorStyle();
00328   ~vtkInteractorStyle();
00329   
00331 
00332   static void ProcessEvents(vtkObject* object, 
00333                             unsigned long event,
00334                             void* clientdata, 
00335                             void* calldata);
00337   
00338   // Keep track of current state
00339   int State;  
00340   int AnimState;  
00341 
00342   // Should observers be handled here, should we fire timers
00343   int HandleObservers; 
00344   int UseTimers;       
00345   int TimerId; //keep track of the timers that are created/destroyed
00346 
00347   int AutoAdjustCameraClippingRange;
00348 
00349   // For picking and highlighting props
00350   vtkOutlineSource   *Outline;
00351   vtkPolyDataMapper  *OutlineMapper;
00352   vtkActor           *OutlineActor;
00353   vtkRenderer        *PickedRenderer;
00354   vtkProp            *CurrentProp;
00355   vtkActor2D         *PickedActor2D;
00356   int                PropPicked;      // bool: prop picked?
00357   double             PickColor[3];    // support 2D picking
00358   double             MouseWheelMotionFactor;
00359 
00360   // Control the timer duration
00361   unsigned long  TimerDuration; //in milliseconds
00362   
00363   // Forward events to the RenderWindowInteractor
00364   vtkEventForwarderCommand * EventForwarder;
00365 
00366   vtkTDxInteractorStyle *TDxStyle;
00367   
00368 private:
00369   vtkInteractorStyle(const vtkInteractorStyle&);  // Not implemented.
00370   void operator=(const vtkInteractorStyle&);  // Not implemented.
00371 };
00372 
00373 #endif