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
40#ifndef vtkAbstractWidget_h
41#define vtkAbstractWidget_h
42
43#include "vtkInteractionWidgetsModule.h" // For export macro
45
46VTK_ABI_NAMESPACE_BEGIN
50
51class VTKINTERACTIONWIDGETS_EXPORT vtkAbstractWidget : public vtkInteractorObserver
52{
53public:
55
59 void PrintSelf(ostream& os, vtkIndent indent) override;
61
69 void SetEnabled(int) override;
70
72
78 vtkSetClampMacro(ProcessEvents, vtkTypeBool, 0, 1);
80 {
81 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning ProcessEvents of "
82 << this->ProcessEvents);
83 return this->ProcessEvents;
84 }
85 vtkBooleanMacro(ProcessEvents, vtkTypeBool);
87
92 vtkWidgetEventTranslator* GetEventTranslator() { return this->EventTranslator; }
93
100 virtual void CreateDefaultRepresentation() = 0;
101
108 void Render();
109
116 void SetParent(vtkAbstractWidget* parent) { this->Parent = parent; }
117 vtkGetObjectMacro(Parent, vtkAbstractWidget);
118
120
127 {
128 this->CreateDefaultRepresentation();
129 return this->WidgetRep;
130 }
132
134
141 vtkSetMacro(ManagesCursor, vtkTypeBool);
142 vtkGetMacro(ManagesCursor, vtkTypeBool);
143 vtkBooleanMacro(ManagesCursor, vtkTypeBool);
145
151 void SetPriority(float) override;
152
153protected:
156
157 // Handles the events; centralized here for all widgets.
159 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
160
161 // The representation for the widget. This is typically called by the
162 // SetRepresentation() methods particular to each widget (i.e. subclasses
163 // of this class). This method does the actual work; the SetRepresentation()
164 // methods constrain the type that can be set.
167
168 // helper methods for cursor management
170 virtual void SetCursor(int vtkNotUsed(state)) {}
171
172 // For translating and invoking events
175
176 // The parent, if any, for this widget
178
179 // Call data which can be retrieved by the widget. This data is set
180 // by ProcessEvents() if call data is provided during a callback
181 // sequence.
182 void* CallData;
183
184 // Flag indicating if the widget should handle interaction events.
185 // On by default.
187
188 // Used by subclasses to ensure different events comes from the same
189 // hardware device. Such as starting a move with the right controller
190 // should then only respond to move events from the right controller.
192
193private:
194 vtkAbstractWidget(const vtkAbstractWidget&) = delete;
195 void operator=(const vtkAbstractWidget&) = delete;
196};
197
198VTK_ABI_NAMESPACE_END
199#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:29
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:49
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