VTK  9.3.1
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
89 #ifndef vtkInteractorStyle_h
90 #define vtkInteractorStyle_h
91 
92 #include "vtkInteractorObserver.h"
93 #include "vtkRenderingCoreModule.h" // For export macro
94 
95 // Motion flags
96 
97 #define VTKIS_START 0
98 #define VTKIS_NONE 0
99 
100 #define VTKIS_ROTATE 1
101 #define VTKIS_PAN 2
102 #define VTKIS_SPIN 3
103 #define VTKIS_DOLLY 4
104 #define VTKIS_ZOOM 5
105 #define VTKIS_USCALE 6
106 #define VTKIS_TIMER 7
107 #define VTKIS_FORWARDFLY 8
108 #define VTKIS_REVERSEFLY 9
109 #define VTKIS_TWO_POINTER 10
110 #define VTKIS_CLIP 11
111 #define VTKIS_PICK 12 // perform a pick at the last location
112 #define VTKIS_LOAD_CAMERA_POSE 13 // iterate through saved camera poses
113 #define VTKIS_POSITION_PROP 14 // adjust the position, orientation of a prop
114 #define VTKIS_EXIT 15 // call exit callback
115 #define VTKIS_TOGGLE_DRAW_CONTROLS 16 // draw device controls helpers
116 #define VTKIS_MENU 17 // invoke an application menu
117 #define VTKIS_GESTURE 18 // touch interaction in progress
118 #define VTKIS_ENV_ROTATE 19 // rotate the renderer environment texture
119 #define VTKIS_GROUNDMOVEMENT 20 // horizontal movement according to the 4 directions
120 #define VTKIS_ELEVATION 21 // vertical movement (up and down)
121 
122 #define VTKIS_ANIM_OFF 0
123 #define VTKIS_ANIM_ON 1
124 
125 VTK_ABI_NAMESPACE_BEGIN
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:
146  static vtkInteractorStyle* New();
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  virtual void OnElevation3D(vtkEventData*) {}
258 
263  void OnChar() override;
264 
265  // OnKeyDown is triggered by pressing any key (identical to OnKeyPress()).
266  // An empty implementation is provided. The behavior of this function should
267  // be specified in the subclass.
268  virtual void OnKeyDown() {}
269 
270  // OnKeyUp is triggered by releaseing any key (identical to OnKeyRelease()).
271  // An empty implementation is provided. The behavior of this function should
272  // be specified in the subclass.
273  virtual void OnKeyUp() {}
274 
275  // OnKeyPress is triggered by pressing any key (identical to OnKeyDown()).
276  // An empty implementation is provided. The behavior of this function should
277  // be specified in the subclass.
278  virtual void OnKeyPress() {}
279 
280  // OnKeyRelease is triggered by pressing any key (identical to OnKeyUp()).
281  // An empty implementation is provided. The behavior of this function should
282  // be specified in the subclass.
283  virtual void OnKeyRelease() {}
284 
288  virtual void OnExpose() {}
289  virtual void OnConfigure() {}
290  virtual void OnEnter() {}
291  virtual void OnLeave() {}
292 
297  virtual void OnTimer();
298 
305  virtual void Rotate() {}
306  virtual void Spin() {}
307  virtual void Pan() {}
308  virtual void Dolly() {}
309  virtual void Zoom() {}
310  virtual void UniformScale() {}
311  virtual void EnvironmentRotate() {}
312 
316  virtual void OnStartSwipe() {}
317  virtual void OnSwipe() {}
318  virtual void OnEndSwipe() {}
319  virtual void OnStartPinch() {}
320  virtual void OnPinch() {}
321  virtual void OnEndPinch() {}
322  virtual void OnStartRotate() {}
323  virtual void OnRotate() {}
324  virtual void OnEndRotate() {}
325  virtual void OnStartPan() {}
326  virtual void OnPan() {}
327  virtual void OnEndPan() {}
328  virtual void OnTap() {}
329  virtual void OnLongTap() {}
330 
332 
335  virtual void StartState(int newstate);
336  virtual void StopState();
338 
340 
343  virtual void StartAnimate();
344  virtual void StopAnimate();
345  virtual void StartRotate();
346  virtual void EndRotate();
347  virtual void StartZoom();
348  virtual void EndZoom();
349  virtual void StartPan();
350  virtual void EndPan();
351  virtual void StartSpin();
352  virtual void EndSpin();
353  virtual void StartDolly();
354  virtual void EndDolly();
355  virtual void StartUniformScale();
356  virtual void EndUniformScale();
357  virtual void StartTimer();
358  virtual void EndTimer();
359  virtual void StartTwoPointer();
360  virtual void EndTwoPointer();
361  virtual void StartGesture();
362  virtual void EndGesture();
363  virtual void StartEnvRotate();
364  virtual void EndEnvRotate();
366 
373  virtual void OnDropLocation(double* vtkNotUsed(position)) {}
374 
380  virtual void OnDropFiles(vtkStringArray* vtkNotUsed(filePaths)) {}
381 
383 
389  virtual void HighlightProp(vtkProp* prop);
390  virtual void HighlightActor2D(vtkActor2D* actor2D);
391  virtual void HighlightProp3D(vtkProp3D* prop3D);
393 
395 
399  vtkSetVector3Macro(PickColor, double);
400  vtkGetVectorMacro(PickColor, double, 3);
402 
404 
409  vtkSetMacro(MouseWheelMotionFactor, double);
410  vtkGetMacro(MouseWheelMotionFactor, double);
412 
414 
418  vtkGetObjectMacro(TDxStyle, vtkTDxInteractorStyle);
419  virtual void SetTDxStyle(vtkTDxInteractorStyle* tdxStyle);
421 
425  void DelegateTDxEvent(unsigned long event, void* calldata);
426 
427 protected:
429  ~vtkInteractorStyle() override;
430 
434  static void ProcessEvents(
435  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
436 
437  // Keep track of current state
438  int State;
440 
441  // Should observers be handled here, should we fire timers
444  int TimerId; // keep track of the timers that are created/destroyed
445 
447 
448  // For picking and highlighting props
455  int PropPicked; // bool: prop picked?
456  double PickColor[3]; // support 2D picking
458 
459  // Control the timer duration
460  unsigned long TimerDuration; // in milliseconds
461 
462  // Forward events to the RenderWindowInteractor
464 
466 
467 private:
468  vtkInteractorStyle(const vtkInteractorStyle&) = delete;
469  void operator=(const vtkInteractorStyle&) = delete;
470 };
471 
472 VTK_ABI_NAMESPACE_END
473 #endif
a simple event forwarder command
virtual void OnLeftButtonDoubleClick()
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:45
virtual void SetInteractor(vtkRenderWindowInteractor *iren)
This method is used to associate the widget with the render window interactor.
virtual void OnDropFiles(vtkStringArray *vtkNotUsed(filePaths))
When files are dropped on the render window.
virtual void OnSwipe()
virtual void OnMouseWheelRight()
virtual void OnRotate()
virtual void OnMiddleButtonDown()
virtual void OnRightButtonDown()
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:40
abstract base class for most VTK objects
Definition: vtkObject.h:51
virtual void OnClip3D(vtkEventData *)
virtual void OnButton3D(vtkEventData *)
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 OnEndPinch()
virtual void OnFifthButtonUp()
a actor that draws 2D data
Definition: vtkActor2D.h:34
virtual void OnPositionProp3D(vtkEventData *)
virtual void OnEndPan()
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
virtual void UniformScale()
a vtkAbstractArray subclass for strings
abstract specification for renderers
Definition: vtkRenderer.h:61
virtual void OnMouseWheelLeft()
virtual void OnMouseWheelForward()
represents an 3D object for placement in a rendered scene
Definition: vtkProp3D.h:38
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
int vtkTypeBool
Definition: vtkABI.h:64
virtual void OnRightButtonUp()
platform-independent render window interaction including picking and frame rate control.
virtual void OnMiddleButtonDoubleClick()
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 OnMove3D(vtkEventData *)
Generic 3D event bindings can be overridden in subclasses.
virtual void OnRightButtonDoubleClick()
virtual void OnKeyDown()
virtual void OnConfigure()
virtual void OnSelect3D(vtkEventData *)
a simple class to control print indentation
Definition: vtkIndent.h:28
virtual void OnMouseWheelBackward()
unsigned long TimerDuration
virtual void OnStartPinch()
create wireframe outline around bounding box
virtual void OnEndSwipe()
virtual void OnDropLocation(double *vtkNotUsed(position))
When the mouse location is updated while dragging files.
vtkTypeBool AutoAdjustCameraClippingRange
virtual void OnStartPan()
virtual void OnMenu3D(vtkEventData *)
vtkRenderer * PickedRenderer
provide 3DConnexion device event-driven interface to the rendering window
virtual void OnFifthButtonDown()
map vtkPolyData to graphics primitives
virtual void OnNextPose3D(vtkEventData *)
virtual void OnStartSwipe()
gesture based events
virtual void OnStartRotate()
virtual void OnPick3D(vtkEventData *)
provide event-driven interface to the rendering window (defines trackball mode)
virtual void OnElevation3D(vtkEventData *)
virtual void OnLeave()
virtual void OnViewerMovement3D(vtkEventData *)
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 OnEndRotate()
virtual void OnFourthButtonDown()
virtual void OnPinch()
virtual void EnvironmentRotate()
virtual void OnMouseMove()
Generic event bindings can be overridden in subclasses.
virtual void OnFourthButtonUp()
vtkOutlineSource * Outline
vtkTDxInteractorStyle * TDxStyle