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 =========================================================================*/
55 #ifndef vtkAbstractWidget_h
56 #define vtkAbstractWidget_h
57 
58 #include "vtkInteractionWidgetsModule.h" // For export macro
59 #include "vtkInteractorObserver.h"
60 
64 
65 class VTKINTERACTIONWIDGETS_EXPORT vtkAbstractWidget : public vtkInteractorObserver
66 {
67 public:
69 
73  void PrintSelf(ostream& os, vtkIndent indent) override;
75 
83  void SetEnabled(int) override;
84 
86 
92  vtkSetClampMacro(ProcessEvents, vtkTypeBool, 0, 1);
94  {
95  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning ProcessEvents of "
96  << this->ProcessEvents);
97  return this->ProcessEvents;
98  }
99  vtkBooleanMacro(ProcessEvents, vtkTypeBool);
101 
106  vtkWidgetEventTranslator* GetEventTranslator() { return this->EventTranslator; }
107 
114  virtual void CreateDefaultRepresentation() = 0;
115 
122  void Render();
123 
130  void SetParent(vtkAbstractWidget* parent) { this->Parent = parent; }
131  vtkGetObjectMacro(Parent, vtkAbstractWidget);
132 
134 
141  {
142  this->CreateDefaultRepresentation();
143  return this->WidgetRep;
144  }
146 
148 
155  vtkSetMacro(ManagesCursor, vtkTypeBool);
156  vtkGetMacro(ManagesCursor, vtkTypeBool);
157  vtkBooleanMacro(ManagesCursor, vtkTypeBool);
159 
165  void SetPriority(float) override;
166 
167 protected:
169  ~vtkAbstractWidget() override;
170 
171  // Handles the events; centralized here for all widgets.
172  static void ProcessEventsHandler(
173  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
174 
175  // The representation for the widget. This is typically called by the
176  // SetRepresentation() methods particular to each widget (i.e. subclasses
177  // of this class). This method does the actual work; the SetRepresentation()
178  // methods constrain the type that can be set.
179  void SetWidgetRepresentation(vtkWidgetRepresentation* r);
181 
182  // helper methods for cursor management
184  virtual void SetCursor(int vtkNotUsed(state)) {}
185 
186  // For translating and invoking events
189 
190  // The parent, if any, for this widget
192 
193  // Call data which can be retrieved by the widget. This data is set
194  // by ProcessEvents() if call data is provided during a callback
195  // sequence.
196  void* CallData;
197 
198  // Flag indicating if the widget should handle interaction events.
199  // On by default.
201 
202  // Used by subclasses to ensure different events comes from the same
203  // hardware device. Such as starting a move with the right controller
204  // should then only respond to move events from the right controller.
206 
207 private:
208  vtkAbstractWidget(const vtkAbstractWidget&) = delete;
209  void operator=(const vtkAbstractWidget&) = delete;
210 };
211 
212 #endif
virtual void SetCursor(int vtkNotUsed(state))
vtkTypeBool ProcessEvents
abstract base class for most VTK objects
Definition: vtkObject.h:62
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:69
virtual void SetPriority(float)
Set/Get the priority at which events are processed.
a simple class to control print indentation
Definition: vtkIndent.h:39
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...
vtkWidgetEventTranslator * EventTranslator