Medical Imaging Interaction Toolkit
2025.08.99-f7084adb
Medical Imaging Interaction Toolkit
|
Base class for all nnInteractive interactors. More...
#include <mitknnInteractiveInteractor.h>
Public Member Functions | |
virtual | ~Interactor () |
InteractionType | GetType () const |
Returns the interaction type associated with this interactor. More... | |
void | SetToolManager (ToolManager *toolManager) |
Sets the ToolManager for this interactor. More... | |
void | HandleEvent (InteractionEvent *event) |
Handles an interaction event. More... | |
void | Enable (PromptType promptType) |
Enables the interactor for the given prompt type. More... | |
void | Disable () |
Disables the interactor. More... | |
bool | IsEnabled () const |
Checks whether the interactor is currently enabled. More... | |
void | Reset () |
Resets the interactor to its initial state. More... | |
std::string | GetIcon () const |
Retrieves the SVG icon as a string from module resources. More... | |
std::string | GetCursor (PromptType promptType) const |
Retrieves the SVG cursor as a string from module resources based on PromptType. More... | |
virtual bool | HasInteractions () const =0 |
Checks whether any interactions have occurred. More... | |
Public Attributes | |
Message1< bool > | UpdatePreviewEvent |
Event triggered after an interaction has occurred. More... | |
Protected Member Functions | |
Interactor (InteractionType type, InteractionMode mode=InteractionMode::Default) | |
Constructs an interactor with a given type and mode. More... | |
virtual void | OnSetToolManager () |
Called when a ToolManager is assigned. More... | |
virtual void | OnHandleEvent (InteractionEvent *) |
Called when an interaction event for a tool is received. More... | |
virtual void | OnEnable ()=0 |
Called when the interactor is enabled. More... | |
virtual void | OnDisable ()=0 |
Called when the interactor is disabled. More... | |
virtual void | OnReset ()=0 |
Called when the interactor is reset. More... | |
ToolManager * | GetToolManager () const |
Returns the ToolManager associated with this interactor. More... | |
DataStorage * | GetDataStorage () const |
Convenience method for accessing the DataStorage. More... | |
PromptType | GetCurrentPromptType () const |
Returns the currently active prompt type. More... | |
Base class for all nnInteractive interactors.
This class encapsulates the common logic and control interface for nnInteractive interactors. Essentially, they can be enabled, disabled, and reset. Derived classes must respond to these events by overriding the corresponding methods: OnEnable(), OnDisable(), and OnReset().
nnInteractive interactors are typically implemented by reusing either existing MITK interactors or manual segmentation tools. For the latter, methods like OnSetToolManager() and OnHandleEvent() can be overridden to properly configure tools and forward relevant events to them.
Utility methods such as GetToolManager(), GetDataStorage(), and GetCurrentPromptType() provide essential functionality for derived classes.
Derived classes are pragmatically linked to this base class through their InteractionType, an enum class with enumerators for each interactor. This simplifies handling collections of interactors, such as using InteractionType as a key in maps (see GetType()).
This base class optionally blocks global crosshair navigation via left clicks while an nnInteractive interactor is enabled. This allows derived classes to use plain left clicks in MITK interactor event configurations, which would otherwise require modifier keys (see InteractionMode).
nnInteractive interactors are mutually exclusive, and the client is responsible for ensuring that no more than one interactor is enabled at a time.
Definition at line 57 of file mitknnInteractiveInteractor.h.
|
virtual |
|
explicitprotected |
Constructs an interactor with a given type and mode.
If a derived class uses InteractionMode::BlockLMBDisplayInteraction, the crosshair navigation via left click will be blocked while the interactor is enabled.
type | The interaction type associated with this interactor. |
mode | The interaction mode, defaulting to InteractionMode::Default. |
void mitk::nnInteractive::Interactor::Disable | ( | ) |
Disables the interactor.
Derived classes must implement OnDisable() to define specific behavior.
If crosshair navigation via left click was previously blocked, it will be unblocked after this method is called.
void mitk::nnInteractive::Interactor::Enable | ( | PromptType | promptType | ) |
Enables the interactor for the given prompt type.
Derived classes must implement OnEnable() to define specific behavior. To switch the prompt type for an enabled interactor, simply call this method again and it will automatically call Disable() before re-enabling the interactor for the other prompt type.
If a derived class uses InteractionMode::BlockLMBDisplayInteraction, the crosshair navigation via left click will be blocked while the interactor is enabled.
|
protected |
std::string mitk::nnInteractive::Interactor::GetCursor | ( | PromptType | promptType | ) | const |
Retrieves the SVG cursor as a string from module resources based on PromptType.
The cursor path is automatically determined using the InteractionType and the specified PromptType, e.g., "nnInteractive/PositivePointCursor.svg". Returns an empty string if the cursor is not found in the resources.
|
protected |
Convenience method for accessing the DataStorage.
SetToolManager() must be called beforehand.
std::string mitk::nnInteractive::Interactor::GetIcon | ( | ) | const |
Retrieves the SVG icon as a string from module resources.
The icon path is automatically determined based on the InteractionType, e.g., "nnInteractive/Point.svg". Returns an empty string if the icon is not found in the resources.
|
protected |
Returns the ToolManager associated with this interactor.
SetToolManager() must be called beforehand.
InteractionType mitk::nnInteractive::Interactor::GetType | ( | ) | const |
Returns the interaction type associated with this interactor.
The interaction type serves as a unique identifier for each interactor, allowing them to be easily distinguished or mapped in data structures.
void mitk::nnInteractive::Interactor::HandleEvent | ( | InteractionEvent * | event | ) |
Handles an interaction event.
This method forwards input events to enabled interactors. If a derived class uses a segmentation tool class, override OnHandleEvent() to call Tool::HandleEvent().
|
pure virtual |
Checks whether any interactions have occurred.
Derived classes must implement this method to determine whether the interactor has processed any interactions.
Implemented in mitk::nnInteractive::BoxInteractor, mitk::nnInteractive::LassoInteractor, mitk::nnInteractive::ScribbleInteractor, and mitk::nnInteractive::PointInteractor.
bool mitk::nnInteractive::Interactor::IsEnabled | ( | ) | const |
Checks whether the interactor is currently enabled.
|
protectedpure virtual |
Called when the interactor is disabled.
Derived classes must implement this method to define specific behavior when the interactor is deactivated.
|
protectedpure virtual |
Called when the interactor is enabled.
Derived classes must implement this method to define specific behavior when the interactor is activated.
|
inlineprotectedvirtual |
Called when an interaction event for a tool is received.
Invoked only when the interactor is enabled.
Derived classes can override this method to forward the event to their tool.
Definition at line 190 of file mitknnInteractiveInteractor.h.
|
protectedpure virtual |
Called when the interactor is reset.
Derived classes must implement this method to handle reset logic, ensuring the interactor returns to a clean state.
|
inlineprotectedvirtual |
Called when a ToolManager is assigned.
Derived classes can override this method to configure tools and set up necessary connections when a ToolManager is assigned.
Definition at line 179 of file mitknnInteractiveInteractor.h.
void mitk::nnInteractive::Interactor::Reset | ( | ) |
void mitk::nnInteractive::Interactor::SetToolManager | ( | ToolManager * | toolManager | ) |
Sets the ToolManager for this interactor.
The ToolManager is responsible for managing segmentation tools potentially used by derived classes. This method should be called as early as possible to ensure that derived classes have access to the tool manager (and data storage) if needed.
Message1<bool> mitk::nnInteractive::Interactor::UpdatePreviewEvent |
Event triggered after an interaction has occurred.
The signature matches SegWithPreviewTool::UpdatePreview().
Definition at line 154 of file mitknnInteractiveInteractor.h.