VTK  9.2.6
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 =========================================================================*/
64 #ifndef vtkAbstractWidget_h
65 #define vtkAbstractWidget_h
66 
67 #include "vtkInteractionWidgetsModule.h" // For export macro
68 #include "vtkInteractorObserver.h"
69 
73 
74 class VTKINTERACTIONWIDGETS_EXPORT vtkAbstractWidget : public vtkInteractorObserver
75 {
76 public:
78 
82  void PrintSelf(ostream& os, vtkIndent indent) override;
84 
92  void SetEnabled(int) override;
93 
95 
101  vtkSetClampMacro(ProcessEvents, vtkTypeBool, 0, 1);
103  {
104  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning ProcessEvents of "
105  << this->ProcessEvents);
106  return this->ProcessEvents;
107  }
108  vtkBooleanMacro(ProcessEvents, vtkTypeBool);
110 
115  vtkWidgetEventTranslator* GetEventTranslator() { return this->EventTranslator; }
116 
123  virtual void CreateDefaultRepresentation() = 0;
124 
131  void Render();
132 
139  void SetParent(vtkAbstractWidget* parent) { this->Parent = parent; }
140  vtkGetObjectMacro(Parent, vtkAbstractWidget);
141 
143 
150  {
151  this->CreateDefaultRepresentation();
152  return this->WidgetRep;
153  }
155 
157 
164  vtkSetMacro(ManagesCursor, vtkTypeBool);
165  vtkGetMacro(ManagesCursor, vtkTypeBool);
166  vtkBooleanMacro(ManagesCursor, vtkTypeBool);
168 
174  void SetPriority(float) override;
175 
176 protected:
178  ~vtkAbstractWidget() override;
179 
180  // Handles the events; centralized here for all widgets.
181  static void ProcessEventsHandler(
182  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
183 
184  // The representation for the widget. This is typically called by the
185  // SetRepresentation() methods particular to each widget (i.e. subclasses
186  // of this class). This method does the actual work; the SetRepresentation()
187  // methods constrain the type that can be set.
190 
191  // helper methods for cursor management
193  virtual void SetCursor(int vtkNotUsed(state)) {}
194 
195  // For translating and invoking events
198 
199  // The parent, if any, for this widget
201 
202  // Call data which can be retrieved by the widget. This data is set
203  // by ProcessEvents() if call data is provided during a callback
204  // sequence.
205  void* CallData;
206 
207  // Flag indicating if the widget should handle interaction events.
208  // On by default.
210 
211  // Used by subclasses to ensure different events comes from the same
212  // hardware device. Such as starting a move with the right controller
213  // should then only respond to move events from the right controller.
215 
216 private:
217  vtkAbstractWidget(const vtkAbstractWidget&) = delete;
218  void operator=(const vtkAbstractWidget&) = delete;
219 };
220 
221 #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:49
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:72
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