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 =========================================================================*/
70 #ifndef vtkInteractorObserver_h
71 #define vtkInteractorObserver_h
72 
73 #include "vtkObject.h"
74 #include "vtkRenderingCoreModule.h" // For export macro
75 
77 class vtkAssemblyPath;
79 class vtkRenderer;
80 class vtkCallbackCommand;
82 class vtkPickingManager;
83 
84 class VTKRENDERINGCORE_EXPORT vtkInteractorObserver : public vtkObject
85 {
86 public:
88  void PrintSelf(ostream& os, vtkIndent indent) override;
89 
98  virtual void SetEnabled(int) {}
99  int GetEnabled() { return this->Enabled; }
100  void EnabledOn() { this->SetEnabled(1); }
101  void EnabledOff() { this->SetEnabled(0); }
102  void On() { this->SetEnabled(1); }
103  void Off() { this->SetEnabled(0); }
104 
106 
115  vtkGetObjectMacro(Interactor, vtkRenderWindowInteractor);
117 
119 
129  vtkSetClampMacro(Priority, float, 0.0f, 1.0f);
130  vtkGetMacro(Priority, float);
132 
134 
138  vtkBooleanMacro(PickingManaged, bool);
139  virtual void SetPickingManaged(bool managed);
140  vtkGetMacro(PickingManaged, bool);
142 
144 
150  vtkSetMacro(KeyPressActivation, vtkTypeBool);
151  vtkGetMacro(KeyPressActivation, vtkTypeBool);
152  vtkBooleanMacro(KeyPressActivation, vtkTypeBool);
154 
156 
163  vtkSetMacro(KeyPressActivationValue, char);
164  vtkGetMacro(KeyPressActivationValue, char);
166 
168 
176  vtkGetObjectMacro(DefaultRenderer, vtkRenderer);
179 
181 
192  vtkGetObjectMacro(CurrentRenderer, vtkRenderer);
195 
199  virtual void OnChar();
200 
202 
207  vtkRenderer* ren, double x, double y, double z, double worldPt[4]);
209  vtkRenderer* ren, double x, double y, double z, double displayPt[3]);
211 
213 
223  void GrabFocus(vtkCommand* mouseEvents, vtkCommand* keypressEvents = nullptr);
224  void ReleaseFocus();
226 
227 protected:
230 
232 
237  virtual void StartInteraction();
238  virtual void EndInteraction();
240 
244  static void ProcessEvents(
245  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
246 
248 
251  void ComputeDisplayToWorld(double x, double y, double z, double worldPt[4]);
252  void ComputeWorldToDisplay(double x, double y, double z, double displayPt[3]);
254 
255  // The state of the widget, whether on or off (observing events or not)
256  int Enabled;
257 
258  // Used to process events
259  vtkCallbackCommand* EventCallbackCommand; // subclasses use one
260  vtkCallbackCommand* KeyPressCallbackCommand; // listens to key activation
261 
262  // Priority at which events are processed
263  float Priority;
264 
265  // This variable controls whether the picking is managed by the Picking
266  // Manager process or not. True by default.
268 
274  virtual void RegisterPickers();
275 
280 
286 
291  vtkAssemblyPath* GetAssemblyPath(double X, double Y, double Z, vtkAbstractPropPicker* picker);
292 
293  // Keypress activation controls
296 
297  // Used to associate observers with the interactor
299 
300  // Internal ivars for processing events
303 
304  unsigned long CharObserverTag;
305  unsigned long DeleteObserverTag;
306 
307  // The mediator used to request resources from the interactor.
309  int RequestCursorShape(int requestedShape);
310 
311 private:
313  void operator=(const vtkInteractorObserver&) = delete;
314 };
315 
316 #endif
vtkCommand
superclass for callback/observer methods
Definition: vtkCommand.h:394
vtkInteractorObserver::KeyPressActivationValue
char KeyPressActivationValue
Definition: vtkInteractorObserver.h:295
vtkInteractorObserver::EventCallbackCommand
vtkCallbackCommand * EventCallbackCommand
Definition: vtkInteractorObserver.h:259
vtkInteractorObserver::ComputeDisplayToWorld
void ComputeDisplayToWorld(double x, double y, double z, double worldPt[4])
Helper method for subclasses.
vtkInteractorObserver::DeleteObserverTag
unsigned long DeleteObserverTag
Definition: vtkInteractorObserver.h:305
vtkInteractorObserver::GrabFocus
void GrabFocus(vtkCommand *mouseEvents, vtkCommand *keypressEvents=nullptr)
These methods enable an interactor observer to exclusively grab all events invoked by its associated ...
vtkInteractorObserver::EnabledOn
void EnabledOn()
Definition: vtkInteractorObserver.h:100
vtkInteractorObserver::OnChar
virtual void OnChar()
Sets up the keypress-i event.
vtkInteractorObserver::SetDefaultRenderer
virtual void SetDefaultRenderer(vtkRenderer *)
Set/Get the default renderer to use when activating the interactor observer.
vtkInteractorObserver::ReleaseFocus
void ReleaseFocus()
These methods enable an interactor observer to exclusively grab all events invoked by its associated ...
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:82
vtkInteractorObserver::PickingManaged
bool PickingManaged
Definition: vtkInteractorObserver.h:267
vtkInteractorObserver::CharObserverTag
unsigned long CharObserverTag
Definition: vtkInteractorObserver.h:304
vtkAssemblyPath
a list of nodes that form an assembly path
Definition: vtkAssemblyPath.h:91
vtkInteractorObserver
an abstract superclass for classes observing events invoked by vtkRenderWindowInteractor
Definition: vtkInteractorObserver.h:85
vtkInteractorObserver::SetPickingManaged
virtual void SetPickingManaged(bool managed)
Enable/Disable the use of a manager to process the picking.
vtkInteractorObserver::ProcessEvents
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Handles the char widget activation event.
vtkInteractorObserver::Off
void Off()
Definition: vtkInteractorObserver.h:103
vtkInteractorObserver::On
void On()
Definition: vtkInteractorObserver.h:102
vtkInteractorObserver::SetEnabled
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
Definition: vtkInteractorObserver.h:98
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
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:99
vtkInteractorObserver::CurrentRenderer
vtkRenderer * CurrentRenderer
Definition: vtkInteractorObserver.h:301
vtkInteractorObserver::GetPickingManager
vtkPickingManager * GetPickingManager()
Return the picking manager associated on the context on which the observer currently belong.
vtkInteractorObserver::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:192
vtkInteractorObserver::RequestCursorShape
int RequestCursorShape(int requestedShape)
vtkInteractorObserver::Priority
float Priority
Definition: vtkInteractorObserver.h:263
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:302
vtkInteractorObserver::RegisterPickers
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkInteractorObserver::KeyPressActivation
vtkTypeBool KeyPressActivation
Definition: vtkInteractorObserver.h:294
vtkInteractorObserver::ComputeWorldToDisplay
void ComputeWorldToDisplay(double x, double y, double z, double displayPt[3])
Helper method for subclasses.
vtkInteractorObserver::SetInteractor
virtual void SetInteractor(vtkRenderWindowInteractor *iren)
This method is used to associate the widget with the render window interactor.
vtkInteractorObserver::Interactor
vtkRenderWindowInteractor * Interactor
Definition: vtkInteractorObserver.h:298
vtkInteractorObserver::ComputeWorldToDisplay
static void ComputeWorldToDisplay(vtkRenderer *ren, double x, double y, double z, double displayPt[3])
Convenience methods for outside classes.
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:182
vtkCallbackCommand
supports function callbacks
Definition: vtkCallbackCommand.h:154
vtkInteractorObserver::KeyPressCallbackCommand
vtkCallbackCommand * KeyPressCallbackCommand
Definition: vtkInteractorObserver.h:260
vtkObserverMediator
manage contention for cursors and other resources
Definition: vtkObserverMediator.h:42
vtkInteractorObserver::ObserverMediator
vtkObserverMediator * ObserverMediator
Definition: vtkInteractorObserver.h:308
vtkInteractorObserver::StartInteraction
virtual void StartInteraction()
Utility routines used to start and end interaction.
vtkInteractorObserver::vtkInteractorObserver
vtkInteractorObserver()
vtkInteractorObserver::Enabled
int Enabled
Definition: vtkInteractorObserver.h:256
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkInteractorObserver::SetCurrentRenderer
virtual void SetCurrentRenderer(vtkRenderer *)
Set/Get the current renderer.
vtkPickingManager
Class defines API to manage the picking process.
Definition: vtkPickingManager.h:83
vtkInteractorObserver::EnabledOff
void EnabledOff()
Definition: vtkInteractorObserver.h:101
vtkInteractorObserver::~vtkInteractorObserver
~vtkInteractorObserver() override
vtkInteractorObserver::EndInteraction
virtual void EndInteraction()
Utility routines used to start and end interaction.