VTK  9.3.20240423
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
72#ifndef vtkAbstractWidget_h
73#define vtkAbstractWidget_h
74
75#include "vtkInteractionWidgetsModule.h" // For export macro
77#include "vtkWrappingHints.h" // For VTK_MARSHALMANUAL
78
79VTK_ABI_NAMESPACE_BEGIN
83
84class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALMANUAL vtkAbstractWidget
86{
87public:
89
93 void PrintSelf(ostream& os, vtkIndent indent) override;
95
103 void SetEnabled(int) override;
104
106
112 vtkSetClampMacro(ProcessEvents, vtkTypeBool, 0, 1);
114 {
115 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning ProcessEvents of "
116 << this->ProcessEvents);
117 return this->ProcessEvents;
118 }
119 vtkBooleanMacro(ProcessEvents, vtkTypeBool);
121
126 vtkWidgetEventTranslator* GetEventTranslator() { return this->EventTranslator; }
127
134 virtual void CreateDefaultRepresentation() = 0;
135
142 void Render();
143
150 void SetParent(vtkAbstractWidget* parent) { this->Parent = parent; }
151 vtkGetObjectMacro(Parent, vtkAbstractWidget);
152
154
161 {
162 this->CreateDefaultRepresentation();
163 return this->WidgetRep;
164 }
166
168
175 vtkSetMacro(ManagesCursor, vtkTypeBool);
176 vtkGetMacro(ManagesCursor, vtkTypeBool);
177 vtkBooleanMacro(ManagesCursor, vtkTypeBool);
179
185 void SetPriority(float) override;
186
187protected:
190
191 // Handles the events; centralized here for all widgets.
193 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
194
195 // The representation for the widget. This is typically called by the
196 // SetRepresentation() methods particular to each widget (i.e. subclasses
197 // of this class). This method does the actual work; the SetRepresentation()
198 // methods constrain the type that can be set.
201
202 // helper methods for cursor management
204 virtual void SetCursor(int vtkNotUsed(state)) {}
205
206 // For translating and invoking events
209
210 // The parent, if any, for this widget
212
213 // Call data which can be retrieved by the widget. This data is set
214 // by ProcessEvents() if call data is provided during a callback
215 // sequence.
216 void* CallData;
217
218 // Flag indicating if the widget should handle interaction events.
219 // On by default.
221
222 // Used by subclasses to ensure different events comes from the same
223 // hardware device. Such as starting a move with the right controller
224 // should then only respond to move events from the right controller.
226
227private:
228 vtkAbstractWidget(const vtkAbstractWidget&) = delete;
229 void operator=(const vtkAbstractWidget&) = delete;
230};
231
232VTK_ABI_NAMESPACE_END
233#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:108
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:162
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
#define VTK_MARSHALMANUAL