VTK  9.0.1
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 
132 #define VTKIS_ANIM_OFF 0
133 #define VTKIS_ANIM_ON 1
134 
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:
155  static vtkInteractorStyle* New();
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 OnMouseWheelForward() {}
243  virtual void OnMouseWheelBackward() {}
244  virtual void OnMouseWheelLeft() {}
245  virtual void OnMouseWheelRight() {}
246  virtual void OnFourthButtonDown() {}
247  virtual void OnFourthButtonUp() {}
248  virtual void OnFifthButtonDown() {}
249  virtual void OnFifthButtonUp() {}
250 
254  virtual void OnMove3D(vtkEventData*) {}
255  virtual void OnButton3D(vtkEventData*) {}
256 
261  void OnChar() override;
262 
263  // OnKeyDown is triggered by pressing any key (identical to OnKeyPress()).
264  // An empty implementation is provided. The behavior of this function should
265  // be specified in the subclass.
266  virtual void OnKeyDown() {}
267 
268  // OnKeyUp is triggered by releaseing any key (identical to OnKeyRelease()).
269  // An empty implementation is provided. The behavior of this function should
270  // be specified in the subclass.
271  virtual void OnKeyUp() {}
272 
273  // OnKeyPress is triggered by pressing any key (identical to OnKeyDown()).
274  // An empty implementation is provided. The behavior of this function should
275  // be specified in the subclass.
276  virtual void OnKeyPress() {}
277 
278  // OnKeyRelease is triggered by pressing any key (identical to OnKeyUp()).
279  // An empty implementation is provided. The behavior of this function should
280  // be specified in the subclass.
281  virtual void OnKeyRelease() {}
282 
286  virtual void OnExpose() {}
287  virtual void OnConfigure() {}
288  virtual void OnEnter() {}
289  virtual void OnLeave() {}
290 
295  virtual void OnTimer();
296 
303  virtual void Rotate() {}
304  virtual void Spin() {}
305  virtual void Pan() {}
306  virtual void Dolly() {}
307  virtual void Zoom() {}
308  virtual void UniformScale() {}
309  virtual void EnvironmentRotate() {}
310 
314  virtual void OnStartSwipe() {}
315  virtual void OnSwipe() {}
316  virtual void OnEndSwipe() {}
317  virtual void OnStartPinch() {}
318  virtual void OnPinch() {}
319  virtual void OnEndPinch() {}
320  virtual void OnStartRotate() {}
321  virtual void OnRotate() {}
322  virtual void OnEndRotate() {}
323  virtual void OnStartPan() {}
324  virtual void OnPan() {}
325  virtual void OnEndPan() {}
326  virtual void OnTap() {}
327  virtual void OnLongTap() {}
328 
330 
333  virtual void StartState(int newstate);
334  virtual void StopState();
336 
338 
341  virtual void StartAnimate();
342  virtual void StopAnimate();
343  virtual void StartRotate();
344  virtual void EndRotate();
345  virtual void StartZoom();
346  virtual void EndZoom();
347  virtual void StartPan();
348  virtual void EndPan();
349  virtual void StartSpin();
350  virtual void EndSpin();
351  virtual void StartDolly();
352  virtual void EndDolly();
353  virtual void StartUniformScale();
354  virtual void EndUniformScale();
355  virtual void StartTimer();
356  virtual void EndTimer();
357  virtual void StartTwoPointer();
358  virtual void EndTwoPointer();
359  virtual void StartGesture();
360  virtual void EndGesture();
361  virtual void StartEnvRotate();
362  virtual void EndEnvRotate();
364 
371  virtual void OnDropLocation(double* vtkNotUsed(position)) {}
372 
378  virtual void OnDropFiles(vtkStringArray* vtkNotUsed(filePaths)) {}
379 
381 
387  virtual void HighlightProp(vtkProp* prop);
388  virtual void HighlightActor2D(vtkActor2D* actor2D);
389  virtual void HighlightProp3D(vtkProp3D* prop3D);
391 
393 
397  vtkSetVector3Macro(PickColor, double);
398  vtkGetVectorMacro(PickColor, double, 3);
400 
402 
407  vtkSetMacro(MouseWheelMotionFactor, double);
408  vtkGetMacro(MouseWheelMotionFactor, double);
410 
412 
416  vtkGetObjectMacro(TDxStyle, vtkTDxInteractorStyle);
417  virtual void SetTDxStyle(vtkTDxInteractorStyle* tdxStyle);
419 
423  void DelegateTDxEvent(unsigned long event, void* calldata);
424 
425 protected:
427  ~vtkInteractorStyle() override;
428 
432  static void ProcessEvents(
433  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
434 
435  // Keep track of current state
436  int State;
438 
439  // Should observers be handled here, should we fire timers
442  int TimerId; // keep track of the timers that are created/destroyed
443 
445 
446  // For picking and highlighting props
453  int PropPicked; // bool: prop picked?
454  double PickColor[3]; // support 2D picking
456 
457  // Control the timer duration
458  unsigned long TimerDuration; // in milliseconds
459 
460  // Forward events to the RenderWindowInteractor
462 
464 
465 private:
466  vtkInteractorStyle(const vtkInteractorStyle&) = delete;
467  void operator=(const vtkInteractorStyle&) = delete;
468 };
469 
470 #endif
a simple event forwarder command
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:53
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:45
abstract base class for most VTK objects
Definition: vtkObject.h:62
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:39
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:67
virtual void OnMouseWheelLeft()
virtual void OnMouseWheelForward()
represents an 3D object for placement in a rendered scene
Definition: vtkProp3D.h:43
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 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 OnKeyDown()
virtual void OnConfigure()
a simple class to control print indentation
Definition: vtkIndent.h:33
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()
vtkRenderer * PickedRenderer
provide 3DConnexion device event-driven interface to the rendering window
virtual void OnFifthButtonDown()
map vtkPolyData to graphics primitives
virtual void OnStartSwipe()
gesture based events
virtual void OnStartRotate()
provide event-driven interface to the rendering window (defines trackball mode)
virtual void OnLeave()
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