VTK
|
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 #define VTKIS_TWO_POINTER 10 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 vtkEventForwarderCommand; 00129 class vtkOutlineSource; 00130 class vtkPolyDataMapper; 00131 class vtkProp3D; 00132 class vtkProp; 00133 class vtkTDxInteractorStyle; 00134 00135 class VTKRENDERINGCORE_EXPORT vtkInteractorStyle : public vtkInteractorObserver 00136 { 00137 public: 00141 static vtkInteractorStyle *New(); 00142 00143 vtkTypeMacro(vtkInteractorStyle,vtkInteractorObserver); 00144 void PrintSelf(ostream& os, vtkIndent indent); 00145 00148 virtual void SetInteractor(vtkRenderWindowInteractor *interactor); 00149 00155 virtual void SetEnabled(int); 00156 00158 00164 vtkSetClampMacro(AutoAdjustCameraClippingRange, int, 0, 1 ); 00165 vtkGetMacro(AutoAdjustCameraClippingRange, int ); 00166 vtkBooleanMacro(AutoAdjustCameraClippingRange, int ); 00168 00172 void FindPokedRenderer(int,int); 00173 00175 00176 vtkGetMacro(State,int); 00178 00180 00181 vtkGetMacro(UseTimers,int); 00182 vtkSetMacro(UseTimers,int); 00183 vtkBooleanMacro(UseTimers,int); 00185 00187 00191 vtkSetClampMacro(TimerDuration,unsigned long,1,100000); 00192 vtkGetMacro(TimerDuration,unsigned long); 00194 00196 00197 vtkSetMacro(HandleObservers,int); 00198 vtkGetMacro(HandleObservers,int); 00199 vtkBooleanMacro(HandleObservers,int); 00201 00203 00204 virtual void OnMouseMove() {} 00205 virtual void OnLeftButtonDown() {} 00206 virtual void OnLeftButtonUp() {} 00207 virtual void OnMiddleButtonDown() {} 00208 virtual void OnMiddleButtonUp() {} 00209 virtual void OnRightButtonDown() {} 00210 virtual void OnRightButtonUp() {} 00211 virtual void OnMouseWheelForward() {} 00212 virtual void OnMouseWheelBackward() {} 00214 00217 virtual void OnChar(); 00218 00219 // OnKeyDown is triggered by pressing any key (identical to OnKeyPress()). 00220 // An empty implementation is provided. The behavior of this function should 00221 // be specified in the subclass. 00222 virtual void OnKeyDown() {} 00223 00224 // OnKeyUp is triggered by releaseing any key (identical to OnKeyRelease()). 00225 // An empty implementation is provided. The behavior of this function should 00226 // be specified in the subclass. 00227 virtual void OnKeyUp() {} 00228 00229 // OnKeyPress is triggered by pressing any key (identical to OnKeyDown()). 00230 // An empty implementation is provided. The behavior of this function should 00231 // be specified in the subclass. 00232 virtual void OnKeyPress() {} 00233 00234 // OnKeyRelease is triggered by pressing any key (identical to OnKeyUp()). 00235 // An empty implementation is provided. The behavior of this function should 00236 // be specified in the subclass. 00237 virtual void OnKeyRelease() {} 00238 00240 00241 virtual void OnExpose() {} 00242 virtual void OnConfigure() {} 00243 virtual void OnEnter() {} 00244 virtual void OnLeave() {} 00246 00249 virtual void OnTimer(); 00250 00252 00256 virtual void Rotate() {} 00257 virtual void Spin() {} 00258 virtual void Pan() {} 00259 virtual void Dolly() {} 00260 virtual void Zoom() {} 00261 virtual void UniformScale() {} 00263 00265 00266 virtual void StartState(int newstate); 00267 virtual void StopState(); 00269 00271 00272 virtual void StartAnimate(); 00273 virtual void StopAnimate(); 00274 virtual void StartRotate(); 00275 virtual void EndRotate(); 00276 virtual void StartZoom(); 00277 virtual void EndZoom(); 00278 virtual void StartPan(); 00279 virtual void EndPan(); 00280 virtual void StartSpin(); 00281 virtual void EndSpin(); 00282 virtual void StartDolly(); 00283 virtual void EndDolly(); 00284 virtual void StartUniformScale(); 00285 virtual void EndUniformScale(); 00286 virtual void StartTimer(); 00287 virtual void EndTimer(); 00288 virtual void StartTwoPointer(); 00289 virtual void EndTwoPointer(); 00291 00293 00297 virtual void HighlightProp(vtkProp *prop); 00298 virtual void HighlightActor2D(vtkActor2D *actor2D); 00299 virtual void HighlightProp3D(vtkProp3D *prop3D); 00301 00303 00305 vtkSetVector3Macro(PickColor,double); 00306 vtkGetVectorMacro(PickColor, double, 3); 00308 00310 00313 vtkSetMacro(MouseWheelMotionFactor, double); 00314 vtkGetMacro(MouseWheelMotionFactor, double); 00316 00318 00320 vtkGetObjectMacro(TDxStyle,vtkTDxInteractorStyle); 00321 virtual void SetTDxStyle(vtkTDxInteractorStyle *tdxStyle); 00323 00325 00326 void DelegateTDxEvent(unsigned long event, 00327 void *calldata); 00329 00330 protected: 00331 vtkInteractorStyle(); 00332 ~vtkInteractorStyle(); 00333 00335 00336 static void ProcessEvents(vtkObject* object, 00337 unsigned long event, 00338 void* clientdata, 00339 void* calldata); 00341 00342 // Keep track of current state 00343 int State; 00344 int AnimState; 00345 00346 // Should observers be handled here, should we fire timers 00347 int HandleObservers; 00348 int UseTimers; 00349 int TimerId; //keep track of the timers that are created/destroyed 00350 00351 int AutoAdjustCameraClippingRange; 00352 00353 // For picking and highlighting props 00354 vtkOutlineSource *Outline; 00355 vtkPolyDataMapper *OutlineMapper; 00356 vtkActor *OutlineActor; 00357 vtkRenderer *PickedRenderer; 00358 vtkProp *CurrentProp; 00359 vtkActor2D *PickedActor2D; 00360 int PropPicked; // bool: prop picked? 00361 double PickColor[3]; // support 2D picking 00362 double MouseWheelMotionFactor; 00363 00364 // Control the timer duration 00365 unsigned long TimerDuration; //in milliseconds 00366 00367 // Forward events to the RenderWindowInteractor 00368 vtkEventForwarderCommand * EventForwarder; 00369 00370 vtkTDxInteractorStyle *TDxStyle; 00371 00372 private: 00373 vtkInteractorStyle(const vtkInteractorStyle&); // Not implemented. 00374 void operator=(const vtkInteractorStyle&); // Not implemented. 00375 }; 00376 00377 #endif