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 =========================================================================*/
95 #ifndef vtkInteractorStyle_h
96 #define vtkInteractorStyle_h
97 
98 #include "vtkInteractorObserver.h"
99 #include "vtkRenderingCoreModule.h" // For export macro
100 
101 // Motion flags
102 
103 #define VTKIS_START 0
104 #define VTKIS_NONE 0
105 
106 #define VTKIS_ROTATE 1
107 #define VTKIS_PAN 2
108 #define VTKIS_SPIN 3
109 #define VTKIS_DOLLY 4
110 #define VTKIS_ZOOM 5
111 #define VTKIS_USCALE 6
112 #define VTKIS_TIMER 7
113 #define VTKIS_FORWARDFLY 8
114 #define VTKIS_REVERSEFLY 9
115 #define VTKIS_TWO_POINTER 10
116 #define VTKIS_CLIP 11
117 #define VTKIS_PICK 12 // perform a pick at the last location
118 #define VTKIS_LOAD_CAMERA_POSE 13 // iterate through saved camera poses
119 #define VTKIS_POSITION_PROP 14 // adjust the position, orientation of a prop
120 #define VTKIS_EXIT 15 // call exit callback
121 #define VTKIS_TOGGLE_DRAW_CONTROLS 16 // draw device controls helpers
122 #define VTKIS_MENU 17 // invoke an application menu
123 #define VTKIS_GESTURE 18 // touch interaction in progress
124 #define VTKIS_ENV_ROTATE 19 // rotate the renderer environment texture
125 
126 #define VTKIS_ANIM_OFF 0
127 #define VTKIS_ANIM_ON 1
128 
129 class vtkActor2D;
130 class vtkActor;
131 class vtkCallbackCommand;
132 class vtkEventData;
134 class vtkOutlineSource;
135 class vtkPolyDataMapper;
136 class vtkProp3D;
137 class vtkProp;
138 class vtkStringArray;
140 
141 class VTKRENDERINGCORE_EXPORT vtkInteractorStyle : public vtkInteractorObserver
142 {
143 public:
149  static vtkInteractorStyle* New();
150 
152  void PrintSelf(ostream& os, vtkIndent indent) override;
153 
158  void SetInteractor(vtkRenderWindowInteractor* interactor) override;
159 
167  void SetEnabled(int) override;
168 
170 
178  vtkSetClampMacro(AutoAdjustCameraClippingRange, vtkTypeBool, 0, 1);
179  vtkGetMacro(AutoAdjustCameraClippingRange, vtkTypeBool);
180  vtkBooleanMacro(AutoAdjustCameraClippingRange, vtkTypeBool);
182 
188  void FindPokedRenderer(int, int);
189 
191 
194  vtkGetMacro(State, int);
196 
198 
201  vtkGetMacro(UseTimers, vtkTypeBool);
202  vtkSetMacro(UseTimers, vtkTypeBool);
203  vtkBooleanMacro(UseTimers, vtkTypeBool);
205 
207 
213  vtkSetClampMacro(TimerDuration, unsigned long, 1, 100000);
214  vtkGetMacro(TimerDuration, unsigned long);
216 
218 
221  vtkSetMacro(HandleObservers, vtkTypeBool);
222  vtkGetMacro(HandleObservers, vtkTypeBool);
223  vtkBooleanMacro(HandleObservers, vtkTypeBool);
225 
229  virtual void OnMouseMove() {}
230  virtual void OnLeftButtonDown() {}
231  virtual void OnLeftButtonUp() {}
232  virtual void OnMiddleButtonDown() {}
233  virtual void OnMiddleButtonUp() {}
234  virtual void OnRightButtonDown() {}
235  virtual void OnRightButtonUp() {}
236  virtual void OnMouseWheelForward() {}
237  virtual void OnMouseWheelBackward() {}
238  virtual void OnFourthButtonDown() {}
239  virtual void OnFourthButtonUp() {}
240  virtual void OnFifthButtonDown() {}
241  virtual void OnFifthButtonUp() {}
242 
246  virtual void OnMove3D(vtkEventData*) {}
247  virtual void OnButton3D(vtkEventData*) {}
248 
253  void OnChar() override;
254 
255  // OnKeyDown is triggered by pressing any key (identical to OnKeyPress()).
256  // An empty implementation is provided. The behavior of this function should
257  // be specified in the subclass.
258  virtual void OnKeyDown() {}
259 
260  // OnKeyUp is triggered by releaseing any key (identical to OnKeyRelease()).
261  // An empty implementation is provided. The behavior of this function should
262  // be specified in the subclass.
263  virtual void OnKeyUp() {}
264 
265  // OnKeyPress is triggered by pressing any key (identical to OnKeyDown()).
266  // An empty implementation is provided. The behavior of this function should
267  // be specified in the subclass.
268  virtual void OnKeyPress() {}
269 
270  // OnKeyRelease is triggered by pressing any key (identical to OnKeyUp()).
271  // An empty implementation is provided. The behavior of this function should
272  // be specified in the subclass.
273  virtual void OnKeyRelease() {}
274 
278  virtual void OnExpose() {}
279  virtual void OnConfigure() {}
280  virtual void OnEnter() {}
281  virtual void OnLeave() {}
282 
287  virtual void OnTimer();
288 
295  virtual void Rotate() {}
296  virtual void Spin() {}
297  virtual void Pan() {}
298  virtual void Dolly() {}
299  virtual void Zoom() {}
300  virtual void UniformScale() {}
301  virtual void EnvironmentRotate() {}
302 
306  virtual void OnStartSwipe() {}
307  virtual void OnSwipe() {}
308  virtual void OnEndSwipe() {}
309  virtual void OnStartPinch() {}
310  virtual void OnPinch() {}
311  virtual void OnEndPinch() {}
312  virtual void OnStartRotate() {}
313  virtual void OnRotate() {}
314  virtual void OnEndRotate() {}
315  virtual void OnStartPan() {}
316  virtual void OnPan() {}
317  virtual void OnEndPan() {}
318  virtual void OnTap() {}
319  virtual void OnLongTap() {}
320 
322 
325  virtual void StartState(int newstate);
326  virtual void StopState();
328 
330 
333  virtual void StartAnimate();
334  virtual void StopAnimate();
335  virtual void StartRotate();
336  virtual void EndRotate();
337  virtual void StartZoom();
338  virtual void EndZoom();
339  virtual void StartPan();
340  virtual void EndPan();
341  virtual void StartSpin();
342  virtual void EndSpin();
343  virtual void StartDolly();
344  virtual void EndDolly();
345  virtual void StartUniformScale();
346  virtual void EndUniformScale();
347  virtual void StartTimer();
348  virtual void EndTimer();
349  virtual void StartTwoPointer();
350  virtual void EndTwoPointer();
351  virtual void StartGesture();
352  virtual void EndGesture();
353  virtual void StartEnvRotate();
354  virtual void EndEnvRotate();
356 
363  virtual void OnDropLocation(double* vtkNotUsed(position)) {}
364 
370  virtual void OnDropFiles(vtkStringArray* vtkNotUsed(filePaths)) {}
371 
373 
379  virtual void HighlightProp(vtkProp* prop);
380  virtual void HighlightActor2D(vtkActor2D* actor2D);
381  virtual void HighlightProp3D(vtkProp3D* prop3D);
383 
385 
389  vtkSetVector3Macro(PickColor, double);
390  vtkGetVectorMacro(PickColor, double, 3);
392 
394 
399  vtkSetMacro(MouseWheelMotionFactor, double);
400  vtkGetMacro(MouseWheelMotionFactor, double);
402 
404 
408  vtkGetObjectMacro(TDxStyle, vtkTDxInteractorStyle);
409  virtual void SetTDxStyle(vtkTDxInteractorStyle* tdxStyle);
411 
415  void DelegateTDxEvent(unsigned long event, void* calldata);
416 
417 protected:
419  ~vtkInteractorStyle() override;
420 
424  static void ProcessEvents(
425  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
426 
427  // Keep track of current state
428  int State;
430 
431  // Should observers be handled here, should we fire timers
434  int TimerId; // keep track of the timers that are created/destroyed
435 
437 
438  // For picking and highlighting props
445  int PropPicked; // bool: prop picked?
446  double PickColor[3]; // support 2D picking
448 
449  // Control the timer duration
450  unsigned long TimerDuration; // in milliseconds
451 
452  // Forward events to the RenderWindowInteractor
454 
456 
457 private:
458  vtkInteractorStyle(const vtkInteractorStyle&) = delete;
459  void operator=(const vtkInteractorStyle&) = delete;
460 };
461 
462 #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:50
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 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:56
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:61
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