VTK  9.0.1
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 =========================================================================*/
92 #ifndef vtkInteractorStyle_h
93 #define vtkInteractorStyle_h
94 
95 #include "vtkInteractorObserver.h"
96 #include "vtkRenderingCoreModule.h" // For export macro
97 
98 // Motion flags
99 
100 #define VTKIS_START 0
101 #define VTKIS_NONE 0
102 
103 #define VTKIS_ROTATE 1
104 #define VTKIS_PAN 2
105 #define VTKIS_SPIN 3
106 #define VTKIS_DOLLY 4
107 #define VTKIS_ZOOM 5
108 #define VTKIS_USCALE 6
109 #define VTKIS_TIMER 7
110 #define VTKIS_FORWARDFLY 8
111 #define VTKIS_REVERSEFLY 9
112 #define VTKIS_TWO_POINTER 10
113 #define VTKIS_CLIP 11
114 #define VTKIS_PICK 12 // perform a pick at the last location
115 #define VTKIS_LOAD_CAMERA_POSE 13 // iterate through saved camera poses
116 #define VTKIS_POSITION_PROP 14 // adjust the position, orientation of a prop
117 #define VTKIS_EXIT 15 // call exit callback
118 #define VTKIS_TOGGLE_DRAW_CONTROLS 16 // draw device controls helpers
119 #define VTKIS_MENU 17 // invoke an application menu
120 #define VTKIS_GESTURE 18 // touch interaction in progress
121 #define VTKIS_ENV_ROTATE 19 // rotate the renderer environment texture
122 
123 #define VTKIS_ANIM_OFF 0
124 #define VTKIS_ANIM_ON 1
125 
126 class vtkActor2D;
127 class vtkActor;
128 class vtkCallbackCommand;
129 class vtkEventData;
131 class vtkOutlineSource;
132 class vtkPolyDataMapper;
133 class vtkProp3D;
134 class vtkProp;
135 class vtkStringArray;
137 
138 class VTKRENDERINGCORE_EXPORT vtkInteractorStyle : public vtkInteractorObserver
139 {
140 public:
147 
149  void PrintSelf(ostream& os, vtkIndent indent) override;
150 
155  void SetInteractor(vtkRenderWindowInteractor* interactor) override;
156 
164  void SetEnabled(int) override;
165 
167 
175  vtkSetClampMacro(AutoAdjustCameraClippingRange, vtkTypeBool, 0, 1);
176  vtkGetMacro(AutoAdjustCameraClippingRange, vtkTypeBool);
177  vtkBooleanMacro(AutoAdjustCameraClippingRange, vtkTypeBool);
179 
185  void FindPokedRenderer(int, int);
186 
188 
191  vtkGetMacro(State, int);
193 
195 
198  vtkGetMacro(UseTimers, vtkTypeBool);
199  vtkSetMacro(UseTimers, vtkTypeBool);
200  vtkBooleanMacro(UseTimers, vtkTypeBool);
202 
204 
210  vtkSetClampMacro(TimerDuration, unsigned long, 1, 100000);
211  vtkGetMacro(TimerDuration, unsigned long);
213 
215 
218  vtkSetMacro(HandleObservers, vtkTypeBool);
219  vtkGetMacro(HandleObservers, vtkTypeBool);
220  vtkBooleanMacro(HandleObservers, vtkTypeBool);
222 
226  virtual void OnMouseMove() {}
227  virtual void OnLeftButtonDown() {}
228  virtual void OnLeftButtonUp() {}
229  virtual void OnMiddleButtonDown() {}
230  virtual void OnMiddleButtonUp() {}
231  virtual void OnRightButtonDown() {}
232  virtual void OnRightButtonUp() {}
233  virtual void OnMouseWheelForward() {}
234  virtual void OnMouseWheelBackward() {}
235  virtual void OnFourthButtonDown() {}
236  virtual void OnFourthButtonUp() {}
237  virtual void OnFifthButtonDown() {}
238  virtual void OnFifthButtonUp() {}
239 
243  virtual void OnMove3D(vtkEventData*) {}
244  virtual void OnButton3D(vtkEventData*) {}
245 
250  void OnChar() override;
251 
252  // OnKeyDown is triggered by pressing any key (identical to OnKeyPress()).
253  // An empty implementation is provided. The behavior of this function should
254  // be specified in the subclass.
255  virtual void OnKeyDown() {}
256 
257  // OnKeyUp is triggered by releaseing any key (identical to OnKeyRelease()).
258  // An empty implementation is provided. The behavior of this function should
259  // be specified in the subclass.
260  virtual void OnKeyUp() {}
261 
262  // OnKeyPress is triggered by pressing any key (identical to OnKeyDown()).
263  // An empty implementation is provided. The behavior of this function should
264  // be specified in the subclass.
265  virtual void OnKeyPress() {}
266 
267  // OnKeyRelease is triggered by pressing any key (identical to OnKeyUp()).
268  // An empty implementation is provided. The behavior of this function should
269  // be specified in the subclass.
270  virtual void OnKeyRelease() {}
271 
275  virtual void OnExpose() {}
276  virtual void OnConfigure() {}
277  virtual void OnEnter() {}
278  virtual void OnLeave() {}
279 
284  virtual void OnTimer();
285 
292  virtual void Rotate() {}
293  virtual void Spin() {}
294  virtual void Pan() {}
295  virtual void Dolly() {}
296  virtual void Zoom() {}
297  virtual void UniformScale() {}
298  virtual void EnvironmentRotate() {}
299 
303  virtual void OnStartSwipe() {}
304  virtual void OnSwipe() {}
305  virtual void OnEndSwipe() {}
306  virtual void OnStartPinch() {}
307  virtual void OnPinch() {}
308  virtual void OnEndPinch() {}
309  virtual void OnStartRotate() {}
310  virtual void OnRotate() {}
311  virtual void OnEndRotate() {}
312  virtual void OnStartPan() {}
313  virtual void OnPan() {}
314  virtual void OnEndPan() {}
315  virtual void OnTap() {}
316  virtual void OnLongTap() {}
317 
319 
322  virtual void StartState(int newstate);
323  virtual void StopState();
325 
327 
330  virtual void StartAnimate();
331  virtual void StopAnimate();
332  virtual void StartRotate();
333  virtual void EndRotate();
334  virtual void StartZoom();
335  virtual void EndZoom();
336  virtual void StartPan();
337  virtual void EndPan();
338  virtual void StartSpin();
339  virtual void EndSpin();
340  virtual void StartDolly();
341  virtual void EndDolly();
342  virtual void StartUniformScale();
343  virtual void EndUniformScale();
344  virtual void StartTimer();
345  virtual void EndTimer();
346  virtual void StartTwoPointer();
347  virtual void EndTwoPointer();
348  virtual void StartGesture();
349  virtual void EndGesture();
350  virtual void StartEnvRotate();
351  virtual void EndEnvRotate();
353 
360  virtual void OnDropLocation(double* vtkNotUsed(position)) {}
361 
367  virtual void OnDropFiles(vtkStringArray* vtkNotUsed(filePaths)) {}
368 
370 
376  virtual void HighlightProp(vtkProp* prop);
377  virtual void HighlightActor2D(vtkActor2D* actor2D);
378  virtual void HighlightProp3D(vtkProp3D* prop3D);
380 
382 
386  vtkSetVector3Macro(PickColor, double);
387  vtkGetVectorMacro(PickColor, double, 3);
389 
391 
396  vtkSetMacro(MouseWheelMotionFactor, double);
397  vtkGetMacro(MouseWheelMotionFactor, double);
399 
401 
405  vtkGetObjectMacro(TDxStyle, vtkTDxInteractorStyle);
406  virtual void SetTDxStyle(vtkTDxInteractorStyle* tdxStyle);
408 
412  void DelegateTDxEvent(unsigned long event, void* calldata);
413 
414 protected:
417 
421  static void ProcessEvents(
422  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
423 
424  // Keep track of current state
425  int State;
427 
428  // Should observers be handled here, should we fire timers
431  int TimerId; // keep track of the timers that are created/destroyed
432 
434 
435  // For picking and highlighting props
442  int PropPicked; // bool: prop picked?
443  double PickColor[3]; // support 2D picking
445 
446  // Control the timer duration
447  unsigned long TimerDuration; // in milliseconds
448 
449  // Forward events to the RenderWindowInteractor
451 
453 
454 private:
455  vtkInteractorStyle(const vtkInteractorStyle&) = delete;
456  void operator=(const vtkInteractorStyle&) = delete;
457 };
458 
459 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:40
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:46
supports function callbacks
a simple event forwarder command
a simple class to control print indentation
Definition: vtkIndent.h:34
an abstract superclass for classes observing events invoked by vtkRenderWindowInteractor
provide event-driven interface to the rendering window (defines trackball mode)
virtual void StopAnimate()
vtkPolyDataMapper * OutlineMapper
virtual void OnFifthButtonUp()
virtual void OnMove3D(vtkEventData *)
Generic 3D event bindings can be overridden in subclasses.
virtual void OnMouseWheelBackward()
virtual void OnMiddleButtonDown()
virtual void OnLongTap()
virtual void OnEnter()
void SetEnabled(int) override
Turn on/off this interactor.
virtual void StartEnvRotate()
virtual void HighlightProp(vtkProp *prop)
When picking successfully selects an actor, this method highlights the picked prop appropriately.
virtual void EndUniformScale()
virtual void OnStartSwipe()
gesture based events
virtual void StartPan()
vtkEventForwarderCommand * EventForwarder
virtual void StartTimer()
virtual void OnRightButtonDown()
virtual void OnDropLocation(double *vtkNotUsed(position))
When the mouse location is updated while dragging files.
virtual void Rotate()
These methods for the different interactions in different modes are overridden in subclasses to perfo...
void DelegateTDxEvent(unsigned long event, void *calldata)
Called by the callback to process 3DConnexion device events.
virtual void EndDolly()
virtual void OnKeyPress()
virtual void OnEndPan()
virtual void HighlightProp3D(vtkProp3D *prop3D)
virtual void UniformScale()
virtual void OnExpose()
These are more esoteric events, but are useful in some cases.
virtual void OnRightButtonUp()
virtual void OnStartPinch()
virtual void StartGesture()
virtual void OnKeyUp()
virtual void OnEndPinch()
virtual void OnKeyDown()
virtual void OnStartRotate()
virtual void OnConfigure()
virtual void OnPinch()
virtual void OnLeftButtonDown()
virtual void EndPan()
unsigned long TimerDuration
virtual void OnRotate()
virtual void OnMouseWheelForward()
virtual void OnDropFiles(vtkStringArray *vtkNotUsed(filePaths))
When files are dropped on the render window.
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Main process event method.
virtual void OnFourthButtonUp()
virtual void HighlightActor2D(vtkActor2D *actor2D)
virtual void OnMiddleButtonUp()
virtual void EndGesture()
void SetInteractor(vtkRenderWindowInteractor *interactor) override
Set/Get the Interactor wrapper being controlled by this object.
virtual void StartState(int newstate)
utility routines used by state changes
virtual void EnvironmentRotate()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void OnFifthButtonDown()
virtual void EndTwoPointer()
virtual void OnTimer()
OnTimer calls Rotate, Rotate etc which should be overridden by style subclasses.
virtual void OnLeave()
virtual void StartUniformScale()
static vtkInteractorStyle * New()
This class must be supplied with a vtkRenderWindowInteractor wrapper or parent.
virtual void OnStartPan()
vtkOutlineSource * Outline
virtual void SetTDxStyle(vtkTDxInteractorStyle *tdxStyle)
virtual void OnEndSwipe()
vtkRenderer * PickedRenderer
virtual void OnEndRotate()
virtual void StartZoom()
virtual void StartSpin()
virtual void OnMouseMove()
Generic event bindings can be overridden in subclasses.
virtual void EndEnvRotate()
virtual void OnKeyRelease()
void FindPokedRenderer(int, int)
When an event occurs, we must determine which Renderer the event occurred within, since one RenderWin...
virtual void StopState()
virtual void EndSpin()
virtual void EndTimer()
virtual void EndZoom()
virtual void OnLeftButtonUp()
virtual void StartTwoPointer()
virtual void OnButton3D(vtkEventData *)
vtkActor2D * PickedActor2D
virtual void StartDolly()
~vtkInteractorStyle() override
virtual void OnSwipe()
virtual void StartRotate()
virtual void StartAnimate()
Interaction mode entry points used internally.
vtkTDxInteractorStyle * TDxStyle
virtual void OnFourthButtonDown()
void OnChar() override
OnChar is triggered when an ASCII key is pressed.
virtual void EndRotate()
vtkTypeBool AutoAdjustCameraClippingRange
abstract base class for most VTK objects
Definition: vtkObject.h:54
create wireframe outline around bounding box
map vtkPolyData to graphics primitives
represents an 3D object for placement in a rendered scene
Definition: vtkProp3D.h:44
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:48
platform-independent render window interaction including picking and frame rate control.
abstract specification for renderers
Definition: vtkRenderer.h:59
a vtkAbstractArray subclass for strings
provide 3DConnexion device event-driven interface to the rendering window
@ position
Definition: vtkX3D.h:267
int vtkTypeBool
Definition: vtkABI.h:69