VTK  9.1.20211023
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 =========================================================================*/
160 #ifndef vtkInteractorStyle_h
161 #define vtkInteractorStyle_h
162 
163 #include "vtkInteractorObserver.h"
164 #include "vtkRenderingCoreModule.h" // For export macro
165 
166 // Motion flags
167 
168 #define VTKIS_START 0
169 #define VTKIS_NONE 0
170 
171 #define VTKIS_ROTATE 1
172 #define VTKIS_PAN 2
173 #define VTKIS_SPIN 3
174 #define VTKIS_DOLLY 4
175 #define VTKIS_ZOOM 5
176 #define VTKIS_USCALE 6
177 #define VTKIS_TIMER 7
178 #define VTKIS_FORWARDFLY 8
179 #define VTKIS_REVERSEFLY 9
180 #define VTKIS_TWO_POINTER 10
181 #define VTKIS_CLIP 11
182 #define VTKIS_PICK 12 // perform a pick at the last location
183 #define VTKIS_LOAD_CAMERA_POSE 13 // iterate through saved camera poses
184 #define VTKIS_POSITION_PROP 14 // adjust the position, orientation of a prop
185 #define VTKIS_EXIT 15 // call exit callback
186 #define VTKIS_TOGGLE_DRAW_CONTROLS 16 // draw device controls helpers
187 #define VTKIS_MENU 17 // invoke an application menu
188 #define VTKIS_GESTURE 18 // touch interaction in progress
189 #define VTKIS_ENV_ROTATE 19 // rotate the renderer environment texture
190 
191 #define VTKIS_ANIM_OFF 0
192 #define VTKIS_ANIM_ON 1
193 
194 class vtkActor2D;
195 class vtkActor;
196 class vtkCallbackCommand;
197 class vtkEventData;
199 class vtkOutlineSource;
200 class vtkPolyDataMapper;
201 class vtkProp3D;
202 class vtkProp;
203 class vtkStringArray;
205 
206 class VTKRENDERINGCORE_EXPORT vtkInteractorStyle : public vtkInteractorObserver
207 {
208 public:
215 
217  void PrintSelf(ostream& os, vtkIndent indent) override;
218 
223  void SetInteractor(vtkRenderWindowInteractor* interactor) override;
224 
232  void SetEnabled(int) override;
233 
235 
243  vtkSetClampMacro(AutoAdjustCameraClippingRange, vtkTypeBool, 0, 1);
244  vtkGetMacro(AutoAdjustCameraClippingRange, vtkTypeBool);
245  vtkBooleanMacro(AutoAdjustCameraClippingRange, vtkTypeBool);
247 
253  void FindPokedRenderer(int, int);
254 
256 
259  vtkGetMacro(State, int);
261 
263 
266  vtkGetMacro(UseTimers, vtkTypeBool);
267  vtkSetMacro(UseTimers, vtkTypeBool);
268  vtkBooleanMacro(UseTimers, vtkTypeBool);
270 
272 
278  vtkSetClampMacro(TimerDuration, unsigned long, 1, 100000);
279  vtkGetMacro(TimerDuration, unsigned long);
281 
283 
286  vtkSetMacro(HandleObservers, vtkTypeBool);
287  vtkGetMacro(HandleObservers, vtkTypeBool);
288  vtkBooleanMacro(HandleObservers, vtkTypeBool);
290 
294  virtual void OnMouseMove() {}
295  virtual void OnLeftButtonDown() {}
296  virtual void OnLeftButtonUp() {}
297  virtual void OnMiddleButtonDown() {}
298  virtual void OnMiddleButtonUp() {}
299  virtual void OnRightButtonDown() {}
300  virtual void OnRightButtonUp() {}
301  virtual void OnLeftButtonDoubleClick() {}
302  virtual void OnMiddleButtonDoubleClick() {}
303  virtual void OnRightButtonDoubleClick() {}
304  virtual void OnMouseWheelForward() {}
305  virtual void OnMouseWheelBackward() {}
306  virtual void OnMouseWheelLeft() {}
307  virtual void OnMouseWheelRight() {}
308  virtual void OnFourthButtonDown() {}
309  virtual void OnFourthButtonUp() {}
310  virtual void OnFifthButtonDown() {}
311  virtual void OnFifthButtonUp() {}
312 
316  virtual void OnMove3D(vtkEventData*) {}
317  virtual void OnButton3D(vtkEventData*) {}
318  virtual void OnPick3D(vtkEventData*) {}
319  virtual void OnClip3D(vtkEventData*) {}
320  virtual void OnSelect3D(vtkEventData*) {}
321  virtual void OnMenu3D(vtkEventData*) {}
322  virtual void OnNextPose3D(vtkEventData*) {}
323  virtual void OnPositionProp3D(vtkEventData*) {}
325 
330  void OnChar() override;
331 
332  // OnKeyDown is triggered by pressing any key (identical to OnKeyPress()).
333  // An empty implementation is provided. The behavior of this function should
334  // be specified in the subclass.
335  virtual void OnKeyDown() {}
336 
337  // OnKeyUp is triggered by releaseing any key (identical to OnKeyRelease()).
338  // An empty implementation is provided. The behavior of this function should
339  // be specified in the subclass.
340  virtual void OnKeyUp() {}
341 
342  // OnKeyPress is triggered by pressing any key (identical to OnKeyDown()).
343  // An empty implementation is provided. The behavior of this function should
344  // be specified in the subclass.
345  virtual void OnKeyPress() {}
346 
347  // OnKeyRelease is triggered by pressing any key (identical to OnKeyUp()).
348  // An empty implementation is provided. The behavior of this function should
349  // be specified in the subclass.
350  virtual void OnKeyRelease() {}
351 
355  virtual void OnExpose() {}
356  virtual void OnConfigure() {}
357  virtual void OnEnter() {}
358  virtual void OnLeave() {}
359 
364  virtual void OnTimer();
365 
372  virtual void Rotate() {}
373  virtual void Spin() {}
374  virtual void Pan() {}
375  virtual void Dolly() {}
376  virtual void Zoom() {}
377  virtual void UniformScale() {}
378  virtual void EnvironmentRotate() {}
379 
383  virtual void OnStartSwipe() {}
384  virtual void OnSwipe() {}
385  virtual void OnEndSwipe() {}
386  virtual void OnStartPinch() {}
387  virtual void OnPinch() {}
388  virtual void OnEndPinch() {}
389  virtual void OnStartRotate() {}
390  virtual void OnRotate() {}
391  virtual void OnEndRotate() {}
392  virtual void OnStartPan() {}
393  virtual void OnPan() {}
394  virtual void OnEndPan() {}
395  virtual void OnTap() {}
396  virtual void OnLongTap() {}
397 
399 
402  virtual void StartState(int newstate);
403  virtual void StopState();
405 
407 
410  virtual void StartAnimate();
411  virtual void StopAnimate();
412  virtual void StartRotate();
413  virtual void EndRotate();
414  virtual void StartZoom();
415  virtual void EndZoom();
416  virtual void StartPan();
417  virtual void EndPan();
418  virtual void StartSpin();
419  virtual void EndSpin();
420  virtual void StartDolly();
421  virtual void EndDolly();
422  virtual void StartUniformScale();
423  virtual void EndUniformScale();
424  virtual void StartTimer();
425  virtual void EndTimer();
426  virtual void StartTwoPointer();
427  virtual void EndTwoPointer();
428  virtual void StartGesture();
429  virtual void EndGesture();
430  virtual void StartEnvRotate();
431  virtual void EndEnvRotate();
433 
440  virtual void OnDropLocation(double* vtkNotUsed(position)) {}
441 
447  virtual void OnDropFiles(vtkStringArray* vtkNotUsed(filePaths)) {}
448 
450 
456  virtual void HighlightProp(vtkProp* prop);
457  virtual void HighlightActor2D(vtkActor2D* actor2D);
458  virtual void HighlightProp3D(vtkProp3D* prop3D);
460 
462 
466  vtkSetVector3Macro(PickColor, double);
467  vtkGetVectorMacro(PickColor, double, 3);
469 
471 
476  vtkSetMacro(MouseWheelMotionFactor, double);
477  vtkGetMacro(MouseWheelMotionFactor, double);
479 
481 
485  vtkGetObjectMacro(TDxStyle, vtkTDxInteractorStyle);
486  virtual void SetTDxStyle(vtkTDxInteractorStyle* tdxStyle);
488 
492  void DelegateTDxEvent(unsigned long event, void* calldata);
493 
494 protected:
497 
501  static void ProcessEvents(
502  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
503 
504  // Keep track of current state
505  int State;
507 
508  // Should observers be handled here, should we fire timers
511  int TimerId; // keep track of the timers that are created/destroyed
512 
514 
515  // For picking and highlighting props
522  int PropPicked; // bool: prop picked?
523  double PickColor[3]; // support 2D picking
525 
526  // Control the timer duration
527  unsigned long TimerDuration; // in milliseconds
528 
529  // Forward events to the RenderWindowInteractor
531 
533 
534 private:
535  vtkInteractorStyle(const vtkInteractorStyle&) = delete;
536  void operator=(const vtkInteractorStyle&) = delete;
537 };
538 
539 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:149
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:155
supports function callbacks
a simple event forwarder command
a simple class to control print indentation
Definition: vtkIndent.h:113
an abstract superclass for classes observing events invoked by vtkRenderWindowInteractor
provide event-driven interface to the rendering window (defines trackball mode)
virtual void StopAnimate()
Interaction mode entry points used internally.
vtkPolyDataMapper * OutlineMapper
virtual void OnFifthButtonUp()
virtual void OnMove3D(vtkEventData *)
Generic 3D event bindings can be overridden in subclasses.
virtual void OnMouseWheelBackward()
virtual void OnLeftButtonDoubleClick()
virtual void OnMiddleButtonDown()
virtual void OnLongTap()
virtual void OnEnter()
void SetEnabled(int) override
Turn on/off this interactor.
virtual void StartEnvRotate()
Interaction mode entry points used internally.
virtual void HighlightProp(vtkProp *prop)
When picking successfully selects an actor, this method highlights the picked prop appropriately.
virtual void EndUniformScale()
Interaction mode entry points used internally.
virtual void OnStartSwipe()
gesture based events
virtual void StartPan()
Interaction mode entry points used internally.
vtkEventForwarderCommand * EventForwarder
virtual void StartTimer()
Interaction mode entry points used internally.
virtual void OnRightButtonDown()
virtual void OnDropLocation(double *vtkNotUsed(position))
When the mouse location is updated while dragging files.
virtual void Rotate()
These methods for the different interactions in different modes are overridden in subclasses to perfo...
void DelegateTDxEvent(unsigned long event, void *calldata)
Called by the callback to process 3DConnexion device events.
virtual void EndDolly()
Interaction mode entry points used internally.
virtual void OnKeyPress()
virtual void OnEndPan()
virtual void HighlightProp3D(vtkProp3D *prop3D)
When picking successfully selects an actor, this method highlights the picked prop appropriately.
virtual void UniformScale()
virtual void OnExpose()
These are more esoteric events, but are useful in some cases.
virtual void OnRightButtonUp()
virtual void OnStartPinch()
virtual void StartGesture()
Interaction mode entry points used internally.
virtual void OnKeyUp()
virtual void OnEndPinch()
virtual void OnKeyDown()
virtual void OnStartRotate()
virtual void OnMouseWheelRight()
virtual void OnConfigure()
virtual void OnPinch()
virtual void OnLeftButtonDown()
virtual void EndPan()
Interaction mode entry points used internally.
unsigned long TimerDuration
virtual void OnRotate()
virtual void OnMouseWheelForward()
virtual void OnDropFiles(vtkStringArray *vtkNotUsed(filePaths))
When files are dropped on the render window.
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Main process event method.
virtual void OnFourthButtonUp()
virtual void HighlightActor2D(vtkActor2D *actor2D)
When picking successfully selects an actor, this method highlights the picked prop appropriately.
virtual void OnMiddleButtonUp()
virtual void EndGesture()
Interaction mode entry points used internally.
void SetInteractor(vtkRenderWindowInteractor *interactor) override
Set/Get the Interactor wrapper being controlled by this object.
virtual void OnMenu3D(vtkEventData *)
virtual void StartState(int newstate)
utility routines used by state changes
virtual void OnPick3D(vtkEventData *)
virtual void EnvironmentRotate()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void OnRightButtonDoubleClick()
virtual void OnFifthButtonDown()
virtual void EndTwoPointer()
Interaction mode entry points used internally.
virtual void OnTimer()
OnTimer calls Rotate, Rotate etc which should be overridden by style subclasses.
virtual void OnLeave()
virtual void OnPositionProp3D(vtkEventData *)
virtual void StartUniformScale()
Interaction mode entry points used internally.
static vtkInteractorStyle * New()
This class must be supplied with a vtkRenderWindowInteractor wrapper or parent.
virtual void OnStartPan()
vtkOutlineSource * Outline
virtual void SetTDxStyle(vtkTDxInteractorStyle *tdxStyle)
3Dconnexion device interactor style.
virtual void OnEndSwipe()
virtual void OnViewerMovement3D(vtkEventData *)
vtkRenderer * PickedRenderer
virtual void OnEndRotate()
virtual void OnClip3D(vtkEventData *)
virtual void StartZoom()
Interaction mode entry points used internally.
virtual void OnMouseWheelLeft()
virtual void StartSpin()
Interaction mode entry points used internally.
virtual void OnMouseMove()
Generic event bindings can be overridden in subclasses.
virtual void EndEnvRotate()
Interaction mode entry points used internally.
virtual void OnKeyRelease()
void FindPokedRenderer(int, int)
When an event occurs, we must determine which Renderer the event occurred within, since one RenderWin...
virtual void StopState()
utility routines used by state changes
virtual void EndSpin()
Interaction mode entry points used internally.
virtual void EndTimer()
Interaction mode entry points used internally.
virtual void EndZoom()
Interaction mode entry points used internally.
virtual void OnLeftButtonUp()
virtual void OnNextPose3D(vtkEventData *)
virtual void StartTwoPointer()
Interaction mode entry points used internally.
virtual void OnButton3D(vtkEventData *)
vtkActor2D * PickedActor2D
virtual void StartDolly()
Interaction mode entry points used internally.
~vtkInteractorStyle() override
virtual void OnSwipe()
virtual void StartRotate()
Interaction mode entry points used internally.
virtual void StartAnimate()
Interaction mode entry points used internally.
virtual void OnMiddleButtonDoubleClick()
virtual void OnSelect3D(vtkEventData *)
vtkTDxInteractorStyle * TDxStyle
virtual void OnFourthButtonDown()
void OnChar() override
OnChar is triggered when an ASCII key is pressed.
virtual void EndRotate()
Interaction mode entry points used internally.
vtkTypeBool AutoAdjustCameraClippingRange
abstract base class for most VTK objects
Definition: vtkObject.h:82
create wireframe outline around bounding box
map vtkPolyData to graphics primitives
represents an 3D object for placement in a rendered scene
Definition: vtkProp3D.h:93
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:76
platform-independent render window interaction including picking and frame rate control.
abstract specification for renderers
Definition: vtkRenderer.h:182
a vtkAbstractArray subclass for strings
provide 3DConnexion device event-driven interface to the rendering window
@ position
Definition: vtkX3D.h:267
int vtkTypeBool
Definition: vtkABI.h:69