VTK  9.1.0
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);
93  vtkGetMacro(ProcessEvents, vtkTypeBool);
94  vtkBooleanMacro(ProcessEvents, vtkTypeBool);
96 
101  vtkWidgetEventTranslator* GetEventTranslator() { return this->EventTranslator; }
102 
109  virtual void CreateDefaultRepresentation() = 0;
110 
117  void Render();
118 
125  void SetParent(vtkAbstractWidget* parent) { this->Parent = parent; }
126  vtkGetObjectMacro(Parent, vtkAbstractWidget);
127 
129 
136  {
137  this->CreateDefaultRepresentation();
138  return this->WidgetRep;
139  }
141 
143 
150  vtkSetMacro(ManagesCursor, vtkTypeBool);
151  vtkGetMacro(ManagesCursor, vtkTypeBool);
152  vtkBooleanMacro(ManagesCursor, vtkTypeBool);
154 
160  void SetPriority(float) override;
161 
162 protected:
164  ~vtkAbstractWidget() override;
165 
166  // Handles the events; centralized here for all widgets.
167  static void ProcessEventsHandler(
168  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
169 
170  // The representation for the widget. This is typically called by the
171  // SetRepresentation() methods particular to each widget (i.e. subclasses
172  // of this class). This method does the actual work; the SetRepresentation()
173  // methods constrain the type that can be set.
176 
177  // helper methods for cursor management
179  virtual void SetCursor(int vtkNotUsed(state)) {}
180 
181  // For translating and invoking events
184 
185  // The parent, if any, for this widget
187 
188  // Call data which can be retrieved by the widget. This data is set
189  // by ProcessEvents() if call data is provided during a callback
190  // sequence.
191  void* CallData;
192 
193  // Flag indicating if the widget should handle interaction events.
194  // On by default.
196 
197  // Used by subclasses to ensure different events comes from the same
198  // hardware device. Such as starting a move with the right controller
199  // should then only respond to move events from the right controller.
201 
202 private:
203  vtkAbstractWidget(const vtkAbstractWidget&) = delete;
204  void operator=(const vtkAbstractWidget&) = delete;
205 };
206 
207 #endif
vtkAbstractWidget::SetCursor
virtual void SetCursor(int vtkNotUsed(state))
Definition: vtkAbstractWidget.h:179
vtkAbstractWidget::GetRepresentation
vtkWidgetRepresentation * GetRepresentation()
Return an instance of vtkWidgetRepresentation used to represent this widget in the scene.
Definition: vtkAbstractWidget.h:135
vtkAbstractWidget::GetEventTranslator
vtkWidgetEventTranslator * GetEventTranslator()
Get the event translator.
Definition: vtkAbstractWidget.h:101
vtkAbstractWidget::EventTranslator
vtkWidgetEventTranslator * EventTranslator
Definition: vtkAbstractWidget.h:182
vtkAbstractWidget::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Standard macros implementing standard VTK methods.
vtkAbstractWidget::ProcessEventsHandler
static void ProcessEventsHandler(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
vtkWidgetRepresentation
abstract class defines interface between the widget and widget representation classes
Definition: vtkWidgetRepresentation.h:60
vtkAbstractWidget::WidgetRep
vtkWidgetRepresentation * WidgetRep
Definition: vtkAbstractWidget.h:175
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:82
vtkAbstractWidget::CallbackMapper
vtkWidgetCallbackMapper * CallbackMapper
Definition: vtkAbstractWidget.h:183
vtkWidgetCallbackMapper
map widget events into callbacks
Definition: vtkWidgetCallbackMapper.h:61
vtkAbstractWidget::Render
void Render()
This method is called by subclasses when a render method is to be invoked on the vtkRenderWindowInter...
vtkInteractorObserver
an abstract superclass for classes observing events invoked by vtkRenderWindowInteractor
Definition: vtkInteractorObserver.h:85
vtkAbstractWidget::ManagesCursor
vtkTypeBool ManagesCursor
Definition: vtkAbstractWidget.h:178
vtkAbstractWidget::~vtkAbstractWidget
~vtkAbstractWidget() override
vtkAbstractWidget::LastDevice
int LastDevice
Definition: vtkAbstractWidget.h:200
vtkAbstractWidget
define the API for widget / widget representation
Definition: vtkAbstractWidget.h:66
vtkAbstractWidget::CreateDefaultRepresentation
virtual void CreateDefaultRepresentation()=0
Create the default widget representation if one is not set.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkAbstractWidget::SetPriority
void SetPriority(float) override
Override the superclass method.
vtkAbstractWidget::vtkAbstractWidget
vtkAbstractWidget()
vtkAbstractWidget::CallData
void * CallData
Definition: vtkAbstractWidget.h:191
vtkAbstractWidget::SetEnabled
void SetEnabled(int) override
Methods for activating this widget.
vtkInteractorObserver.h
vtkAbstractWidget::Parent
vtkAbstractWidget * Parent
Definition: vtkAbstractWidget.h:186
vtkWidgetEventTranslator
map VTK events into widget events
Definition: vtkWidgetEventTranslator.h:138
vtkAbstractWidget::ProcessEvents
vtkTypeBool ProcessEvents
Definition: vtkAbstractWidget.h:195
vtkAbstractWidget::SetWidgetRepresentation
void SetWidgetRepresentation(vtkWidgetRepresentation *r)
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkAbstractWidget::SetParent
void SetParent(vtkAbstractWidget *parent)
Specifying a parent to this widget is used when creating composite widgets.
Definition: vtkAbstractWidget.h:125