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 
120 #define VTKIS_ANIM_OFF 0
121 #define VTKIS_ANIM_ON 1
122 
123 class vtkActor2D;
124 class vtkActor;
125 class vtkCallbackCommand;
127 class vtkOutlineSource;
128 class vtkPolyDataMapper;
129 class vtkProp3D;
130 class vtkProp;
132 
133 class VTKRENDERINGCORE_EXPORT vtkInteractorStyle : public vtkInteractorObserver
134 {
135 public:
141  static vtkInteractorStyle *New();
142 
144  void PrintSelf(ostream& os, vtkIndent indent);
145 
150  virtual void SetInteractor(vtkRenderWindowInteractor *interactor);
151 
159  virtual void SetEnabled(int);
160 
162 
170  vtkSetClampMacro(AutoAdjustCameraClippingRange, int, 0, 1 );
171  vtkGetMacro(AutoAdjustCameraClippingRange, int );
172  vtkBooleanMacro(AutoAdjustCameraClippingRange, int );
174 
180  void FindPokedRenderer(int,int);
181 
183 
186  vtkGetMacro(State,int);
188 
190 
193  vtkGetMacro(UseTimers,int);
194  vtkSetMacro(UseTimers,int);
195  vtkBooleanMacro(UseTimers,int);
197 
199 
205  vtkSetClampMacro(TimerDuration,unsigned long,1,100000);
206  vtkGetMacro(TimerDuration,unsigned long);
208 
210 
213  vtkSetMacro(HandleObservers,int);
214  vtkGetMacro(HandleObservers,int);
215  vtkBooleanMacro(HandleObservers,int);
217 
221  virtual void OnMouseMove() {}
222  virtual void OnLeftButtonDown() {}
223  virtual void OnLeftButtonUp() {}
224  virtual void OnMiddleButtonDown() {}
225  virtual void OnMiddleButtonUp() {}
226  virtual void OnRightButtonDown() {}
227  virtual void OnRightButtonUp() {}
228  virtual void OnMouseWheelForward() {}
229  virtual void OnMouseWheelBackward() {}
230 
235  virtual void OnChar();
236 
237  // OnKeyDown is triggered by pressing any key (identical to OnKeyPress()).
238  // An empty implementation is provided. The behavior of this function should
239  // be specified in the subclass.
240  virtual void OnKeyDown() {}
241 
242  // OnKeyUp is triggered by releaseing any key (identical to OnKeyRelease()).
243  // An empty implementation is provided. The behavior of this function should
244  // be specified in the subclass.
245  virtual void OnKeyUp() {}
246 
247  // OnKeyPress is triggered by pressing any key (identical to OnKeyDown()).
248  // An empty implementation is provided. The behavior of this function should
249  // be specified in the subclass.
250  virtual void OnKeyPress() {}
251 
252  // OnKeyRelease is triggered by pressing any key (identical to OnKeyUp()).
253  // An empty implementation is provided. The behavior of this function should
254  // be specified in the subclass.
255  virtual void OnKeyRelease() {}
256 
260  virtual void OnExpose() {}
261  virtual void OnConfigure() {}
262  virtual void OnEnter() {}
263  virtual void OnLeave() {}
264 
269  virtual void OnTimer();
270 
277  virtual void Rotate() {}
278  virtual void Spin() {}
279  virtual void Pan() {}
280  virtual void Dolly() {}
281  virtual void Zoom() {}
282  virtual void UniformScale() {}
283 
287  virtual void OnPinch() {}
288  virtual void OnRotate() {}
289  virtual void OnPan() {}
290  virtual void OnTap() {}
291  virtual void OnLongTap() {}
292  virtual void OnSwipe() {}
293 
295 
298  virtual void StartState(int newstate);
299  virtual void StopState();
301 
303 
306  virtual void StartAnimate();
307  virtual void StopAnimate();
308  virtual void StartRotate();
309  virtual void EndRotate();
310  virtual void StartZoom();
311  virtual void EndZoom();
312  virtual void StartPan();
313  virtual void EndPan();
314  virtual void StartSpin();
315  virtual void EndSpin();
316  virtual void StartDolly();
317  virtual void EndDolly();
318  virtual void StartUniformScale();
319  virtual void EndUniformScale();
320  virtual void StartTimer();
321  virtual void EndTimer();
322  virtual void StartTwoPointer();
323  virtual void EndTwoPointer();
325 
327 
333  virtual void HighlightProp(vtkProp *prop);
334  virtual void HighlightActor2D(vtkActor2D *actor2D);
335  virtual void HighlightProp3D(vtkProp3D *prop3D);
337 
339 
343  vtkSetVector3Macro(PickColor,double);
344  vtkGetVectorMacro(PickColor, double, 3);
346 
348 
353  vtkSetMacro(MouseWheelMotionFactor, double);
354  vtkGetMacro(MouseWheelMotionFactor, double);
356 
358 
362  vtkGetObjectMacro(TDxStyle,vtkTDxInteractorStyle);
363  virtual void SetTDxStyle(vtkTDxInteractorStyle *tdxStyle);
365 
369  void DelegateTDxEvent(unsigned long event,
370  void *calldata);
371 
372 protected:
375 
379  static void ProcessEvents(vtkObject* object,
380  unsigned long event,
381  void* clientdata,
382  void* calldata);
383 
384  // Keep track of current state
385  int State;
387 
388  // Should observers be handled here, should we fire timers
391  int TimerId; //keep track of the timers that are created/destroyed
392 
394 
395  // For picking and highlighting props
402  int PropPicked; // bool: prop picked?
403  double PickColor[3]; // support 2D picking
405 
406  // Control the timer duration
407  unsigned long TimerDuration; //in milliseconds
408 
409  // Forward events to the RenderWindowInteractor
411 
413 
414 private:
415  vtkInteractorStyle(const vtkInteractorStyle&) VTK_DELETE_FUNCTION;
416  void operator=(const vtkInteractorStyle&) VTK_DELETE_FUNCTION;
417 };
418 
419 #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 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 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()
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()
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:39
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
map vtkPolyData to graphics primitives
provide event-driven interface to the rendering window (defines trackball mode)
virtual void OnLeave()
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
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 OnPinch()
gesture based events
virtual void OnMouseMove()
Generic event bindings can be overridden in subclasses.
vtkOutlineSource * Outline
vtkTDxInteractorStyle * TDxStyle