VTK  9.4.20241112
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
138#ifndef vtkInteractorStyle_h
139#define vtkInteractorStyle_h
140
142#include "vtkRenderingCoreModule.h" // For export macro
143#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
144
145// Motion flags
146
147#define VTKIS_START 0
148#define VTKIS_NONE 0
149
150#define VTKIS_ROTATE 1
151#define VTKIS_PAN 2
152#define VTKIS_SPIN 3
153#define VTKIS_DOLLY 4
154#define VTKIS_ZOOM 5
155#define VTKIS_USCALE 6
156#define VTKIS_TIMER 7
157#define VTKIS_FORWARDFLY 8
158#define VTKIS_REVERSEFLY 9
159#define VTKIS_TWO_POINTER 10
160#define VTKIS_CLIP 11
161#define VTKIS_PICK 12 // perform a pick at the last location
162#define VTKIS_LOAD_CAMERA_POSE 13 // iterate through saved camera poses
163#define VTKIS_POSITION_PROP 14 // adjust the position, orientation of a prop
164#define VTKIS_EXIT 15 // call exit callback
165#define VTKIS_TOGGLE_DRAW_CONTROLS 16 // draw device controls helpers
166#define VTKIS_MENU 17 // invoke an application menu
167#define VTKIS_GESTURE 18 // touch interaction in progress
168#define VTKIS_ENV_ROTATE 19 // rotate the renderer environment texture
169#define VTKIS_GROUNDMOVEMENT 20 // horizontal movement according to the 4 directions
170#define VTKIS_ELEVATION 21 // vertical movement (up and down)
171#define VTKIS_TELEPORTATION 22 // teleportation (move instantly between two positions)
172
173#define VTKIS_ANIM_OFF 0
174#define VTKIS_ANIM_ON 1
175
176VTK_ABI_NAMESPACE_BEGIN
177class vtkActor2D;
178class vtkActor;
180class vtkEventData;
182class vtkOutlineSource;
184class vtkProp3D;
185class vtkProp;
186class vtkStringArray;
188
189class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkInteractorStyle : public vtkInteractorObserver
190{
191public:
198
200 void PrintSelf(ostream& os, vtkIndent indent) override;
201
207 void SetInteractor(vtkRenderWindowInteractor* interactor) override;
208
217 void SetEnabled(int) override;
218
220
228 vtkSetClampMacro(AutoAdjustCameraClippingRange, vtkTypeBool, 0, 1);
229 vtkGetMacro(AutoAdjustCameraClippingRange, vtkTypeBool);
230 vtkBooleanMacro(AutoAdjustCameraClippingRange, vtkTypeBool);
232
238 void FindPokedRenderer(int, int);
239
241
244 vtkGetMacro(State, int);
246
248
251 vtkGetMacro(UseTimers, vtkTypeBool);
252 vtkSetMacro(UseTimers, vtkTypeBool);
253 vtkBooleanMacro(UseTimers, vtkTypeBool);
255
257
263 vtkSetClampMacro(TimerDuration, unsigned long, 1, 100000);
264 vtkGetMacro(TimerDuration, unsigned long);
266
268
271 vtkSetMacro(HandleObservers, vtkTypeBool);
272 vtkGetMacro(HandleObservers, vtkTypeBool);
273 vtkBooleanMacro(HandleObservers, vtkTypeBool);
275
279 virtual void OnMouseMove() {}
280 virtual void OnLeftButtonDown() {}
281 virtual void OnLeftButtonUp() {}
282 virtual void OnMiddleButtonDown() {}
283 virtual void OnMiddleButtonUp() {}
284 virtual void OnRightButtonDown() {}
285 virtual void OnRightButtonUp() {}
286 virtual void OnLeftButtonDoubleClick() {}
288 virtual void OnRightButtonDoubleClick() {}
289 virtual void OnMouseWheelForward() {}
290 virtual void OnMouseWheelBackward() {}
291 virtual void OnMouseWheelLeft() {}
292 virtual void OnMouseWheelRight() {}
293 virtual void OnFourthButtonDown() {}
294 virtual void OnFourthButtonUp() {}
295 virtual void OnFifthButtonDown() {}
296 virtual void OnFifthButtonUp() {}
297
301 virtual void OnMove3D(vtkEventData*) {}
302 virtual void OnButton3D(vtkEventData*) {}
303 virtual void OnPick3D(vtkEventData*) {}
304 virtual void OnClip3D(vtkEventData*) {}
305 virtual void OnSelect3D(vtkEventData*) {}
306 virtual void OnMenu3D(vtkEventData*) {}
307 virtual void OnNextPose3D(vtkEventData*) {}
310 virtual void OnElevation3D(vtkEventData*) {}
311
316 void OnChar() override;
317
318 // OnKeyDown is triggered by pressing any key (identical to OnKeyPress()).
319 // An empty implementation is provided. The behavior of this function should
320 // be specified in the subclass.
321 virtual void OnKeyDown() {}
322
323 // OnKeyUp is triggered by releaseing any key (identical to OnKeyRelease()).
324 // An empty implementation is provided. The behavior of this function should
325 // be specified in the subclass.
326 virtual void OnKeyUp() {}
327
328 // OnKeyPress is triggered by pressing any key (identical to OnKeyDown()).
329 // An empty implementation is provided. The behavior of this function should
330 // be specified in the subclass.
331 virtual void OnKeyPress() {}
332
333 // OnKeyRelease is triggered by pressing any key (identical to OnKeyUp()).
334 // An empty implementation is provided. The behavior of this function should
335 // be specified in the subclass.
336 virtual void OnKeyRelease() {}
337
341 virtual void OnExpose() {}
342 virtual void OnConfigure() {}
343 virtual void OnEnter() {}
344 virtual void OnLeave() {}
345
350 virtual void OnTimer();
351
358 virtual void Rotate() {}
359 virtual void Spin() {}
360 virtual void Pan() {}
361 virtual void Dolly() {}
362 virtual void Zoom() {}
363 virtual void UniformScale() {}
364 virtual void EnvironmentRotate() {}
365
369 virtual void OnStartSwipe() {}
370 virtual void OnSwipe() {}
371 virtual void OnEndSwipe() {}
372 virtual void OnStartPinch() {}
373 virtual void OnPinch() {}
374 virtual void OnEndPinch() {}
375 virtual void OnStartRotate() {}
376 virtual void OnRotate() {}
377 virtual void OnEndRotate() {}
378 virtual void OnStartPan() {}
379 virtual void OnPan() {}
380 virtual void OnEndPan() {}
381 virtual void OnTap() {}
382 virtual void OnLongTap() {}
383
385
388 virtual void StartState(int newstate);
389 virtual void StopState();
391
393
396 virtual void StartAnimate();
397 virtual void StopAnimate();
398 virtual void StartRotate();
399 virtual void EndRotate();
400 virtual void StartZoom();
401 virtual void EndZoom();
402 virtual void StartPan();
403 virtual void EndPan();
404 virtual void StartSpin();
405 virtual void EndSpin();
406 virtual void StartDolly();
407 virtual void EndDolly();
408 virtual void StartUniformScale();
409 virtual void EndUniformScale();
410 virtual void StartTimer();
411 virtual void EndTimer();
412 virtual void StartTwoPointer();
413 virtual void EndTwoPointer();
414 virtual void StartGesture();
415 virtual void EndGesture();
416 virtual void StartEnvRotate();
417 virtual void EndEnvRotate();
419
426 virtual void OnDropLocation(double* vtkNotUsed(position)) {}
427
433 virtual void OnDropFiles(vtkStringArray* vtkNotUsed(filePaths)) {}
434
436
442 virtual void HighlightProp(vtkProp* prop);
443 virtual void HighlightActor2D(vtkActor2D* actor2D);
444 virtual void HighlightProp3D(vtkProp3D* prop3D);
446
448
452 vtkSetVector3Macro(PickColor, double);
453 vtkGetVectorMacro(PickColor, double, 3);
455
457
462 vtkSetMacro(MouseWheelMotionFactor, double);
463 vtkGetMacro(MouseWheelMotionFactor, double);
465
467
472 vtkGetObjectMacro(TDxStyle, vtkTDxInteractorStyle);
474 virtual void SetTDxStyle(vtkTDxInteractorStyle* tdxStyle);
476
480 void DelegateTDxEvent(unsigned long event, void* calldata);
481
482protected:
485
489 static void ProcessEvents(
490 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
491
492 // Keep track of current state
493 int State;
494 int AnimState;
495
496 // Should observers be handled here, should we fire timers
497 vtkTypeBool HandleObservers;
498 vtkTypeBool UseTimers;
499 int TimerId; // keep track of the timers that are created/destroyed
500
501 vtkTypeBool AutoAdjustCameraClippingRange;
502
503 // For picking and highlighting props
505 vtkPolyDataMapper* OutlineMapper;
506 vtkActor* OutlineActor;
507 vtkRenderer* PickedRenderer;
508 vtkProp* CurrentProp;
509 vtkActor2D* PickedActor2D;
510 int PropPicked; // bool: prop picked?
511 double PickColor[3]; // support 2D picking
512 double MouseWheelMotionFactor;
513
514 // Control the timer duration
515 unsigned long TimerDuration; // in milliseconds
516
517 // Forward events to the RenderWindowInteractor
519
521
522private:
523 vtkInteractorStyle(const vtkInteractorStyle&) = delete;
524 void operator=(const vtkInteractorStyle&) = delete;
525};
526
527VTK_ABI_NAMESPACE_END
528#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
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.
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 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.
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...
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.
virtual void OnMouseWheelForward()
virtual void OnDropFiles(vtkStringArray *vtkNotUsed(filePaths))
When files are dropped on the render window.
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.
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()
virtual void OnEndSwipe()
virtual void OnViewerMovement3D(vtkEventData *)
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 EndEnvRotate()
Interaction mode entry points used internally.
virtual void OnKeyRelease()
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 *)
virtual void OnFourthButtonDown()
void OnChar() override
OnChar is triggered when an ASCII key is pressed.
virtual void EndRotate()
Interaction mode entry points used internally.
abstract base class for most VTK objects
Definition vtkObject.h:162
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:66
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)