Medical Imaging Interaction Toolkit
2018.4.99-389bf124
Medical Imaging Interaction Toolkit
|
This class simplifies the process of adding an itkEventObject-itkCommand pair as an observer of a DisplayActionEventBroadcast instance. The 'SetObservableBroadcast'-function can be used to define the broadcast instance that should be observed. The 'ConnectDisplayActionEvent'-function can be used to add a an observer to the broadcast. Such an observer consists of a DisplayActionEvent (an itkEventObject) and a StdFunctionCommand (an itkCommand). The StdFunctionCommand is created inside the function by the given two std::functions. More...
#include <mitkDisplayActionEventHandler.h>
Public Types | |
using | OberserverTagType = unsigned long |
Public Member Functions | |
virtual | ~DisplayActionEventHandler () |
void | SetObservableBroadcast (DisplayActionEventBroadcast *observableBroadcast) |
Sets the display action event broadcast class that should be observed. This class receives events from the given broadcast class and triggers the "corresponding functions" to perform the custom actions. "Corresponding functions" are std::functions inside commands that observe the specific display action event. More... | |
OberserverTagType | ConnectDisplayActionEvent (const DisplayActionEvent &displayActionEvent, const StdFunctionCommand::ActionFunction &actionFunction, const StdFunctionCommand::FilterFunction &filterFunction=[](const itk::EventObject &) { return true;}) |
Uses the given std::functions to customize a command: The display action event is used to define on which event the command should react. The display action event broadcast class member is then observed by the newly created command. A tag for the command is returned and stored in a member vector. More... | |
void | DisconnectObserver (OberserverTagType observerTag) |
Uses the given observer tag to remove the corresponding custom command as an observer of the observed display action event broadcast class. If the given tag is not contained in the member vector of observer tags, nothing happens. More... | |
const std::vector< OberserverTagType > & | GetAllObserverTags () |
void | InitActions () |
This function can be used by sub-classes to initialize a set of pre-defined DisplayActionEventFunctions and connect them to the observable broadcast member. In order to customize a sub-class behavior this function calls the virtual function InitActionsImpl. All currently connected display action events will be removed as observer from the broadcast instance. More... | |
Protected Member Functions | |
virtual void | InitActionsImpl () |
Sub-classes need to implement this function to define a customized behavior for default action pre-definition. More... | |
Protected Attributes | |
WeakPointer< DisplayActionEventBroadcast > | m_ObservableBroadcast |
std::vector< OberserverTagType > | m_ObserverTags |
This class simplifies the process of adding an itkEventObject-itkCommand pair as an observer of a DisplayActionEventBroadcast instance. The 'SetObservableBroadcast'-function can be used to define the broadcast instance that should be observed. The 'ConnectDisplayActionEvent'-function can be used to add a an observer to the broadcast. Such an observer consists of a DisplayActionEvent (an itkEventObject) and a StdFunctionCommand (an itkCommand). The StdFunctionCommand is created inside the function by the given two std::functions.
Definition at line 33 of file mitkDisplayActionEventHandler.h.
using mitk::DisplayActionEventHandler::OberserverTagType = unsigned long |
Definition at line 37 of file mitkDisplayActionEventHandler.h.
|
virtual |
Definition at line 15 of file mitkDisplayActionEventHandler.cpp.
References m_ObservableBroadcast, and m_ObserverTags.
mitk::DisplayActionEventHandler::OberserverTagType mitk::DisplayActionEventHandler::ConnectDisplayActionEvent | ( | const DisplayActionEvent & | displayActionEvent, |
const StdFunctionCommand::ActionFunction & | actionFunction, | ||
const StdFunctionCommand::FilterFunction & | filterFunction = [](const itk::EventObject&) { return true; } |
||
) |
Uses the given std::functions to customize a command: The display action event is used to define on which event the command should react. The display action event broadcast class member is then observed by the newly created command. A tag for the command is returned and stored in a member vector.
mitk::Exception,if | the class' observable is null. |
displayActionEvent | The 'DisplayActionEvent' on which the command should react. |
actionFunction | A custom std::Function that will be executed if the command receives the correct event. |
filterFunction | A custom std::Function that will be checked before the execution of the action function. If the filter function is not specified, a default filter always returning 'true' will be used. |
Definition at line 54 of file mitkDisplayActionEventHandler.cpp.
References m_ObservableBroadcast, m_ObserverTags, mitkThrow, and mitk::StdFunctionCommand::New().
Referenced by mitk::DisplayActionEventHandlerDesynchronized::InitActionsImpl(), mitk::DisplayActionEventHandlerSynchronized::InitActionsImpl(), and mitk::DisplayActionEventHandlerStd::InitActionsImpl().
void mitk::DisplayActionEventHandler::DisconnectObserver | ( | OberserverTagType | observerTag | ) |
Uses the given observer tag to remove the corresponding custom command as an observer of the observed display action event broadcast class. If the given tag is not contained in the member vector of observer tags, nothing happens.
mitk::Exception,if | the class' observable is null. |
observerTag | The tag to identify the 'StdFunctionCommand' observer. |
Definition at line 72 of file mitkDisplayActionEventHandler.cpp.
References m_ObservableBroadcast, m_ObserverTags, and mitkThrow.
|
inline |
Definition at line 86 of file mitkDisplayActionEventHandler.h.
Referenced by InitActions().
void mitk::DisplayActionEventHandler::InitActions | ( | ) |
This function can be used by sub-classes to initialize a set of pre-defined DisplayActionEventFunctions and connect them to the observable broadcast member. In order to customize a sub-class behavior this function calls the virtual function InitActionsImpl. All currently connected display action events will be removed as observer from the broadcast instance.
mitk::Exception,if | the class' observable is null. |
Definition at line 88 of file mitkDisplayActionEventHandler.cpp.
References GetAllObserverTags(), InitActionsImpl(), m_ObservableBroadcast, m_ObserverTags, and mitkThrow.
|
inlineprotectedvirtual |
Sub-classes need to implement this function to define a customized behavior for default action pre-definition.
Reimplemented in mitk::DisplayActionEventHandlerStd, mitk::DisplayActionEventHandlerDesynchronized, and mitk::DisplayActionEventHandlerSynchronized.
Definition at line 106 of file mitkDisplayActionEventHandler.h.
Referenced by InitActions().
void mitk::DisplayActionEventHandler::SetObservableBroadcast | ( | DisplayActionEventBroadcast * | observableBroadcast | ) |
Sets the display action event broadcast class that should be observed. This class receives events from the given broadcast class and triggers the "corresponding functions" to perform the custom actions. "Corresponding functions" are std::functions inside commands that observe the specific display action event.
observableBroadcast | The 'DisplayActionEventBroadcast'-class that should be observed. |
Definition at line 30 of file mitkDisplayActionEventHandler.cpp.
References m_ObservableBroadcast, and m_ObserverTags.
|
protected |
Definition at line 108 of file mitkDisplayActionEventHandler.h.
Referenced by ConnectDisplayActionEvent(), DisconnectObserver(), InitActions(), SetObservableBroadcast(), and ~DisplayActionEventHandler().
|
protected |
Definition at line 109 of file mitkDisplayActionEventHandler.h.
Referenced by ConnectDisplayActionEvent(), DisconnectObserver(), InitActions(), SetObservableBroadcast(), and ~DisplayActionEventHandler().