VTK  9.3.1
vtkBalloonWidget.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
62 #ifndef vtkBalloonWidget_h
63 #define vtkBalloonWidget_h
64 
65 #include "vtkHoverWidget.h"
66 #include "vtkInteractionWidgetsModule.h" // For export macro
67 
68 VTK_ABI_NAMESPACE_BEGIN
70 class vtkProp;
72 class vtkStdString;
73 class vtkPropMap;
74 class vtkImageData;
75 
76 class VTKINTERACTIONWIDGETS_EXPORT vtkBalloonWidget : public vtkHoverWidget
77 {
78 public:
82  static vtkBalloonWidget* New();
83 
85 
89  void PrintSelf(ostream& os, vtkIndent indent) override;
91 
96  void SetEnabled(int) override;
97 
104  {
105  this->Superclass::SetWidgetRepresentation(reinterpret_cast<vtkWidgetRepresentation*>(r));
106  }
107 
112  {
113  return reinterpret_cast<vtkBalloonRepresentation*>(this->WidgetRep);
114  }
115 
119  void CreateDefaultRepresentation() override;
120 
122 
126  void AddBalloon(vtkProp* prop, vtkStdString* str, vtkImageData* img);
127  void AddBalloon(vtkProp* prop, const char* str, vtkImageData* img);
128  void AddBalloon(vtkProp* prop, const char* str) // for wrapping
129  {
130  this->AddBalloon(prop, str, nullptr);
131  }
132  void RemoveBalloon(vtkProp* prop);
134 
136 
142  const char* GetBalloonString(vtkProp* prop);
143  vtkImageData* GetBalloonImage(vtkProp* prop);
145 
147 
151  void UpdateBalloonString(vtkProp* prop, const char* str);
152  void UpdateBalloonImage(vtkProp* prop, vtkImageData* image);
154 
159  virtual vtkProp* GetCurrentProp() { return this->CurrentProp; }
160 
162 
168  void SetPicker(vtkAbstractPropPicker*);
169  vtkGetObjectMacro(Picker, vtkAbstractPropPicker);
171 
172  /*
173  * Register internal Pickers within PickingManager
174  */
175  void RegisterPickers() override;
176 
177 protected:
179  ~vtkBalloonWidget() override;
180 
181  // This class implements the method called from its superclass.
182  int SubclassEndHoverAction() override;
183  int SubclassHoverAction() override;
184 
185  // Classes for managing balloons
186  vtkPropMap* PropMap; // PIMPL'd map of (vtkProp,vtkStdString)
187 
188  // Support for picking
190 
191  // The vtkProp that is being hovered over (which may be nullptr)
193 
194 private:
195  vtkBalloonWidget(const vtkBalloonWidget&) = delete;
196  void operator=(const vtkBalloonWidget&) = delete;
197 };
198 
199 VTK_ABI_NAMESPACE_END
200 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:45
void SetEnabled(int) override
The method for activating and deactivating this widget.
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:28
vtkBalloonRepresentation * GetBalloonRepresentation()
Return the representation as a vtkBalloonRepresentation.
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkWidgetRepresentation * WidgetRep
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for a VTK class.
a simple class to control print indentation
Definition: vtkIndent.h:28
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
void CreateDefaultRepresentation() override
A default representation, of which there is none, is created.
virtual int SubclassHoverAction()
popup text balloons above instance of vtkProp when hovering occurs
represent the vtkBalloonWidget
virtual int SubclassEndHoverAction()
abstract API for pickers that can pick an instance of vtkProp
vtkAbstractPropPicker * Picker
virtual vtkProp * GetCurrentProp()
Return the current vtkProp that is being hovered over.
invoke a vtkTimerEvent when hovering
void SetWidgetRepresentation(vtkWidgetRepresentation *r)
void AddBalloon(vtkProp *prop, const char *str)
Add and remove text and/or an image to be associated with a vtkProp.
vtkPropMap * PropMap
static vtkHoverWidget * New()
Instantiate this class.
void SetRepresentation(vtkBalloonRepresentation *r)
Specify an instance of vtkWidgetRepresentation used to represent this widget in the scene...