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 
115 #define VTKIS_ANIM_OFF 0
116 #define VTKIS_ANIM_ON 1
117 
118 class vtkActor2D;
119 class vtkActor;
120 class vtkCallbackCommand;
122 class vtkOutlineSource;
123 class vtkPolyDataMapper;
124 class vtkProp3D;
125 class vtkProp;
127 
128 class VTKRENDERINGCORE_EXPORT vtkInteractorStyle : public vtkInteractorObserver
129 {
130 public:
136  static vtkInteractorStyle *New();
137 
139  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
140 
145  void SetInteractor(vtkRenderWindowInteractor *interactor) VTK_OVERRIDE;
146 
154  void SetEnabled(int) VTK_OVERRIDE;
155 
157 
165  vtkSetClampMacro(AutoAdjustCameraClippingRange, int, 0, 1 );
166  vtkGetMacro(AutoAdjustCameraClippingRange, int );
167  vtkBooleanMacro(AutoAdjustCameraClippingRange, int );
169 
175  void FindPokedRenderer(int,int);
176 
178 
181  vtkGetMacro(State,int);
183 
185 
188  vtkGetMacro(UseTimers,int);
189  vtkSetMacro(UseTimers,int);
190  vtkBooleanMacro(UseTimers,int);
192 
194 
200  vtkSetClampMacro(TimerDuration,unsigned long,1,100000);
201  vtkGetMacro(TimerDuration,unsigned long);
203 
205 
208  vtkSetMacro(HandleObservers,int);
209  vtkGetMacro(HandleObservers,int);
210  vtkBooleanMacro(HandleObservers,int);
212 
216  virtual void OnMouseMove() {}
217  virtual void OnLeftButtonDown() {}
218  virtual void OnLeftButtonUp() {}
219  virtual void OnMiddleButtonDown() {}
220  virtual void OnMiddleButtonUp() {}
221  virtual void OnRightButtonDown() {}
222  virtual void OnRightButtonUp() {}
223  virtual void OnMouseWheelForward() {}
224  virtual void OnMouseWheelBackward() {}
225  virtual void OnFourthButtonDown() {}
226  virtual void OnFourthButtonUp() {}
227  virtual void OnFifthButtonDown() {}
228  virtual void OnFifthButtonUp() {}
229 
234  void OnChar() VTK_OVERRIDE;
235 
236  // OnKeyDown is triggered by pressing any key (identical to OnKeyPress()).
237  // An empty implementation is provided. The behavior of this function should
238  // be specified in the subclass.
239  virtual void OnKeyDown() {}
240 
241  // OnKeyUp is triggered by releaseing any key (identical to OnKeyRelease()).
242  // An empty implementation is provided. The behavior of this function should
243  // be specified in the subclass.
244  virtual void OnKeyUp() {}
245 
246  // OnKeyPress is triggered by pressing any key (identical to OnKeyDown()).
247  // An empty implementation is provided. The behavior of this function should
248  // be specified in the subclass.
249  virtual void OnKeyPress() {}
250 
251  // OnKeyRelease is triggered by pressing any key (identical to OnKeyUp()).
252  // An empty implementation is provided. The behavior of this function should
253  // be specified in the subclass.
254  virtual void OnKeyRelease() {}
255 
259  virtual void OnExpose() {}
260  virtual void OnConfigure() {}
261  virtual void OnEnter() {}
262  virtual void OnLeave() {}
263 
268  virtual void OnTimer();
269 
276  virtual void Rotate() {}
277  virtual void Spin() {}
278  virtual void Pan() {}
279  virtual void Dolly() {}
280  virtual void Zoom() {}
281  virtual void UniformScale() {}
282 
286  virtual void OnPinch() {}
287  virtual void OnRotate() {}
288  virtual void OnPan() {}
289  virtual void OnTap() {}
290  virtual void OnLongTap() {}
291  virtual void OnSwipe() {}
292 
294 
297  virtual void StartState(int newstate);
298  virtual void StopState();
300 
302 
305  virtual void StartAnimate();
306  virtual void StopAnimate();
307  virtual void StartRotate();
308  virtual void EndRotate();
309  virtual void StartZoom();
310  virtual void EndZoom();
311  virtual void StartPan();
312  virtual void EndPan();
313  virtual void StartSpin();
314  virtual void EndSpin();
315  virtual void StartDolly();
316  virtual void EndDolly();
317  virtual void StartUniformScale();
318  virtual void EndUniformScale();
319  virtual void StartTimer();
320  virtual void EndTimer();
321  virtual void StartTwoPointer();
322  virtual void EndTwoPointer();
324 
326 
332  virtual void HighlightProp(vtkProp *prop);
333  virtual void HighlightActor2D(vtkActor2D *actor2D);
334  virtual void HighlightProp3D(vtkProp3D *prop3D);
336 
338 
342  vtkSetVector3Macro(PickColor,double);
343  vtkGetVectorMacro(PickColor, double, 3);
345 
347 
352  vtkSetMacro(MouseWheelMotionFactor, double);
353  vtkGetMacro(MouseWheelMotionFactor, double);
355 
357 
361  vtkGetObjectMacro(TDxStyle,vtkTDxInteractorStyle);
362  virtual void SetTDxStyle(vtkTDxInteractorStyle *tdxStyle);
364 
368  void DelegateTDxEvent(unsigned long event,
369  void *calldata);
370 
371 protected:
373  ~vtkInteractorStyle() VTK_OVERRIDE;
374 
378  static void ProcessEvents(vtkObject* object,
379  unsigned long event,
380  void* clientdata,
381  void* calldata);
382 
383  // Keep track of current state
384  int State;
386 
387  // Should observers be handled here, should we fire timers
390  int TimerId; //keep track of the timers that are created/destroyed
391 
393 
394  // For picking and highlighting props
401  int PropPicked; // bool: prop picked?
402  double PickColor[3]; // support 2D picking
404 
405  // Control the timer duration
406  unsigned long TimerDuration; //in milliseconds
407 
408  // Forward events to the RenderWindowInteractor
410 
412 
413 private:
414  vtkInteractorStyle(const vtkInteractorStyle&) VTK_DELETE_FUNCTION;
415  void operator=(const vtkInteractorStyle&) VTK_DELETE_FUNCTION;
416 };
417 
418 #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 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
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 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
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
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()
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
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