![]() |
ImFusion SDK 4.3
|
#include <ImFusion/GUI/SliceView.h>
2D renderer for SharedImageSets that can be hosted inside a Display. More...
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.
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 GlSliceView & | glView () const |
Returns the underlying GlSliceView. | |
GlSliceView & | glView () |
RadiologyViewGroup * | viewGroup () const |
Returns the optional RadiologyViewGroup this view can participate in. | |
const DisplayOptions2d * | displayOptions (const Data &data) const |
Returns the DisplayOptions2d instance that is used for the given dataset by the underlying GlSlice. | |
DisplayOptions2d * | displayOptions (const Data &data) |
SliceViewDefaultEventHandler * | defaultEventHandler () 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 ¢er, 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 ¢er, 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. | |
![]() | |
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. | |
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 data that should be shown in this view. | |
const DataList & | visibleData () const |
Returns a list of the currently displayed data. | |
bool | showData (Data *data) |
Appends the given Data instance to the list of visible data. | |
void | hideData (const Data *data) |
Removes the given Data instance to the list of visible data. | |
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. | |
virtual std::unique_ptr< ViewOverlay > | removeOverlay (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 (ViewObject *object) |
Remove the given ViewObject from this view. | |
std::vector< ViewObject * > | objects () const |
Returns all ViewObjects of this view. | |
const GlView * | view () const |
GlView * | view () |
Return associated GlView object. | |
![]() | |
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 |
![]() | |
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 | signalSettingsChanged |
Signal emitted whenever one of the view settings changed which can be linked by ViewGroup3D. | |
![]() | |
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. | |
![]() | |
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. | |
![]() | |
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. | |
![]() | |
void | disconnectAll () |
Disconnects all existing connections. | |
Protected Attributes | |
GlSliceView * | m_glSliceView |
RadiologyViewGroup * | m_viewGroup = nullptr |
ZoomMode | m_zoomMode = ZoomMode::FitToView |
bool | m_autoSetViewSettings = true |
![]() | |
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. | |
![]() | |
std::vector< Param > | m_params |
List of all registered Parameter and SubProperty instances. | |
|
strong |
Enumeration to describe the zooming mode used for a 2D view.
|
explicit |
Creates a new instance using the given GlSliceView which must not be null.
Furthermore, the constructor will add a SliceViewDefaultEventHandler.
|
explicit |
Creates a new instance default constructing a GlSliceView with the given parameters.
Furthermore, the constructor will add a SliceViewDefaultEventHandler.
const DisplayOptions2d * 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()
.
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).
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.
|
overridevirtual |
|
overridevirtual |
Sets the BorderConfig struct defining if and how to render a border frame surrounding the view.
Reimplemented from View.
|
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 View.
Signal signalSettingsChanged |
Signal emitted whenever one of the view settings changed which can be linked by ViewGroup3D.