VTK
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 =========================================================================*/
52 #ifndef vtkAbstractWidget_h
53 #define vtkAbstractWidget_h
54 
55 #include "vtkInteractionWidgetsModule.h" // For export macro
56 #include "vtkInteractorObserver.h"
57 
61 
62 class VTKINTERACTIONWIDGETS_EXPORT vtkAbstractWidget : public vtkInteractorObserver
63 {
64 public:
66 
70  void PrintSelf(ostream& os, vtkIndent indent) override;
72 
80  void SetEnabled(int) override;
81 
83 
89  vtkSetClampMacro(ProcessEvents, vtkTypeBool, 0, 1);
90  vtkGetMacro(ProcessEvents, vtkTypeBool);
91  vtkBooleanMacro(ProcessEvents, vtkTypeBool);
93 
98  vtkWidgetEventTranslator* GetEventTranslator() { return this->EventTranslator; }
99 
106  virtual void CreateDefaultRepresentation() = 0;
107 
114  void Render();
115 
122  void SetParent(vtkAbstractWidget* parent) { this->Parent = parent; }
123  vtkGetObjectMacro(Parent, vtkAbstractWidget);
124 
126 
133  {
134  this->CreateDefaultRepresentation();
135  return this->WidgetRep;
136  }
138 
140 
147  vtkSetMacro(ManagesCursor, vtkTypeBool);
148  vtkGetMacro(ManagesCursor, vtkTypeBool);
149  vtkBooleanMacro(ManagesCursor, vtkTypeBool);
151 
157  void SetPriority(float) override;
158 
159 protected:
161  ~vtkAbstractWidget() override;
162 
163  // Handles the events; centralized here for all widgets.
164  static void ProcessEventsHandler(
165  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
166 
167  // The representation for the widget. This is typically called by the
168  // SetRepresentation() methods particular to each widget (i.e. subclasses
169  // of this class). This method does the actual work; the SetRepresentation()
170  // methods constrain the type that can be set.
171  void SetWidgetRepresentation(vtkWidgetRepresentation* r);
173 
174  // helper methods for cursor management
176  virtual void SetCursor(int vtkNotUsed(state)) {}
177 
178  // For translating and invoking events
181 
182  // The parent, if any, for this widget
184 
185  // Call data which can be retrieved by the widget. This data is set
186  // by ProcessEvents() if call data is provided during a callback
187  // sequence.
188  void* CallData;
189 
190  // Flag indicating if the widget should handle interaction events.
191  // On by default.
193 
194 private:
195  vtkAbstractWidget(const vtkAbstractWidget&) = delete;
196  void operator=(const vtkAbstractWidget&) = delete;
197 };
198 
199 #endif
vtkAbstractWidget::SetCursor
virtual void SetCursor(int vtkNotUsed(state))
Definition: vtkAbstractWidget.h:176
vtkAbstractWidget::GetRepresentation
vtkWidgetRepresentation * GetRepresentation()
Return an instance of vtkWidgetRepresentation used to represent this widget in the scene.
Definition: vtkAbstractWidget.h:132
vtkAbstractWidget::GetEventTranslator
vtkWidgetEventTranslator * GetEventTranslator()
Get the event translator.
Definition: vtkAbstractWidget.h:98
vtkAbstractWidget::EventTranslator
vtkWidgetEventTranslator * EventTranslator
Definition: vtkAbstractWidget.h:179
vtkWidgetRepresentation
abstract class defines interface between the widget and widget representation classes
Definition: vtkWidgetRepresentation.h:59
vtkAbstractWidget::WidgetRep
vtkWidgetRepresentation * WidgetRep
Definition: vtkAbstractWidget.h:172
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:53
vtkAbstractWidget::CallbackMapper
vtkWidgetCallbackMapper * CallbackMapper
Definition: vtkAbstractWidget.h:180
vtkWidgetCallbackMapper
map widget events into callbacks
Definition: vtkWidgetCallbackMapper.h:41
vtkInteractorObserver
an abstract superclass for classes observing events invoked by vtkRenderWindowInteractor
Definition: vtkInteractorObserver.h:59
vtkAbstractWidget::ManagesCursor
vtkTypeBool ManagesCursor
Definition: vtkAbstractWidget.h:175
vtkAbstractWidget
define the API for widget / widget representation
Definition: vtkAbstractWidget.h:62
vtkInteractorObserver::SetEnabled
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
Definition: vtkInteractorObserver.h:73
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkInteractorObserver::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkAbstractWidget::CallData
void * CallData
Definition: vtkAbstractWidget.h:188
vtkInteractorObserver.h
vtkInteractorObserver::SetPriority
virtual void SetPriority(float)
Set/Get the priority at which events are processed.
vtkAbstractWidget::Parent
vtkAbstractWidget * Parent
Definition: vtkAbstractWidget.h:183
vtkWidgetEventTranslator
map VTK events into widget events
Definition: vtkWidgetEventTranslator.h:48
vtkAbstractWidget::ProcessEvents
vtkTypeBool ProcessEvents
Definition: vtkAbstractWidget.h:192
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:122