VTK  9.2.6
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=========================================================================*/
95#ifndef vtkInteractorStyle_h
96#define vtkInteractorStyle_h
97
99#include "vtkRenderingCoreModule.h" // For export macro
100
101// Motion flags
102
103#define VTKIS_START 0
104#define VTKIS_NONE 0
105
106#define VTKIS_ROTATE 1
107#define VTKIS_PAN 2
108#define VTKIS_SPIN 3
109#define VTKIS_DOLLY 4
110#define VTKIS_ZOOM 5
111#define VTKIS_USCALE 6
112#define VTKIS_TIMER 7
113#define VTKIS_FORWARDFLY 8
114#define VTKIS_REVERSEFLY 9
115#define VTKIS_TWO_POINTER 10
116#define VTKIS_CLIP 11
117#define VTKIS_PICK 12 // perform a pick at the last location
118#define VTKIS_LOAD_CAMERA_POSE 13 // iterate through saved camera poses
119#define VTKIS_POSITION_PROP 14 // adjust the position, orientation of a prop
120#define VTKIS_EXIT 15 // call exit callback
121#define VTKIS_TOGGLE_DRAW_CONTROLS 16 // draw device controls helpers
122#define VTKIS_MENU 17 // invoke an application menu
123#define VTKIS_GESTURE 18 // touch interaction in progress
124#define VTKIS_ENV_ROTATE 19 // rotate the renderer environment texture
125#define VTKIS_GROUNDMOVEMENT 20 // horizontal movement according to the 4 directions
126#define VTKIS_ELEVATION 21 // vertical movement (up and down)
127
128#define VTKIS_ANIM_OFF 0
129#define VTKIS_ANIM_ON 1
130
131class vtkActor2D;
132class vtkActor;
134class vtkEventData;
136class vtkOutlineSource;
138class vtkProp3D;
139class vtkProp;
140class vtkStringArray;
142
143class VTKRENDERINGCORE_EXPORT vtkInteractorStyle : public vtkInteractorObserver
144{
145public:
152
154 void PrintSelf(ostream& os, vtkIndent indent) override;
155
160 void SetInteractor(vtkRenderWindowInteractor* interactor) override;
161
169 void SetEnabled(int) override;
170
172
180 vtkSetClampMacro(AutoAdjustCameraClippingRange, vtkTypeBool, 0, 1);
181 vtkGetMacro(AutoAdjustCameraClippingRange, vtkTypeBool);
182 vtkBooleanMacro(AutoAdjustCameraClippingRange, vtkTypeBool);
184
190 void FindPokedRenderer(int, int);
191
193
196 vtkGetMacro(State, int);
198
200
203 vtkGetMacro(UseTimers, vtkTypeBool);
204 vtkSetMacro(UseTimers, vtkTypeBool);
205 vtkBooleanMacro(UseTimers, vtkTypeBool);
207
209
215 vtkSetClampMacro(TimerDuration, unsigned long, 1, 100000);
216 vtkGetMacro(TimerDuration, unsigned long);
218
220
223 vtkSetMacro(HandleObservers, vtkTypeBool);
224 vtkGetMacro(HandleObservers, vtkTypeBool);
225 vtkBooleanMacro(HandleObservers, vtkTypeBool);
227
231 virtual void OnMouseMove() {}
232 virtual void OnLeftButtonDown() {}
233 virtual void OnLeftButtonUp() {}
234 virtual void OnMiddleButtonDown() {}
235 virtual void OnMiddleButtonUp() {}
236 virtual void OnRightButtonDown() {}
237 virtual void OnRightButtonUp() {}
238 virtual void OnLeftButtonDoubleClick() {}
240 virtual void OnRightButtonDoubleClick() {}
241 virtual void OnMouseWheelForward() {}
242 virtual void OnMouseWheelBackward() {}
243 virtual void OnMouseWheelLeft() {}
244 virtual void OnMouseWheelRight() {}
245 virtual void OnFourthButtonDown() {}
246 virtual void OnFourthButtonUp() {}
247 virtual void OnFifthButtonDown() {}
248 virtual void OnFifthButtonUp() {}
249
253 virtual void OnMove3D(vtkEventData*) {}
254 virtual void OnButton3D(vtkEventData*) {}
255 virtual void OnPick3D(vtkEventData*) {}
256 virtual void OnClip3D(vtkEventData*) {}
257 virtual void OnSelect3D(vtkEventData*) {}
258 virtual void OnMenu3D(vtkEventData*) {}
259 virtual void OnNextPose3D(vtkEventData*) {}
262 virtual void OnElevation3D(vtkEventData*) {}
263
268 void OnChar() override;
269
270 // OnKeyDown is triggered by pressing any key (identical to OnKeyPress()).
271 // An empty implementation is provided. The behavior of this function should
272 // be specified in the subclass.
273 virtual void OnKeyDown() {}
274
275 // OnKeyUp is triggered by releaseing any key (identical to OnKeyRelease()).
276 // An empty implementation is provided. The behavior of this function should
277 // be specified in the subclass.
278 virtual void OnKeyUp() {}
279
280 // OnKeyPress is triggered by pressing any key (identical to OnKeyDown()).
281 // An empty implementation is provided. The behavior of this function should
282 // be specified in the subclass.
283 virtual void OnKeyPress() {}
284
285 // OnKeyRelease is triggered by pressing any key (identical to OnKeyUp()).
286 // An empty implementation is provided. The behavior of this function should
287 // be specified in the subclass.
288 virtual void OnKeyRelease() {}
289
293 virtual void OnExpose() {}
294 virtual void OnConfigure() {}
295 virtual void OnEnter() {}
296 virtual void OnLeave() {}
297
302 virtual void OnTimer();
303
310 virtual void Rotate() {}
311 virtual void Spin() {}
312 virtual void Pan() {}
313 virtual void Dolly() {}
314 virtual void Zoom() {}
315 virtual void UniformScale() {}
316 virtual void EnvironmentRotate() {}
317
321 virtual void OnStartSwipe() {}
322 virtual void OnSwipe() {}
323 virtual void OnEndSwipe() {}
324 virtual void OnStartPinch() {}
325 virtual void OnPinch() {}
326 virtual void OnEndPinch() {}
327 virtual void OnStartRotate() {}
328 virtual void OnRotate() {}
329 virtual void OnEndRotate() {}
330 virtual void OnStartPan() {}
331 virtual void OnPan() {}
332 virtual void OnEndPan() {}
333 virtual void OnTap() {}
334 virtual void OnLongTap() {}
335
337
340 virtual void StartState(int newstate);
341 virtual void StopState();
343
345
348 virtual void StartAnimate();
349 virtual void StopAnimate();
350 virtual void StartRotate();
351 virtual void EndRotate();
352 virtual void StartZoom();
353 virtual void EndZoom();
354 virtual void StartPan();
355 virtual void EndPan();
356 virtual void StartSpin();
357 virtual void EndSpin();
358 virtual void StartDolly();
359 virtual void EndDolly();
360 virtual void StartUniformScale();
361 virtual void EndUniformScale();
362 virtual void StartTimer();
363 virtual void EndTimer();
364 virtual void StartTwoPointer();
365 virtual void EndTwoPointer();
366 virtual void StartGesture();
367 virtual void EndGesture();
368 virtual void StartEnvRotate();
369 virtual void EndEnvRotate();
371
378 virtual void OnDropLocation(double* vtkNotUsed(position)) {}
379
385 virtual void OnDropFiles(vtkStringArray* vtkNotUsed(filePaths)) {}
386
388
394 virtual void HighlightProp(vtkProp* prop);
395 virtual void HighlightActor2D(vtkActor2D* actor2D);
396 virtual void HighlightProp3D(vtkProp3D* prop3D);
398
400
404 vtkSetVector3Macro(PickColor, double);
405 vtkGetVectorMacro(PickColor, double, 3);
407
409
414 vtkSetMacro(MouseWheelMotionFactor, double);
415 vtkGetMacro(MouseWheelMotionFactor, double);
417
419
423 vtkGetObjectMacro(TDxStyle, vtkTDxInteractorStyle);
424 virtual void SetTDxStyle(vtkTDxInteractorStyle* tdxStyle);
426
430 void DelegateTDxEvent(unsigned long event, void* calldata);
431
432protected:
435
439 static void ProcessEvents(
440 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
441
442 // Keep track of current state
443 int State;
445
446 // Should observers be handled here, should we fire timers
449 int TimerId; // keep track of the timers that are created/destroyed
450
452
453 // For picking and highlighting props
460 int PropPicked; // bool: prop picked?
461 double PickColor[3]; // support 2D picking
463
464 // Control the timer duration
465 unsigned long TimerDuration; // in milliseconds
466
467 // Forward events to the RenderWindowInteractor
469
471
472private:
473 vtkInteractorStyle(const vtkInteractorStyle&) = delete;
474 void operator=(const vtkInteractorStyle&) = delete;
475};
476
477#endif
a actor that draws 2D data
Definition vtkActor2D.h:40
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:46
supports function callbacks
a simple event forwarder command
a simple class to control print indentation
Definition vtkIndent.h:34
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()
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.
static vtkInteractorStyle * New()
This class must be supplied with a vtkRenderWindowInteractor wrapper or parent.
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 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 OnEndPinch()
virtual void OnStartRotate()
virtual void OnMouseWheelRight()
virtual void OnConfigure()
virtual void OnLeftButtonDown()
virtual void EndPan()
Interaction mode entry points used internally.
unsigned long TimerDuration
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 OnPositionProp3D(vtkEventData *)
virtual void StartUniformScale()
Interaction mode entry points used internally.
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 *)
virtual void StartDolly()
Interaction mode entry points used internally.
~vtkInteractorStyle() override
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:57
create wireframe outline around bounding box
map vtkPolyData to graphics primitives
represents an 3D object for placement in a rendered scene
Definition vtkProp3D.h:47
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:51
platform-independent render window interaction including picking and frame rate control.
abstract specification for renderers
Definition vtkRenderer.h:67
a vtkAbstractArray subclass for strings
provide 3DConnexion device event-driven interface to the rendering window
int vtkTypeBool
Definition vtkABI.h:69