VTK  9.0.20200813
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 
95  virtual void SetInteractor(vtkRenderWindowInteractor* iren);
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);
158  virtual void SetDefaultRenderer(vtkRenderer*);
160 
162 
173  vtkGetObjectMacro(CurrentRenderer, vtkRenderer);
174  virtual void SetCurrentRenderer(vtkRenderer*);
176 
180  virtual void OnChar();
181 
183 
187  static void ComputeDisplayToWorld(
188  vtkRenderer* ren, double x, double y, double z, double worldPt[4]);
189  static void ComputeWorldToDisplay(
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:
210  ~vtkInteractorObserver() override;
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 
260  void UnRegisterPickers();
261 
266  vtkPickingManager* GetPickingManager();
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
vtkCommand
superclass for callback/observer methods
Definition: vtkCommand.h:385
vtkInteractorObserver::KeyPressActivationValue
char KeyPressActivationValue
Definition: vtkInteractorObserver.h:276
vtkInteractorObserver::EventCallbackCommand
vtkCallbackCommand * EventCallbackCommand
Definition: vtkInteractorObserver.h:240
vtkInteractorObserver::DeleteObserverTag
unsigned long DeleteObserverTag
Definition: vtkInteractorObserver.h:286
vtkInteractorObserver::EnabledOn
void EnabledOn()
Definition: vtkInteractorObserver.h:81
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkInteractorObserver::PickingManaged
bool PickingManaged
Definition: vtkInteractorObserver.h:248
vtkInteractorObserver::CharObserverTag
unsigned long CharObserverTag
Definition: vtkInteractorObserver.h:285
vtkAssemblyPath
a list of nodes that form an assembly path
Definition: vtkAssemblyPath.h:41
vtkInteractorObserver
an abstract superclass for classes observing events invoked by vtkRenderWindowInteractor
Definition: vtkInteractorObserver.h:65
vtkInteractorObserver::Off
void Off()
Definition: vtkInteractorObserver.h:84
vtkInteractorObserver::On
void On()
Definition: vtkInteractorObserver.h:83
vtkInteractorObserver::SetEnabled
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
Definition: vtkInteractorObserver.h:79
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkInteractorObserver::GetEnabled
int GetEnabled()
Definition: vtkInteractorObserver.h:80
vtkInteractorObserver::CurrentRenderer
vtkRenderer * CurrentRenderer
Definition: vtkInteractorObserver.h:282
vtkObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkRenderWindowInteractor
platform-independent render window interaction including picking and frame rate control.
Definition: vtkRenderWindowInteractor.h:82
vtkInteractorObserver::Priority
float Priority
Definition: vtkInteractorObserver.h:244
vtkAbstractPropPicker
abstract API for pickers that can pick an instance of vtkProp
Definition: vtkAbstractPropPicker.h:79
vtkObject.h
vtkInteractorObserver::DefaultRenderer
vtkRenderer * DefaultRenderer
Definition: vtkInteractorObserver.h:283
vtkInteractorObserver::KeyPressActivation
vtkTypeBool KeyPressActivation
Definition: vtkInteractorObserver.h:275
vtkInteractorObserver::Interactor
vtkRenderWindowInteractor * Interactor
Definition: vtkInteractorObserver.h:279
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:67
vtkCallbackCommand
supports function callbacks
Definition: vtkCallbackCommand.h:44
vtkInteractorObserver::KeyPressCallbackCommand
vtkCallbackCommand * KeyPressCallbackCommand
Definition: vtkInteractorObserver.h:241
vtkObserverMediator
manage contention for cursors and other resources
Definition: vtkObserverMediator.h:41
vtkInteractorObserver::ObserverMediator
vtkObserverMediator * ObserverMediator
Definition: vtkInteractorObserver.h:289
vtkInteractorObserver::Enabled
int Enabled
Definition: vtkInteractorObserver.h:237
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkPickingManager
Definition: vtkPickingManager.h:82
vtkInteractorObserver::EnabledOff
void EnabledOff()
Definition: vtkInteractorObserver.h:82