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 =========================================================================*/
101 #ifndef vtkInteractorStyle_h
102 #define vtkInteractorStyle_h
103 
104 #include "vtkInteractorObserver.h"
105 #include "vtkRenderingCoreModule.h" // For export macro
106 
107 // Motion flags
108 
109 #define VTKIS_START 0
110 #define VTKIS_NONE 0
111 
112 #define VTKIS_ROTATE 1
113 #define VTKIS_PAN 2
114 #define VTKIS_SPIN 3
115 #define VTKIS_DOLLY 4
116 #define VTKIS_ZOOM 5
117 #define VTKIS_USCALE 6
118 #define VTKIS_TIMER 7
119 #define VTKIS_FORWARDFLY 8
120 #define VTKIS_REVERSEFLY 9
121 #define VTKIS_TWO_POINTER 10
122 #define VTKIS_CLIP 11
123 #define VTKIS_PICK 12 // perform a pick at the last location
124 #define VTKIS_LOAD_CAMERA_POSE 13 // iterate through saved camera poses
125 #define VTKIS_POSITION_PROP 14 // adjust the position, orientation of a prop
126 #define VTKIS_EXIT 15 // call exit callback
127 #define VTKIS_TOGGLE_DRAW_CONTROLS 16 // draw device controls helpers
128 #define VTKIS_MENU 17 // invoke an application menu
129 #define VTKIS_GESTURE 18 // touch interaction in progress
130 #define VTKIS_ENV_ROTATE 19 // rotate the renderer environment texture
131 #define VTKIS_GROUNDMOVEMENT 20 // horizontal movement according to the 4 directions
132 #define VTKIS_ELEVATION 21 // vertical movement (up and down)
133 
134 #define VTKIS_ANIM_OFF 0
135 #define VTKIS_ANIM_ON 1
136 
137 class vtkActor2D;
138 class vtkActor;
139 class vtkCallbackCommand;
140 class vtkEventData;
142 class vtkOutlineSource;
143 class vtkPolyDataMapper;
144 class vtkProp3D;
145 class vtkProp;
146 class vtkStringArray;
148 
149 class VTKRENDERINGCORE_EXPORT vtkInteractorStyle : public vtkInteractorObserver
150 {
151 public:
157  static vtkInteractorStyle* New();
158 
160  void PrintSelf(ostream& os, vtkIndent indent) override;
161 
166  void SetInteractor(vtkRenderWindowInteractor* interactor) override;
167 
175  void SetEnabled(int) override;
176 
178 
186  vtkSetClampMacro(AutoAdjustCameraClippingRange, vtkTypeBool, 0, 1);
187  vtkGetMacro(AutoAdjustCameraClippingRange, vtkTypeBool);
188  vtkBooleanMacro(AutoAdjustCameraClippingRange, vtkTypeBool);
190 
196  void FindPokedRenderer(int, int);
197 
199 
202  vtkGetMacro(State, int);
204 
206 
209  vtkGetMacro(UseTimers, vtkTypeBool);
210  vtkSetMacro(UseTimers, vtkTypeBool);
211  vtkBooleanMacro(UseTimers, vtkTypeBool);
213 
215 
221  vtkSetClampMacro(TimerDuration, unsigned long, 1, 100000);
222  vtkGetMacro(TimerDuration, unsigned long);
224 
226 
229  vtkSetMacro(HandleObservers, vtkTypeBool);
230  vtkGetMacro(HandleObservers, vtkTypeBool);
231  vtkBooleanMacro(HandleObservers, vtkTypeBool);
233 
237  virtual void OnMouseMove() {}
238  virtual void OnLeftButtonDown() {}
239  virtual void OnLeftButtonUp() {}
240  virtual void OnMiddleButtonDown() {}
241  virtual void OnMiddleButtonUp() {}
242  virtual void OnRightButtonDown() {}
243  virtual void OnRightButtonUp() {}
244  virtual void OnLeftButtonDoubleClick() {}
245  virtual void OnMiddleButtonDoubleClick() {}
246  virtual void OnRightButtonDoubleClick() {}
247  virtual void OnMouseWheelForward() {}
248  virtual void OnMouseWheelBackward() {}
249  virtual void OnMouseWheelLeft() {}
250  virtual void OnMouseWheelRight() {}
251  virtual void OnFourthButtonDown() {}
252  virtual void OnFourthButtonUp() {}
253  virtual void OnFifthButtonDown() {}
254  virtual void OnFifthButtonUp() {}
255 
259  virtual void OnMove3D(vtkEventData*) {}
260  virtual void OnButton3D(vtkEventData*) {}
261  virtual void OnPick3D(vtkEventData*) {}
262  virtual void OnClip3D(vtkEventData*) {}
263  virtual void OnSelect3D(vtkEventData*) {}
264  virtual void OnMenu3D(vtkEventData*) {}
265  virtual void OnNextPose3D(vtkEventData*) {}
266  virtual void OnPositionProp3D(vtkEventData*) {}
268  virtual void OnElevation3D(vtkEventData*) {}
269 
274  void OnChar() override;
275 
276  // OnKeyDown is triggered by pressing any key (identical to OnKeyPress()).
277  // An empty implementation is provided. The behavior of this function should
278  // be specified in the subclass.
279  virtual void OnKeyDown() {}
280 
281  // OnKeyUp is triggered by releaseing any key (identical to OnKeyRelease()).
282  // An empty implementation is provided. The behavior of this function should
283  // be specified in the subclass.
284  virtual void OnKeyUp() {}
285 
286  // OnKeyPress is triggered by pressing any key (identical to OnKeyDown()).
287  // An empty implementation is provided. The behavior of this function should
288  // be specified in the subclass.
289  virtual void OnKeyPress() {}
290 
291  // OnKeyRelease is triggered by pressing any key (identical to OnKeyUp()).
292  // An empty implementation is provided. The behavior of this function should
293  // be specified in the subclass.
294  virtual void OnKeyRelease() {}
295 
299  virtual void OnExpose() {}
300  virtual void OnConfigure() {}
301  virtual void OnEnter() {}
302  virtual void OnLeave() {}
303 
308  virtual void OnTimer();
309 
316  virtual void Rotate() {}
317  virtual void Spin() {}
318  virtual void Pan() {}
319  virtual void Dolly() {}
320  virtual void Zoom() {}
321  virtual void UniformScale() {}
322  virtual void EnvironmentRotate() {}
323 
327  virtual void OnStartSwipe() {}
328  virtual void OnSwipe() {}
329  virtual void OnEndSwipe() {}
330  virtual void OnStartPinch() {}
331  virtual void OnPinch() {}
332  virtual void OnEndPinch() {}
333  virtual void OnStartRotate() {}
334  virtual void OnRotate() {}
335  virtual void OnEndRotate() {}
336  virtual void OnStartPan() {}
337  virtual void OnPan() {}
338  virtual void OnEndPan() {}
339  virtual void OnTap() {}
340  virtual void OnLongTap() {}
341 
343 
346  virtual void StartState(int newstate);
347  virtual void StopState();
349 
351 
354  virtual void StartAnimate();
355  virtual void StopAnimate();
356  virtual void StartRotate();
357  virtual void EndRotate();
358  virtual void StartZoom();
359  virtual void EndZoom();
360  virtual void StartPan();
361  virtual void EndPan();
362  virtual void StartSpin();
363  virtual void EndSpin();
364  virtual void StartDolly();
365  virtual void EndDolly();
366  virtual void StartUniformScale();
367  virtual void EndUniformScale();
368  virtual void StartTimer();
369  virtual void EndTimer();
370  virtual void StartTwoPointer();
371  virtual void EndTwoPointer();
372  virtual void StartGesture();
373  virtual void EndGesture();
374  virtual void StartEnvRotate();
375  virtual void EndEnvRotate();
377 
384  virtual void OnDropLocation(double* vtkNotUsed(position)) {}
385 
391  virtual void OnDropFiles(vtkStringArray* vtkNotUsed(filePaths)) {}
392 
394 
400  virtual void HighlightProp(vtkProp* prop);
401  virtual void HighlightActor2D(vtkActor2D* actor2D);
402  virtual void HighlightProp3D(vtkProp3D* prop3D);
404 
406 
410  vtkSetVector3Macro(PickColor, double);
411  vtkGetVectorMacro(PickColor, double, 3);
413 
415 
420  vtkSetMacro(MouseWheelMotionFactor, double);
421  vtkGetMacro(MouseWheelMotionFactor, double);
423 
425 
429  vtkGetObjectMacro(TDxStyle, vtkTDxInteractorStyle);
430  virtual void SetTDxStyle(vtkTDxInteractorStyle* tdxStyle);
432 
436  void DelegateTDxEvent(unsigned long event, void* calldata);
437 
438 protected:
440  ~vtkInteractorStyle() override;
441 
445  static void ProcessEvents(
446  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
447 
448  // Keep track of current state
449  int State;
451 
452  // Should observers be handled here, should we fire timers
455  int TimerId; // keep track of the timers that are created/destroyed
456 
458 
459  // For picking and highlighting props
466  int PropPicked; // bool: prop picked?
467  double PickColor[3]; // support 2D picking
469 
470  // Control the timer duration
471  unsigned long TimerDuration; // in milliseconds
472 
473  // Forward events to the RenderWindowInteractor
475 
477 
478 private:
479  vtkInteractorStyle(const vtkInteractorStyle&) = delete;
480  void operator=(const vtkInteractorStyle&) = delete;
481 };
482 
483 #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:56
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:51
abstract base class for most VTK objects
Definition: vtkObject.h:62
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:45
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:72
virtual void OnMouseWheelLeft()
virtual void OnMouseWheelForward()
represents an 3D object for placement in a rendered scene
Definition: vtkProp3D.h:49
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:69
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:39
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