VTK  9.3.0
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
49#ifndef vtkAbstractWidget_h
50#define vtkAbstractWidget_h
51
52#include "vtkInteractionWidgetsModule.h" // For export macro
54
55VTK_ABI_NAMESPACE_BEGIN
59
60class VTKINTERACTIONWIDGETS_EXPORT vtkAbstractWidget : public vtkInteractorObserver
61{
62public:
64
68 void PrintSelf(ostream& os, vtkIndent indent) override;
70
78 void SetEnabled(int) override;
79
81
87 vtkSetClampMacro(ProcessEvents, vtkTypeBool, 0, 1);
89 {
90 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning ProcessEvents of "
91 << this->ProcessEvents);
92 return this->ProcessEvents;
93 }
94 vtkBooleanMacro(ProcessEvents, vtkTypeBool);
96
101 vtkWidgetEventTranslator* GetEventTranslator() { return this->EventTranslator; }
102
109 virtual void CreateDefaultRepresentation() = 0;
110
117 void Render();
118
125 void SetParent(vtkAbstractWidget* parent) { this->Parent = parent; }
126 vtkGetObjectMacro(Parent, vtkAbstractWidget);
127
129
136 {
137 this->CreateDefaultRepresentation();
138 return this->WidgetRep;
139 }
141
143
150 vtkSetMacro(ManagesCursor, vtkTypeBool);
151 vtkGetMacro(ManagesCursor, vtkTypeBool);
152 vtkBooleanMacro(ManagesCursor, vtkTypeBool);
154
160 void SetPriority(float) override;
161
162protected:
165
166 // Handles the events; centralized here for all widgets.
168 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
169
170 // The representation for the widget. This is typically called by the
171 // SetRepresentation() methods particular to each widget (i.e. subclasses
172 // of this class). This method does the actual work; the SetRepresentation()
173 // methods constrain the type that can be set.
176
177 // helper methods for cursor management
179 virtual void SetCursor(int vtkNotUsed(state)) {}
180
181 // For translating and invoking events
184
185 // The parent, if any, for this widget
187
188 // Call data which can be retrieved by the widget. This data is set
189 // by ProcessEvents() if call data is provided during a callback
190 // sequence.
191 void* CallData;
192
193 // Flag indicating if the widget should handle interaction events.
194 // On by default.
196
197 // Used by subclasses to ensure different events comes from the same
198 // hardware device. Such as starting a move with the right controller
199 // should then only respond to move events from the right controller.
201
202private:
203 vtkAbstractWidget(const vtkAbstractWidget&) = delete;
204 void operator=(const vtkAbstractWidget&) = delete;
205};
206
207VTK_ABI_NAMESPACE_END
208#endif
define the API for widget / widget representation
void SetParent(vtkAbstractWidget *parent)
Specifying a parent to this widget is used when creating composite widgets.
vtkWidgetRepresentation * GetRepresentation()
Return an instance of vtkWidgetRepresentation used to represent this widget in the scene.
void SetPriority(float) override
Override the superclass method.
virtual vtkTypeBool GetProcessEvents()
Methods to change whether the widget responds to interaction.
vtkWidgetEventTranslator * EventTranslator
void SetWidgetRepresentation(vtkWidgetRepresentation *r)
vtkWidgetRepresentation * WidgetRep
~vtkAbstractWidget() override
virtual void CreateDefaultRepresentation()=0
Create the default widget representation if one is not set.
void Render()
This method is called by subclasses when a render method is to be invoked on the vtkRenderWindowInter...
vtkWidgetCallbackMapper * CallbackMapper
vtkWidgetEventTranslator * GetEventTranslator()
Get the event translator.
static void ProcessEventsHandler(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
vtkAbstractWidget * Parent
virtual void SetCursor(int vtkNotUsed(state))
void PrintSelf(ostream &os, vtkIndent indent) override
Standard macros implementing standard VTK methods.
void SetEnabled(int) override
Methods for activating this widget.
a simple class to control print indentation
Definition vtkIndent.h:38
an abstract superclass for classes observing events invoked by vtkRenderWindowInteractor
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Handles the char widget activation event.
const char * GetClassName() const
Return the class name as a string.
abstract base class for most VTK objects
Definition vtkObject.h:58
map widget events into callbacks
map VTK events into widget events
abstract class defines interface between the widget and widget representation classes
int vtkTypeBool
Definition vtkABI.h:64