VTK  9.5.2
vtkInteractorStyle.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
85
86#ifndef vtkInteractorStyle_h
87#define vtkInteractorStyle_h
88
90#include "vtkRenderingCoreModule.h" // For export macro
91#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
92
93// Motion flags
94
95#define VTKIS_START 0
96#define VTKIS_NONE 0
97
98#define VTKIS_ROTATE 1
99#define VTKIS_PAN 2
100#define VTKIS_SPIN 3
101#define VTKIS_DOLLY 4
102#define VTKIS_ZOOM 5
103#define VTKIS_USCALE 6
104#define VTKIS_TIMER 7
105#define VTKIS_FORWARDFLY 8
106#define VTKIS_REVERSEFLY 9
107#define VTKIS_TWO_POINTER 10
108#define VTKIS_CLIP 11
109#define VTKIS_PICK 12 // perform a pick at the last location
110#define VTKIS_LOAD_CAMERA_POSE 13 // iterate through saved camera poses
111#define VTKIS_POSITION_PROP 14 // adjust the position, orientation of a prop
112#define VTKIS_EXIT 15 // call exit callback
113#define VTKIS_TOGGLE_DRAW_CONTROLS 16 // draw device controls helpers
114#define VTKIS_MENU 17 // invoke an application menu
115#define VTKIS_GESTURE 18 // touch interaction in progress
116#define VTKIS_ENV_ROTATE 19 // rotate the renderer environment texture
117#define VTKIS_GROUNDMOVEMENT 20 // horizontal movement according to the 4 directions
118#define VTKIS_ELEVATION 21 // vertical movement (up and down)
119#define VTKIS_TELEPORTATION 22 // teleportation (move instantly between two positions)
120
121#define VTKIS_ANIM_OFF 0
122#define VTKIS_ANIM_ON 1
123
124VTK_ABI_NAMESPACE_BEGIN
125class vtkActor2D;
126class vtkActor;
128class vtkEventData;
130class vtkOutlineSource;
132class vtkProp3D;
133class vtkProp;
134class vtkStringArray;
136
137class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkInteractorStyle : public vtkInteractorObserver
138{
139public:
146
148 void PrintSelf(ostream& os, vtkIndent indent) override;
149
155 void SetInteractor(vtkRenderWindowInteractor* interactor) override;
156
165 void SetEnabled(int) override;
166
168
180
186 void FindPokedRenderer(int, int);
187
189
192 vtkGetMacro(State, int);
194
196
199 vtkGetMacro(UseTimers, vtkTypeBool);
200 vtkSetMacro(UseTimers, vtkTypeBool);
201 vtkBooleanMacro(UseTimers, vtkTypeBool);
203
205
211 vtkSetClampMacro(TimerDuration, unsigned long, 1, 100000);
212 vtkGetMacro(TimerDuration, unsigned long);
214
216
221 vtkBooleanMacro(HandleObservers, vtkTypeBool);
223
227 virtual void OnMouseMove() {}
228 virtual void OnLeftButtonDown() {}
229 virtual void OnLeftButtonUp() {}
230 virtual void OnMiddleButtonDown() {}
231 virtual void OnMiddleButtonUp() {}
232 virtual void OnRightButtonDown() {}
233 virtual void OnRightButtonUp() {}
234 virtual void OnLeftButtonDoubleClick() {}
236 virtual void OnRightButtonDoubleClick() {}
237 virtual void OnMouseWheelForward() {}
238 virtual void OnMouseWheelBackward() {}
239 virtual void OnMouseWheelLeft() {}
240 virtual void OnMouseWheelRight() {}
241 virtual void OnFourthButtonDown() {}
242 virtual void OnFourthButtonUp() {}
243 virtual void OnFifthButtonDown() {}
244 virtual void OnFifthButtonUp() {}
245
249 virtual void OnMove3D(vtkEventData*) {}
250 virtual void OnButton3D(vtkEventData*) {}
251 virtual void OnPick3D(vtkEventData*) {}
252 virtual void OnClip3D(vtkEventData*) {}
253 virtual void OnSelect3D(vtkEventData*) {}
254 virtual void OnMenu3D(vtkEventData*) {}
255 virtual void OnNextPose3D(vtkEventData*) {}
258 virtual void OnElevation3D(vtkEventData*) {}
259
264 void OnChar() override;
265
266 // OnKeyDown is triggered by pressing any key (identical to OnKeyPress()).
267 // An empty implementation is provided. The behavior of this function should
268 // be specified in the subclass.
269 virtual void OnKeyDown() {}
270
271 // OnKeyUp is triggered by releasing any key (identical to OnKeyRelease()).
272 // An empty implementation is provided. The behavior of this function should
273 // be specified in the subclass.
274 virtual void OnKeyUp() {}
275
276 // OnKeyPress is triggered by pressing any key (identical to OnKeyDown()).
277 // An empty implementation is provided. The behavior of this function should
278 // be specified in the subclass.
279 virtual void OnKeyPress() {}
280
281 // OnKeyRelease is triggered by pressing any key (identical to OnKeyUp()).
282 // An empty implementation is provided. The behavior of this function should
283 // be specified in the subclass.
284 virtual void OnKeyRelease() {}
285
289 virtual void OnExpose() {}
290 virtual void OnConfigure() {}
291 virtual void OnEnter() {}
292 virtual void OnLeave() {}
293
298 virtual void OnTimer();
299
306 virtual void Rotate() {}
307 virtual void Spin() {}
308 virtual void Pan() {}
309 virtual void Dolly() {}
310 virtual void Zoom() {}
311 virtual void UniformScale() {}
312 virtual void EnvironmentRotate() {}
313
317 virtual void OnStartSwipe() {}
318 virtual void OnSwipe() {}
319 virtual void OnEndSwipe() {}
320 virtual void OnStartPinch() {}
321 virtual void OnPinch() {}
322 virtual void OnEndPinch() {}
323 virtual void OnStartRotate() {}
324 virtual void OnRotate() {}
325 virtual void OnEndRotate() {}
326 virtual void OnStartPan() {}
327 virtual void OnPan() {}
328 virtual void OnEndPan() {}
329 virtual void OnTap() {}
330 virtual void OnLongTap() {}
331
333
336 virtual void StartState(int newstate);
337 virtual void StopState();
339
341
344 virtual void StartAnimate();
345 virtual void StopAnimate();
346 virtual void StartRotate();
347 virtual void EndRotate();
348 virtual void StartZoom();
349 virtual void EndZoom();
350 virtual void StartPan();
351 virtual void EndPan();
352 virtual void StartSpin();
353 virtual void EndSpin();
354 virtual void StartDolly();
355 virtual void EndDolly();
356 virtual void StartUniformScale();
357 virtual void EndUniformScale();
358 virtual void StartTimer();
359 virtual void EndTimer();
360 virtual void StartTwoPointer();
361 virtual void EndTwoPointer();
362 virtual void StartGesture();
363 virtual void EndGesture();
364 virtual void StartEnvRotate();
365 virtual void EndEnvRotate();
367
374 virtual void OnDropLocation(double* vtkNotUsed(position)) {}
375
381 virtual void OnDropFiles(vtkStringArray* vtkNotUsed(filePaths)) {}
382
384
390 virtual void HighlightProp(vtkProp* prop);
391 virtual void HighlightActor2D(vtkActor2D* actor2D);
392 virtual void HighlightProp3D(vtkProp3D* prop3D);
394
396
400 vtkSetVector3Macro(PickColor, double);
401 vtkGetVectorMacro(PickColor, double, 3);
403
405
410 vtkSetMacro(MouseWheelMotionFactor, double);
411 vtkGetMacro(MouseWheelMotionFactor, double);
413
415
420 vtkGetObjectMacro(TDxStyle, vtkTDxInteractorStyle);
422 virtual void SetTDxStyle(vtkTDxInteractorStyle* tdxStyle);
424
428 void DelegateTDxEvent(unsigned long event, void* calldata);
429
430protected:
433
437 static void ProcessEvents(
438 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
439
440 // Keep track of current state
441 int State;
443
444 // Should observers be handled here, should we fire timers
447 int TimerId; // keep track of the timers that are created/destroyed
448
450
451 // For picking and highlighting props
458 int PropPicked; // bool: prop picked?
459 double PickColor[3]; // support 2D picking
461
462 // Control the timer duration
463 unsigned long TimerDuration; // in milliseconds
464
465 // Forward events to the RenderWindowInteractor
467
469
470private:
471 vtkInteractorStyle(const vtkInteractorStyle&) = delete;
472 void operator=(const vtkInteractorStyle&) = delete;
473};
474
475VTK_ABI_NAMESPACE_END
476#endif
a actor that draws 2D data
Definition vtkActor2D.h:36
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:42
supports function callbacks
a simple event forwarder command
a simple class to control print indentation
Definition vtkIndent.h:29
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.
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
create wireframe outline around bounding box
map vtkPolyData to graphics primitives
represents an 3D object for placement in a rendered scene
Definition vtkProp3D.h:40
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:44
platform-independent render window interaction including picking and frame rate control.
abstract specification for renderers
Definition vtkRenderer.h:60
a vtkAbstractArray subclass for strings
provide 3DConnexion device event-driven interface to the rendering window
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_MARSHAL_EXCLUDE_REASON_IS_REDUNDANT
#define VTK_MARSHAL_EXCLUDE_REASON_IS_INTERNAL
#define VTK_MARSHALAUTO
#define VTK_MARSHALEXCLUDE(reason)