Medical Imaging Interaction Toolkit  2025.08.99-f7084adb
Medical Imaging Interaction Toolkit
mitk::nnInteractive::Interactor Class Referenceabstract

Base class for all nnInteractive interactors. More...

#include <mitknnInteractiveInteractor.h>

Inheritance diagram for mitk::nnInteractive::Interactor:
Collaboration diagram for mitk::nnInteractive::Interactor:

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...
 
ToolManagerGetToolManager () const
 Returns the ToolManager associated with this interactor. More...
 
DataStorageGetDataStorage () const
 Convenience method for accessing the DataStorage. More...
 
PromptType GetCurrentPromptType () const
 Returns the currently active prompt type. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ~Interactor()

virtual mitk::nnInteractive::Interactor::~Interactor ( )
virtual

◆ Interactor()

mitk::nnInteractive::Interactor::Interactor ( InteractionType  type,
InteractionMode  mode = InteractionMode::Default 
)
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.

Note
Enumerators of InteractionType must not be reused across different derived classes. Each interactor must be associated with a unique interaction type.
Parameters
typeThe interaction type associated with this interactor.
modeThe interaction mode, defaulting to InteractionMode::Default.

Member Function Documentation

◆ Disable()

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.

See also
OnDisable()

◆ Enable()

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.

See also
OnEnable()

◆ GetCurrentPromptType()

PromptType mitk::nnInteractive::Interactor::GetCurrentPromptType ( ) const
protected

Returns the currently active prompt type.

The active prompt type is determined by the most recent call to Enable().

See also
Enable()

◆ GetCursor()

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.

◆ GetDataStorage()

DataStorage* mitk::nnInteractive::Interactor::GetDataStorage ( ) const
protected

Convenience method for accessing the DataStorage.

SetToolManager() must be called beforehand.

See also
SetToolManager()

◆ GetIcon()

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.

◆ GetToolManager()

ToolManager* mitk::nnInteractive::Interactor::GetToolManager ( ) const
protected

Returns the ToolManager associated with this interactor.

SetToolManager() must be called beforehand.

See also
SetToolManager()

◆ GetType()

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.

◆ HandleEvent()

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().

◆ HasInteractions()

virtual bool mitk::nnInteractive::Interactor::HasInteractions ( ) const
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.

◆ IsEnabled()

bool mitk::nnInteractive::Interactor::IsEnabled ( ) const

Checks whether the interactor is currently enabled.

◆ OnDisable()

virtual void mitk::nnInteractive::Interactor::OnDisable ( )
protectedpure virtual

Called when the interactor is disabled.

Derived classes must implement this method to define specific behavior when the interactor is deactivated.

See also
Disable()

◆ OnEnable()

virtual void mitk::nnInteractive::Interactor::OnEnable ( )
protectedpure virtual

Called when the interactor is enabled.

Derived classes must implement this method to define specific behavior when the interactor is activated.

See also
Enable()

◆ OnHandleEvent()

virtual void mitk::nnInteractive::Interactor::OnHandleEvent ( InteractionEvent )
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.

See also
HandleEvent(), Tool::HandleEvent()

Definition at line 190 of file mitknnInteractiveInteractor.h.

◆ OnReset()

virtual void mitk::nnInteractive::Interactor::OnReset ( )
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.

Note
Consider calling this method also from a derived class destructor to perform clean up.
See also
Reset()

◆ OnSetToolManager()

virtual void mitk::nnInteractive::Interactor::OnSetToolManager ( )
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.

See also
SetToolManager(), GetToolManager()

Definition at line 179 of file mitknnInteractiveInteractor.h.

◆ Reset()

void mitk::nnInteractive::Interactor::Reset ( )

Resets the interactor to its initial state.

This function clears any ongoing interactions and restores the interactor to a clean state.

Derived classes must implement OnReset() for specific behavior.

See also
OnReset()

◆ SetToolManager()

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.

Member Data Documentation

◆ UpdatePreviewEvent

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.


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