VTK  9.2.6
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 =========================================================================*/
110 #ifndef vtkInteractorStyle_h
111 #define vtkInteractorStyle_h
112 
113 #include "vtkInteractorObserver.h"
114 #include "vtkRenderingCoreModule.h" // For export macro
115 
116 // Motion flags
117 
118 #define VTKIS_START 0
119 #define VTKIS_NONE 0
120 
121 #define VTKIS_ROTATE 1
122 #define VTKIS_PAN 2
123 #define VTKIS_SPIN 3
124 #define VTKIS_DOLLY 4
125 #define VTKIS_ZOOM 5
126 #define VTKIS_USCALE 6
127 #define VTKIS_TIMER 7
128 #define VTKIS_FORWARDFLY 8
129 #define VTKIS_REVERSEFLY 9
130 #define VTKIS_TWO_POINTER 10
131 #define VTKIS_CLIP 11
132 #define VTKIS_PICK 12 // perform a pick at the last location
133 #define VTKIS_LOAD_CAMERA_POSE 13 // iterate through saved camera poses
134 #define VTKIS_POSITION_PROP 14 // adjust the position, orientation of a prop
135 #define VTKIS_EXIT 15 // call exit callback
136 #define VTKIS_TOGGLE_DRAW_CONTROLS 16 // draw device controls helpers
137 #define VTKIS_MENU 17 // invoke an application menu
138 #define VTKIS_GESTURE 18 // touch interaction in progress
139 #define VTKIS_ENV_ROTATE 19 // rotate the renderer environment texture
140 #define VTKIS_GROUNDMOVEMENT 20 // horizontal movement according to the 4 directions
141 #define VTKIS_ELEVATION 21 // vertical movement (up and down)
142 
143 #define VTKIS_ANIM_OFF 0
144 #define VTKIS_ANIM_ON 1
145 
146 class vtkActor2D;
147 class vtkActor;
148 class vtkCallbackCommand;
149 class vtkEventData;
151 class vtkOutlineSource;
152 class vtkPolyDataMapper;
153 class vtkProp3D;
154 class vtkProp;
155 class vtkStringArray;
157 
158 class VTKRENDERINGCORE_EXPORT vtkInteractorStyle : public vtkInteractorObserver
159 {
160 public:
167 
169  void PrintSelf(ostream& os, vtkIndent indent) override;
170 
175  void SetInteractor(vtkRenderWindowInteractor* interactor) override;
176 
184  void SetEnabled(int) override;
185 
187 
195  vtkSetClampMacro(AutoAdjustCameraClippingRange, vtkTypeBool, 0, 1);
196  vtkGetMacro(AutoAdjustCameraClippingRange, vtkTypeBool);
197  vtkBooleanMacro(AutoAdjustCameraClippingRange, vtkTypeBool);
199 
205  void FindPokedRenderer(int, int);
206 
208 
211  vtkGetMacro(State, int);
213 
215 
218  vtkGetMacro(UseTimers, vtkTypeBool);
219  vtkSetMacro(UseTimers, vtkTypeBool);
220  vtkBooleanMacro(UseTimers, vtkTypeBool);
222 
224 
230  vtkSetClampMacro(TimerDuration, unsigned long, 1, 100000);
231  vtkGetMacro(TimerDuration, unsigned long);
233 
235 
238  vtkSetMacro(HandleObservers, vtkTypeBool);
239  vtkGetMacro(HandleObservers, vtkTypeBool);
240  vtkBooleanMacro(HandleObservers, vtkTypeBool);
242 
246  virtual void OnMouseMove() {}
247  virtual void OnLeftButtonDown() {}
248  virtual void OnLeftButtonUp() {}
249  virtual void OnMiddleButtonDown() {}
250  virtual void OnMiddleButtonUp() {}
251  virtual void OnRightButtonDown() {}
252  virtual void OnRightButtonUp() {}
253  virtual void OnLeftButtonDoubleClick() {}
254  virtual void OnMiddleButtonDoubleClick() {}
255  virtual void OnRightButtonDoubleClick() {}
256  virtual void OnMouseWheelForward() {}
257  virtual void OnMouseWheelBackward() {}
258  virtual void OnMouseWheelLeft() {}
259  virtual void OnMouseWheelRight() {}
260  virtual void OnFourthButtonDown() {}
261  virtual void OnFourthButtonUp() {}
262  virtual void OnFifthButtonDown() {}
263  virtual void OnFifthButtonUp() {}
264 
268  virtual void OnMove3D(vtkEventData*) {}
269  virtual void OnButton3D(vtkEventData*) {}
270  virtual void OnPick3D(vtkEventData*) {}
271  virtual void OnClip3D(vtkEventData*) {}
272  virtual void OnSelect3D(vtkEventData*) {}
273  virtual void OnMenu3D(vtkEventData*) {}
274  virtual void OnNextPose3D(vtkEventData*) {}
275  virtual void OnPositionProp3D(vtkEventData*) {}
277  virtual void OnElevation3D(vtkEventData*) {}
278 
283  void OnChar() override;
284 
285  // OnKeyDown is triggered by pressing any key (identical to OnKeyPress()).
286  // An empty implementation is provided. The behavior of this function should
287  // be specified in the subclass.
288  virtual void OnKeyDown() {}
289 
290  // OnKeyUp is triggered by releaseing any key (identical to OnKeyRelease()).
291  // An empty implementation is provided. The behavior of this function should
292  // be specified in the subclass.
293  virtual void OnKeyUp() {}
294 
295  // OnKeyPress is triggered by pressing any key (identical to OnKeyDown()).
296  // An empty implementation is provided. The behavior of this function should
297  // be specified in the subclass.
298  virtual void OnKeyPress() {}
299 
300  // OnKeyRelease is triggered by pressing any key (identical to OnKeyUp()).
301  // An empty implementation is provided. The behavior of this function should
302  // be specified in the subclass.
303  virtual void OnKeyRelease() {}
304 
308  virtual void OnExpose() {}
309  virtual void OnConfigure() {}
310  virtual void OnEnter() {}
311  virtual void OnLeave() {}
312 
317  virtual void OnTimer();
318 
325  virtual void Rotate() {}
326  virtual void Spin() {}
327  virtual void Pan() {}
328  virtual void Dolly() {}
329  virtual void Zoom() {}
330  virtual void UniformScale() {}
331  virtual void EnvironmentRotate() {}
332 
336  virtual void OnStartSwipe() {}
337  virtual void OnSwipe() {}
338  virtual void OnEndSwipe() {}
339  virtual void OnStartPinch() {}
340  virtual void OnPinch() {}
341  virtual void OnEndPinch() {}
342  virtual void OnStartRotate() {}
343  virtual void OnRotate() {}
344  virtual void OnEndRotate() {}
345  virtual void OnStartPan() {}
346  virtual void OnPan() {}
347  virtual void OnEndPan() {}
348  virtual void OnTap() {}
349  virtual void OnLongTap() {}
350 
352 
355  virtual void StartState(int newstate);
356  virtual void StopState();
358 
360 
363  virtual void StartAnimate();
364  virtual void StopAnimate();
365  virtual void StartRotate();
366  virtual void EndRotate();
367  virtual void StartZoom();
368  virtual void EndZoom();
369  virtual void StartPan();
370  virtual void EndPan();
371  virtual void StartSpin();
372  virtual void EndSpin();
373  virtual void StartDolly();
374  virtual void EndDolly();
375  virtual void StartUniformScale();
376  virtual void EndUniformScale();
377  virtual void StartTimer();
378  virtual void EndTimer();
379  virtual void StartTwoPointer();
380  virtual void EndTwoPointer();
381  virtual void StartGesture();
382  virtual void EndGesture();
383  virtual void StartEnvRotate();
384  virtual void EndEnvRotate();
386 
393  virtual void OnDropLocation(double* vtkNotUsed(position)) {}
394 
400  virtual void OnDropFiles(vtkStringArray* vtkNotUsed(filePaths)) {}
401 
403 
409  virtual void HighlightProp(vtkProp* prop);
410  virtual void HighlightActor2D(vtkActor2D* actor2D);
411  virtual void HighlightProp3D(vtkProp3D* prop3D);
413 
415 
419  vtkSetVector3Macro(PickColor, double);
420  vtkGetVectorMacro(PickColor, double, 3);
422 
424 
429  vtkSetMacro(MouseWheelMotionFactor, double);
430  vtkGetMacro(MouseWheelMotionFactor, double);
432 
434 
438  vtkGetObjectMacro(TDxStyle, vtkTDxInteractorStyle);
439  virtual void SetTDxStyle(vtkTDxInteractorStyle* tdxStyle);
441 
445  void DelegateTDxEvent(unsigned long event, void* calldata);
446 
447 protected:
450 
454  static void ProcessEvents(
455  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
456 
457  // Keep track of current state
458  int State;
460 
461  // Should observers be handled here, should we fire timers
464  int TimerId; // keep track of the timers that are created/destroyed
465 
467 
468  // For picking and highlighting props
475  int PropPicked; // bool: prop picked?
476  double PickColor[3]; // support 2D picking
478 
479  // Control the timer duration
480  unsigned long TimerDuration; // in milliseconds
481 
482  // Forward events to the RenderWindowInteractor
484 
486 
487 private:
488  vtkInteractorStyle(const vtkInteractorStyle&) = delete;
489  void operator=(const vtkInteractorStyle&) = delete;
490 };
491 
492 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:55
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:61
supports function callbacks
a simple event forwarder command
a simple class to control print indentation
Definition: vtkIndent.h:49
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:72
create wireframe outline around bounding box
map vtkPolyData to graphics primitives
represents an 3D object for placement in a rendered scene
Definition: vtkProp3D.h:59
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:66
platform-independent render window interaction including picking and frame rate control.
abstract specification for renderers
Definition: vtkRenderer.h:82
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