VTK
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 =========================================================================*/
45 #ifndef vtkInteractorObserver_h
46 #define vtkInteractorObserver_h
47 
48 #include "vtkObject.h"
49 #include "vtkRenderingCoreModule.h" // For export macro
50 
52 class vtkAssemblyPath;
54 class vtkRenderer;
55 class vtkCallbackCommand;
57 class vtkPickingManager;
58 
59 class VTKRENDERINGCORE_EXPORT vtkInteractorObserver : public vtkObject
60 {
61 public:
63  void PrintSelf(ostream& os, vtkIndent indent) override;
64 
73  virtual void SetEnabled(int) {}
74  int GetEnabled() { return this->Enabled; }
75  void EnabledOn() { this->SetEnabled(1); }
76  void EnabledOff() { this->SetEnabled(0); }
77  void On() { this->SetEnabled(1); }
78  void Off() { this->SetEnabled(0); }
79 
81 
89  virtual void SetInteractor(vtkRenderWindowInteractor* iren);
90  vtkGetObjectMacro(Interactor, vtkRenderWindowInteractor);
92 
94 
104  vtkSetClampMacro(Priority, float, 0.0f, 1.0f);
105  vtkGetMacro(Priority, float);
107 
109 
113  vtkBooleanMacro(PickingManaged, bool);
114  virtual void SetPickingManaged(bool managed);
115  vtkGetMacro(PickingManaged, bool);
117 
119 
125  vtkSetMacro(KeyPressActivation, vtkTypeBool);
126  vtkGetMacro(KeyPressActivation, vtkTypeBool);
127  vtkBooleanMacro(KeyPressActivation, vtkTypeBool);
129 
131 
138  vtkSetMacro(KeyPressActivationValue, char);
139  vtkGetMacro(KeyPressActivationValue, char);
141 
143 
151  vtkGetObjectMacro(DefaultRenderer, vtkRenderer);
152  virtual void SetDefaultRenderer(vtkRenderer*);
154 
156 
167  vtkGetObjectMacro(CurrentRenderer, vtkRenderer);
168  virtual void SetCurrentRenderer(vtkRenderer*);
170 
174  virtual void OnChar();
175 
177 
181  static void ComputeDisplayToWorld(
182  vtkRenderer* ren, double x, double y, double z, double worldPt[4]);
183  static void ComputeWorldToDisplay(
184  vtkRenderer* ren, double x, double y, double z, double displayPt[3]);
186 
188 
198  void GrabFocus(vtkCommand* mouseEvents, vtkCommand* keypressEvents = nullptr);
199  void ReleaseFocus();
201 
202 protected:
204  ~vtkInteractorObserver() override;
205 
207 
212  virtual void StartInteraction();
213  virtual void EndInteraction();
215 
219  static void ProcessEvents(
220  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
221 
223 
226  void ComputeDisplayToWorld(double x, double y, double z, double worldPt[4]);
227  void ComputeWorldToDisplay(double x, double y, double z, double displayPt[3]);
229 
230  // The state of the widget, whether on or off (observing events or not)
231  int Enabled;
232 
233  // Used to process events
234  vtkCallbackCommand* EventCallbackCommand; // subclasses use one
235  vtkCallbackCommand* KeyPressCallbackCommand; // listens to key activation
236 
237  // Priority at which events are processed
238  float Priority;
239 
240  // This variable controls whether the picking is managed by the Picking
241  // Manager process or not. True by default.
243 
249  virtual void RegisterPickers();
250 
254  void UnRegisterPickers();
255 
260  vtkPickingManager* GetPickingManager();
261 
266  vtkAssemblyPath* GetAssemblyPath(double X, double Y, double Z, vtkAbstractPropPicker* picker);
267 
268  // Keypress activation controls
271 
272  // Used to associate observers with the interactor
274 
275  // Internal ivars for processing events
278 
279  unsigned long CharObserverTag;
280  unsigned long DeleteObserverTag;
281 
282  // The mediator used to request resources from the interactor.
284  int RequestCursorShape(int requestedShape);
285 
286 private:
288  void operator=(const vtkInteractorObserver&) = delete;
289 };
290 
291 #endif
vtkCommand
superclass for callback/observer methods
Definition: vtkCommand.h:375
vtkInteractorObserver::KeyPressActivationValue
char KeyPressActivationValue
Definition: vtkInteractorObserver.h:270
vtkInteractorObserver::EventCallbackCommand
vtkCallbackCommand * EventCallbackCommand
Definition: vtkInteractorObserver.h:234
vtkInteractorObserver::DeleteObserverTag
unsigned long DeleteObserverTag
Definition: vtkInteractorObserver.h:280
vtkInteractorObserver::EnabledOn
void EnabledOn()
Definition: vtkInteractorObserver.h:75
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:53
vtkInteractorObserver::PickingManaged
bool PickingManaged
Definition: vtkInteractorObserver.h:242
vtkInteractorObserver::CharObserverTag
unsigned long CharObserverTag
Definition: vtkInteractorObserver.h:279
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:59
vtkInteractorObserver::Off
void Off()
Definition: vtkInteractorObserver.h:78
vtkInteractorObserver::On
void On()
Definition: vtkInteractorObserver.h:77
vtkInteractorObserver::SetEnabled
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
Definition: vtkInteractorObserver.h:73
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkInteractorObserver::GetEnabled
int GetEnabled()
Definition: vtkInteractorObserver.h:74
vtkInteractorObserver::CurrentRenderer
vtkRenderer * CurrentRenderer
Definition: vtkInteractorObserver.h:276
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:72
vtkInteractorObserver::Priority
float Priority
Definition: vtkInteractorObserver.h:238
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:277
vtkInteractorObserver::KeyPressActivation
vtkTypeBool KeyPressActivation
Definition: vtkInteractorObserver.h:269
vtkInteractorObserver::Interactor
vtkRenderWindowInteractor * Interactor
Definition: vtkInteractorObserver.h:273
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:58
vtkCallbackCommand
supports function callbacks
Definition: vtkCallbackCommand.h:44
vtkInteractorObserver::KeyPressCallbackCommand
vtkCallbackCommand * KeyPressCallbackCommand
Definition: vtkInteractorObserver.h:235
vtkObserverMediator
manage contention for cursors and other resources
Definition: vtkObserverMediator.h:41
vtkInteractorObserver::ObserverMediator
vtkObserverMediator * ObserverMediator
Definition: vtkInteractorObserver.h:283
vtkInteractorObserver::Enabled
int Enabled
Definition: vtkInteractorObserver.h:231
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkPickingManager
Definition: vtkPickingManager.h:82
vtkInteractorObserver::EnabledOff
void EnabledOff()
Definition: vtkInteractorObserver.h:76