VTK: Interaction/Widgets/vtkAbstractWidget.h Source File

| VTK 9.3.1

vtkAbstractWidget.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
52 #ifndef vtkAbstractWidget_h
53 #define vtkAbstractWidget_h
54
55 #include "vtkInteractionWidgetsModule.h" // For export macro
56 #include "vtkInteractorObserver.h"
57
58 VTK_ABI_NAMESPACE_BEGIN
59 class vtkWidgetEventTranslator;
60 class vtkWidgetCallbackMapper;
61 class vtkWidgetRepresentation;
62
63 class VTKINTERACTIONWIDGETS_EXPORT vtkAbstractWidget : public vtkInteractorObserver
64 {
65 public:
67
70 vtkTypeMacro(vtkAbstractWidget, vtkInteractorObserver);
71 void PrintSelf(ostream& os, vtkIndent indent) override;
73
81 void SetEnabled(int) override;
82
84
90 vtkSetClampMacro(ProcessEvents, vtkTypeBool, 0, 1);
91 virtual vtkTypeBool GetProcessEvents()
92 {
93 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning ProcessEvents of "
94 << this->ProcessEvents);
95 return this->ProcessEvents;
96 }
97 vtkBooleanMacro(ProcessEvents, vtkTypeBool);
99
104 vtkWidgetEventTranslator* GetEventTranslator() { return this->EventTranslator; }
105
112 virtual void CreateDefaultRepresentation() = 0;
113
120 void Render();
121
128 void SetParent(vtkAbstractWidget* parent) { this->Parent = parent; }
129 vtkGetObjectMacro(Parent, vtkAbstractWidget);
130
132
138 vtkWidgetRepresentation* GetRepresentation()
139 {
140 this->CreateDefaultRepresentation();
141 return this->WidgetRep;
142 }
144
146
153 vtkSetMacro(ManagesCursor, vtkTypeBool);
154 vtkGetMacro(ManagesCursor, vtkTypeBool);
155 vtkBooleanMacro(ManagesCursor, vtkTypeBool);
157
163 void SetPriority(float) override;
164
165 protected:
166 vtkAbstractWidget();
167 ~vtkAbstractWidget() override;
168
169 // Handles the events; centralized here for all widgets.
170 static void ProcessEventsHandler(
171 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
172
173 // The representation for the widget. This is typically called by the
174 // SetRepresentation() methods particular to each widget (i.e. subclasses
175 // of this class). This method does the actual work; the SetRepresentation()
176 // methods constrain the type that can be set.
177 void SetWidgetRepresentation(vtkWidgetRepresentation* r);
178 vtkWidgetRepresentation* WidgetRep;
179
180 // helper methods for cursor management
181 vtkTypeBool ManagesCursor;
182 virtual void SetCursor(int vtkNotUsed(state)) {}
183
184 // For translating and invoking events
185 vtkWidgetEventTranslator* EventTranslator;
186 vtkWidgetCallbackMapper* CallbackMapper;
187
188 // The parent, if any, for this widget
189 vtkAbstractWidget* Parent;
190
191 // Call data which can be retrieved by the widget. This data is set
192 // by ProcessEvents() if call data is provided during a callback
193 // sequence.
194 void* CallData;
195
196 // Flag indicating if the widget should handle interaction events.
197 // On by default.
198 vtkTypeBool ProcessEvents;
199
200 // Used by subclasses to ensure different events comes from the same
201 // hardware device. Such as starting a move with the right controller
202 // should then only respond to move events from the right controller.
203 int LastDevice;
204
205 private:
206 vtkAbstractWidget(const vtkAbstractWidget&) = delete;
207 void operator=(const vtkAbstractWidget&) = delete;
208 };
209
210 VTK_ABI_NAMESPACE_END
211 #endif
vtkAbstractWidget
define the API for widget / widget representation
Definition: vtkAbstractWidget.h:64
vtkAbstractWidget::SetParent
void SetParent(vtkAbstractWidget *parent)
Specifying a parent to this widget is used when creating composite widgets.
Definition: vtkAbstractWidget.h:128
vtkAbstractWidget::vtkAbstractWidget
vtkAbstractWidget()
vtkAbstractWidget::SetPriority
void SetPriority(float) override
Override the superclass method.
vtkAbstractWidget::GetProcessEvents
virtual vtkTypeBool GetProcessEvents()
Methods to change whether the widget responds to interaction.
Definition: vtkAbstractWidget.h:91
vtkAbstractWidget::EventTranslator
vtkWidgetEventTranslator * EventTranslator
Definition: vtkAbstractWidget.h:185
vtkAbstractWidget::GetRepresentation
vtkWidgetRepresentation * GetRepresentation()
Return an instance of vtkWidgetRepresentation used to represent this widget in the scene.
Definition: vtkAbstractWidget.h:138
vtkAbstractWidget::SetWidgetRepresentation
void SetWidgetRepresentation(vtkWidgetRepresentation *r)
vtkAbstractWidget::ProcessEvents
vtkTypeBool ProcessEvents
Definition: vtkAbstractWidget.h:198
vtkAbstractWidget::WidgetRep
vtkWidgetRepresentation * WidgetRep
Definition: vtkAbstractWidget.h:178
vtkAbstractWidget::~vtkAbstractWidget
~vtkAbstractWidget() override
vtkAbstractWidget::CallData
void * CallData
Definition: vtkAbstractWidget.h:194
vtkAbstractWidget::CreateDefaultRepresentation
virtual void CreateDefaultRepresentation()=0
Create the default widget representation if one is not set.
vtkAbstractWidget::Render
void Render()
This method is called by subclasses when a render method is to be invoked on the vtkRenderWindowInter...
vtkAbstractWidget::CallbackMapper
vtkWidgetCallbackMapper * CallbackMapper
Definition: vtkAbstractWidget.h:186
vtkAbstractWidget::ManagesCursor
vtkTypeBool ManagesCursor
Definition: vtkAbstractWidget.h:181
vtkAbstractWidget::ProcessEventsHandler
static void ProcessEventsHandler(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
vtkAbstractWidget::Parent
vtkAbstractWidget * Parent
Definition: vtkAbstractWidget.h:189
vtkAbstractWidget::SetCursor
virtual void SetCursor(int vtkNotUsed(state))
Definition: vtkAbstractWidget.h:182
vtkAbstractWidget::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Standard macros implementing standard VTK methods.
vtkAbstractWidget::SetEnabled
void SetEnabled(int) override
Methods for activating this widget.
vtkAbstractWidget::GetEventTranslator
vtkWidgetEventTranslator * GetEventTranslator()
Get the event translator.
Definition: vtkAbstractWidget.h:104
vtkAbstractWidget::LastDevice
int LastDevice
Definition: vtkAbstractWidget.h:203
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkInteractorObserver
an abstract superclass for classes observing events invoked by vtkRenderWindowInteractor
Definition: vtkInteractorObserver.h:64
vtkInteractorObserver::ProcessEvents
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Handles the char widget activation event.
vtkObjectBase::GetClassName
const char * GetClassName() const
Return the class name as a string.
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:61
vtkWidgetCallbackMapper
map widget events into callbacks
Definition: vtkWidgetCallbackMapper.h:40
vtkWidgetEventTranslator
map VTK events into widget events
Definition: vtkWidgetEventTranslator.h:41
vtkWidgetRepresentation
abstract class defines interface between the widget and widget representation classes
Definition: vtkWidgetRepresentation.h:65
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:64
vtkInteractorObserver.h