VTK  9.1.0
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 OnLeftButtonDoubleClick() {}
234  virtual void OnMiddleButtonDoubleClick() {}
235  virtual void OnRightButtonDoubleClick() {}
236  virtual void OnMouseWheelForward() {}
237  virtual void OnMouseWheelBackward() {}
238  virtual void OnMouseWheelLeft() {}
239  virtual void OnMouseWheelRight() {}
240  virtual void OnFourthButtonDown() {}
241  virtual void OnFourthButtonUp() {}
242  virtual void OnFifthButtonDown() {}
243  virtual void OnFifthButtonUp() {}
244 
248  virtual void OnMove3D(vtkEventData*) {}
249  virtual void OnButton3D(vtkEventData*) {}
250  virtual void OnPick3D(vtkEventData*) {}
251  virtual void OnClip3D(vtkEventData*) {}
252  virtual void OnSelect3D(vtkEventData*) {}
253  virtual void OnMenu3D(vtkEventData*) {}
254  virtual void OnNextPose3D(vtkEventData*) {}
255  virtual void OnPositionProp3D(vtkEventData*) {}
257 
262  void OnChar() override;
263 
264  // OnKeyDown is triggered by pressing any key (identical to OnKeyPress()).
265  // An empty implementation is provided. The behavior of this function should
266  // be specified in the subclass.
267  virtual void OnKeyDown() {}
268 
269  // OnKeyUp is triggered by releaseing any key (identical to OnKeyRelease()).
270  // An empty implementation is provided. The behavior of this function should
271  // be specified in the subclass.
272  virtual void OnKeyUp() {}
273 
274  // OnKeyPress is triggered by pressing any key (identical to OnKeyDown()).
275  // An empty implementation is provided. The behavior of this function should
276  // be specified in the subclass.
277  virtual void OnKeyPress() {}
278 
279  // OnKeyRelease is triggered by pressing any key (identical to OnKeyUp()).
280  // An empty implementation is provided. The behavior of this function should
281  // be specified in the subclass.
282  virtual void OnKeyRelease() {}
283 
287  virtual void OnExpose() {}
288  virtual void OnConfigure() {}
289  virtual void OnEnter() {}
290  virtual void OnLeave() {}
291 
296  virtual void OnTimer();
297 
304  virtual void Rotate() {}
305  virtual void Spin() {}
306  virtual void Pan() {}
307  virtual void Dolly() {}
308  virtual void Zoom() {}
309  virtual void UniformScale() {}
310  virtual void EnvironmentRotate() {}
311 
315  virtual void OnStartSwipe() {}
316  virtual void OnSwipe() {}
317  virtual void OnEndSwipe() {}
318  virtual void OnStartPinch() {}
319  virtual void OnPinch() {}
320  virtual void OnEndPinch() {}
321  virtual void OnStartRotate() {}
322  virtual void OnRotate() {}
323  virtual void OnEndRotate() {}
324  virtual void OnStartPan() {}
325  virtual void OnPan() {}
326  virtual void OnEndPan() {}
327  virtual void OnTap() {}
328  virtual void OnLongTap() {}
329 
331 
334  virtual void StartState(int newstate);
335  virtual void StopState();
337 
339 
342  virtual void StartAnimate();
343  virtual void StopAnimate();
344  virtual void StartRotate();
345  virtual void EndRotate();
346  virtual void StartZoom();
347  virtual void EndZoom();
348  virtual void StartPan();
349  virtual void EndPan();
350  virtual void StartSpin();
351  virtual void EndSpin();
352  virtual void StartDolly();
353  virtual void EndDolly();
354  virtual void StartUniformScale();
355  virtual void EndUniformScale();
356  virtual void StartTimer();
357  virtual void EndTimer();
358  virtual void StartTwoPointer();
359  virtual void EndTwoPointer();
360  virtual void StartGesture();
361  virtual void EndGesture();
362  virtual void StartEnvRotate();
363  virtual void EndEnvRotate();
365 
372  virtual void OnDropLocation(double* vtkNotUsed(position)) {}
373 
379  virtual void OnDropFiles(vtkStringArray* vtkNotUsed(filePaths)) {}
380 
382 
388  virtual void HighlightProp(vtkProp* prop);
389  virtual void HighlightActor2D(vtkActor2D* actor2D);
390  virtual void HighlightProp3D(vtkProp3D* prop3D);
392 
394 
398  vtkSetVector3Macro(PickColor, double);
399  vtkGetVectorMacro(PickColor, double, 3);
401 
403 
408  vtkSetMacro(MouseWheelMotionFactor, double);
409  vtkGetMacro(MouseWheelMotionFactor, double);
411 
413 
417  vtkGetObjectMacro(TDxStyle, vtkTDxInteractorStyle);
418  virtual void SetTDxStyle(vtkTDxInteractorStyle* tdxStyle);
420 
424  void DelegateTDxEvent(unsigned long event, void* calldata);
425 
426 protected:
429 
433  static void ProcessEvents(
434  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
435 
436  // Keep track of current state
437  int State;
439 
440  // Should observers be handled here, should we fire timers
443  int TimerId; // keep track of the timers that are created/destroyed
444 
446 
447  // For picking and highlighting props
454  int PropPicked; // bool: prop picked?
455  double PickColor[3]; // support 2D picking
457 
458  // Control the timer duration
459  unsigned long TimerDuration; // in milliseconds
460 
461  // Forward events to the RenderWindowInteractor
463 
465 
466 private:
467  vtkInteractorStyle(const vtkInteractorStyle&) = delete;
468  void operator=(const vtkInteractorStyle&) = delete;
469 };
470 
471 #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()
Interaction mode entry points used internally.
vtkPolyDataMapper * OutlineMapper
virtual void OnFifthButtonUp()
virtual void OnMove3D(vtkEventData *)
Generic 3D event bindings can be overridden in subclasses.
virtual void OnMouseWheelBackward()
virtual void OnLeftButtonDoubleClick()
virtual void OnMiddleButtonDown()
virtual void OnLongTap()
virtual void OnEnter()
void SetEnabled(int) override
Turn on/off this interactor.
virtual void StartEnvRotate()
Interaction mode entry points used internally.
virtual void HighlightProp(vtkProp *prop)
When picking successfully selects an actor, this method highlights the picked prop appropriately.
virtual void EndUniformScale()
Interaction mode entry points used internally.
virtual void OnStartSwipe()
gesture based events
virtual void StartPan()
Interaction mode entry points used internally.
vtkEventForwarderCommand * EventForwarder
virtual void StartTimer()
Interaction mode entry points used internally.
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()
Interaction mode entry points used internally.
virtual void OnKeyPress()
virtual void OnEndPan()
virtual void HighlightProp3D(vtkProp3D *prop3D)
When picking successfully selects an actor, this method highlights the picked prop appropriately.
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()
Interaction mode entry points used internally.
virtual void OnKeyUp()
virtual void OnEndPinch()
virtual void OnKeyDown()
virtual void OnStartRotate()
virtual void OnMouseWheelRight()
virtual void OnConfigure()
virtual void OnPinch()
virtual void OnLeftButtonDown()
virtual void EndPan()
Interaction mode entry points used internally.
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)
When picking successfully selects an actor, this method highlights the picked prop appropriately.
virtual void OnMiddleButtonUp()
virtual void EndGesture()
Interaction mode entry points used internally.
void SetInteractor(vtkRenderWindowInteractor *interactor) override
Set/Get the Interactor wrapper being controlled by this object.
virtual void OnMenu3D(vtkEventData *)
virtual void StartState(int newstate)
utility routines used by state changes
virtual void OnPick3D(vtkEventData *)
virtual void EnvironmentRotate()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void OnRightButtonDoubleClick()
virtual void OnFifthButtonDown()
virtual void EndTwoPointer()
Interaction mode entry points used internally.
virtual void OnTimer()
OnTimer calls Rotate, Rotate etc which should be overridden by style subclasses.
virtual void OnLeave()
virtual void OnPositionProp3D(vtkEventData *)
virtual void StartUniformScale()
Interaction mode entry points used internally.
static vtkInteractorStyle * New()
This class must be supplied with a vtkRenderWindowInteractor wrapper or parent.
virtual void OnStartPan()
vtkOutlineSource * Outline
virtual void SetTDxStyle(vtkTDxInteractorStyle *tdxStyle)
3Dconnexion device interactor style.
virtual void OnEndSwipe()
virtual void OnViewerMovement3D(vtkEventData *)
vtkRenderer * PickedRenderer
virtual void OnEndRotate()
virtual void OnClip3D(vtkEventData *)
virtual void StartZoom()
Interaction mode entry points used internally.
virtual void OnMouseWheelLeft()
virtual void StartSpin()
Interaction mode entry points used internally.
virtual void OnMouseMove()
Generic event bindings can be overridden in subclasses.
virtual void EndEnvRotate()
Interaction mode entry points used internally.
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()
utility routines used by state changes
virtual void EndSpin()
Interaction mode entry points used internally.
virtual void EndTimer()
Interaction mode entry points used internally.
virtual void EndZoom()
Interaction mode entry points used internally.
virtual void OnLeftButtonUp()
virtual void OnNextPose3D(vtkEventData *)
virtual void StartTwoPointer()
Interaction mode entry points used internally.
virtual void OnButton3D(vtkEventData *)
vtkActor2D * PickedActor2D
virtual void StartDolly()
Interaction mode entry points used internally.
~vtkInteractorStyle() override
virtual void OnSwipe()
virtual void StartRotate()
Interaction mode entry points used internally.
virtual void StartAnimate()
Interaction mode entry points used internally.
virtual void OnMiddleButtonDoubleClick()
virtual void OnSelect3D(vtkEventData *)
vtkTDxInteractorStyle * TDxStyle
virtual void OnFourthButtonDown()
void OnChar() override
OnChar is triggered when an ASCII key is pressed.
virtual void EndRotate()
Interaction mode entry points used internally.
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:64
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