ImFusion C++ SDK 4.4.0
ImFusion::GUI::SliceView Class Reference

#include <ImFusion/GUI/SliceView.h>

2D renderer for SharedImageSets that can be hosted inside a Display. More...

Inheritance diagram for ImFusion::GUI::SliceView:

Detailed Description

2D renderer for SharedImageSets that can be hosted inside a Display.

This class wraps the GlSliceView renderer that implements 2D/MPR rendering of one or multiple images with compositing and blending of any number of regular geometry-based GlObjects. It is mostly a wrapper object to combine the plain OpenGL renderer with input event handling functionality and put it into the a Display. Note that the GlSlice::is3D() flag of the underlying renderer defines whether this view accepts 2D or 3D images.

It comes with a SliceViewDefaultEventHandler pre-installed so that it is ready to use directly after instantiation. Furthermore, it provides a couple of additional high-level member functions to configure the most important properties of the renderer.

See also
GlSliceView, GlSlice, GlSliceRenderer

Public Types

enum class  ZoomMode { FitToView = 0 , Fixed = 1 , OriginalPixelSize }
 Enumeration to describe the zooming mode used for a 2D view. More...
enum class  ResetOptions {
  None = 0 , Everything = 0xFFFF , ViewMatrix = 1 << 0 , Zoom = 1 << 1 ,
  BlendingMode = 1 << 2 , InterpolationMode = 1 << 3
}
 Bitfield enumeration to specify what aspects of the view shall be reset.

Public Member Functions

 SliceView (std::unique_ptr< GlSliceView > glSliceView)
 Creates a new instance using the given GlSliceView which must not be null.
 SliceView (bool is3d, Slice::AnatomicalPlane plane=Slice::AnatomicalPlane::Undefined)
 Creates a new instance default constructing a GlSliceView with the given parameters.
const GlSliceViewglView () const
 Returns the underlying GlSliceView.
GlSliceViewglView ()
RadiologyViewGroup * viewGroup () const
 Returns the optional RadiologyViewGroup this view can participate in.
const DisplayOptions2ddisplayOptions (const Data &data) const
 Returns the DisplayOptions2d instance that is used for the given dataset by the underlying GlSlice.
DisplayOptions2ddisplayOptions (const Data &data)
SliceViewDefaultEventHandlerdefaultEventHandler () const
 Convenience function to return the first interaction of type SliceViewDefaultEventHandler if present.
ZoomMode zoomMode () const
 Returns the ZoomMode describing how the zoomFactor() is supposed to be interpreted.
void setZoomMode (ZoomMode value)
 Sets the ZoomMode describing how the zoomFactor() is supposed to be interpreted.
double zoomFactor () const
 Returns the zoom factor describing the amount of magnification of the shown image slice.
void setZoomFactor (double value)
 Sets the zoom factor describing the amount of magnification of the shown image slice.
bool flipsY () const
 Returns the flag whether to flip the display of the slice view vertically along the Y axis.
void setFlipY (bool value)
 Sets the flag whether to flip the display of the slice view vertically along the Y axis.
GlSliceRendererImage::InterpolationMode interpolationMode () const
 Returns the interpolation mode of the underlying GlSlice's default renderer.
void setInterpolationMode (GlSliceRendererImage::InterpolationMode value)
 Sets the interpolation mode of the underlying GlSlice's default renderer.
GlSlice::BlendingMode blendingMode () const
 Returns the blending behavior of the underlying GlSlice when rendering multiple images.
void setBlendingMode (GlSlice::BlendingMode value)
 Sets the blending behavior of the underlying GlSlice when rendering multiple images.
double blendingFactor () const
 Returns the blending factor in range 0..1 of the underlying GlSlice if applicable to the current blendingMode().
void setBlendingFactor (double value)
 Sets the blending factor in range 0..1 of the underlying GlSlice if applicable to the current blendingMode().
bool autoViewSettings () const
 Returns whether this class automatically configures settings of the underlying GlSliceView based on the shown data.
void setAutoViewSettings (bool value)
 Sets whether this class automatically configures settings of the underlying GlSliceView based on the shown data.
void setMatrix (const mat4 &camToWorldMatrix, bool suppressAnimation=false)
 Set camera-to-world matrix of the underlying GlSliceView using a smooth animation if enabled/unless suppressed.
void setMatrix (const vec3 &center, std::optional< mat3 > rotationMatrix=std::nullopt, bool suppressAnimation=false)
 Set camera-to-world matrix of the underlying GlSliceView based on the given center and optional rotation matrix.
void setSliceDepth (const vec3 &center, bool suppressAnimation=false)
 Changes the slice matrix so that it matches center in Z direction but remains unchanged in X and Y direction (view space).
void reset (Flags< ResetOptions > resetOptions=ResetOptions::Everything)
 Reset selected parameters of this view to their default state.
void setViewport (const GL::Viewport &rect) override
 Sets the area where this view is drawn in render() wrt. the attached framebuffer.
void setBorderConfig (const BorderConfig &value) override
 Sets the BorderConfig struct defining if and how to render a border frame surrounding the view.
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 GlViewglView () const
 Returns the underlying GlView.
GlViewglView ()
 Returns the underlying GlView.
const GL::Viewportviewport () 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 BorderConfigborderConfig () const
 Returns 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 DataListvisibleData () 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< EventHandlerremoveEventHandler (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.
virtual std::unique_ptr< ViewOverlayremoveOverlay (ViewOverlay *overlay)
 Remove a previously added overlay from this view again.
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.
virtual void addObject (ViewObject *object)
 Will add the underlying GlObject to the GlView and register the event handler.
virtual void removeObject (const ViewObject *object)
 Remove the given ViewObject from this view unregistering both the GlObject renderer and the event handler.
std::vector< ViewObject * > objects () const
 Returns all currently registered ViewObjects of this view.
const GlViewview () const
GlViewview ()
 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.
SignalReceiveroperator= (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 signalSettingsChanged
 Signal emitted whenever one of the view settings changed which can be linked by ViewGroup3D.
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

void updateScale ()
void updateViewSettings ()
void showDataImpl (Data *data) override
 Override this function to implement custom logic whenever a dataset is added to the list of visible data.
Protected Member Functions inherited from ImFusion::GUI::View
virtual EventResult dispatchToViewOverlays (const InputEvent &event)
 Dispatch event to all known ViewOverlays considering m_mouseEventFocusObject and m_touchEventFocusObject.
virtual EventResult dispatchToViewObjects (const InputEvent &event)
 Dispatch event to all known ViewObjects considering m_mouseEventFocusObject and m_touchEventFocusObject.
virtual EventResult dispatchToViewEventHandlers (const InputEvent &event)
 Dispatch event to all known View::EventHandlers considering m_mouseEventFocusObject and m_touchEventFocusObject.
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 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

GlSliceViewm_glSliceView
RadiologyViewGroup * m_viewGroup = nullptr
ZoomMode m_zoomMode = ZoomMode::FitToView
bool m_autoSetViewSettings = true
Protected Attributes inherited from ImFusion::GUI::View
std::unique_ptr< GlViewm_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< Paramm_params
 List of all registered Parameter and SubProperty instances.

Member Enumeration Documentation

◆ ZoomMode

Enumeration to describe the zooming mode used for a 2D view.

Enumerator
FitToView 

A zoom factor of 1 will fit the shown image to the viewport.

Fixed 

A zoom factor of 1 will show 1mm per viewport pixel.

OriginalPixelSize 

A zoom factor of 1 will show 1 image pixel (of the first visible image) per viewport pixel.

Constructor & Destructor Documentation

◆ SliceView() [1/2]

ImFusion::GUI::SliceView::SliceView ( std::unique_ptr< GlSliceView > glSliceView)
explicit

Creates a new instance using the given GlSliceView which must not be null.

Furthermore, the constructor will add a SliceViewDefaultEventHandler.

◆ SliceView() [2/2]

ImFusion::GUI::SliceView::SliceView ( bool is3d,
Slice::AnatomicalPlane plane = Slice::AnatomicalPlane::Undefined )
explicit

Creates a new instance default constructing a GlSliceView with the given parameters.

Furthermore, the constructor will add a SliceViewDefaultEventHandler.

Member Function Documentation

◆ displayOptions()

const DisplayOptions2d * ImFusion::GUI::SliceView::displayOptions ( const Data & data) const

Returns the DisplayOptions2d instance that is used for the given dataset by the underlying GlSlice.

Returns nullptr in case data is not part of glView().slice()->data().

◆ setSliceDepth()

void ImFusion::GUI::SliceView::setSliceDepth ( const vec3 & center,
bool suppressAnimation = false )

Changes the slice matrix so that it matches center in Z direction but remains unchanged in X and Y direction (view space).

Essentially, it projects center onto the current slice plane and then translates the Z coordinate of the view matrix. This function is useful if you want to center a set of MPR views to show a particular point without changing the in-plane translation of each view.

◆ setViewport()

void ImFusion::GUI::SliceView::setViewport ( const GL::Viewport & rect)
overridevirtual

Sets the area where this view is drawn in render() wrt. the attached framebuffer.

Reimplemented from ImFusion::GUI::View.

◆ setBorderConfig()

void ImFusion::GUI::SliceView::setBorderConfig ( const BorderConfig & value)
overridevirtual

Sets the BorderConfig struct defining if and how to render a border frame surrounding the view.

Reimplemented from ImFusion::GUI::View.

◆ showDataImpl()

void ImFusion::GUI::SliceView::showDataImpl ( Data * data)
overrideprotectedvirtual

Override this function to implement custom logic whenever a dataset is added to the list of visible data.

The default implementation will call DataDisplayDispatcher::show() and add data to m_visibleData.

Reimplemented from ImFusion::GUI::View.

Member Data Documentation

◆ signalSettingsChanged

Signal ImFusion::GUI::SliceView::signalSettingsChanged

Signal emitted whenever one of the view settings changed which can be linked by ViewGroup3D.

Warning
This signal is part of the high-level SliceView API, however it relates to settings of the underlying low-level GlSlice(View). This signal will only be emitted if changes are originate from the SliceView API. Changes applied directly to the underlying GlSlice(View) may not reliably trigger this signal.

The documentation for this class was generated from the following file:
  • ImFusion/GUI/SliceView.h
Search Tab / S to search, Esc to close