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
52 #ifndef vtkAbstractWidget_h
53 #define vtkAbstractWidget_h
54 
55 #include "vtkInteractionWidgetsModule.h" // For export macro
56 #include "vtkInteractorObserver.h"
57 
58 VTK_ABI_NAMESPACE_BEGIN
62 
63 class VTKINTERACTIONWIDGETS_EXPORT vtkAbstractWidget : public vtkInteractorObserver
64 {
65 public:
67 
71  void PrintSelf(ostream& os, vtkIndent indent) override;
73 
81  void SetEnabled(int) override;
82 
84 
90  vtkSetClampMacro(ProcessEvents, vtkTypeBool, 0, 1);
92  {
93  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning ProcessEvents of "
94  << this->ProcessEvents);
95  return this->ProcessEvents;
96  }
97  vtkBooleanMacro(ProcessEvents, vtkTypeBool);
99 
104  vtkWidgetEventTranslator* GetEventTranslator() { return this->EventTranslator; }
105 
112  virtual void CreateDefaultRepresentation() = 0;
113 
120  void Render();
121 
128  void SetParent(vtkAbstractWidget* parent) { this->Parent = parent; }
129  vtkGetObjectMacro(Parent, vtkAbstractWidget);
130 
132 
139  {
140  this->CreateDefaultRepresentation();
141  return this->WidgetRep;
142  }
144 
146 
153  vtkSetMacro(ManagesCursor, vtkTypeBool);
154  vtkGetMacro(ManagesCursor, vtkTypeBool);
155  vtkBooleanMacro(ManagesCursor, vtkTypeBool);
157 
163  void SetPriority(float) override;
164 
165 protected:
167  ~vtkAbstractWidget() override;
168 
169  // Handles the events; centralized here for all widgets.
170  static void ProcessEventsHandler(
171  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
172 
173  // The representation for the widget. This is typically called by the
174  // SetRepresentation() methods particular to each widget (i.e. subclasses
175  // of this class). This method does the actual work; the SetRepresentation()
176  // methods constrain the type that can be set.
179 
180  // helper methods for cursor management
182  virtual void SetCursor(int vtkNotUsed(state)) {}
183 
184  // For translating and invoking events
187 
188  // The parent, if any, for this widget
190 
191  // Call data which can be retrieved by the widget. This data is set
192  // by ProcessEvents() if call data is provided during a callback
193  // sequence.
194  void* CallData;
195 
196  // Flag indicating if the widget should handle interaction events.
197  // On by default.
199 
200  // Used by subclasses to ensure different events comes from the same
201  // hardware device. Such as starting a move with the right controller
202  // should then only respond to move events from the right controller.
204 
205 private:
206  vtkAbstractWidget(const vtkAbstractWidget&) = delete;
207  void operator=(const vtkAbstractWidget&) = delete;
208 };
209 
210 VTK_ABI_NAMESPACE_END
211 #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:38
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:61
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