VTK
dox/Rendering/Core/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 "vtkRenderingCoreModule.h" // For export macro
00104 #include "vtkInteractorObserver.h"
00105 
00106 // Motion flags
00107 
00108 #define VTKIS_START        0
00109 #define VTKIS_NONE         0
00110 
00111 #define VTKIS_ROTATE       1
00112 #define VTKIS_PAN          2
00113 #define VTKIS_SPIN         3
00114 #define VTKIS_DOLLY        4
00115 #define VTKIS_ZOOM         5
00116 #define VTKIS_USCALE       6
00117 #define VTKIS_TIMER        7
00118 #define VTKIS_FORWARDFLY   8
00119 #define VTKIS_REVERSEFLY   9
00120 
00121 #define VTKIS_ANIM_OFF 0
00122 #define VTKIS_ANIM_ON  1
00123 
00124 class vtkActor2D;
00125 class vtkActor;
00126 class vtkCallbackCommand;
00127 class vtkEventForwarderCommand;
00128 class vtkOutlineSource;
00129 class vtkPolyDataMapper;
00130 class vtkProp3D;
00131 class vtkProp;
00132 class vtkTDxInteractorStyle;
00133 
00134 class VTKRENDERINGCORE_EXPORT vtkInteractorStyle : public vtkInteractorObserver
00135 {
00136 public:
00140   static vtkInteractorStyle *New();
00141 
00142   vtkTypeMacro(vtkInteractorStyle,vtkInteractorObserver);
00143   void PrintSelf(ostream& os, vtkIndent indent);
00144 
00147   virtual void SetInteractor(vtkRenderWindowInteractor *interactor);
00148 
00154   virtual void SetEnabled(int);
00155 
00157 
00163   vtkSetClampMacro(AutoAdjustCameraClippingRange, int, 0, 1 );
00164   vtkGetMacro(AutoAdjustCameraClippingRange, int );
00165   vtkBooleanMacro(AutoAdjustCameraClippingRange, int );
00167 
00171   void FindPokedRenderer(int,int);
00172 
00174 
00175   vtkGetMacro(State,int);
00177 
00179 
00180   vtkGetMacro(UseTimers,int);
00181   vtkSetMacro(UseTimers,int);
00182   vtkBooleanMacro(UseTimers,int);
00184 
00186 
00190   vtkSetClampMacro(TimerDuration,unsigned long,1,100000);
00191   vtkGetMacro(TimerDuration,unsigned long);
00193 
00195 
00196   vtkSetMacro(HandleObservers,int);
00197   vtkGetMacro(HandleObservers,int);
00198   vtkBooleanMacro(HandleObservers,int);
00200 
00202 
00203   virtual void OnMouseMove() {}
00204   virtual void OnLeftButtonDown() {}
00205   virtual void OnLeftButtonUp() {}
00206   virtual void OnMiddleButtonDown() {}
00207   virtual void OnMiddleButtonUp() {}
00208   virtual void OnRightButtonDown() {}
00209   virtual void OnRightButtonUp() {}
00210   virtual void OnMouseWheelForward() {}
00211   virtual void OnMouseWheelBackward() {}
00213 
00216   virtual void OnChar();
00217 
00218   // OnKeyDown is triggered by pressing any key (identical to OnKeyPress()).
00219   // An empty implementation is provided. The behavior of this function should
00220   // be specified in the subclass.
00221   virtual void OnKeyDown() {}
00222 
00223   // OnKeyUp is triggered by releaseing any key (identical to OnKeyRelease()).
00224   // An empty implementation is provided. The behavior of this function should
00225   // be specified in the subclass.
00226   virtual void OnKeyUp() {}
00227 
00228   // OnKeyPress is triggered by pressing any key (identical to OnKeyDown()).
00229   // An empty implementation is provided. The behavior of this function should
00230   // be specified in the subclass.
00231   virtual void OnKeyPress() {}
00232 
00233   // OnKeyRelease is triggered by pressing any key (identical to OnKeyUp()).
00234   // An empty implementation is provided. The behavior of this function should
00235   // be specified in the subclass.
00236   virtual void OnKeyRelease() {}
00237 
00239 
00240   virtual void OnExpose() {}
00241   virtual void OnConfigure() {}
00242   virtual void OnEnter() {}
00243   virtual void OnLeave() {}
00245 
00248   virtual void OnTimer();
00249 
00251 
00255   virtual void Rotate() {}
00256   virtual void Spin() {}
00257   virtual void Pan() {}
00258   virtual void Dolly() {}
00259   virtual void Zoom() {}
00260   virtual void UniformScale() {}
00262 
00264 
00265   virtual void StartState(int newstate);
00266   virtual void StopState();
00268 
00270 
00271   virtual void StartAnimate();
00272   virtual void StopAnimate();
00273   virtual void StartRotate();
00274   virtual void EndRotate();
00275   virtual void StartZoom();
00276   virtual void EndZoom();
00277   virtual void StartPan();
00278   virtual void EndPan();
00279   virtual void StartSpin();
00280   virtual void EndSpin();
00281   virtual void StartDolly();
00282   virtual void EndDolly();
00283   virtual void StartUniformScale();
00284   virtual void EndUniformScale();
00285   virtual void StartTimer();
00286   virtual void EndTimer();
00288 
00290 
00294   virtual void HighlightProp(vtkProp *prop);
00295   virtual void HighlightActor2D(vtkActor2D *actor2D);
00296   virtual void HighlightProp3D(vtkProp3D *prop3D);
00298 
00300 
00302   vtkSetVector3Macro(PickColor,double);
00303   vtkGetVectorMacro(PickColor, double, 3);
00305 
00307 
00310   vtkSetMacro(MouseWheelMotionFactor, double);
00311   vtkGetMacro(MouseWheelMotionFactor, double);
00313 
00315 
00317   vtkGetObjectMacro(TDxStyle,vtkTDxInteractorStyle);
00318   virtual void SetTDxStyle(vtkTDxInteractorStyle *tdxStyle);
00320 
00322 
00323   void DelegateTDxEvent(unsigned long event,
00324                         void *calldata);
00326 
00327 protected:
00328   vtkInteractorStyle();
00329   ~vtkInteractorStyle();
00330 
00332 
00333   static void ProcessEvents(vtkObject* object,
00334                             unsigned long event,
00335                             void* clientdata,
00336                             void* calldata);
00338 
00339   // Keep track of current state
00340   int State;
00341   int AnimState;
00342 
00343   // Should observers be handled here, should we fire timers
00344   int HandleObservers;
00345   int UseTimers;
00346   int TimerId; //keep track of the timers that are created/destroyed
00347 
00348   int AutoAdjustCameraClippingRange;
00349 
00350   // For picking and highlighting props
00351   vtkOutlineSource   *Outline;
00352   vtkPolyDataMapper  *OutlineMapper;
00353   vtkActor           *OutlineActor;
00354   vtkRenderer        *PickedRenderer;
00355   vtkProp            *CurrentProp;
00356   vtkActor2D         *PickedActor2D;
00357   int                PropPicked;      // bool: prop picked?
00358   double             PickColor[3];    // support 2D picking
00359   double             MouseWheelMotionFactor;
00360 
00361   // Control the timer duration
00362   unsigned long  TimerDuration; //in milliseconds
00363 
00364   // Forward events to the RenderWindowInteractor
00365   vtkEventForwarderCommand * EventForwarder;
00366 
00367   vtkTDxInteractorStyle *TDxStyle;
00368 
00369 private:
00370   vtkInteractorStyle(const vtkInteractorStyle&);  // Not implemented.
00371   void operator=(const vtkInteractorStyle&);  // Not implemented.
00372 };
00373 
00374 #endif