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
39 #ifndef vtkInteractorObserver_h
40 #define vtkInteractorObserver_h
41 
42 #include "vtkObject.h"
43 #include "vtkRenderingCoreModule.h" // For export macro
44 
45 VTK_ABI_NAMESPACE_BEGIN
47 class vtkAssemblyPath;
49 class vtkRenderer;
50 class vtkCallbackCommand;
52 class vtkPickingManager;
53 
54 class VTKRENDERINGCORE_EXPORT vtkInteractorObserver : public vtkObject
55 {
56 public:
58  void PrintSelf(ostream& os, vtkIndent indent) override;
59 
68  virtual void SetEnabled(int) {}
69  int GetEnabled() { return this->Enabled; }
70  void EnabledOn() { this->SetEnabled(1); }
71  void EnabledOff() { this->SetEnabled(0); }
72  void On() { this->SetEnabled(1); }
73  void Off() { this->SetEnabled(0); }
74 
76 
85  vtkGetObjectMacro(Interactor, vtkRenderWindowInteractor);
87 
89 
99  vtkSetClampMacro(Priority, float, 0.0f, 1.0f);
100  vtkGetMacro(Priority, float);
102 
104 
108  vtkBooleanMacro(PickingManaged, bool);
109  virtual void SetPickingManaged(bool managed);
110  vtkGetMacro(PickingManaged, bool);
112 
114 
120  vtkSetMacro(KeyPressActivation, vtkTypeBool);
121  vtkGetMacro(KeyPressActivation, vtkTypeBool);
122  vtkBooleanMacro(KeyPressActivation, vtkTypeBool);
124 
126 
133  vtkSetMacro(KeyPressActivationValue, char);
134  vtkGetMacro(KeyPressActivationValue, char);
136 
138 
146  vtkGetObjectMacro(DefaultRenderer, vtkRenderer);
149 
151 
162  vtkGetObjectMacro(CurrentRenderer, vtkRenderer);
165 
169  virtual void OnChar();
170 
172 
177  vtkRenderer* ren, double x, double y, double z, double worldPt[4]);
179  vtkRenderer* ren, double x, double y, double z, double displayPt[3]);
181 
183 
193  void GrabFocus(vtkCommand* mouseEvents, vtkCommand* keypressEvents = nullptr);
194  void ReleaseFocus();
196 
197 protected:
200 
202 
207  virtual void StartInteraction();
208  virtual void EndInteraction();
210 
214  static void ProcessEvents(
215  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
216 
218 
221  void ComputeDisplayToWorld(double x, double y, double z, double worldPt[4]);
222  void ComputeWorldToDisplay(double x, double y, double z, double displayPt[3]);
224 
225  // The state of the widget, whether on or off (observing events or not)
226  int Enabled;
227 
228  // Used to process events
229  vtkCallbackCommand* EventCallbackCommand; // subclasses use one
230  vtkCallbackCommand* KeyPressCallbackCommand; // listens to key activation
231 
232  // Priority at which events are processed
233  float Priority;
234 
235  // This variable controls whether the picking is managed by the Picking
236  // Manager process or not. True by default.
238 
244  virtual void RegisterPickers();
245 
250 
256 
261  vtkAssemblyPath* GetAssemblyPath(double X, double Y, double Z, vtkAbstractPropPicker* picker);
262 
263  // Keypress activation controls
266 
267  // Used to associate observers with the interactor
269 
270  // Internal ivars for processing events
273 
274  unsigned long CharObserverTag;
275  unsigned long DeleteObserverTag;
276 
277  // The mediator used to request resources from the interactor.
279  int RequestCursorShape(int requestedShape);
280 
281 private:
283  void operator=(const vtkInteractorObserver&) = delete;
284 };
285 
286 VTK_ABI_NAMESPACE_END
287 #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
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:52
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:62
int vtkTypeBool
Definition: vtkABI.h:64