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
134
135#ifndef vtkInteractorStyle_h
136#define vtkInteractorStyle_h
137
139#include "vtkRenderingCoreModule.h" // For export macro
140#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
141
142// Motion flags
143
144#define VTKIS_START 0
145#define VTKIS_NONE 0
146
147#define VTKIS_ROTATE 1
148#define VTKIS_PAN 2
149#define VTKIS_SPIN 3
150#define VTKIS_DOLLY 4
151#define VTKIS_ZOOM 5
152#define VTKIS_USCALE 6
153#define VTKIS_TIMER 7
154#define VTKIS_FORWARDFLY 8
155#define VTKIS_REVERSEFLY 9
156#define VTKIS_TWO_POINTER 10
157#define VTKIS_CLIP 11
158#define VTKIS_PICK 12 // perform a pick at the last location
159#define VTKIS_LOAD_CAMERA_POSE 13 // iterate through saved camera poses
160#define VTKIS_POSITION_PROP 14 // adjust the position, orientation of a prop
161#define VTKIS_EXIT 15 // call exit callback
162#define VTKIS_TOGGLE_DRAW_CONTROLS 16 // draw device controls helpers
163#define VTKIS_MENU 17 // invoke an application menu
164#define VTKIS_GESTURE 18 // touch interaction in progress
165#define VTKIS_ENV_ROTATE 19 // rotate the renderer environment texture
166#define VTKIS_GROUNDMOVEMENT 20 // horizontal movement according to the 4 directions
167#define VTKIS_ELEVATION 21 // vertical movement (up and down)
168#define VTKIS_TELEPORTATION 22 // teleportation (move instantly between two positions)
169
170#define VTKIS_ANIM_OFF 0
171#define VTKIS_ANIM_ON 1
172
173VTK_ABI_NAMESPACE_BEGIN
174class vtkActor2D;
175class vtkActor;
177class vtkEventData;
179class vtkOutlineSource;
181class vtkProp3D;
182class vtkProp;
183class vtkStringArray;
185
186class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkInteractorStyle : public vtkInteractorObserver
187{
188public:
195
197 void PrintSelf(ostream& os, vtkIndent indent) override;
198
204 void SetInteractor(vtkRenderWindowInteractor* interactor) override;
205
214 void SetEnabled(int) override;
215
217
229
235 void FindPokedRenderer(int, int);
236
238
241 vtkGetMacro(State, int);
243
245
248 vtkGetMacro(UseTimers, vtkTypeBool);
249 vtkSetMacro(UseTimers, vtkTypeBool);
250 vtkBooleanMacro(UseTimers, vtkTypeBool);
252
254
260 vtkSetClampMacro(TimerDuration, unsigned long, 1, 100000);
261 vtkGetMacro(TimerDuration, unsigned long);
263
265
270 vtkBooleanMacro(HandleObservers, vtkTypeBool);
272
276 virtual void OnMouseMove() {}
277 virtual void OnLeftButtonDown() {}
278 virtual void OnLeftButtonUp() {}
279 virtual void OnMiddleButtonDown() {}
280 virtual void OnMiddleButtonUp() {}
281 virtual void OnRightButtonDown() {}
282 virtual void OnRightButtonUp() {}
283 virtual void OnLeftButtonDoubleClick() {}
285 virtual void OnRightButtonDoubleClick() {}
286 virtual void OnMouseWheelForward() {}
287 virtual void OnMouseWheelBackward() {}
288 virtual void OnMouseWheelLeft() {}
289 virtual void OnMouseWheelRight() {}
290 virtual void OnFourthButtonDown() {}
291 virtual void OnFourthButtonUp() {}
292 virtual void OnFifthButtonDown() {}
293 virtual void OnFifthButtonUp() {}
294
298 virtual void OnMove3D(vtkEventData*) {}
299 virtual void OnButton3D(vtkEventData*) {}
300 virtual void OnPick3D(vtkEventData*) {}
301 virtual void OnClip3D(vtkEventData*) {}
302 virtual void OnSelect3D(vtkEventData*) {}
303 virtual void OnMenu3D(vtkEventData*) {}
304 virtual void OnNextPose3D(vtkEventData*) {}
307 virtual void OnElevation3D(vtkEventData*) {}
308
313 void OnChar() override;
314
315 // OnKeyDown is triggered by pressing any key (identical to OnKeyPress()).
316 // An empty implementation is provided. The behavior of this function should
317 // be specified in the subclass.
318 virtual void OnKeyDown() {}
319
320 // OnKeyUp is triggered by releasing any key (identical to OnKeyRelease()).
321 // An empty implementation is provided. The behavior of this function should
322 // be specified in the subclass.
323 virtual void OnKeyUp() {}
324
325 // OnKeyPress is triggered by pressing any key (identical to OnKeyDown()).
326 // An empty implementation is provided. The behavior of this function should
327 // be specified in the subclass.
328 virtual void OnKeyPress() {}
329
330 // OnKeyRelease is triggered by pressing any key (identical to OnKeyUp()).
331 // An empty implementation is provided. The behavior of this function should
332 // be specified in the subclass.
333 virtual void OnKeyRelease() {}
334
338 virtual void OnExpose() {}
339 virtual void OnConfigure() {}
340 virtual void OnEnter() {}
341 virtual void OnLeave() {}
342
347 virtual void OnTimer();
348
355 virtual void Rotate() {}
356 virtual void Spin() {}
357 virtual void Pan() {}
358 virtual void Dolly() {}
359 virtual void Zoom() {}
360 virtual void UniformScale() {}
361 virtual void EnvironmentRotate() {}
362
366 virtual void OnStartSwipe() {}
367 virtual void OnSwipe() {}
368 virtual void OnEndSwipe() {}
369 virtual void OnStartPinch() {}
370 virtual void OnPinch() {}
371 virtual void OnEndPinch() {}
372 virtual void OnStartRotate() {}
373 virtual void OnRotate() {}
374 virtual void OnEndRotate() {}
375 virtual void OnStartPan() {}
376 virtual void OnPan() {}
377 virtual void OnEndPan() {}
378 virtual void OnTap() {}
379 virtual void OnLongTap() {}
380
382
385 virtual void StartState(int newstate);
386 virtual void StopState();
388
390
393 virtual void StartAnimate();
394 virtual void StopAnimate();
395 virtual void StartRotate();
396 virtual void EndRotate();
397 virtual void StartZoom();
398 virtual void EndZoom();
399 virtual void StartPan();
400 virtual void EndPan();
401 virtual void StartSpin();
402 virtual void EndSpin();
403 virtual void StartDolly();
404 virtual void EndDolly();
405 virtual void StartUniformScale();
406 virtual void EndUniformScale();
407 virtual void StartTimer();
408 virtual void EndTimer();
409 virtual void StartTwoPointer();
410 virtual void EndTwoPointer();
411 virtual void StartGesture();
412 virtual void EndGesture();
413 virtual void StartEnvRotate();
414 virtual void EndEnvRotate();
416
423 virtual void OnDropLocation(double* vtkNotUsed(position)) {}
424
430 virtual void OnDropFiles(vtkStringArray* vtkNotUsed(filePaths)) {}
431
433
439 virtual void HighlightProp(vtkProp* prop);
440 virtual void HighlightActor2D(vtkActor2D* actor2D);
441 virtual void HighlightProp3D(vtkProp3D* prop3D);
443
445
449 vtkSetVector3Macro(PickColor, double);
450 vtkGetVectorMacro(PickColor, double, 3);
452
454
459 vtkSetMacro(MouseWheelMotionFactor, double);
460 vtkGetMacro(MouseWheelMotionFactor, double);
462
464
469 vtkGetObjectMacro(TDxStyle, vtkTDxInteractorStyle);
471 virtual void SetTDxStyle(vtkTDxInteractorStyle* tdxStyle);
473
477 void DelegateTDxEvent(unsigned long event, void* calldata);
478
479protected:
482
486 static void ProcessEvents(
487 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
488
489 // Keep track of current state
490 int State;
492
493 // Should observers be handled here, should we fire timers
496 int TimerId; // keep track of the timers that are created/destroyed
497
499
500 // For picking and highlighting props
507 int PropPicked; // bool: prop picked?
508 double PickColor[3]; // support 2D picking
510
511 // Control the timer duration
512 unsigned long TimerDuration; // in milliseconds
513
514 // Forward events to the RenderWindowInteractor
516
518
519private:
520 vtkInteractorStyle(const vtkInteractorStyle&) = delete;
521 void operator=(const vtkInteractorStyle&) = delete;
522};
523
524VTK_ABI_NAMESPACE_END
525#endif
a actor that draws 2D data
Definition vtkActor2D.h:145
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
supports function callbacks
a simple event forwarder command
a simple class to control print indentation
Definition vtkIndent.h:108
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:89
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:63
platform-independent render window interaction including picking and frame rate control.
abstract specification for renderers
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)