/*========================================================================= Program: Visualization Toolkit Module: vtkBalloonWidget.h Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ /** * @class vtkBalloonWidget * @brief popup text balloons above instance of vtkProp when hovering occurs * * The vtkBalloonWidget is used to popup text and/or an image when the mouse * hovers over an instance of vtkProp. The widget keeps track of * (vtkProp,vtkBalloon) pairs (where the internal vtkBalloon class is defined * by a pair of vtkStdString and vtkImageData), and when the mouse stops * moving for a user-specified period of time over the vtkProp, then the * vtkBalloon is drawn nearby the vtkProp. Note that an instance of * vtkBalloonRepresentation is used to draw the balloon. * * To use this widget, specify an instance of vtkBalloonWidget and a * representation (e.g., vtkBalloonRepresentation). Then list all instances * of vtkProp, a text string, and/or an instance of vtkImageData to be * associated with each vtkProp. (Note that you can specify both text and an * image, or just one or the other.) You may also wish to specify the hover * delay (i.e., set in the superclass vtkHoverWidget). * * @par Event Bindings: * By default, the widget observes the following VTK events (i.e., it * watches the vtkRenderWindowInteractor for these events): *
* MouseMoveEvent - occurs when mouse is moved in render window. * TimerEvent - occurs when the time between events (e.g., mouse move) * is greater than TimerDuration. * KeyPressEvent - when the "Enter" key is pressed after the balloon appears, * a callback is activated (e.g., WidgetActivateEvent). ** * @par Event Bindings: * Note that the event bindings described above can be changed using this * class's vtkWidgetEventTranslator. This class translates VTK events * into the vtkBalloonWidget's widget events: *
* vtkWidgetEvent::Move -- start the timer * vtkWidgetEvent::TimedOut -- when hovering occurs, * vtkWidgetEvent::SelectAction -- activate any callbacks associated * with the balloon. ** * @par Event Bindings: * This widget invokes the following VTK events on itself (which observers * can listen for): *
* vtkCommand::TimerEvent (when hovering is determined to occur) * vtkCommand::EndInteractionEvent (after a hover has occurred and the * mouse begins moving again). * vtkCommand::WidgetActivateEvent (when the balloon is selected with a * keypress). ** * @sa * vtkAbstractWidget */ #ifndef vtkBalloonWidget_h #define vtkBalloonWidget_h #include "vtkHoverWidget.h" #include "vtkInteractionWidgetsModule.h" // For export macro class vtkBalloonRepresentation; class vtkProp; class vtkAbstractPropPicker; class vtkStdString; class vtkPropMap; class vtkImageData; class VTKINTERACTIONWIDGETS_EXPORT vtkBalloonWidget : public vtkHoverWidget { public: /** * Instantiate this class. */ static vtkBalloonWidget* New(); //@{ /** * Standard methods for a VTK class. */ vtkTypeMacro(vtkBalloonWidget, vtkHoverWidget); void PrintSelf(ostream& os, vtkIndent indent) override; //@} /** * The method for activating and deactivating this widget. This method * must be overridden because it performs special timer-related operations. */ void SetEnabled(int) override; /** * Specify an instance of vtkWidgetRepresentation used to represent this * widget in the scene. Note that the representation is a subclass of vtkProp * so it can be added to the renderer independent of the widget. */ void SetRepresentation(vtkBalloonRepresentation* r) { this->Superclass::SetWidgetRepresentation(reinterpret_cast