VTK  9.7.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 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
45 
46 VTK_ABI_NAMESPACE_BEGIN
48 class vtkAssemblyPath;
50 class vtkRenderer;
51 class vtkCallbackCommand;
53 class vtkPickingManager;
54 
55 class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkInteractorObserver : public vtkObject
56 {
57 public:
59  void PrintSelf(ostream& os, vtkIndent indent) override;
60 
62 
70  virtual void SetInteractor(vtkRenderWindowInteractor* iren);
71  vtkGetObjectMacro(Interactor, vtkRenderWindowInteractor);
73 
82  virtual void SetEnabled(int) {}
83  int GetEnabled() { return this->Enabled; }
84  void EnabledOn() { this->SetEnabled(1); }
85  void EnabledOff() { this->SetEnabled(0); }
86  void On() { this->SetEnabled(1); }
87  void Off() { this->SetEnabled(0); }
88 
90 
100  vtkSetClampMacro(Priority, float, 0.0f, 1.0f);
101  vtkGetMacro(Priority, float);
103 
105 
109  vtkBooleanMacro(PickingManaged, bool);
110  virtual void SetPickingManaged(bool managed);
111  vtkGetMacro(PickingManaged, bool);
113 
115 
121  vtkSetMacro(KeyPressActivation, vtkTypeBool);
122  vtkGetMacro(KeyPressActivation, vtkTypeBool);
123  vtkBooleanMacro(KeyPressActivation, vtkTypeBool);
125 
127 
134  vtkSetMacro(KeyPressActivationValue, char);
135  vtkGetMacro(KeyPressActivationValue, char);
137 
139 
147  vtkGetObjectMacro(DefaultRenderer, vtkRenderer);
148  virtual void SetDefaultRenderer(vtkRenderer*);
150 
152 
163  vtkGetObjectMacro(CurrentRenderer, vtkRenderer);
164  virtual void SetCurrentRenderer(vtkRenderer*);
166 
170  virtual void OnChar();
171 
173 
177  static void ComputeDisplayToWorld(
178  vtkRenderer* ren, double x, double y, double z, double worldPt[4]);
179  static void ComputeWorldToDisplay(
180  vtkRenderer* ren, double x, double y, double z, double displayPt[3]);
182 
184 
194  void GrabFocus(vtkCommand* mouseEvents, vtkCommand* keypressEvents = nullptr);
195  void ReleaseFocus();
197 
198 protected:
200  ~vtkInteractorObserver() override;
201 
203 
208  virtual void StartInteraction();
209  virtual void EndInteraction();
211 
215  static void ProcessEvents(
216  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
217 
219 
222  void ComputeDisplayToWorld(double x, double y, double z, double worldPt[4]);
223  void ComputeWorldToDisplay(double x, double y, double z, double displayPt[3]);
225 
226  // The state of the widget, whether on or off (observing events or not)
227  int Enabled;
228 
229  // Used to process events
230  vtkCallbackCommand* EventCallbackCommand; // subclasses use one
231  vtkCallbackCommand* KeyPressCallbackCommand; // listens to key activation
232 
233  // Priority at which events are processed
234  float Priority;
235 
236  // This variable controls whether the picking is managed by the Picking
237  // Manager process or not. True by default.
239 
245  virtual void RegisterPickers();
246 
250  void UnRegisterPickers();
251 
256  vtkPickingManager* GetPickingManager();
257 
262  vtkAssemblyPath* GetAssemblyPath(double X, double Y, double Z, vtkAbstractPropPicker* picker);
263 
264  // Keypress activation controls
267 
268  // Used to associate observers with the interactor
270 
271  // Internal ivars for processing events
274 
275  unsigned long CharObserverTag;
276  unsigned long DeleteObserverTag;
277 
278  // The mediator used to request resources from the interactor.
280  int RequestCursorShape(int requestedShape);
281 
282 private:
284  void operator=(const vtkInteractorObserver&) = delete;
285 };
286 
287 VTK_ABI_NAMESPACE_END
288 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:52
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:63
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:384
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
#define VTK_MARSHALAUTO
vtkRenderWindowInteractor * Interactor
manage contention for cursors and other resources
vtkCallbackCommand * EventCallbackCommand