VTK  9.1.0
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=========================================================================*/
61#ifndef vtkAbstractWidget_h
62#define vtkAbstractWidget_h
63
64#include "vtkInteractionWidgetsModule.h" // For export macro
66
70
71class VTKINTERACTIONWIDGETS_EXPORT vtkAbstractWidget : public vtkInteractorObserver
72{
73public:
75
79 void PrintSelf(ostream& os, vtkIndent indent) override;
81
89 void SetEnabled(int) override;
90
92
98 vtkSetClampMacro(ProcessEvents, vtkTypeBool, 0, 1);
99 vtkGetMacro(ProcessEvents, vtkTypeBool);
100 vtkBooleanMacro(ProcessEvents, vtkTypeBool);
102
107 vtkWidgetEventTranslator* GetEventTranslator() { return this->EventTranslator; }
108
115 virtual void CreateDefaultRepresentation() = 0;
116
123 void Render();
124
131 void SetParent(vtkAbstractWidget* parent) { this->Parent = parent; }
132 vtkGetObjectMacro(Parent, vtkAbstractWidget);
133
135
142 {
143 this->CreateDefaultRepresentation();
144 return this->WidgetRep;
145 }
147
149
156 vtkSetMacro(ManagesCursor, vtkTypeBool);
157 vtkGetMacro(ManagesCursor, vtkTypeBool);
158 vtkBooleanMacro(ManagesCursor, vtkTypeBool);
160
166 void SetPriority(float) override;
167
168protected:
171
172 // Handles the events; centralized here for all widgets.
174 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
175
176 // The representation for the widget. This is typically called by the
177 // SetRepresentation() methods particular to each widget (i.e. subclasses
178 // of this class). This method does the actual work; the SetRepresentation()
179 // methods constrain the type that can be set.
182
183 // helper methods for cursor management
185 virtual void SetCursor(int vtkNotUsed(state)) {}
186
187 // For translating and invoking events
190
191 // The parent, if any, for this widget
193
194 // Call data which can be retrieved by the widget. This data is set
195 // by ProcessEvents() if call data is provided during a callback
196 // sequence.
197 void* CallData;
198
199 // Flag indicating if the widget should handle interaction events.
200 // On by default.
202
203 // Used by subclasses to ensure different events comes from the same
204 // hardware device. Such as starting a move with the right controller
205 // should then only respond to move events from the right controller.
207
208private:
209 vtkAbstractWidget(const vtkAbstractWidget&) = delete;
210 void operator=(const vtkAbstractWidget&) = delete;
211};
212
213#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.
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:43
an abstract superclass for classes observing events invoked by vtkRenderWindowInteractor
abstract base class for most VTK objects
Definition: vtkObject.h:63
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