VTK  9.1.0
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 =========================================================================*/
51 #ifndef vtkInteractorObserver_h
52 #define vtkInteractorObserver_h
53 
54 #include "vtkObject.h"
55 #include "vtkRenderingCoreModule.h" // For export macro
56 
58 class vtkAssemblyPath;
60 class vtkRenderer;
61 class vtkCallbackCommand;
63 class vtkPickingManager;
64 
65 class VTKRENDERINGCORE_EXPORT vtkInteractorObserver : public vtkObject
66 {
67 public:
69  void PrintSelf(ostream& os, vtkIndent indent) override;
70 
79  virtual void SetEnabled(int) {}
80  int GetEnabled() { return this->Enabled; }
81  void EnabledOn() { this->SetEnabled(1); }
82  void EnabledOff() { this->SetEnabled(0); }
83  void On() { this->SetEnabled(1); }
84  void Off() { this->SetEnabled(0); }
85 
87 
96  vtkGetObjectMacro(Interactor, vtkRenderWindowInteractor);
98 
100 
110  vtkSetClampMacro(Priority, float, 0.0f, 1.0f);
111  vtkGetMacro(Priority, float);
113 
115 
119  vtkBooleanMacro(PickingManaged, bool);
120  virtual void SetPickingManaged(bool managed);
121  vtkGetMacro(PickingManaged, bool);
123 
125 
131  vtkSetMacro(KeyPressActivation, vtkTypeBool);
132  vtkGetMacro(KeyPressActivation, vtkTypeBool);
133  vtkBooleanMacro(KeyPressActivation, vtkTypeBool);
135 
137 
144  vtkSetMacro(KeyPressActivationValue, char);
145  vtkGetMacro(KeyPressActivationValue, char);
147 
149 
157  vtkGetObjectMacro(DefaultRenderer, vtkRenderer);
160 
162 
173  vtkGetObjectMacro(CurrentRenderer, vtkRenderer);
176 
180  virtual void OnChar();
181 
183 
188  vtkRenderer* ren, double x, double y, double z, double worldPt[4]);
190  vtkRenderer* ren, double x, double y, double z, double displayPt[3]);
192 
194 
204  void GrabFocus(vtkCommand* mouseEvents, vtkCommand* keypressEvents = nullptr);
205  void ReleaseFocus();
207 
208 protected:
211 
213 
218  virtual void StartInteraction();
219  virtual void EndInteraction();
221 
225  static void ProcessEvents(
226  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
227 
229 
232  void ComputeDisplayToWorld(double x, double y, double z, double worldPt[4]);
233  void ComputeWorldToDisplay(double x, double y, double z, double displayPt[3]);
235 
236  // The state of the widget, whether on or off (observing events or not)
237  int Enabled;
238 
239  // Used to process events
240  vtkCallbackCommand* EventCallbackCommand; // subclasses use one
241  vtkCallbackCommand* KeyPressCallbackCommand; // listens to key activation
242 
243  // Priority at which events are processed
244  float Priority;
245 
246  // This variable controls whether the picking is managed by the Picking
247  // Manager process or not. True by default.
249 
255  virtual void RegisterPickers();
256 
261 
267 
272  vtkAssemblyPath* GetAssemblyPath(double X, double Y, double Z, vtkAbstractPropPicker* picker);
273 
274  // Keypress activation controls
277 
278  // Used to associate observers with the interactor
280 
281  // Internal ivars for processing events
284 
285  unsigned long CharObserverTag;
286  unsigned long DeleteObserverTag;
287 
288  // The mediator used to request resources from the interactor.
290  int RequestCursorShape(int requestedShape);
291 
292 private:
294  void operator=(const vtkInteractorObserver&) = delete;
295 };
296 
297 #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:394
a simple class to control print indentation
Definition: vtkIndent.h:34
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:63
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:73
int vtkTypeBool
Definition: vtkABI.h:69