VTK  9.0.1
vtkInteractorObserver.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkInteractorObserver.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
48 #ifndef vtkInteractorObserver_h
49 #define vtkInteractorObserver_h
50 
51 #include "vtkObject.h"
52 #include "vtkRenderingCoreModule.h" // For export macro
53 
55 class vtkAssemblyPath;
57 class vtkRenderer;
58 class vtkCallbackCommand;
60 class vtkPickingManager;
61 
62 class VTKRENDERINGCORE_EXPORT vtkInteractorObserver : public vtkObject
63 {
64 public:
66  void PrintSelf(ostream& os, vtkIndent indent) override;
67 
76  virtual void SetEnabled(int) {}
77  int GetEnabled() { return this->Enabled; }
78  void EnabledOn() { this->SetEnabled(1); }
79  void EnabledOff() { this->SetEnabled(0); }
80  void On() { this->SetEnabled(1); }
81  void Off() { this->SetEnabled(0); }
82 
84 
92  virtual void SetInteractor(vtkRenderWindowInteractor* iren);
93  vtkGetObjectMacro(Interactor, vtkRenderWindowInteractor);
95 
97 
107  vtkSetClampMacro(Priority, float, 0.0f, 1.0f);
108  vtkGetMacro(Priority, float);
110 
112 
116  vtkBooleanMacro(PickingManaged, bool);
117  virtual void SetPickingManaged(bool managed);
118  vtkGetMacro(PickingManaged, bool);
120 
122 
128  vtkSetMacro(KeyPressActivation, vtkTypeBool);
129  vtkGetMacro(KeyPressActivation, vtkTypeBool);
130  vtkBooleanMacro(KeyPressActivation, vtkTypeBool);
132 
134 
141  vtkSetMacro(KeyPressActivationValue, char);
142  vtkGetMacro(KeyPressActivationValue, char);
144 
146 
154  vtkGetObjectMacro(DefaultRenderer, vtkRenderer);
155  virtual void SetDefaultRenderer(vtkRenderer*);
157 
159 
170  vtkGetObjectMacro(CurrentRenderer, vtkRenderer);
171  virtual void SetCurrentRenderer(vtkRenderer*);
173 
177  virtual void OnChar();
178 
180 
184  static void ComputeDisplayToWorld(
185  vtkRenderer* ren, double x, double y, double z, double worldPt[4]);
186  static void ComputeWorldToDisplay(
187  vtkRenderer* ren, double x, double y, double z, double displayPt[3]);
189 
191 
201  void GrabFocus(vtkCommand* mouseEvents, vtkCommand* keypressEvents = nullptr);
202  void ReleaseFocus();
204 
205 protected:
207  ~vtkInteractorObserver() override;
208 
210 
215  virtual void StartInteraction();
216  virtual void EndInteraction();
218 
222  static void ProcessEvents(
223  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
224 
226 
229  void ComputeDisplayToWorld(double x, double y, double z, double worldPt[4]);
230  void ComputeWorldToDisplay(double x, double y, double z, double displayPt[3]);
232 
233  // The state of the widget, whether on or off (observing events or not)
234  int Enabled;
235 
236  // Used to process events
237  vtkCallbackCommand* EventCallbackCommand; // subclasses use one
238  vtkCallbackCommand* KeyPressCallbackCommand; // listens to key activation
239 
240  // Priority at which events are processed
241  float Priority;
242 
243  // This variable controls whether the picking is managed by the Picking
244  // Manager process or not. True by default.
246 
252  virtual void RegisterPickers();
253 
257  void UnRegisterPickers();
258 
263  vtkPickingManager* GetPickingManager();
264 
269  vtkAssemblyPath* GetAssemblyPath(double X, double Y, double Z, vtkAbstractPropPicker* picker);
270 
271  // Keypress activation controls
274 
275  // Used to associate observers with the interactor
277 
278  // Internal ivars for processing events
281 
282  unsigned long CharObserverTag;
283  unsigned long DeleteObserverTag;
284 
285  // The mediator used to request resources from the interactor.
287  int RequestCursorShape(int requestedShape);
288 
289 private:
291  void operator=(const vtkInteractorObserver&) = delete;
292 };
293 
294 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:56
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:69
platform-independent render window interaction including picking and frame rate control.
superclass for callback/observer methods
Definition: vtkCommand.h:377
supports function callbacks
a list of nodes that form an assembly path
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkCallbackCommand * KeyPressCallbackCommand
abstract API for pickers that can pick an instance of vtkProp
vtkRenderWindowInteractor * Interactor
manage contention for cursors and other resources
vtkCallbackCommand * EventCallbackCommand