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
43 #ifndef vtkAbstractWidget_h
44 #define vtkAbstractWidget_h
45 
46 #include "vtkInteractionWidgetsModule.h" // For export macro
47 #include "vtkInteractorObserver.h"
48 
49 VTK_ABI_NAMESPACE_BEGIN
53 
54 class VTKINTERACTIONWIDGETS_EXPORT vtkAbstractWidget : public vtkInteractorObserver
55 {
56 public:
58 
62  void PrintSelf(ostream& os, vtkIndent indent) override;
64 
72  void SetEnabled(int) override;
73 
75 
81  vtkSetClampMacro(ProcessEvents, vtkTypeBool, 0, 1);
83  {
84  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning ProcessEvents of "
85  << this->ProcessEvents);
86  return this->ProcessEvents;
87  }
88  vtkBooleanMacro(ProcessEvents, vtkTypeBool);
90 
95  vtkWidgetEventTranslator* GetEventTranslator() { return this->EventTranslator; }
96 
103  virtual void CreateDefaultRepresentation() = 0;
104 
111  void Render();
112 
119  void SetParent(vtkAbstractWidget* parent) { this->Parent = parent; }
120  vtkGetObjectMacro(Parent, vtkAbstractWidget);
121 
123 
130  {
131  this->CreateDefaultRepresentation();
132  return this->WidgetRep;
133  }
135 
137 
144  vtkSetMacro(ManagesCursor, vtkTypeBool);
145  vtkGetMacro(ManagesCursor, vtkTypeBool);
146  vtkBooleanMacro(ManagesCursor, vtkTypeBool);
148 
154  void SetPriority(float) override;
155 
156 protected:
158  ~vtkAbstractWidget() override;
159 
160  // Handles the events; centralized here for all widgets.
161  static void ProcessEventsHandler(
162  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
163 
164  // The representation for the widget. This is typically called by the
165  // SetRepresentation() methods particular to each widget (i.e. subclasses
166  // of this class). This method does the actual work; the SetRepresentation()
167  // methods constrain the type that can be set.
170 
171  // helper methods for cursor management
173  virtual void SetCursor(int vtkNotUsed(state)) {}
174 
175  // For translating and invoking events
178 
179  // The parent, if any, for this widget
181 
182  // Call data which can be retrieved by the widget. This data is set
183  // by ProcessEvents() if call data is provided during a callback
184  // sequence.
185  void* CallData;
186 
187  // Flag indicating if the widget should handle interaction events.
188  // On by default.
190 
191  // Used by subclasses to ensure different events comes from the same
192  // hardware device. Such as starting a move with the right controller
193  // should then only respond to move events from the right controller.
195 
196 private:
197  vtkAbstractWidget(const vtkAbstractWidget&) = delete;
198  void operator=(const vtkAbstractWidget&) = delete;
199 };
200 
201 VTK_ABI_NAMESPACE_END
202 #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:29
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:52
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