VTK  9.3.20240228
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
76 #include "vtkInteractorObserver.h"
77 
78 VTK_ABI_NAMESPACE_BEGIN
82 
83 class VTKINTERACTIONWIDGETS_EXPORT vtkAbstractWidget : public vtkInteractorObserver
84 {
85 public:
87 
91  void PrintSelf(ostream& os, vtkIndent indent) override;
93 
101  void SetEnabled(int) override;
102 
104 
110  vtkSetClampMacro(ProcessEvents, vtkTypeBool, 0, 1);
112  {
113  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning ProcessEvents of "
114  << this->ProcessEvents);
115  return this->ProcessEvents;
116  }
117  vtkBooleanMacro(ProcessEvents, vtkTypeBool);
119 
124  vtkWidgetEventTranslator* GetEventTranslator() { return this->EventTranslator; }
125 
132  virtual void CreateDefaultRepresentation() = 0;
133 
140  void Render();
141 
148  void SetParent(vtkAbstractWidget* parent) { this->Parent = parent; }
149  vtkGetObjectMacro(Parent, vtkAbstractWidget);
150 
152 
159  {
160  this->CreateDefaultRepresentation();
161  return this->WidgetRep;
162  }
164 
166 
173  vtkSetMacro(ManagesCursor, vtkTypeBool);
174  vtkGetMacro(ManagesCursor, vtkTypeBool);
175  vtkBooleanMacro(ManagesCursor, vtkTypeBool);
177 
183  void SetPriority(float) override;
184 
185 protected:
187  ~vtkAbstractWidget() override;
188 
189  // Handles the events; centralized here for all widgets.
190  static void ProcessEventsHandler(
191  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
192 
193  // The representation for the widget. This is typically called by the
194  // SetRepresentation() methods particular to each widget (i.e. subclasses
195  // of this class). This method does the actual work; the SetRepresentation()
196  // methods constrain the type that can be set.
199 
200  // helper methods for cursor management
202  virtual void SetCursor(int vtkNotUsed(state)) {}
203 
204  // For translating and invoking events
207 
208  // The parent, if any, for this widget
210 
211  // Call data which can be retrieved by the widget. This data is set
212  // by ProcessEvents() if call data is provided during a callback
213  // sequence.
214  void* CallData;
215 
216  // Flag indicating if the widget should handle interaction events.
217  // On by default.
219 
220  // Used by subclasses to ensure different events comes from the same
221  // hardware device. Such as starting a move with the right controller
222  // should then only respond to move events from the right controller.
224 
225 private:
226  vtkAbstractWidget(const vtkAbstractWidget&) = delete;
227  void operator=(const vtkAbstractWidget&) = delete;
228 };
229 
230 VTK_ABI_NAMESPACE_END
231 #endif
define the API for widget / widget representation
void SetParent(vtkAbstractWidget *parent)
Specifying a parent to this widget is used when creating composite widgets.
void SetPriority(float) override
Override the superclass method.
virtual vtkTypeBool GetProcessEvents()
Methods to change whether the widget responds to interaction.
vtkWidgetEventTranslator * EventTranslator
vtkWidgetRepresentation * GetRepresentation()
Return an instance of vtkWidgetRepresentation used to represent this widget in the scene.
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
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.
vtkWidgetEventTranslator * GetEventTranslator()
Get the event translator.
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:161
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