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
48 #ifndef vtkInteractorObserver_h
49 #define vtkInteractorObserver_h
50 
51 #include "vtkObject.h"
52 #include "vtkRenderingCoreModule.h" // For export macro
53 
54 VTK_ABI_NAMESPACE_BEGIN
56 class vtkAssemblyPath;
58 class vtkRenderer;
59 class vtkCallbackCommand;
61 class vtkPickingManager;
62 
63 class VTKRENDERINGCORE_EXPORT vtkInteractorObserver : public vtkObject
64 {
65 public:
67  void PrintSelf(ostream& os, vtkIndent indent) override;
68 
77  virtual void SetEnabled(int) {}
78  int GetEnabled() { return this->Enabled; }
79  void EnabledOn() { this->SetEnabled(1); }
80  void EnabledOff() { this->SetEnabled(0); }
81  void On() { this->SetEnabled(1); }
82  void Off() { this->SetEnabled(0); }
83 
85 
94  vtkGetObjectMacro(Interactor, vtkRenderWindowInteractor);
96 
98 
108  vtkSetClampMacro(Priority, float, 0.0f, 1.0f);
109  vtkGetMacro(Priority, float);
111 
113 
117  vtkBooleanMacro(PickingManaged, bool);
118  virtual void SetPickingManaged(bool managed);
119  vtkGetMacro(PickingManaged, bool);
121 
123 
129  vtkSetMacro(KeyPressActivation, vtkTypeBool);
130  vtkGetMacro(KeyPressActivation, vtkTypeBool);
131  vtkBooleanMacro(KeyPressActivation, vtkTypeBool);
133 
135 
142  vtkSetMacro(KeyPressActivationValue, char);
143  vtkGetMacro(KeyPressActivationValue, char);
145 
147 
155  vtkGetObjectMacro(DefaultRenderer, vtkRenderer);
158 
160 
171  vtkGetObjectMacro(CurrentRenderer, vtkRenderer);
174 
178  virtual void OnChar();
179 
181 
186  vtkRenderer* ren, double x, double y, double z, double worldPt[4]);
188  vtkRenderer* ren, double x, double y, double z, double displayPt[3]);
190 
192 
202  void GrabFocus(vtkCommand* mouseEvents, vtkCommand* keypressEvents = nullptr);
203  void ReleaseFocus();
205 
206 protected:
209 
211 
216  virtual void StartInteraction();
217  virtual void EndInteraction();
219 
223  static void ProcessEvents(
224  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
225 
227 
230  void ComputeDisplayToWorld(double x, double y, double z, double worldPt[4]);
231  void ComputeWorldToDisplay(double x, double y, double z, double displayPt[3]);
233 
234  // The state of the widget, whether on or off (observing events or not)
235  int Enabled;
236 
237  // Used to process events
238  vtkCallbackCommand* EventCallbackCommand; // subclasses use one
239  vtkCallbackCommand* KeyPressCallbackCommand; // listens to key activation
240 
241  // Priority at which events are processed
242  float Priority;
243 
244  // This variable controls whether the picking is managed by the Picking
245  // Manager process or not. True by default.
247 
253  virtual void RegisterPickers();
254 
259 
265 
270  vtkAssemblyPath* GetAssemblyPath(double X, double Y, double Z, vtkAbstractPropPicker* picker);
271 
272  // Keypress activation controls
275 
276  // Used to associate observers with the interactor
278 
279  // Internal ivars for processing events
282 
283  unsigned long CharObserverTag;
284  unsigned long DeleteObserverTag;
285 
286  // The mediator used to request resources from the interactor.
288  int RequestCursorShape(int requestedShape);
289 
290 private:
292  void operator=(const vtkInteractorObserver&) = delete;
293 };
294 
295 VTK_ABI_NAMESPACE_END
296 #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:38
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:61
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:71
int vtkTypeBool
Definition: vtkABI.h:64