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 "vtkRenderingCoreModule.h" // For export macro
49 #include "vtkObject.h"
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);
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 
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  vtkSetMacro(PickingManaged, bool);
115  vtkGetMacro(PickingManaged, bool);
117 
119 
125  vtkSetMacro(KeyPressActivation,int);
126  vtkGetMacro(KeyPressActivation,int);
127  vtkBooleanMacro(KeyPressActivation,int);
129 
131 
138  vtkSetMacro(KeyPressActivationValue,char);
139  vtkGetMacro(KeyPressActivationValue,char);
141 
143 
151  vtkGetObjectMacro(DefaultRenderer,vtkRenderer);
154 
156 
167  vtkGetObjectMacro(CurrentRenderer,vtkRenderer);
170 
174  virtual void OnChar();
175 
177 
181  static void ComputeDisplayToWorld(vtkRenderer *ren, double x, double y,
182  double z, double worldPt[4]);
183  static void ComputeWorldToDisplay(vtkRenderer *ren, double x, double y,
184  double z, double displayPt[3]);
186 
188 
198  void GrabFocus(vtkCommand *mouseEvents, vtkCommand *keypressEvents=NULL);
199  void ReleaseFocus();
201 
202 protected:
205 
207 
212  virtual void StartInteraction();
213  virtual void EndInteraction();
215 
219  static void ProcessEvents(vtkObject* object,
220  unsigned long event,
221  void* clientdata,
222  void* calldata);
223 
225 
228  void ComputeDisplayToWorld(double x, double y, double z,
229  double worldPt[4]);
230  void ComputeWorldToDisplay(double x, double y, double z,
231  double displayPt[3]);
233 
234  // The state of the widget, whether on or off (observing events or not)
235  int Enabled;
236 
237  // Used to process events
239  vtkCallbackCommand* KeyPressCallbackCommand; //listens to key activation
240 
241  // Priority at which events are processed
242  float Priority;
243 
244  // This variable controls whether the picking is managed by the Picking
245  // Manager process or not. True by default.
247 
253  virtual void RegisterPickers();
254 
259 
264  virtual void PickersModified();
265 
271 
276  vtkAssemblyPath* GetAssemblyPath(double X, double Y, double Z,
277  vtkAbstractPropPicker* picker);
278 
279  // Keypress activation controls
282 
283  // Used to associate observers with the interactor
285 
286  // Internal ivars for processing events
289 
290  unsigned long CharObserverTag;
291  unsigned long DeleteObserverTag;
292 
293  // The mediator used to request resources from the interactor.
295  int RequestCursorShape(int requestedShape);
296 
297 private:
298  vtkInteractorObserver(const vtkInteractorObserver&) VTK_DELETE_FUNCTION;
299  void operator=(const vtkInteractorObserver&) VTK_DELETE_FUNCTION;
300 
301 };
302 
303 #endif
vtkCommand
superclass for callback/observer methods
Definition: vtkCommand.h:342
vtkInteractorObserver::KeyPressActivationValue
char KeyPressActivationValue
Definition: vtkInteractorObserver.h:281
vtkInteractorObserver::EventCallbackCommand
vtkCallbackCommand * EventCallbackCommand
Definition: vtkInteractorObserver.h:238
vtkInteractorObserver::ComputeDisplayToWorld
void ComputeDisplayToWorld(double x, double y, double z, double worldPt[4])
Helper method for subclasses.
vtkInteractorObserver::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkInteractorObserver::DeleteObserverTag
unsigned long DeleteObserverTag
Definition: vtkInteractorObserver.h:291
vtkInteractorObserver::EnabledOn
void EnabledOn()
Definition: vtkInteractorObserver.h:75
vtkInteractorObserver::OnChar
virtual void OnChar()
Sets up the keypress-i event.
vtkInteractorObserver::SetDefaultRenderer
virtual void SetDefaultRenderer(vtkRenderer *)
vtkInteractorObserver::ReleaseFocus
void ReleaseFocus()
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:60
vtkInteractorObserver::PickingManaged
bool PickingManaged
Definition: vtkInteractorObserver.h:246
vtkInteractorObserver::CharObserverTag
unsigned long CharObserverTag
Definition: vtkInteractorObserver.h:290
vtkAssemblyPath
a list of nodes that form an assembly path
Definition: vtkAssemblyPath.h:42
vtkInteractorObserver
an abstract superclass for classes observing events invoked by vtkRenderWindowInteractor
Definition: vtkInteractorObserver.h:60
vtkInteractorObserver::~vtkInteractorObserver
~vtkInteractorObserver()
vtkInteractorObserver::GrabFocus
void GrabFocus(vtkCommand *mouseEvents, vtkCommand *keypressEvents=NULL)
These methods enable an interactor observer to exclusively grab all events invoked by its associated ...
vtkInteractorObserver::ProcessEvents
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Handles the char widget activation event.
vtkInteractorObserver::KeyPressActivation
int KeyPressActivation
Definition: vtkInteractorObserver.h:280
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:40
vtkInteractorObserver::ComputeDisplayToWorld
static void ComputeDisplayToWorld(vtkRenderer *ren, double x, double y, double z, double worldPt[4])
Convenience methods for outside classes.
vtkInteractorObserver::UnRegisterPickers
void UnRegisterPickers()
Unregister internal pickers from the Picking Manager.
vtkInteractorObserver::GetAssemblyPath
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...
vtkInteractorObserver::GetEnabled
int GetEnabled()
Definition: vtkInteractorObserver.h:74
vtkInteractorObserver::CurrentRenderer
vtkRenderer * CurrentRenderer
Definition: vtkInteractorObserver.h:287
vtkInteractorObserver::GetPickingManager
vtkPickingManager * GetPickingManager()
Return the picking manager associated on the context on which the observer currently belong.
vtkRenderWindowInteractor
platform-independent render window interaction including picking and frame rate control.
Definition: vtkRenderWindowInteractor.h:79
vtkInteractorObserver::RequestCursorShape
int RequestCursorShape(int requestedShape)
vtkInteractorObserver::Priority
float Priority
Definition: vtkInteractorObserver.h:242
vtkAbstractPropPicker
abstract API for pickers that can pick an instance of vtkProp
Definition: vtkAbstractPropPicker.h:80
vtkObject.h
vtkInteractorObserver::DefaultRenderer
vtkRenderer * DefaultRenderer
Definition: vtkInteractorObserver.h:288
vtkBooleanMacro
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkInteractorObserver::RegisterPickers
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkInteractorObserver::ComputeWorldToDisplay
void ComputeWorldToDisplay(double x, double y, double z, double displayPt[3])
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkInteractorObserver::SetInteractor
virtual void SetInteractor(vtkRenderWindowInteractor *iren)
This method is used to associate the widget with the render window interactor.
vtkInteractorObserver::PickersModified
virtual void PickersModified()
Update the pickers registered in the Picking Manager when pickers are modified.
vtkInteractorObserver::Interactor
vtkRenderWindowInteractor * Interactor
Definition: vtkInteractorObserver.h:284
vtkInteractorObserver::ComputeWorldToDisplay
static void ComputeWorldToDisplay(vtkRenderer *ren, double x, double y, double z, double displayPt[3])
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:64
vtkCallbackCommand
supports function callbacks
Definition: vtkCallbackCommand.h:51
vtkInteractorObserver::KeyPressCallbackCommand
vtkCallbackCommand * KeyPressCallbackCommand
Definition: vtkInteractorObserver.h:239
vtkObserverMediator
manage contention for cursors and other resources
Definition: vtkObserverMediator.h:43
vtkInteractorObserver::ObserverMediator
vtkObserverMediator * ObserverMediator
Definition: vtkInteractorObserver.h:294
vtkInteractorObserver::StartInteraction
virtual void StartInteraction()
Utility routines used to start and end interaction.
vtkInteractorObserver::vtkInteractorObserver
vtkInteractorObserver()
vtkInteractorObserver::Enabled
int Enabled
Definition: vtkInteractorObserver.h:235
vtkInteractorObserver::SetCurrentRenderer
virtual void SetCurrentRenderer(vtkRenderer *)
vtkPickingManager
Class defines API to manage the picking process.
Definition: vtkPickingManager.h:86
vtkInteractorObserver::EnabledOff
void EnabledOff()
Definition: vtkInteractorObserver.h:76
vtkInteractorObserver::EndInteraction
virtual void EndInteraction()