VTK  9.3.20240425
vtkInteractorObserver.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
78#ifndef vtkInteractorObserver_h
79#define vtkInteractorObserver_h
80
81#include "vtkObject.h"
82#include "vtkRenderingCoreModule.h" // For export macro
83#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
84
85VTK_ABI_NAMESPACE_BEGIN
87class vtkAssemblyPath;
89class vtkRenderer;
93
94class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkInteractorObserver : public vtkObject
95{
96public:
98 void PrintSelf(ostream& os, vtkIndent indent) override;
99
109 "is overridden by vtkInteractorStyle::Enabled in the correct order after Interactor")
110 virtual void SetEnabled(int) {}
112 "is overridden by vtkInteractorStyle::Enabled in the correct order after Interactor")
113 int GetEnabled() { return this->Enabled; }
114 void EnabledOn() { this->SetEnabled(1); }
115 void EnabledOff() { this->SetEnabled(0); }
116 void On() { this->SetEnabled(1); }
117 void Off() { this->SetEnabled(0); }
118
120
129 "is overridden by vtkInteractorStyle::Interactor in the correct order before Enabled")
130 virtual void SetInteractor(vtkRenderWindowInteractor* iren);
132 "is overridden by vtkInteractorStyle::Interactor in the correct order before Enabled")
133 vtkGetObjectMacro(Interactor, vtkRenderWindowInteractor);
135
137
147 vtkSetClampMacro(Priority, float, 0.0f, 1.0f);
148 vtkGetMacro(Priority, float);
150
152
156 vtkBooleanMacro(PickingManaged, bool);
157 virtual void SetPickingManaged(bool managed);
158 vtkGetMacro(PickingManaged, bool);
160
162
168 vtkSetMacro(KeyPressActivation, vtkTypeBool);
169 vtkGetMacro(KeyPressActivation, vtkTypeBool);
170 vtkBooleanMacro(KeyPressActivation, vtkTypeBool);
172
174
181 vtkSetMacro(KeyPressActivationValue, char);
182 vtkGetMacro(KeyPressActivationValue, char);
184
186
194 vtkGetObjectMacro(DefaultRenderer, vtkRenderer);
195 virtual void SetDefaultRenderer(vtkRenderer*);
197
199
210 vtkGetObjectMacro(CurrentRenderer, vtkRenderer);
211 virtual void SetCurrentRenderer(vtkRenderer*);
213
217 virtual void OnChar();
218
220
224 static void ComputeDisplayToWorld(
225 vtkRenderer* ren, double x, double y, double z, double worldPt[4]);
226 static void ComputeWorldToDisplay(
227 vtkRenderer* ren, double x, double y, double z, double displayPt[3]);
229
231
241 void GrabFocus(vtkCommand* mouseEvents, vtkCommand* keypressEvents = nullptr);
242 void ReleaseFocus();
244
245protected:
248
250
255 virtual void StartInteraction();
256 virtual void EndInteraction();
258
262 static void ProcessEvents(
263 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
264
266
269 void ComputeDisplayToWorld(double x, double y, double z, double worldPt[4]);
270 void ComputeWorldToDisplay(double x, double y, double z, double displayPt[3]);
272
273 // The state of the widget, whether on or off (observing events or not)
274 int Enabled;
275
276 // Used to process events
277 vtkCallbackCommand* EventCallbackCommand; // subclasses use one
278 vtkCallbackCommand* KeyPressCallbackCommand; // listens to key activation
279
280 // Priority at which events are processed
281 float Priority;
282
283 // This variable controls whether the picking is managed by the Picking
284 // Manager process or not. True by default.
285 bool PickingManaged;
286
292 virtual void RegisterPickers();
293
297 void UnRegisterPickers();
298
303 vtkPickingManager* GetPickingManager();
304
309 vtkAssemblyPath* GetAssemblyPath(double X, double Y, double Z, vtkAbstractPropPicker* picker);
310
311 // Keypress activation controls
312 vtkTypeBool KeyPressActivation;
313 char KeyPressActivationValue;
314
315 // Used to associate observers with the interactor
317
318 // Internal ivars for processing events
319 vtkRenderer* CurrentRenderer;
320 vtkRenderer* DefaultRenderer;
321
322 unsigned long CharObserverTag;
323 unsigned long DeleteObserverTag;
324
325 // The mediator used to request resources from the interactor.
326 vtkObserverMediator* ObserverMediator;
327 int RequestCursorShape(int requestedShape);
328
329private:
331 void operator=(const vtkInteractorObserver&) = delete;
332};
333
334VTK_ABI_NAMESPACE_END
335#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:384
a simple class to control print indentation
Definition vtkIndent.h:108
an abstract superclass for classes observing events invoked by vtkRenderWindowInteractor
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
provide event-driven interface to the rendering window (defines trackball mode)
abstract base class for most VTK objects
Definition vtkObject.h:162
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
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_MARSHALAUTO
#define VTK_MARSHALEXCLUDE(reason)