VTK
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 =========================================================================*/
98 #ifndef vtkInteractorStyle_h
99 #define vtkInteractorStyle_h
100 
101 #include "vtkRenderingCoreModule.h" // For export macro
102 #include "vtkInteractorObserver.h"
103 
104 // Motion flags
105 
106 #define VTKIS_START 0
107 #define VTKIS_NONE 0
108 
109 #define VTKIS_ROTATE 1
110 #define VTKIS_PAN 2
111 #define VTKIS_SPIN 3
112 #define VTKIS_DOLLY 4
113 #define VTKIS_ZOOM 5
114 #define VTKIS_USCALE 6
115 #define VTKIS_TIMER 7
116 #define VTKIS_FORWARDFLY 8
117 #define VTKIS_REVERSEFLY 9
118 #define VTKIS_TWO_POINTER 10
119 #define VTKIS_CLIP 11
120 #define VTKIS_PICK 12 // perform a pick at the last location
121 #define VTKIS_LOAD_CAMERA_POSE 13 // iterate through saved camera poses
122 #define VTKIS_POSITION_PROP 14 // adjust the position, orientation of a prop
123 #define VTKIS_EXIT 15 // call exit callback
124 #define VTKIS_TOGGLE_DRAW_CONTROLS 16 // draw device controls helpers
125 #define VTKIS_MENU 17 // invoke an application menu
126 
127 #define VTKIS_ANIM_OFF 0
128 #define VTKIS_ANIM_ON 1
129 
130 class vtkActor2D;
131 class vtkActor;
132 class vtkCallbackCommand;
133 class vtkEventData;
135 class vtkOutlineSource;
136 class vtkPolyDataMapper;
137 class vtkProp3D;
138 class vtkProp;
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 
243 
247  virtual void OnMove3D(vtkEventData *) {}
248  virtual void OnButton3D(vtkEventData *) {}
249 
254  void OnChar() override;
255 
256  // OnKeyDown is triggered by pressing any key (identical to OnKeyPress()).
257  // An empty implementation is provided. The behavior of this function should
258  // be specified in the subclass.
259  virtual void OnKeyDown() {}
260 
261  // OnKeyUp is triggered by releaseing any key (identical to OnKeyRelease()).
262  // An empty implementation is provided. The behavior of this function should
263  // be specified in the subclass.
264  virtual void OnKeyUp() {}
265 
266  // OnKeyPress is triggered by pressing any key (identical to OnKeyDown()).
267  // An empty implementation is provided. The behavior of this function should
268  // be specified in the subclass.
269  virtual void OnKeyPress() {}
270 
271  // OnKeyRelease is triggered by pressing any key (identical to OnKeyUp()).
272  // An empty implementation is provided. The behavior of this function should
273  // be specified in the subclass.
274  virtual void OnKeyRelease() {}
275 
279  virtual void OnExpose() {}
280  virtual void OnConfigure() {}
281  virtual void OnEnter() {}
282  virtual void OnLeave() {}
283 
288  virtual void OnTimer();
289 
296  virtual void Rotate() {}
297  virtual void Spin() {}
298  virtual void Pan() {}
299  virtual void Dolly() {}
300  virtual void Zoom() {}
301  virtual void UniformScale() {}
302 
306  virtual void OnPinch() {}
307  virtual void OnRotate() {}
308  virtual void OnPan() {}
309  virtual void OnTap() {}
310  virtual void OnLongTap() {}
311  virtual void OnSwipe() {}
312 
314 
317  virtual void StartState(int newstate);
318  virtual void StopState();
320 
322 
325  virtual void StartAnimate();
326  virtual void StopAnimate();
327  virtual void StartRotate();
328  virtual void EndRotate();
329  virtual void StartZoom();
330  virtual void EndZoom();
331  virtual void StartPan();
332  virtual void EndPan();
333  virtual void StartSpin();
334  virtual void EndSpin();
335  virtual void StartDolly();
336  virtual void EndDolly();
337  virtual void StartUniformScale();
338  virtual void EndUniformScale();
339  virtual void StartTimer();
340  virtual void EndTimer();
341  virtual void StartTwoPointer();
342  virtual void EndTwoPointer();
344 
346 
352  virtual void HighlightProp(vtkProp *prop);
353  virtual void HighlightActor2D(vtkActor2D *actor2D);
354  virtual void HighlightProp3D(vtkProp3D *prop3D);
356 
358 
362  vtkSetVector3Macro(PickColor,double);
363  vtkGetVectorMacro(PickColor, double, 3);
365 
367 
372  vtkSetMacro(MouseWheelMotionFactor, double);
373  vtkGetMacro(MouseWheelMotionFactor, double);
375 
377 
381  vtkGetObjectMacro(TDxStyle,vtkTDxInteractorStyle);
382  virtual void SetTDxStyle(vtkTDxInteractorStyle *tdxStyle);
384 
388  void DelegateTDxEvent(unsigned long event,
389  void *calldata);
390 
391 protected:
393  ~vtkInteractorStyle() override;
394 
398  static void ProcessEvents(vtkObject* object,
399  unsigned long event,
400  void* clientdata,
401  void* calldata);
402 
403  // Keep track of current state
404  int State;
406 
407  // Should observers be handled here, should we fire timers
410  int TimerId; //keep track of the timers that are created/destroyed
411 
413 
414  // For picking and highlighting props
421  int PropPicked; // bool: prop picked?
422  double PickColor[3]; // support 2D picking
424 
425  // Control the timer duration
426  unsigned long TimerDuration; //in milliseconds
427 
428  // Forward events to the RenderWindowInteractor
430 
432 
433 private:
434  vtkInteractorStyle(const vtkInteractorStyle&) = delete;
435  void operator=(const vtkInteractorStyle&) = delete;
436 };
437 
438 #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:52
virtual void SetInteractor(vtkRenderWindowInteractor *iren)
This method is used to associate the widget with the render window interactor.
virtual void OnSwipe()
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:59
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 OnFifthButtonUp()
a actor that draws 2D data
Definition: vtkActor2D.h:45
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
virtual void UniformScale()
abstract specification for renderers
Definition: vtkRenderer.h:63
virtual void OnMouseWheelForward()
represents an 3D object for placement in a rendered scene
Definition: vtkProp3D.h:46
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:39
virtual void OnMouseWheelBackward()
unsigned long TimerDuration
create wireframe outline around bounding box
vtkTypeBool AutoAdjustCameraClippingRange
vtkRenderer * PickedRenderer
provide 3DConnexion device event-driven interface to the rendering window
virtual void OnFifthButtonDown()
map vtkPolyData to graphics primitives
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 OnFourthButtonDown()
virtual void OnPinch()
gesture based events
virtual void OnMouseMove()
Generic event bindings can be overridden in subclasses.
virtual void OnFourthButtonUp()
vtkOutlineSource * Outline
vtkTDxInteractorStyle * TDxStyle