VTK  9.3.20240527
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
206 void SetInteractor(vtkRenderWindowInteractor* interactor) override;
207
215 void SetEnabled(int) override;
216
218
226 vtkSetClampMacro(AutoAdjustCameraClippingRange, vtkTypeBool, 0, 1);
227 vtkGetMacro(AutoAdjustCameraClippingRange, vtkTypeBool);
228 vtkBooleanMacro(AutoAdjustCameraClippingRange, vtkTypeBool);
230
236 void FindPokedRenderer(int, int);
237
239
242 vtkGetMacro(State, int);
244
246
249 vtkGetMacro(UseTimers, vtkTypeBool);
250 vtkSetMacro(UseTimers, vtkTypeBool);
251 vtkBooleanMacro(UseTimers, vtkTypeBool);
253
255
261 vtkSetClampMacro(TimerDuration, unsigned long, 1, 100000);
262 vtkGetMacro(TimerDuration, unsigned long);
264
266
269 vtkSetMacro(HandleObservers, vtkTypeBool);
270 vtkGetMacro(HandleObservers, vtkTypeBool);
271 vtkBooleanMacro(HandleObservers, vtkTypeBool);
273
277 virtual void OnMouseMove() {}
278 virtual void OnLeftButtonDown() {}
279 virtual void OnLeftButtonUp() {}
280 virtual void OnMiddleButtonDown() {}
281 virtual void OnMiddleButtonUp() {}
282 virtual void OnRightButtonDown() {}
283 virtual void OnRightButtonUp() {}
284 virtual void OnLeftButtonDoubleClick() {}
286 virtual void OnRightButtonDoubleClick() {}
287 virtual void OnMouseWheelForward() {}
288 virtual void OnMouseWheelBackward() {}
289 virtual void OnMouseWheelLeft() {}
290 virtual void OnMouseWheelRight() {}
291 virtual void OnFourthButtonDown() {}
292 virtual void OnFourthButtonUp() {}
293 virtual void OnFifthButtonDown() {}
294 virtual void OnFifthButtonUp() {}
295
299 virtual void OnMove3D(vtkEventData*) {}
300 virtual void OnButton3D(vtkEventData*) {}
301 virtual void OnPick3D(vtkEventData*) {}
302 virtual void OnClip3D(vtkEventData*) {}
303 virtual void OnSelect3D(vtkEventData*) {}
304 virtual void OnMenu3D(vtkEventData*) {}
305 virtual void OnNextPose3D(vtkEventData*) {}
308 virtual void OnElevation3D(vtkEventData*) {}
309
314 void OnChar() override;
315
316 // OnKeyDown is triggered by pressing any key (identical to OnKeyPress()).
317 // An empty implementation is provided. The behavior of this function should
318 // be specified in the subclass.
319 virtual void OnKeyDown() {}
320
321 // OnKeyUp is triggered by releaseing any key (identical to OnKeyRelease()).
322 // An empty implementation is provided. The behavior of this function should
323 // be specified in the subclass.
324 virtual void OnKeyUp() {}
325
326 // OnKeyPress is triggered by pressing any key (identical to OnKeyDown()).
327 // An empty implementation is provided. The behavior of this function should
328 // be specified in the subclass.
329 virtual void OnKeyPress() {}
330
331 // OnKeyRelease is triggered by pressing any key (identical to OnKeyUp()).
332 // An empty implementation is provided. The behavior of this function should
333 // be specified in the subclass.
334 virtual void OnKeyRelease() {}
335
339 virtual void OnExpose() {}
340 virtual void OnConfigure() {}
341 virtual void OnEnter() {}
342 virtual void OnLeave() {}
343
348 virtual void OnTimer();
349
356 virtual void Rotate() {}
357 virtual void Spin() {}
358 virtual void Pan() {}
359 virtual void Dolly() {}
360 virtual void Zoom() {}
361 virtual void UniformScale() {}
362 virtual void EnvironmentRotate() {}
363
367 virtual void OnStartSwipe() {}
368 virtual void OnSwipe() {}
369 virtual void OnEndSwipe() {}
370 virtual void OnStartPinch() {}
371 virtual void OnPinch() {}
372 virtual void OnEndPinch() {}
373 virtual void OnStartRotate() {}
374 virtual void OnRotate() {}
375 virtual void OnEndRotate() {}
376 virtual void OnStartPan() {}
377 virtual void OnPan() {}
378 virtual void OnEndPan() {}
379 virtual void OnTap() {}
380 virtual void OnLongTap() {}
381
383
386 virtual void StartState(int newstate);
387 virtual void StopState();
389
391
394 virtual void StartAnimate();
395 virtual void StopAnimate();
396 virtual void StartRotate();
397 virtual void EndRotate();
398 virtual void StartZoom();
399 virtual void EndZoom();
400 virtual void StartPan();
401 virtual void EndPan();
402 virtual void StartSpin();
403 virtual void EndSpin();
404 virtual void StartDolly();
405 virtual void EndDolly();
406 virtual void StartUniformScale();
407 virtual void EndUniformScale();
408 virtual void StartTimer();
409 virtual void EndTimer();
410 virtual void StartTwoPointer();
411 virtual void EndTwoPointer();
412 virtual void StartGesture();
413 virtual void EndGesture();
414 virtual void StartEnvRotate();
415 virtual void EndEnvRotate();
417
424 virtual void OnDropLocation(double* vtkNotUsed(position)) {}
425
431 virtual void OnDropFiles(vtkStringArray* vtkNotUsed(filePaths)) {}
432
434
440 virtual void HighlightProp(vtkProp* prop);
441 virtual void HighlightActor2D(vtkActor2D* actor2D);
442 virtual void HighlightProp3D(vtkProp3D* prop3D);
444
446
450 vtkSetVector3Macro(PickColor, double);
451 vtkGetVectorMacro(PickColor, double, 3);
453
455
460 vtkSetMacro(MouseWheelMotionFactor, double);
461 vtkGetMacro(MouseWheelMotionFactor, double);
463
465
470 vtkGetObjectMacro(TDxStyle, vtkTDxInteractorStyle);
472 virtual void SetTDxStyle(vtkTDxInteractorStyle* tdxStyle);
474
478 void DelegateTDxEvent(unsigned long event, void* calldata);
479
480protected:
483
487 static void ProcessEvents(
488 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
489
490 // Keep track of current state
491 int State;
492 int AnimState;
493
494 // Should observers be handled here, should we fire timers
495 vtkTypeBool HandleObservers;
496 vtkTypeBool UseTimers;
497 int TimerId; // keep track of the timers that are created/destroyed
498
499 vtkTypeBool AutoAdjustCameraClippingRange;
500
501 // For picking and highlighting props
503 vtkPolyDataMapper* OutlineMapper;
504 vtkActor* OutlineActor;
505 vtkRenderer* PickedRenderer;
506 vtkProp* CurrentProp;
507 vtkActor2D* PickedActor2D;
508 int PropPicked; // bool: prop picked?
509 double PickColor[3]; // support 2D picking
510 double MouseWheelMotionFactor;
511
512 // Control the timer duration
513 unsigned long TimerDuration; // in milliseconds
514
515 // Forward events to the RenderWindowInteractor
517
519
520private:
521 vtkInteractorStyle(const vtkInteractorStyle&) = delete;
522 void operator=(const vtkInteractorStyle&) = delete;
523};
524
525VTK_ABI_NAMESPACE_END
526#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()
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.
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.
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()
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 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 *)
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_INTERNAL
#define VTK_MARSHALAUTO
#define VTK_MARSHALEXCLUDE(reason)