![]() |
ImFusion C++ SDK 4.4.0
|
#include <ImFusion/GUI/InteractiveView.h>
Abstract base class for a view that can be hosted by a DisplayWidget. More...
Abstract base class for a view that can be hosted by a DisplayWidget.
An InteractiveView is a wrapper around a GlView adding a ViewInteraction, overlays, as well as a set of properties and signals. Each view has a certain size on the screen which is determined by the layout in DisplayWidget. Before rendering the actual view content with GlView, an InteractiveView draws a rectangular border around the content. The color of the border can be set with setDrawBorder.
InteractiveView takes care of automatically layouting the hosted overlays, which are always drawn on top of the view content. Overlays can be placed at different anchors (e.g. corners, edges) of the view. If several overlays reside on the same Anchor, the view will position them in a way that they don't overlap.
Public Types | |
| enum | LayoutDirection { Horizontal = int(GUI::ViewOverlay::LayoutDirection::Horizontal) , Vertical = int(GUI::ViewOverlay::LayoutDirection::Vertical) } |
| Layout direction when stacking multiple InteractiveOverlays at the same anchor. | |
Public Slots | |
| void | setVisible (bool value) |
| Make view hidden/visible. | |
| void | render () override |
| virtual void | reset () |
Signals | |
| void | visibilityChanged (bool visible) |
| void | rectChanged (QRect rect) |
| void | updateRequested () |
| void | visibilityChangeRequested (bool visible) |
| void | visibleDataChanged (const DataList &before, const DataList &now) |
| Emitted in setVisibleData after the visible data has been changed from before to now. | |
Public Member Functions | |
| InteractiveView (std::unique_ptr< GlView > glView) | |
| Construct view with underlying GlView. | |
| void | setInteractions (std::vector< std::unique_ptr< ViewInteraction > > interactions) |
| Replace all existing ViewInteractions with the ones in interactions. | |
| void | addInteraction (std::unique_ptr< ViewInteraction > interaction, int where=-1) |
| Add an interaction at the given position (default is at the end). | |
| void | removeInteraction (ViewInteraction *interaction) |
| Delete the given interaction, if it exists. Note: This will make the pointer invalid. | |
| std::vector< ViewInteraction * > | interactions () const |
| Returns all view interactions of this view. | |
| template<typename T> | |
| T * | findInteraction () const |
| Returns the first ViewInteraction that dynamic_casts to T or nullptr if no such ViewInteraction exists. | |
| void | setBorderColor (const QColor &color) |
| Set border color. | |
| void | setDrawBorder (bool drawBorder) |
| Set whether to draw a border around the view. | |
| bool | isBorderDrawn () const |
| Get whether to draw a border around the view. | |
| void | setBorderPixelSize (int pixelSize) |
| Set the size of the border around the view. | |
| int | borderPixelSize () const |
| Get the size of the border around the view. | |
| void | setBackgroundColor (const QColor &color) |
| Set border color. | |
| void | setViewGroup (ViewGroup *group) |
| Set associated view group. The view is not automatically added to the view group. | |
| ViewGroup * | viewGroup () const |
| Get associated view group. | |
| QRectF | boundingRect () const |
| Bounding rect in item coordinates. | |
| virtual void | setRect (const QRect &rect) |
| Set position and size of view in scene coordinates. | |
| QRect | rect () const |
| Get position and size of view in scene coordinates. | |
| void | setViewport (const GL::Viewport &rect) override |
| Sets the area where this view is drawn in render() wrt. the attached framebuffer. | |
| virtual bool | sceneEvent (QEvent *qtEvent, const GUI::InputEvent &inputEvent) |
| Called by the DisplayWidget if a user input event has happened on this view. | |
| void | addObject (GUI::ViewObject *object) override |
| Add the given InteractiveObject to this view. | |
| void | removeObject (const GUI::ViewObject *object) override |
| Remove the given InteractiveObject from this view. | |
| virtual bool | hasObject (const InteractiveObject *object) const |
| virtual void | addOverlay (std::unique_ptr< InteractiveOverlay > overlay, int position=-1) |
| Add overlay to this view. | |
| std::unique_ptr< GUI::ViewOverlay > | removeOverlay (GUI::ViewOverlay *overlay) override |
| Remove overlay. The user is responsible for deleting the overlay afterwards. | |
| void | setWaterMark (SharedImage *image) |
| Set a water mark to the view. | |
| void | setAnchorLayoutDirection (InteractiveOverlay::AnchorPoint anchor, LayoutDirection direction) |
| Sets in which direction multiple overlays at one anchor are layed out. | |
| void | requestUpdate () |
| Allows some outside interaction to request an update of the view. | |
| bool | showOverlays () const |
| Get flag whether to show overlays. | |
| void | setAndRunAnimation (std::unique_ptr< Animations::Animation >) |
| Launch an animation while ensuring that only one animation is running at a time for this instance. | |
| Public Member Functions inherited from ImFusion::GUI::View | |
| View (std::unique_ptr< GlView > glView) | |
| Instantiate a new View using the given GlView as renderer; glView must not be null. | |
| virtual void | render () |
| Will render the view into the viewport() of the current framebuffer by drawing the optional background color, the optional border, the underlying GlView, and finally all overlays(). | |
| const GlView & | glView () const |
| Returns the underlying GlView. | |
| GlView & | glView () |
| Returns the underlying GlView. | |
| const GL::Viewport & | viewport () const |
| Returns the area where this view is drawn in render() wrt. the attached framebuffer. | |
| bool | isVisible () const |
| Returns whether this view has a non-zero viewport and can therefore be considered visible. | |
| std::optional< vec3 > | backgroundColor () const |
| Returns the optional background color used to clear the viewport before rendering anything. | |
| void | setBackgroundColor (std::optional< vec3 > value) |
| Sets the optional background color used to clear the viewport before rendering anything. | |
| const BorderConfig & | borderConfig () const |
| Returns the BorderConfig struct defining if and how to render a border frame surrounding the view. | |
| virtual void | setBorderConfig (const BorderConfig &value) |
| Sets the BorderConfig struct defining if and how to render a border frame surrounding the view. | |
| bool | showsOverlays () const |
| Returns the flag whether to show overlays or not. | |
| void | setShowOverlays (bool value) |
| Sets the flag whether to show overlays or not. | |
| void | setWatermark (const SharedImage &image) |
| Sets a watermark image to be rendered on top of the view. | |
| virtual EventResult | handleInputEvent (const InputEvent &event) |
| Called by the parent Display if a user input event has happened on this view. | |
| void | setDataDisplayDispatcher (std::shared_ptr< DataDisplayDispatcher > ddd) |
| Sets a common DataDisplayDispatcher so that it can be shared across views. | |
| const DataDisplayDispatcher * | dataDisplayDispatcher () const |
| Returns the DataDisplayDispatcher used by this view. | |
| virtual bool | acceptsData (const Data *data) const |
| Returns whether this view is capable of displaying the given data. | |
| void | setVisibleData (const DataList &data) |
| Set the list of datasets that should be shown in this view. | |
| const DataList & | visibleData () const |
| Returns the list of currently displayed datasets. | |
| bool | showData (Data *data) |
| Appends the given dataset to the list of visible datasets. | |
| void | hideData (const Data *data) |
| Removes the given dataset from the list of visible datasets. | |
| void | setEventHandlers (std::vector< std::unique_ptr< EventHandler > > eventHandlers) |
| Replace all existing EventHandlers with the ones in eventHandlers. | |
| void | addEventHandler (std::unique_ptr< EventHandler > eventHandler, int where=-1) |
| Add an EventHandler at the given position (default is at the end). | |
| std::unique_ptr< EventHandler > | removeEventHandler (EventHandler *interaction) |
| Delete the given interaction, if it exists. Note: This will make the pointer invalid. | |
| std::vector< EventHandler * > | eventHandlers () const |
| Returns all view interactions of this view. | |
| template<typename T> | |
| T * | findEventHandler () const |
| Returns the first EventHandler that dynamic_casts to T, or nullptr if no such EventHandler exists. | |
| void | addOverlay (std::unique_ptr< ViewOverlay > overlay, ViewOverlay::Anchor anchor, int position=-1) |
| Inserts overlay into the list of overlays of this view at position of the given anchor. | |
| std::vector< ViewOverlay * > | overlays () const |
| Returns all InteractiveOverlays of this view. | |
| void | setOverlayAnchor (ViewOverlay *overlay, ViewOverlay::Anchor anchor) |
| Set the anchor point to use for the given overlay. | |
| void | setOverlayLayoutDirection (ViewOverlay::Anchor anchor, ViewOverlay::LayoutDirection direction) |
| Sets in which direction multiple overlays at one anchor are laid out. | |
| std::vector< ViewObject * > | objects () const |
| Returns all currently registered ViewObjects of this view. | |
| const GlView * | view () const |
| GlView * | view () |
| Return associated GlView object. | |
| Public Member Functions inherited from ImFusion::Configurable | |
| virtual void | configure (const Properties *p) |
| Configure this object instance by de-serializing the given Properties. | |
| virtual void | configuration (Properties *p) const |
| Serialize the current object configuration into the given Properties object. | |
| virtual void | configureDefaults () |
| Retrieve the properties of this object, replaces values with their defaults and sets it again. | |
| void | registerParameter (ParameterBase *param) |
| Register the given Parameter or SubProperty, so that it will be configured during configure()/configuration(). | |
| void | unregisterParameter (const ParameterBase *param) |
| Remove the given Parameter or SubProperty from the list of registered parameters. | |
| Configurable (const Configurable &rhs) | |
| Configurable (Configurable &&rhs) noexcept | |
| Configurable & | operator= (const Configurable &) |
| Configurable & | operator= (Configurable &&) noexcept |
| Public Member Functions inherited from ImFusion::SignalReceiver | |
| SignalReceiver ()=default | |
| Default constructor. | |
| SignalReceiver (const SignalReceiver &other) | |
| Copy constructor, does not copy any existing signal connections from other. | |
| SignalReceiver & | operator= (SignalReceiver rhs) |
| Assignment operator, disconnects all existing connections, does not copy any existing signal connections from rhs. | |
| virtual | ~SignalReceiver () |
| Virtual destructor disconnects from all connected signals. | |
Public Attributes | |
| Signal< DataList > | signalRendered |
| Emitted at the end of render(); the passed DataList will hold all visible data. | |
| Public Attributes inherited from ImFusion::GUI::View | |
| Signal | signalUpdateRequested |
| Emitted when this view or one of its overlays has become outdated and needs to be re-rendered. | |
| Signal< const DataList &, const DataList & > | signalVisibleDataChanged |
| Emitted when visibleData() has changed. | |
| Public Attributes inherited from ImFusion::Configurable | |
| Signal | signalParametersChanged |
| Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted. | |
Protected Member Functions | |
| GUI::EventResult | dispatchToViewOverlays (const GUI::InputEvent &event) override |
| Dispatch event to all known ViewOverlays considering m_mouseEventFocusObject and m_touchEventFocusObject. | |
| GUI::EventResult | dispatchToViewObjects (const GUI::InputEvent &event) override |
| Dispatch event to all known ViewObjects considering m_mouseEventFocusObject and m_touchEventFocusObject. | |
| GUI::EventResult | dispatchToViewEventHandlers (const GUI::InputEvent &event) override |
| Dispatch event to all known View::EventHandlers considering m_mouseEventFocusObject and m_touchEventFocusObject. | |
| virtual bool | handleOverlayEvent (QEvent *qtEvent, const GUI::InputEvent &inputEvent) |
| The default implementation will call InteractiveOverlay::sceneEvent() and set m_mouseEventTarget/m_touchEventTarget if needed. | |
| virtual bool | handleObjectEvent (QEvent *qtEvent, const GUI::InputEvent &inputEvent) |
| Auxiliary method for forwarding the scene event to all registered objects. | |
| virtual bool | handleInteractionEvent (QEvent *qtEvent, const GUI::InputEvent &inputEvent) |
| Auxiliary method for forwarding the scene event to the view interaction. | |
| Protected Member Functions inherited from ImFusion::GUI::View | |
| void | updateEventFocus (const InputEvent &event, const void *newTarget) |
| Update the internal bookkeeping of "focus" event handlers: | |
| bool | filterEventFocus (const InputEvent &event, const void *target) const |
| Checks if the object target should receive the given event based on the event type and current "focus" object. | |
| virtual void | showDataImpl (Data *data) |
| Override this function to implement custom logic whenever a dataset is added to the list of visible data. | |
| virtual void | hideDataImpl (const Data *data) |
| Override this function to implement custom logic whenever a dataset is removed from the list of visible data. | |
| Protected Member Functions inherited from ImFusion::SignalReceiver | |
| void | disconnectAll () |
| Disconnects all existing connections. | |
Protected Attributes | |
| std::vector< std::unique_ptr< ViewInteraction > > | m_interactions |
| ViewInteractions used for this view. | |
| ViewGroup * | m_group = nullptr |
| Optional ViewGroup this view is part of. | |
| Protected Attributes inherited from ImFusion::GUI::View | |
| std::unique_ptr< GlView > | m_glView |
| std::unique_ptr< ViewOverlayLayouter > | m_overlayLayouter |
| std::vector< std::unique_ptr< EventHandler > > | m_eventHandlers |
| std::vector< std::unique_ptr< ViewOverlay > > | m_overlays |
| std::vector< ViewObject * > | m_objects |
| DataList | m_visibleData |
| GL::Viewport | m_viewport |
| const void * | m_mouseEventFocusObject = nullptr |
| Pointer to the event receiver that shall receive MouseEvent::Type::Move events exclusively. | |
| const void * | m_touchEventFocusObject = nullptr |
| Pointer to the event receiver that shall receive TouchEvent::Type::Update events exclusively. | |
| Protected Attributes inherited from ImFusion::Configurable | |
| std::vector< Param > | m_params |
| List of all registered Parameter and SubProperty instances. | |
Properties | |
| QRect | rect |
| void ImFusion::InteractiveView::addInteraction | ( | std::unique_ptr< ViewInteraction > | interaction, |
| int | where = -1 ) |
Add an interaction at the given position (default is at the end).
Note that events will be forwarded to the view interactions in the given order, and the first one accepting it will consume it. Thus, subsequent interactions will not receive events already taken care of.
|
virtual |
Set position and size of view in scene coordinates.
Reimplemented in ImFusion::ImageView2D.
|
overridevirtual |
Sets the area where this view is drawn in render() wrt. the attached framebuffer.
Reimplemented from ImFusion::GUI::View.
|
virtual |
Called by the DisplayWidget if a user input event has happened on this view.
The default implementation will forward the event to the sub-objects in the following order:
|
overridevirtual |
Add the given InteractiveObject to this view.
Will add the underlying GlObject to the GlView and register the Manipulator.
Reimplemented from ImFusion::GUI::View.
|
overridevirtual |
Remove the given InteractiveObject from this view.
Reimplemented from ImFusion::GUI::View.
|
virtual |
Add overlay to this view.
If the overlay is not removed, it will be deleted with the view. The optional position argument defines where the overlay should be inserted in between the existing overlays. A position of -1 indicates the end.
|
overridevirtual |
Remove overlay. The user is responsible for deleting the overlay afterwards.
Reimplemented from ImFusion::GUI::View.
| void ImFusion::InteractiveView::setAndRunAnimation | ( | std::unique_ptr< Animations::Animation > | ) |
Launch an animation while ensuring that only one animation is running at a time for this instance.
A potentially running animation is canceled before launching the new animation.
|
overrideprotectedvirtual |
Dispatch event to all known ViewOverlays considering m_mouseEventFocusObject and m_touchEventFocusObject.
Reimplemented from ImFusion::GUI::View.
|
overrideprotectedvirtual |
Dispatch event to all known ViewObjects considering m_mouseEventFocusObject and m_touchEventFocusObject.
Reimplemented from ImFusion::GUI::View.
|
overrideprotectedvirtual |
Dispatch event to all known View::EventHandlers considering m_mouseEventFocusObject and m_touchEventFocusObject.
Reimplemented from ImFusion::GUI::View.
|
protectedvirtual |
The default implementation will call InteractiveOverlay::sceneEvent() and set m_mouseEventTarget/m_touchEventTarget if needed.
Furthermore, it will evaluate m_lastMouseEventOverlay and post enter/leave events to the overlays. Returns true if the event affects any overlay, false otherwise.
|
protectedvirtual |
Auxiliary method for forwarding the scene event to all registered objects.
The default implementation will call InteractiveObject::sceneEvent() and set m_mouseEventTarget if needed. Returns true if the event affects any overlay, false otherwise.
Reimplemented in ImFusion::CurvedView, and ImFusion::ImageView2D.
|
protectedvirtual |
Auxiliary method for forwarding the scene event to the view interaction.
The default implementation will call ViewInteraction::sceneEvent() and set m_mouseEventTarget if needed. It will also handle the ContextMenuEvent. Returns true if the event affects any overlay, false otherwise.