VTK  9.3.0
vtkInteractorObserver.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
36#ifndef vtkInteractorObserver_h
37#define vtkInteractorObserver_h
38
39#include "vtkObject.h"
40#include "vtkRenderingCoreModule.h" // For export macro
41
42VTK_ABI_NAMESPACE_BEGIN
44class vtkAssemblyPath;
46class vtkRenderer;
50
51class VTKRENDERINGCORE_EXPORT vtkInteractorObserver : public vtkObject
52{
53public:
55 void PrintSelf(ostream& os, vtkIndent indent) override;
56
65 virtual void SetEnabled(int) {}
66 int GetEnabled() { return this->Enabled; }
67 void EnabledOn() { this->SetEnabled(1); }
68 void EnabledOff() { this->SetEnabled(0); }
69 void On() { this->SetEnabled(1); }
70 void Off() { this->SetEnabled(0); }
71
73
82 vtkGetObjectMacro(Interactor, vtkRenderWindowInteractor);
84
86
96 vtkSetClampMacro(Priority, float, 0.0f, 1.0f);
97 vtkGetMacro(Priority, float);
99
101
105 vtkBooleanMacro(PickingManaged, bool);
106 virtual void SetPickingManaged(bool managed);
107 vtkGetMacro(PickingManaged, bool);
109
111
117 vtkSetMacro(KeyPressActivation, vtkTypeBool);
118 vtkGetMacro(KeyPressActivation, vtkTypeBool);
119 vtkBooleanMacro(KeyPressActivation, vtkTypeBool);
121
123
130 vtkSetMacro(KeyPressActivationValue, char);
131 vtkGetMacro(KeyPressActivationValue, char);
133
135
143 vtkGetObjectMacro(DefaultRenderer, vtkRenderer);
146
148
159 vtkGetObjectMacro(CurrentRenderer, vtkRenderer);
162
166 virtual void OnChar();
167
169
174 vtkRenderer* ren, double x, double y, double z, double worldPt[4]);
176 vtkRenderer* ren, double x, double y, double z, double displayPt[3]);
178
180
190 void GrabFocus(vtkCommand* mouseEvents, vtkCommand* keypressEvents = nullptr);
193
194protected:
197
199
204 virtual void StartInteraction();
205 virtual void EndInteraction();
207
211 static void ProcessEvents(
212 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
213
215
218 void ComputeDisplayToWorld(double x, double y, double z, double worldPt[4]);
219 void ComputeWorldToDisplay(double x, double y, double z, double displayPt[3]);
221
222 // The state of the widget, whether on or off (observing events or not)
224
225 // Used to process events
227 vtkCallbackCommand* KeyPressCallbackCommand; // listens to key activation
228
229 // Priority at which events are processed
230 float Priority;
231
232 // This variable controls whether the picking is managed by the Picking
233 // Manager process or not. True by default.
235
241 virtual void RegisterPickers();
242
247
253
258 vtkAssemblyPath* GetAssemblyPath(double X, double Y, double Z, vtkAbstractPropPicker* picker);
259
260 // Keypress activation controls
263
264 // Used to associate observers with the interactor
266
267 // Internal ivars for processing events
270
271 unsigned long CharObserverTag;
272 unsigned long DeleteObserverTag;
273
274 // The mediator used to request resources from the interactor.
276 int RequestCursorShape(int requestedShape);
277
278private:
280 void operator=(const vtkInteractorObserver&) = delete;
281};
282
283VTK_ABI_NAMESPACE_END
284#endif
abstract API for pickers that can pick an instance of vtkProp
a list of nodes that form an assembly path
supports function callbacks
superclass for callback/observer methods
Definition vtkCommand.h:384
a simple class to control print indentation
Definition vtkIndent.h:29
an abstract superclass for classes observing events invoked by vtkRenderWindowInteractor
virtual void EndInteraction()
Utility routines used to start and end interaction.
void UnRegisterPickers()
Unregister internal pickers from the Picking Manager.
virtual void StartInteraction()
Utility routines used to start and end interaction.
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Handles the char widget activation event.
~vtkInteractorObserver() override
vtkCallbackCommand * EventCallbackCommand
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkPickingManager * GetPickingManager()
Return the picking manager associated on the context on which the observer currently belong.
void ComputeWorldToDisplay(double x, double y, double z, double displayPt[3])
Helper method for subclasses.
static void ComputeDisplayToWorld(vtkRenderer *ren, double x, double y, double z, double worldPt[4])
Convenience methods for outside classes.
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkCallbackCommand * KeyPressCallbackCommand
void GrabFocus(vtkCommand *mouseEvents, vtkCommand *keypressEvents=nullptr)
These methods enable an interactor observer to exclusively grab all events invoked by its associated ...
virtual void OnChar()
Sets up the keypress-i event.
virtual void SetInteractor(vtkRenderWindowInteractor *iren)
This method is used to associate the widget with the render window interactor.
void ComputeDisplayToWorld(double x, double y, double z, double worldPt[4])
Helper method for subclasses.
void ReleaseFocus()
These methods enable an interactor observer to exclusively grab all events invoked by its associated ...
virtual void SetCurrentRenderer(vtkRenderer *)
Set/Get the current renderer.
vtkObserverMediator * ObserverMediator
int RequestCursorShape(int requestedShape)
virtual void SetDefaultRenderer(vtkRenderer *)
Set/Get the default renderer to use when activating the interactor observer.
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
static void ComputeWorldToDisplay(vtkRenderer *ren, double x, double y, double z, double displayPt[3])
Convenience methods for outside classes.
virtual void SetPickingManaged(bool managed)
Enable/Disable the use of a manager to process the picking.
vtkRenderWindowInteractor * Interactor
vtkAssemblyPath * GetAssemblyPath(double X, double Y, double Z, vtkAbstractPropPicker *picker)
Proceed to a pick, whether through the PickingManager if the picking is managed or directly using the...
abstract base class for most VTK objects
Definition vtkObject.h:49
manage contention for cursors and other resources
Class defines API to manage the picking process.
platform-independent render window interaction including picking and frame rate control.
abstract specification for renderers
Definition vtkRenderer.h:59
int vtkTypeBool
Definition vtkABI.h:64