VTK
vtkInteractorStyle.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkInteractorStyle.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
98 #ifndef vtkInteractorStyle_h
99 #define vtkInteractorStyle_h
100 
101 #include "vtkRenderingCoreModule.h" // For export macro
102 #include "vtkInteractorObserver.h"
103 
104 // Motion flags
105 
106 #define VTKIS_START 0
107 #define VTKIS_NONE 0
108 
109 #define VTKIS_ROTATE 1
110 #define VTKIS_PAN 2
111 #define VTKIS_SPIN 3
112 #define VTKIS_DOLLY 4
113 #define VTKIS_ZOOM 5
114 #define VTKIS_USCALE 6
115 #define VTKIS_TIMER 7
116 #define VTKIS_FORWARDFLY 8
117 #define VTKIS_REVERSEFLY 9
118 #define VTKIS_TWO_POINTER 10
119 #define VTKIS_CLIP 11
120 
121 #define VTKIS_ANIM_OFF 0
122 #define VTKIS_ANIM_ON 1
123 
124 class vtkActor2D;
125 class vtkActor;
126 class vtkCallbackCommand;
128 class vtkOutlineSource;
129 class vtkPolyDataMapper;
130 class vtkProp3D;
131 class vtkProp;
133 
134 class VTKRENDERINGCORE_EXPORT vtkInteractorStyle : public vtkInteractorObserver
135 {
136 public:
142  static vtkInteractorStyle *New();
143 
145  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
146 
151  void SetInteractor(vtkRenderWindowInteractor *interactor) VTK_OVERRIDE;
152 
160  void SetEnabled(int) VTK_OVERRIDE;
161 
163 
171  vtkSetClampMacro(AutoAdjustCameraClippingRange, int, 0, 1 );
172  vtkGetMacro(AutoAdjustCameraClippingRange, int );
173  vtkBooleanMacro(AutoAdjustCameraClippingRange, int );
175 
181  void FindPokedRenderer(int,int);
182 
184 
187  vtkGetMacro(State,int);
189 
191 
194  vtkGetMacro(UseTimers,int);
195  vtkSetMacro(UseTimers,int);
196  vtkBooleanMacro(UseTimers,int);
198 
200 
206  vtkSetClampMacro(TimerDuration,unsigned long,1,100000);
207  vtkGetMacro(TimerDuration,unsigned long);
209 
211 
214  vtkSetMacro(HandleObservers,int);
215  vtkGetMacro(HandleObservers,int);
216  vtkBooleanMacro(HandleObservers,int);
218 
222  virtual void OnMouseMove() {}
223  virtual void OnLeftButtonDown() {}
224  virtual void OnLeftButtonUp() {}
225  virtual void OnMiddleButtonDown() {}
226  virtual void OnMiddleButtonUp() {}
227  virtual void OnRightButtonDown() {}
228  virtual void OnRightButtonUp() {}
229  virtual void OnMouseWheelForward() {}
230  virtual void OnMouseWheelBackward() {}
231  virtual void OnFourthButtonDown() {}
232  virtual void OnFourthButtonUp() {}
233  virtual void OnFifthButtonDown() {}
234  virtual void OnFifthButtonUp() {}
235 
240  void OnChar() VTK_OVERRIDE;
241 
242  // OnKeyDown is triggered by pressing any key (identical to OnKeyPress()).
243  // An empty implementation is provided. The behavior of this function should
244  // be specified in the subclass.
245  virtual void OnKeyDown() {}
246 
247  // OnKeyUp is triggered by releaseing any key (identical to OnKeyRelease()).
248  // An empty implementation is provided. The behavior of this function should
249  // be specified in the subclass.
250  virtual void OnKeyUp() {}
251 
252  // OnKeyPress is triggered by pressing any key (identical to OnKeyDown()).
253  // An empty implementation is provided. The behavior of this function should
254  // be specified in the subclass.
255  virtual void OnKeyPress() {}
256 
257  // OnKeyRelease is triggered by pressing any key (identical to OnKeyUp()).
258  // An empty implementation is provided. The behavior of this function should
259  // be specified in the subclass.
260  virtual void OnKeyRelease() {}
261 
265  virtual void OnExpose() {}
266  virtual void OnConfigure() {}
267  virtual void OnEnter() {}
268  virtual void OnLeave() {}
269 
274  virtual void OnTimer();
275 
282  virtual void Rotate() {}
283  virtual void Spin() {}
284  virtual void Pan() {}
285  virtual void Dolly() {}
286  virtual void Zoom() {}
287  virtual void UniformScale() {}
288 
292  virtual void OnPinch() {}
293  virtual void OnRotate() {}
294  virtual void OnPan() {}
295  virtual void OnTap() {}
296  virtual void OnLongTap() {}
297  virtual void OnSwipe() {}
298 
300 
303  virtual void StartState(int newstate);
304  virtual void StopState();
306 
308 
311  virtual void StartAnimate();
312  virtual void StopAnimate();
313  virtual void StartRotate();
314  virtual void EndRotate();
315  virtual void StartZoom();
316  virtual void EndZoom();
317  virtual void StartPan();
318  virtual void EndPan();
319  virtual void StartSpin();
320  virtual void EndSpin();
321  virtual void StartDolly();
322  virtual void EndDolly();
323  virtual void StartUniformScale();
324  virtual void EndUniformScale();
325  virtual void StartTimer();
326  virtual void EndTimer();
327  virtual void StartTwoPointer();
328  virtual void EndTwoPointer();
330 
332 
338  virtual void HighlightProp(vtkProp *prop);
339  virtual void HighlightActor2D(vtkActor2D *actor2D);
340  virtual void HighlightProp3D(vtkProp3D *prop3D);
342 
344 
348  vtkSetVector3Macro(PickColor,double);
349  vtkGetVectorMacro(PickColor, double, 3);
351 
353 
358  vtkSetMacro(MouseWheelMotionFactor, double);
359  vtkGetMacro(MouseWheelMotionFactor, double);
361 
363 
367  vtkGetObjectMacro(TDxStyle,vtkTDxInteractorStyle);
368  virtual void SetTDxStyle(vtkTDxInteractorStyle *tdxStyle);
370 
374  void DelegateTDxEvent(unsigned long event,
375  void *calldata);
376 
377 protected:
379  ~vtkInteractorStyle() VTK_OVERRIDE;
380 
384  static void ProcessEvents(vtkObject* object,
385  unsigned long event,
386  void* clientdata,
387  void* calldata);
388 
389  // Keep track of current state
390  int State;
392 
393  // Should observers be handled here, should we fire timers
396  int TimerId; //keep track of the timers that are created/destroyed
397 
399 
400  // For picking and highlighting props
407  int PropPicked; // bool: prop picked?
408  double PickColor[3]; // support 2D picking
410 
411  // Control the timer duration
412  unsigned long TimerDuration; //in milliseconds
413 
414  // Forward events to the RenderWindowInteractor
416 
418 
419 private:
420  vtkInteractorStyle(const vtkInteractorStyle&) VTK_DELETE_FUNCTION;
421  void operator=(const vtkInteractorStyle&) VTK_DELETE_FUNCTION;
422 };
423 
424 #endif
a simple event forwarder command
virtual void OnLeftButtonDown()
virtual void Rotate()
These methods for the different interactions in different modes are overridden in subclasses to perfo...
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:50
virtual void SetInteractor(vtkRenderWindowInteractor *iren)
This method is used to associate the widget with the render window interactor.
virtual void OnSwipe()
virtual void OnRotate()
virtual void OnMiddleButtonDown()
virtual void OnRightButtonDown()
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
abstract base class for most VTK objects
Definition: vtkObject.h:59
virtual void OnLeftButtonUp()
virtual void OnKeyUp()
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Handles the char widget activation event.
virtual void OnMiddleButtonUp()
virtual void OnFifthButtonUp()
a actor that draws 2D data
Definition: vtkActor2D.h:45
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
virtual void UniformScale()
abstract specification for renderers
Definition: vtkRenderer.h:63
virtual void OnMouseWheelForward()
represents an 3D object for placement in a rendered scene
Definition: vtkProp3D.h:46
virtual void OnKeyRelease()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void OnKeyPress()
virtual void OnEnter()
an abstract superclass for classes observing events invoked by vtkRenderWindowInteractor ...
vtkPolyDataMapper * OutlineMapper
virtual void OnRightButtonUp()
platform-independent render window interaction including picking and frame rate control.
virtual void OnLongTap()
vtkEventForwarderCommand * EventForwarder
virtual void OnExpose()
These are more esoteric events, but are useful in some cases.
supports function callbacks
vtkActor2D * PickedActor2D
virtual void OnKeyDown()
virtual void OnConfigure()
a simple class to control print indentation
Definition: vtkIndent.h:39
virtual void OnMouseWheelBackward()
unsigned long TimerDuration
create wireframe outline around bounding box
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
vtkRenderer * PickedRenderer
provide 3DConnexion device event-driven interface to the rendering window
virtual void OnFifthButtonDown()
map vtkPolyData to graphics primitives
provide event-driven interface to the rendering window (defines trackball mode)
virtual void OnLeave()
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
virtual void OnChar()
Sets up the keypress-i event.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual void OnFourthButtonDown()
virtual void OnPinch()
gesture based events
virtual void OnFourthButtonUp()
vtkOutlineSource * Outline
vtkTDxInteractorStyle * TDxStyle