VTK  9.3.0
vtkInteractorStyle.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
98 #ifndef vtkInteractorStyle_h
99 #define vtkInteractorStyle_h
100 
101 #include "vtkInteractorObserver.h"
102 #include "vtkRenderingCoreModule.h" // For export macro
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 #define VTKIS_PICK 12 // perform a pick at the last location
121 #define VTKIS_LOAD_CAMERA_POSE 13 // iterate through saved camera poses
122 #define VTKIS_POSITION_PROP 14 // adjust the position, orientation of a prop
123 #define VTKIS_EXIT 15 // call exit callback
124 #define VTKIS_TOGGLE_DRAW_CONTROLS 16 // draw device controls helpers
125 #define VTKIS_MENU 17 // invoke an application menu
126 #define VTKIS_GESTURE 18 // touch interaction in progress
127 #define VTKIS_ENV_ROTATE 19 // rotate the renderer environment texture
128 #define VTKIS_GROUNDMOVEMENT 20 // horizontal movement according to the 4 directions
129 #define VTKIS_ELEVATION 21 // vertical movement (up and down)
130 
131 #define VTKIS_ANIM_OFF 0
132 #define VTKIS_ANIM_ON 1
133 
134 VTK_ABI_NAMESPACE_BEGIN
135 class vtkActor2D;
136 class vtkActor;
137 class vtkCallbackCommand;
138 class vtkEventData;
140 class vtkOutlineSource;
141 class vtkPolyDataMapper;
142 class vtkProp3D;
143 class vtkProp;
144 class vtkStringArray;
146 
147 class VTKRENDERINGCORE_EXPORT vtkInteractorStyle : public vtkInteractorObserver
148 {
149 public:
156 
158  void PrintSelf(ostream& os, vtkIndent indent) override;
159 
164  void SetInteractor(vtkRenderWindowInteractor* interactor) override;
165 
173  void SetEnabled(int) override;
174 
176 
184  vtkSetClampMacro(AutoAdjustCameraClippingRange, vtkTypeBool, 0, 1);
185  vtkGetMacro(AutoAdjustCameraClippingRange, vtkTypeBool);
186  vtkBooleanMacro(AutoAdjustCameraClippingRange, vtkTypeBool);
188 
194  void FindPokedRenderer(int, int);
195 
197 
200  vtkGetMacro(State, int);
202 
204 
207  vtkGetMacro(UseTimers, vtkTypeBool);
208  vtkSetMacro(UseTimers, vtkTypeBool);
209  vtkBooleanMacro(UseTimers, vtkTypeBool);
211 
213 
219  vtkSetClampMacro(TimerDuration, unsigned long, 1, 100000);
220  vtkGetMacro(TimerDuration, unsigned long);
222 
224 
227  vtkSetMacro(HandleObservers, vtkTypeBool);
228  vtkGetMacro(HandleObservers, vtkTypeBool);
229  vtkBooleanMacro(HandleObservers, vtkTypeBool);
231 
235  virtual void OnMouseMove() {}
236  virtual void OnLeftButtonDown() {}
237  virtual void OnLeftButtonUp() {}
238  virtual void OnMiddleButtonDown() {}
239  virtual void OnMiddleButtonUp() {}
240  virtual void OnRightButtonDown() {}
241  virtual void OnRightButtonUp() {}
242  virtual void OnLeftButtonDoubleClick() {}
243  virtual void OnMiddleButtonDoubleClick() {}
244  virtual void OnRightButtonDoubleClick() {}
245  virtual void OnMouseWheelForward() {}
246  virtual void OnMouseWheelBackward() {}
247  virtual void OnMouseWheelLeft() {}
248  virtual void OnMouseWheelRight() {}
249  virtual void OnFourthButtonDown() {}
250  virtual void OnFourthButtonUp() {}
251  virtual void OnFifthButtonDown() {}
252  virtual void OnFifthButtonUp() {}
253 
257  virtual void OnMove3D(vtkEventData*) {}
258  virtual void OnButton3D(vtkEventData*) {}
259  virtual void OnPick3D(vtkEventData*) {}
260  virtual void OnClip3D(vtkEventData*) {}
261  virtual void OnSelect3D(vtkEventData*) {}
262  virtual void OnMenu3D(vtkEventData*) {}
263  virtual void OnNextPose3D(vtkEventData*) {}
264  virtual void OnPositionProp3D(vtkEventData*) {}
266  virtual void OnElevation3D(vtkEventData*) {}
267 
272  void OnChar() override;
273 
274  // OnKeyDown is triggered by pressing any key (identical to OnKeyPress()).
275  // An empty implementation is provided. The behavior of this function should
276  // be specified in the subclass.
277  virtual void OnKeyDown() {}
278 
279  // OnKeyUp is triggered by releaseing any key (identical to OnKeyRelease()).
280  // An empty implementation is provided. The behavior of this function should
281  // be specified in the subclass.
282  virtual void OnKeyUp() {}
283 
284  // OnKeyPress is triggered by pressing any key (identical to OnKeyDown()).
285  // An empty implementation is provided. The behavior of this function should
286  // be specified in the subclass.
287  virtual void OnKeyPress() {}
288 
289  // OnKeyRelease is triggered by pressing any key (identical to OnKeyUp()).
290  // An empty implementation is provided. The behavior of this function should
291  // be specified in the subclass.
292  virtual void OnKeyRelease() {}
293 
297  virtual void OnExpose() {}
298  virtual void OnConfigure() {}
299  virtual void OnEnter() {}
300  virtual void OnLeave() {}
301 
306  virtual void OnTimer();
307 
314  virtual void Rotate() {}
315  virtual void Spin() {}
316  virtual void Pan() {}
317  virtual void Dolly() {}
318  virtual void Zoom() {}
319  virtual void UniformScale() {}
320  virtual void EnvironmentRotate() {}
321 
325  virtual void OnStartSwipe() {}
326  virtual void OnSwipe() {}
327  virtual void OnEndSwipe() {}
328  virtual void OnStartPinch() {}
329  virtual void OnPinch() {}
330  virtual void OnEndPinch() {}
331  virtual void OnStartRotate() {}
332  virtual void OnRotate() {}
333  virtual void OnEndRotate() {}
334  virtual void OnStartPan() {}
335  virtual void OnPan() {}
336  virtual void OnEndPan() {}
337  virtual void OnTap() {}
338  virtual void OnLongTap() {}
339 
341 
344  virtual void StartState(int newstate);
345  virtual void StopState();
347 
349 
352  virtual void StartAnimate();
353  virtual void StopAnimate();
354  virtual void StartRotate();
355  virtual void EndRotate();
356  virtual void StartZoom();
357  virtual void EndZoom();
358  virtual void StartPan();
359  virtual void EndPan();
360  virtual void StartSpin();
361  virtual void EndSpin();
362  virtual void StartDolly();
363  virtual void EndDolly();
364  virtual void StartUniformScale();
365  virtual void EndUniformScale();
366  virtual void StartTimer();
367  virtual void EndTimer();
368  virtual void StartTwoPointer();
369  virtual void EndTwoPointer();
370  virtual void StartGesture();
371  virtual void EndGesture();
372  virtual void StartEnvRotate();
373  virtual void EndEnvRotate();
375 
382  virtual void OnDropLocation(double* vtkNotUsed(position)) {}
383 
389  virtual void OnDropFiles(vtkStringArray* vtkNotUsed(filePaths)) {}
390 
392 
398  virtual void HighlightProp(vtkProp* prop);
399  virtual void HighlightActor2D(vtkActor2D* actor2D);
400  virtual void HighlightProp3D(vtkProp3D* prop3D);
402 
404 
408  vtkSetVector3Macro(PickColor, double);
409  vtkGetVectorMacro(PickColor, double, 3);
411 
413 
418  vtkSetMacro(MouseWheelMotionFactor, double);
419  vtkGetMacro(MouseWheelMotionFactor, double);
421 
423 
427  vtkGetObjectMacro(TDxStyle, vtkTDxInteractorStyle);
428  virtual void SetTDxStyle(vtkTDxInteractorStyle* tdxStyle);
430 
434  void DelegateTDxEvent(unsigned long event, void* calldata);
435 
436 protected:
439 
443  static void ProcessEvents(
444  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
445 
446  // Keep track of current state
447  int State;
449 
450  // Should observers be handled here, should we fire timers
453  int TimerId; // keep track of the timers that are created/destroyed
454 
456 
457  // For picking and highlighting props
464  int PropPicked; // bool: prop picked?
465  double PickColor[3]; // support 2D picking
467 
468  // Control the timer duration
469  unsigned long TimerDuration; // in milliseconds
470 
471  // Forward events to the RenderWindowInteractor
473 
475 
476 private:
477  vtkInteractorStyle(const vtkInteractorStyle&) = delete;
478  void operator=(const vtkInteractorStyle&) = delete;
479 };
480 
481 VTK_ABI_NAMESPACE_END
482 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:44
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
supports function callbacks
a simple event forwarder command
a simple class to control print indentation
Definition: vtkIndent.h:38
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 OnElevation3D(vtkEventData *)
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:61
create wireframe outline around bounding box
map vtkPolyData to graphics primitives
represents an 3D object for placement in a rendered scene
Definition: vtkProp3D.h:48
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:55
platform-independent render window interaction including picking and frame rate control.
abstract specification for renderers
Definition: vtkRenderer.h:71
a vtkAbstractArray subclass for strings
provide 3DConnexion device event-driven interface to the rendering window
@ position
Definition: vtkX3D.h:261
int vtkTypeBool
Definition: vtkABI.h:64