VTK  9.2.6
vtkAbstractWidget.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkAbstractWidget.h,v
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
52#ifndef vtkAbstractWidget_h
53#define vtkAbstractWidget_h
54
55#include "vtkInteractionWidgetsModule.h" // For export macro
57
61
62class VTKINTERACTIONWIDGETS_EXPORT vtkAbstractWidget : public vtkInteractorObserver
63{
64public:
66
70 void PrintSelf(ostream& os, vtkIndent indent) override;
72
80 void SetEnabled(int) override;
81
83
89 vtkSetClampMacro(ProcessEvents, vtkTypeBool, 0, 1);
91 {
92 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning ProcessEvents of "
93 << this->ProcessEvents);
94 return this->ProcessEvents;
95 }
96 vtkBooleanMacro(ProcessEvents, vtkTypeBool);
98
103 vtkWidgetEventTranslator* GetEventTranslator() { return this->EventTranslator; }
104
111 virtual void CreateDefaultRepresentation() = 0;
112
119 void Render();
120
127 void SetParent(vtkAbstractWidget* parent) { this->Parent = parent; }
128 vtkGetObjectMacro(Parent, vtkAbstractWidget);
129
131
138 {
139 this->CreateDefaultRepresentation();
140 return this->WidgetRep;
141 }
143
145
152 vtkSetMacro(ManagesCursor, vtkTypeBool);
153 vtkGetMacro(ManagesCursor, vtkTypeBool);
154 vtkBooleanMacro(ManagesCursor, vtkTypeBool);
156
162 void SetPriority(float) override;
163
164protected:
167
168 // Handles the events; centralized here for all widgets.
170 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
171
172 // The representation for the widget. This is typically called by the
173 // SetRepresentation() methods particular to each widget (i.e. subclasses
174 // of this class). This method does the actual work; the SetRepresentation()
175 // methods constrain the type that can be set.
178
179 // helper methods for cursor management
181 virtual void SetCursor(int vtkNotUsed(state)) {}
182
183 // For translating and invoking events
186
187 // The parent, if any, for this widget
189
190 // Call data which can be retrieved by the widget. This data is set
191 // by ProcessEvents() if call data is provided during a callback
192 // sequence.
193 void* CallData;
194
195 // Flag indicating if the widget should handle interaction events.
196 // On by default.
198
199 // Used by subclasses to ensure different events comes from the same
200 // hardware device. Such as starting a move with the right controller
201 // should then only respond to move events from the right controller.
203
204private:
205 vtkAbstractWidget(const vtkAbstractWidget&) = delete;
206 void operator=(const vtkAbstractWidget&) = delete;
207};
208
209#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)
vtkTypeBool ProcessEvents
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
vtkTypeBool ManagesCursor
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:119
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:79
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:69