Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::DisplayActionEventHandler Class Reference

Simplifies connecting display action event observers to a DisplayActionEventBroadcast. More...

#include <mitkDisplayActionEventHandler.h>

Inheritance diagram for mitk::DisplayActionEventHandler:
Collaboration diagram for mitk::DisplayActionEventHandler:

Public Types

using OberserverTagType = unsigned long
 Tag type used to identify registered observers. More...
 

Public Member Functions

virtual ~DisplayActionEventHandler ()
 Destructor. Removes all registered observers. More...
 
void SetObservableBroadcast (DisplayActionEventBroadcast *observableBroadcast)
 Set the DisplayActionEventBroadcast instance to observe. More...
 
OberserverTagType ConnectDisplayActionEvent (const DisplayActionEvent &displayActionEvent, const StdFunctionCommand::ActionFunction &actionFunction, const StdFunctionCommand::FilterFunction &filterFunction=[](const itk::EventObject &) { return true;})
 Register an observer for a specific display action event. More...
 
void DisconnectObserver (OberserverTagType observerTag)
 Remove an observer identified by its tag. More...
 
const std::vector< OberserverTagType > & GetAllObserverTags ()
 Get all currently registered observer tags. More...
 
void InitActions (std::string prefixFilter="")
 Initialize pre-defined display actions and connect them to the broadcast. More...
 

Protected Member Functions

virtual void InitActionsImpl (const std::string &prefixFilter="")
 Override in sub-classes to define default display action connections. More...
 

Protected Attributes

WeakPointer< DisplayActionEventBroadcast > m_ObservableBroadcast
 
std::vector< OberserverTagType > m_ObserverTags
 

Detailed Description

Simplifies connecting display action event observers to a DisplayActionEventBroadcast.

Use SetObservableBroadcast() to define which broadcast instance to observe, then ConnectDisplayActionEvent() to register event-command pairs. Each observer consists of a DisplayActionEvent (itkEventObject) and a StdFunctionCommand (itkCommand) that is created internally from the supplied std::function objects.

See also
DisplayActionEventBroadcast DisplayActionEvents StdFunctionCommand

Definition at line 37 of file mitkDisplayActionEventHandler.h.

Member Typedef Documentation

◆ OberserverTagType

Tag type used to identify registered observers.

Definition at line 42 of file mitkDisplayActionEventHandler.h.

Constructor & Destructor Documentation

◆ ~DisplayActionEventHandler()

virtual mitk::DisplayActionEventHandler::~DisplayActionEventHandler ( )
virtual

Destructor. Removes all registered observers.

Member Function Documentation

◆ ConnectDisplayActionEvent()

OberserverTagType mitk::DisplayActionEventHandler::ConnectDisplayActionEvent ( const DisplayActionEvent &  displayActionEvent,
const StdFunctionCommand::ActionFunction &  actionFunction,
const StdFunctionCommand::FilterFunction &  filterFunction = [](const itk::EventObject &) { return true;} 
)

Register an observer for a specific display action event.

Creates a StdFunctionCommand from the given action and filter functions, adds it as an observer to the broadcast, and stores its tag.

Precondition
The observable broadcast must have been set via SetObservableBroadcast().
Exceptions
mitk::Exceptionif the observable is null.
Parameters
displayActionEventThe event type to observe.
actionFunctionThe function to execute when the event occurs.
filterFunctionOptional filter checked before execution (defaults to always true).
Returns
A tag identifying the newly created observer.

◆ DisconnectObserver()

void mitk::DisplayActionEventHandler::DisconnectObserver ( OberserverTagType  observerTag)

Remove an observer identified by its tag.

If the tag is not found in the internal list, nothing happens.

Precondition
The observable broadcast must have been set.
Exceptions
mitk::Exceptionif the observable is null.
Parameters
observerTagThe tag identifying the observer to remove.

◆ GetAllObserverTags()

const std::vector<OberserverTagType>& mitk::DisplayActionEventHandler::GetAllObserverTags ( )
inline

Get all currently registered observer tags.

Returns
A const reference to the vector of observer tags.

Definition at line 95 of file mitkDisplayActionEventHandler.h.

◆ InitActions()

void mitk::DisplayActionEventHandler::InitActions ( std::string  prefixFilter = "")

Initialize pre-defined display actions and connect them to the broadcast.

Removes all currently connected observers, then calls InitActionsImpl() to let sub-classes define their specific set of actions.

Precondition
The observable broadcast must have been set.
Exceptions
mitk::Exceptionif the observable is null.
Parameters
prefixFilterOnly react to / send changes to renderers whose name starts with this prefix.

◆ InitActionsImpl()

virtual void mitk::DisplayActionEventHandler::InitActionsImpl ( const std::string &  prefixFilter = "")
protectedvirtual

Override in sub-classes to define default display action connections.

Parameters
prefixFilterOnly react to / send changes to renderers whose name starts with this prefix.

Reimplemented in mitk::DisplayActionEventHandlerSynchronized, mitk::DisplayActionEventHandlerStd, and mitk::DisplayActionEventHandlerDesynchronized.

◆ SetObservableBroadcast()

void mitk::DisplayActionEventHandler::SetObservableBroadcast ( DisplayActionEventBroadcast *  observableBroadcast)

Set the DisplayActionEventBroadcast instance to observe.

This class receives events from the given broadcast and triggers the corresponding action functions.

Postcondition
If the same broadcast was already set, nothing changes.
If a different broadcast was already set, all previously registered observers are removed.
Parameters
observableBroadcastThe broadcast instance to observe.

Member Data Documentation

◆ m_ObservableBroadcast

WeakPointer<DisplayActionEventBroadcast> mitk::DisplayActionEventHandler::m_ObservableBroadcast
protected

Definition at line 119 of file mitkDisplayActionEventHandler.h.

◆ m_ObserverTags

std::vector<OberserverTagType> mitk::DisplayActionEventHandler::m_ObserverTags
protected

Definition at line 120 of file mitkDisplayActionEventHandler.h.


The documentation for this class was generated from the following file: