VTK  9.2.20230603
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 #define VTKIS_GROUNDMOVEMENT 20 // horizontal movement according to the 4 directions
191 #define VTKIS_ELEVATION 21 // vertical movement (up and down)
192 
193 #define VTKIS_ANIM_OFF 0
194 #define VTKIS_ANIM_ON 1
195 
196 VTK_ABI_NAMESPACE_BEGIN
197 class vtkActor2D;
198 class vtkActor;
199 class vtkCallbackCommand;
200 class vtkEventData;
202 class vtkOutlineSource;
203 class vtkPolyDataMapper;
204 class vtkProp3D;
205 class vtkProp;
206 class vtkStringArray;
208 
209 class VTKRENDERINGCORE_EXPORT vtkInteractorStyle : public vtkInteractorObserver
210 {
211 public:
218 
220  void PrintSelf(ostream& os, vtkIndent indent) override;
221 
226  void SetInteractor(vtkRenderWindowInteractor* interactor) override;
227 
235  void SetEnabled(int) override;
236 
238 
246  vtkSetClampMacro(AutoAdjustCameraClippingRange, vtkTypeBool, 0, 1);
247  vtkGetMacro(AutoAdjustCameraClippingRange, vtkTypeBool);
248  vtkBooleanMacro(AutoAdjustCameraClippingRange, vtkTypeBool);
250 
256  void FindPokedRenderer(int, int);
257 
259 
262  vtkGetMacro(State, int);
264 
266 
269  vtkGetMacro(UseTimers, vtkTypeBool);
270  vtkSetMacro(UseTimers, vtkTypeBool);
271  vtkBooleanMacro(UseTimers, vtkTypeBool);
273 
275 
281  vtkSetClampMacro(TimerDuration, unsigned long, 1, 100000);
282  vtkGetMacro(TimerDuration, unsigned long);
284 
286 
289  vtkSetMacro(HandleObservers, vtkTypeBool);
290  vtkGetMacro(HandleObservers, vtkTypeBool);
291  vtkBooleanMacro(HandleObservers, vtkTypeBool);
293 
297  virtual void OnMouseMove() {}
298  virtual void OnLeftButtonDown() {}
299  virtual void OnLeftButtonUp() {}
300  virtual void OnMiddleButtonDown() {}
301  virtual void OnMiddleButtonUp() {}
302  virtual void OnRightButtonDown() {}
303  virtual void OnRightButtonUp() {}
304  virtual void OnLeftButtonDoubleClick() {}
305  virtual void OnMiddleButtonDoubleClick() {}
306  virtual void OnRightButtonDoubleClick() {}
307  virtual void OnMouseWheelForward() {}
308  virtual void OnMouseWheelBackward() {}
309  virtual void OnMouseWheelLeft() {}
310  virtual void OnMouseWheelRight() {}
311  virtual void OnFourthButtonDown() {}
312  virtual void OnFourthButtonUp() {}
313  virtual void OnFifthButtonDown() {}
314  virtual void OnFifthButtonUp() {}
315 
319  virtual void OnMove3D(vtkEventData*) {}
320  virtual void OnButton3D(vtkEventData*) {}
321  virtual void OnPick3D(vtkEventData*) {}
322  virtual void OnClip3D(vtkEventData*) {}
323  virtual void OnSelect3D(vtkEventData*) {}
324  virtual void OnMenu3D(vtkEventData*) {}
325  virtual void OnNextPose3D(vtkEventData*) {}
326  virtual void OnPositionProp3D(vtkEventData*) {}
328  virtual void OnElevation3D(vtkEventData*) {}
329 
334  void OnChar() override;
335 
336  // OnKeyDown is triggered by pressing any key (identical to OnKeyPress()).
337  // An empty implementation is provided. The behavior of this function should
338  // be specified in the subclass.
339  virtual void OnKeyDown() {}
340 
341  // OnKeyUp is triggered by releaseing any key (identical to OnKeyRelease()).
342  // An empty implementation is provided. The behavior of this function should
343  // be specified in the subclass.
344  virtual void OnKeyUp() {}
345 
346  // OnKeyPress is triggered by pressing any key (identical to OnKeyDown()).
347  // An empty implementation is provided. The behavior of this function should
348  // be specified in the subclass.
349  virtual void OnKeyPress() {}
350 
351  // OnKeyRelease is triggered by pressing any key (identical to OnKeyUp()).
352  // An empty implementation is provided. The behavior of this function should
353  // be specified in the subclass.
354  virtual void OnKeyRelease() {}
355 
359  virtual void OnExpose() {}
360  virtual void OnConfigure() {}
361  virtual void OnEnter() {}
362  virtual void OnLeave() {}
363 
368  virtual void OnTimer();
369 
376  virtual void Rotate() {}
377  virtual void Spin() {}
378  virtual void Pan() {}
379  virtual void Dolly() {}
380  virtual void Zoom() {}
381  virtual void UniformScale() {}
382  virtual void EnvironmentRotate() {}
383 
387  virtual void OnStartSwipe() {}
388  virtual void OnSwipe() {}
389  virtual void OnEndSwipe() {}
390  virtual void OnStartPinch() {}
391  virtual void OnPinch() {}
392  virtual void OnEndPinch() {}
393  virtual void OnStartRotate() {}
394  virtual void OnRotate() {}
395  virtual void OnEndRotate() {}
396  virtual void OnStartPan() {}
397  virtual void OnPan() {}
398  virtual void OnEndPan() {}
399  virtual void OnTap() {}
400  virtual void OnLongTap() {}
401 
403 
406  virtual void StartState(int newstate);
407  virtual void StopState();
409 
411 
414  virtual void StartAnimate();
415  virtual void StopAnimate();
416  virtual void StartRotate();
417  virtual void EndRotate();
418  virtual void StartZoom();
419  virtual void EndZoom();
420  virtual void StartPan();
421  virtual void EndPan();
422  virtual void StartSpin();
423  virtual void EndSpin();
424  virtual void StartDolly();
425  virtual void EndDolly();
426  virtual void StartUniformScale();
427  virtual void EndUniformScale();
428  virtual void StartTimer();
429  virtual void EndTimer();
430  virtual void StartTwoPointer();
431  virtual void EndTwoPointer();
432  virtual void StartGesture();
433  virtual void EndGesture();
434  virtual void StartEnvRotate();
435  virtual void EndEnvRotate();
437 
444  virtual void OnDropLocation(double* vtkNotUsed(position)) {}
445 
451  virtual void OnDropFiles(vtkStringArray* vtkNotUsed(filePaths)) {}
452 
454 
460  virtual void HighlightProp(vtkProp* prop);
461  virtual void HighlightActor2D(vtkActor2D* actor2D);
462  virtual void HighlightProp3D(vtkProp3D* prop3D);
464 
466 
470  vtkSetVector3Macro(PickColor, double);
471  vtkGetVectorMacro(PickColor, double, 3);
473 
475 
480  vtkSetMacro(MouseWheelMotionFactor, double);
481  vtkGetMacro(MouseWheelMotionFactor, double);
483 
485 
489  vtkGetObjectMacro(TDxStyle, vtkTDxInteractorStyle);
490  virtual void SetTDxStyle(vtkTDxInteractorStyle* tdxStyle);
492 
496  void DelegateTDxEvent(unsigned long event, void* calldata);
497 
498 protected:
501 
505  static void ProcessEvents(
506  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
507 
508  // Keep track of current state
509  int State;
511 
512  // Should observers be handled here, should we fire timers
515  int TimerId; // keep track of the timers that are created/destroyed
516 
518 
519  // For picking and highlighting props
526  int PropPicked; // bool: prop picked?
527  double PickColor[3]; // support 2D picking
529 
530  // Control the timer duration
531  unsigned long TimerDuration; // in milliseconds
532 
533  // Forward events to the RenderWindowInteractor
535 
537 
538 private:
539  vtkInteractorStyle(const vtkInteractorStyle&) = delete;
540  void operator=(const vtkInteractorStyle&) = delete;
541 };
542 
543 VTK_ABI_NAMESPACE_END
544 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:156
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:162
supports function callbacks
a simple event forwarder command
a simple class to control print indentation
Definition: vtkIndent.h:120
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 OnElevation3D(vtkEventData *)
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:83
create wireframe outline around bounding box
map vtkPolyData to graphics primitives
represents an 3D object for placement in a rendered scene
Definition: vtkProp3D.h:100
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:77
platform-independent render window interaction including picking and frame rate control.
abstract specification for renderers
Definition: vtkRenderer.h:183
a vtkAbstractArray subclass for strings
provide 3DConnexion device event-driven interface to the rendering window
@ position
Definition: vtkX3D.h:273
int vtkTypeBool
Definition: vtkABI.h:71