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

Rendering/vtkInteractorStyle.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkInteractorStyle.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 =========================================================================*/
00102 #ifndef __vtkInteractorStyle_h
00103 #define __vtkInteractorStyle_h
00104 
00105 #include "vtkInteractorObserver.h"
00106 
00107 // Motion flags
00108 
00109 #define VTKIS_START        0
00110 #define VTKIS_NONE         0
00111 
00112 #define VTKIS_ROTATE       1
00113 #define VTKIS_PAN          2
00114 #define VTKIS_SPIN         3
00115 #define VTKIS_DOLLY        4
00116 #define VTKIS_ZOOM         5
00117 #define VTKIS_USCALE       6
00118 #define VTKIS_TIMER        7
00119 #define VTKIS_FORWARDFLY   8
00120 #define VTKIS_REVERSEFLY   9
00121 
00122 #define VTKIS_ANIM_OFF 0
00123 #define VTKIS_ANIM_ON  1
00124 
00125 class vtkActor2D;
00126 class vtkActor;
00127 class vtkCallbackCommand;
00128 class vtkOutlineSource;
00129 class vtkPolyDataMapper;
00130 class vtkProp3D;
00131 class vtkProp;
00132 
00133 class VTK_RENDERING_EXPORT vtkInteractorStyle : public vtkInteractorObserver
00134 {
00135 public:
00139   static vtkInteractorStyle *New();
00140 
00141   vtkTypeRevisionMacro(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 
00186   vtkSetMacro(HandleObservers,int);
00187   vtkGetMacro(HandleObservers,int);
00188   vtkBooleanMacro(HandleObservers,int);
00190 
00192 
00193   virtual void OnMouseMove() {};
00194   virtual void OnLeftButtonDown() {};
00195   virtual void OnLeftButtonUp() {};
00196   virtual void OnMiddleButtonDown() {};
00197   virtual void OnMiddleButtonUp() {};
00198   virtual void OnRightButtonDown() {};
00199   virtual void OnRightButtonUp() {};
00201 
00203 
00205   virtual void OnChar();
00206   virtual void OnKeyDown() {};
00207   virtual void OnKeyUp() {};
00208   virtual void OnKeyPress() {};
00209   virtual void OnKeyRelease() {};
00211 
00213 
00214   virtual void OnExpose() {};
00215   virtual void OnConfigure() {};
00216   virtual void OnEnter() {};
00217   virtual void OnLeave() {};
00219 
00222   virtual void OnTimer();
00223 
00225 
00229   virtual void Rotate() {};
00230   virtual void Spin() {};
00231   virtual void Pan() {};
00232   virtual void Dolly() {};
00233   virtual void Zoom() {};
00234   virtual void UniformScale() {};
00236 
00238 
00239   virtual void StartState(int newstate);
00240   virtual void StopState();
00242 
00244 
00245   virtual void StartAnimate();  
00246   virtual void StopAnimate();  
00247   virtual void StartRotate();
00248   virtual void EndRotate();
00249   virtual void StartZoom();
00250   virtual void EndZoom();
00251   virtual void StartPan();
00252   virtual void EndPan();
00253   virtual void StartSpin();
00254   virtual void EndSpin();
00255   virtual void StartDolly();
00256   virtual void EndDolly();
00257   virtual void StartUniformScale();
00258   virtual void EndUniformScale();
00259   virtual void StartTimer();
00260   virtual void EndTimer();
00262 
00263 #ifndef VTK_REMOVE_LEGACY_CODE
00264 
00265 
00266   void SetLeftButtonPressMethod(void (*f)(void *), void *arg);
00267   void SetLeftButtonPressMethodArgDelete(void (*f)(void *));
00268   void SetLeftButtonReleaseMethod(void (*f)(void *), void *arg);
00269   void SetLeftButtonReleaseMethodArgDelete(void (*f)(void *));
00270   void SetMiddleButtonPressMethod(void (*f)(void *), void *arg);
00271   void SetMiddleButtonPressMethodArgDelete(void (*f)(void *));
00272   void SetMiddleButtonReleaseMethod(void (*f)(void *), void *arg);
00273   void SetMiddleButtonReleaseMethodArgDelete(void (*f)(void *));
00274   void SetRightButtonPressMethod(void (*f)(void *), void *arg);
00275   void SetRightButtonPressMethodArgDelete(void (*f)(void *));
00276   void SetRightButtonReleaseMethod(void (*f)(void *), void *arg);
00277   void SetRightButtonReleaseMethodArgDelete(void (*f)(void *));
00279 #endif
00280 
00282 
00286   virtual void HighlightProp(vtkProp *prop);
00287   virtual void HighlightActor2D(vtkActor2D *actor2D);
00288   virtual void HighlightProp3D(vtkProp3D *prop3D);
00290 
00292 
00294   vtkSetVector3Macro(PickColor,float);
00295   vtkGetVectorMacro(PickColor, float, 3);
00297 
00298 protected:
00299   vtkInteractorStyle();
00300   ~vtkInteractorStyle();
00301   
00303 
00304   static void ProcessEvents(vtkObject* object, 
00305                             unsigned long event,
00306                             void* clientdata, 
00307                             void* calldata);
00309   
00310   // Keep track of current state
00311 
00312   int State;  
00313   int AnimState;  
00314 
00315   // Should observers be handled here, should we fire timers
00316 
00317   int HandleObservers; 
00318   int UseTimers;       
00319 
00320   int AutoAdjustCameraClippingRange;
00321 
00322   // For picking and highlighting props
00323 
00324   vtkOutlineSource   *Outline;
00325   vtkPolyDataMapper  *OutlineMapper;
00326   vtkActor           *OutlineActor;
00327   vtkRenderer        *PickedRenderer;
00328   vtkProp            *CurrentProp;
00329   vtkActor2D         *PickedActor2D;
00330   int                PropPicked;      // bool: prop picked?
00331   float              PickColor[3];    // support 2D picking
00332 
00333   // These should be removed when the Set*Method methods that are
00334   // deprecated above are removed.  We don't want these inside the
00335   // check for VTK_REMOVE_LEGACY_CODE because it will change the size
00336   // of the object.
00337   unsigned long LeftButtonPressTag;
00338   unsigned long LeftButtonReleaseTag;
00339   unsigned long MiddleButtonPressTag;
00340   unsigned long MiddleButtonReleaseTag;
00341   unsigned long RightButtonPressTag;
00342   unsigned long RightButtonReleaseTag;
00343 
00344 private:
00345   vtkInteractorStyle(const vtkInteractorStyle&);  // Not implemented.
00346   void operator=(const vtkInteractorStyle&);  // Not implemented.
00347 };
00348 
00349 #endif