VTK  9.3.20240328
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
78 #ifndef vtkInteractorObserver_h
79 #define vtkInteractorObserver_h
80 
81 #include "vtkObject.h"
82 #include "vtkRenderingCoreModule.h" // For export macro
83 
84 VTK_ABI_NAMESPACE_BEGIN
86 class vtkAssemblyPath;
88 class vtkRenderer;
89 class vtkCallbackCommand;
91 class vtkPickingManager;
92 
93 class VTKRENDERINGCORE_EXPORT vtkInteractorObserver : public vtkObject
94 {
95 public:
97  void PrintSelf(ostream& os, vtkIndent indent) override;
98 
107  virtual void SetEnabled(int) {}
108  int GetEnabled() { return this->Enabled; }
109  void EnabledOn() { this->SetEnabled(1); }
110  void EnabledOff() { this->SetEnabled(0); }
111  void On() { this->SetEnabled(1); }
112  void Off() { this->SetEnabled(0); }
113 
115 
124  vtkGetObjectMacro(Interactor, vtkRenderWindowInteractor);
126 
128 
138  vtkSetClampMacro(Priority, float, 0.0f, 1.0f);
139  vtkGetMacro(Priority, float);
141 
143 
147  vtkBooleanMacro(PickingManaged, bool);
148  virtual void SetPickingManaged(bool managed);
149  vtkGetMacro(PickingManaged, bool);
151 
153 
159  vtkSetMacro(KeyPressActivation, vtkTypeBool);
160  vtkGetMacro(KeyPressActivation, vtkTypeBool);
161  vtkBooleanMacro(KeyPressActivation, vtkTypeBool);
163 
165 
172  vtkSetMacro(KeyPressActivationValue, char);
173  vtkGetMacro(KeyPressActivationValue, char);
175 
177 
185  vtkGetObjectMacro(DefaultRenderer, vtkRenderer);
188 
190 
201  vtkGetObjectMacro(CurrentRenderer, vtkRenderer);
204 
208  virtual void OnChar();
209 
211 
216  vtkRenderer* ren, double x, double y, double z, double worldPt[4]);
218  vtkRenderer* ren, double x, double y, double z, double displayPt[3]);
220 
222 
232  void GrabFocus(vtkCommand* mouseEvents, vtkCommand* keypressEvents = nullptr);
233  void ReleaseFocus();
235 
236 protected:
239 
241 
246  virtual void StartInteraction();
247  virtual void EndInteraction();
249 
253  static void ProcessEvents(
254  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
255 
257 
260  void ComputeDisplayToWorld(double x, double y, double z, double worldPt[4]);
261  void ComputeWorldToDisplay(double x, double y, double z, double displayPt[3]);
263 
264  // The state of the widget, whether on or off (observing events or not)
265  int Enabled;
266 
267  // Used to process events
268  vtkCallbackCommand* EventCallbackCommand; // subclasses use one
269  vtkCallbackCommand* KeyPressCallbackCommand; // listens to key activation
270 
271  // Priority at which events are processed
272  float Priority;
273 
274  // This variable controls whether the picking is managed by the Picking
275  // Manager process or not. True by default.
277 
283  virtual void RegisterPickers();
284 
289 
295 
300  vtkAssemblyPath* GetAssemblyPath(double X, double Y, double Z, vtkAbstractPropPicker* picker);
301 
302  // Keypress activation controls
305 
306  // Used to associate observers with the interactor
308 
309  // Internal ivars for processing events
312 
313  unsigned long CharObserverTag;
314  unsigned long DeleteObserverTag;
315 
316  // The mediator used to request resources from the interactor.
318  int RequestCursorShape(int requestedShape);
319 
320 private:
322  void operator=(const vtkInteractorObserver&) = delete;
323 };
324 
325 VTK_ABI_NAMESPACE_END
326 #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:108
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
vtkPickingManager * GetPickingManager()
Return the picking manager associated on the context on which the observer currently belong.
vtkCallbackCommand * EventCallbackCommand
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void ComputeWorldToDisplay(double x, double y, double z, double displayPt[3])
Helper method for subclasses.
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...
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
abstract base class for most VTK objects
Definition: vtkObject.h:161
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:171
int vtkTypeBool
Definition: vtkABI.h:64