VTK  9.7.1
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
43 #ifndef vtkAbstractWidget_h
44 #define vtkAbstractWidget_h
45 
46 #include "vtkInteractionWidgetsModule.h" // For export macro
47 #include "vtkInteractorObserver.h"
48 #include "vtkWrappingHints.h" // For VTK_MARSHALMANUAL
49 
50 VTK_ABI_NAMESPACE_BEGIN
54 
55 class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALMANUAL vtkAbstractWidget
56  : public vtkInteractorObserver
57 {
58 public:
60 
64  void PrintSelf(ostream& os, vtkIndent indent) override;
66 
74  void SetEnabled(int) override;
75 
77 
83  vtkSetClampMacro(ProcessEvents, vtkTypeBool, 0, 1);
85  {
86  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning ProcessEvents of "
87  << this->ProcessEvents);
88  return this->ProcessEvents;
89  }
90  vtkBooleanMacro(ProcessEvents, vtkTypeBool);
92 
97  vtkWidgetEventTranslator* GetEventTranslator() { return this->EventTranslator; }
98 
105  virtual void CreateDefaultRepresentation() = 0;
106 
113  void Render();
114 
121  void SetParent(vtkAbstractWidget* parent) { this->Parent = parent; }
122  vtkGetObjectMacro(Parent, vtkAbstractWidget);
123 
125 
132  {
133  this->CreateDefaultRepresentation();
134  return this->WidgetRep;
135  }
137 
139 
146  vtkSetMacro(ManagesCursor, vtkTypeBool);
147  vtkGetMacro(ManagesCursor, vtkTypeBool);
148  vtkBooleanMacro(ManagesCursor, vtkTypeBool);
150 
156  void SetPriority(float) override;
157 
158 protected:
160  ~vtkAbstractWidget() override;
161 
162  // Handles the events; centralized here for all widgets.
163  static void ProcessEventsHandler(
164  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
165 
166  // The representation for the widget. This is typically called by the
167  // SetRepresentation() methods particular to each widget (i.e. subclasses
168  // of this class). This method does the actual work; the SetRepresentation()
169  // methods constrain the type that can be set.
170  void SetWidgetRepresentation(vtkWidgetRepresentation* r);
172 
173  // helper methods for cursor management
175  virtual void SetCursor(int vtkNotUsed(state)) {}
176 
177  // For translating and invoking events
180 
181  // The parent, if any, for this widget
183 
184  // Call data which can be retrieved by the widget. This data is set
185  // by ProcessEvents() if call data is provided during a callback
186  // sequence.
187  void* CallData;
188 
189  // Flag indicating if the widget should handle interaction events.
190  // On by default.
192 
193  // Used by subclasses to ensure different events comes from the same
194  // hardware device. Such as starting a move with the right controller
195  // should then only respond to move events from the right controller.
197 
198 private:
199  vtkAbstractWidget(const vtkAbstractWidget&) = delete;
200  void operator=(const vtkAbstractWidget&) = delete;
201 };
202 
203 VTK_ABI_NAMESPACE_END
204 #endif
vtkTypeBool ProcessEvents
abstract base class for most VTK objects
Definition: vtkObject.h:52
vtkWidgetCallbackMapper * CallbackMapper
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Handles the char widget activation event.
map VTK events into widget events
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
vtkWidgetEventTranslator * GetEventTranslator()
Get the event translator.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
abstract class defines interface between the widget and widget representation classes ...
an abstract superclass for classes observing events invoked by vtkRenderWindowInteractor ...
vtkWidgetRepresentation * WidgetRep
int vtkTypeBool
Definition: vtkABI.h:64
#define VTK_MARSHALMANUAL
virtual void SetPriority(float)
Set/Get the priority at which events are processed.
a simple class to control print indentation
Definition: vtkIndent.h:28
virtual vtkTypeBool GetProcessEvents()
Methods to change whether the widget responds to interaction.
const char * GetClassName() const
Return the class name as a string.
vtkTypeBool ManagesCursor
define the API for widget / widget representation
map widget events into callbacks
void SetParent(vtkAbstractWidget *parent)
Specifying a parent to this widget is used when creating composite widgets.
vtkAbstractWidget * Parent
vtkWidgetRepresentation * GetRepresentation()
Return an instance of vtkWidgetRepresentation used to represent this widget in the scene...
virtual void SetCursor(int state)
vtkWidgetEventTranslator * EventTranslator