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 =========================================================================*/
92 #ifndef vtkInteractorStyle_h
93 #define vtkInteractorStyle_h
94 
95 #include "vtkRenderingCoreModule.h" // For export macro
96 #include "vtkInteractorObserver.h"
97 
98 // Motion flags
99 
100 #define VTKIS_START 0
101 #define VTKIS_NONE 0
102 
103 #define VTKIS_ROTATE 1
104 #define VTKIS_PAN 2
105 #define VTKIS_SPIN 3
106 #define VTKIS_DOLLY 4
107 #define VTKIS_ZOOM 5
108 #define VTKIS_USCALE 6
109 #define VTKIS_TIMER 7
110 #define VTKIS_FORWARDFLY 8
111 #define VTKIS_REVERSEFLY 9
112 #define VTKIS_TWO_POINTER 10
113 #define VTKIS_CLIP 11
114 #define VTKIS_PICK 12 // perform a pick at the last location
115 #define VTKIS_LOAD_CAMERA_POSE 13 // iterate through saved camera poses
116 #define VTKIS_POSITION_PROP 14 // adjust the position, orientation of a prop
117 #define VTKIS_EXIT 15 // call exit callback
118 #define VTKIS_TOGGLE_DRAW_CONTROLS 16 // draw device controls helpers
119 #define VTKIS_MENU 17 // invoke an application menu
120 
121 #define VTKIS_ANIM_OFF 0
122 #define VTKIS_ANIM_ON 1
123 
124 class vtkActor2D;
125 class vtkActor;
126 class vtkCallbackCommand;
127 class vtkEventData;
129 class vtkOutlineSource;
130 class vtkPolyDataMapper;
131 class vtkProp3D;
132 class vtkProp;
134 
135 class VTKRENDERINGCORE_EXPORT vtkInteractorStyle : public vtkInteractorObserver
136 {
137 public:
143  static vtkInteractorStyle *New();
144 
146  void PrintSelf(ostream& os, vtkIndent indent) override;
147 
152  void SetInteractor(vtkRenderWindowInteractor *interactor) override;
153 
161  void SetEnabled(int) override;
162 
164 
172  vtkSetClampMacro(AutoAdjustCameraClippingRange, vtkTypeBool, 0, 1 );
173  vtkGetMacro(AutoAdjustCameraClippingRange, vtkTypeBool );
174  vtkBooleanMacro(AutoAdjustCameraClippingRange, vtkTypeBool );
176 
182  void FindPokedRenderer(int,int);
183 
185 
188  vtkGetMacro(State,int);
190 
192 
195  vtkGetMacro(UseTimers,vtkTypeBool);
196  vtkSetMacro(UseTimers,vtkTypeBool);
197  vtkBooleanMacro(UseTimers,vtkTypeBool);
199 
201 
207  vtkSetClampMacro(TimerDuration,unsigned long,1,100000);
208  vtkGetMacro(TimerDuration,unsigned long);
210 
212 
215  vtkSetMacro(HandleObservers,vtkTypeBool);
216  vtkGetMacro(HandleObservers,vtkTypeBool);
217  vtkBooleanMacro(HandleObservers,vtkTypeBool);
219 
223  virtual void OnMouseMove() {}
224  virtual void OnLeftButtonDown() {}
225  virtual void OnLeftButtonUp() {}
226  virtual void OnMiddleButtonDown() {}
227  virtual void OnMiddleButtonUp() {}
228  virtual void OnRightButtonDown() {}
229  virtual void OnRightButtonUp() {}
230  virtual void OnMouseWheelForward() {}
231  virtual void OnMouseWheelBackward() {}
232  virtual void OnFourthButtonDown() {}
233  virtual void OnFourthButtonUp() {}
234  virtual void OnFifthButtonDown() {}
235  virtual void OnFifthButtonUp() {}
236 
237 
241  virtual void OnMove3D(vtkEventData *) {}
242  virtual void OnButton3D(vtkEventData *) {}
243 
248  void OnChar() override;
249 
250  // OnKeyDown is triggered by pressing any key (identical to OnKeyPress()).
251  // An empty implementation is provided. The behavior of this function should
252  // be specified in the subclass.
253  virtual void OnKeyDown() {}
254 
255  // OnKeyUp is triggered by releaseing any key (identical to OnKeyRelease()).
256  // An empty implementation is provided. The behavior of this function should
257  // be specified in the subclass.
258  virtual void OnKeyUp() {}
259 
260  // OnKeyPress is triggered by pressing any key (identical to OnKeyDown()).
261  // An empty implementation is provided. The behavior of this function should
262  // be specified in the subclass.
263  virtual void OnKeyPress() {}
264 
265  // OnKeyRelease is triggered by pressing any key (identical to OnKeyUp()).
266  // An empty implementation is provided. The behavior of this function should
267  // be specified in the subclass.
268  virtual void OnKeyRelease() {}
269 
273  virtual void OnExpose() {}
274  virtual void OnConfigure() {}
275  virtual void OnEnter() {}
276  virtual void OnLeave() {}
277 
282  virtual void OnTimer();
283 
290  virtual void Rotate() {}
291  virtual void Spin() {}
292  virtual void Pan() {}
293  virtual void Dolly() {}
294  virtual void Zoom() {}
295  virtual void UniformScale() {}
296 
300  virtual void OnPinch() {}
301  virtual void OnRotate() {}
302  virtual void OnPan() {}
303  virtual void OnTap() {}
304  virtual void OnLongTap() {}
305  virtual void OnSwipe() {}
306 
308 
311  virtual void StartState(int newstate);
312  virtual void StopState();
314 
316 
319  virtual void StartAnimate();
320  virtual void StopAnimate();
321  virtual void StartRotate();
322  virtual void EndRotate();
323  virtual void StartZoom();
324  virtual void EndZoom();
325  virtual void StartPan();
326  virtual void EndPan();
327  virtual void StartSpin();
328  virtual void EndSpin();
329  virtual void StartDolly();
330  virtual void EndDolly();
331  virtual void StartUniformScale();
332  virtual void EndUniformScale();
333  virtual void StartTimer();
334  virtual void EndTimer();
335  virtual void StartTwoPointer();
336  virtual void EndTwoPointer();
338 
340 
346  virtual void HighlightProp(vtkProp *prop);
347  virtual void HighlightActor2D(vtkActor2D *actor2D);
348  virtual void HighlightProp3D(vtkProp3D *prop3D);
350 
352 
356  vtkSetVector3Macro(PickColor,double);
357  vtkGetVectorMacro(PickColor, double, 3);
359 
361 
366  vtkSetMacro(MouseWheelMotionFactor, double);
367  vtkGetMacro(MouseWheelMotionFactor, double);
369 
371 
375  vtkGetObjectMacro(TDxStyle,vtkTDxInteractorStyle);
376  virtual void SetTDxStyle(vtkTDxInteractorStyle *tdxStyle);
378 
382  void DelegateTDxEvent(unsigned long event,
383  void *calldata);
384 
385 protected:
387  ~vtkInteractorStyle() override;
388 
392  static void ProcessEvents(vtkObject* object,
393  unsigned long event,
394  void* clientdata,
395  void* calldata);
396 
397  // Keep track of current state
398  int State;
400 
401  // Should observers be handled here, should we fire timers
404  int TimerId; //keep track of the timers that are created/destroyed
405 
407 
408  // For picking and highlighting props
415  int PropPicked; // bool: prop picked?
416  double PickColor[3]; // support 2D picking
418 
419  // Control the timer duration
420  unsigned long TimerDuration; //in milliseconds
421 
422  // Forward events to the RenderWindowInteractor
424 
426 
427 private:
428  vtkInteractorStyle(const vtkInteractorStyle&) = delete;
429  void operator=(const vtkInteractorStyle&) = delete;
430 };
431 
432 #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:44
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:45
abstract base class for most VTK objects
Definition: vtkObject.h:53
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:39
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:57
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
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