VTK  9.3.1
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 
84  virtual void SetInteractor(vtkRenderWindowInteractor* iren);
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);
147  virtual void SetDefaultRenderer(vtkRenderer*);
149 
151 
162  vtkGetObjectMacro(CurrentRenderer, vtkRenderer);
163  virtual void SetCurrentRenderer(vtkRenderer*);
165 
169  virtual void OnChar();
170 
172 
176  static void ComputeDisplayToWorld(
177  vtkRenderer* ren, double x, double y, double z, double worldPt[4]);
178  static void ComputeWorldToDisplay(
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:
199  ~vtkInteractorObserver() override;
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 
249  void UnRegisterPickers();
250 
255  vtkPickingManager* GetPickingManager();
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 base class for most VTK objects
Definition: vtkObject.h:51
Class defines API to manage the picking process.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkObserverMediator * ObserverMediator
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
abstract specification for renderers
Definition: vtkRenderer.h:61
an abstract superclass for classes observing events invoked by vtkRenderWindowInteractor ...
int vtkTypeBool
Definition: vtkABI.h:64
platform-independent render window interaction including picking and frame rate control.
superclass for callback/observer methods
Definition: vtkCommand.h:383
supports function callbacks
a list of nodes that form an assembly path
a simple class to control print indentation
Definition: vtkIndent.h:28
vtkCallbackCommand * KeyPressCallbackCommand
abstract API for pickers that can pick an instance of vtkProp
vtkRenderWindowInteractor * Interactor
manage contention for cursors and other resources
vtkCallbackCommand * EventCallbackCommand