|
Medical Imaging Interaction Toolkit
2026.06.00
Medical Imaging Interaction Toolkit
|
Base class for all nnInteractive interactors. More...
#include <mitknnInteractiveInteractor.h>


Public Member Functions | |
| virtual | ~Interactor () |
| Destructor. More... | |
| 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... | |
| virtual void | RemoveLastInteraction (PromptType promptType)=0 |
| Removes the most recent interaction for the given prompt type. More... | |
Public Attributes | |
| Message1< bool > | UpdatePreviewEvent |
| Event triggered after an interaction has occurred. More... | |
Protected Member Functions | |
| Interactor (InteractionType type) | |
| Constructs an interactor with a given type. More... | |
| virtual void | OnSetToolManager () |
| Called when a ToolManager is assigned. More... | |
| virtual void | OnHandleEvent (InteractionEvent *event) |
| Called when an interaction event 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 an existing MITK interactor or by driving a custom EventStateMachine. In the latter case, OnHandleEvent() can be overridden to forward relevant events to the state machine.
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 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.
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 |
Destructor.
|
explicitprotected |
Constructs an interactor with a given type.
| type | The interaction type associated with this interactor. |
| void mitk::nnInteractive::Interactor::Disable | ( | ) |
Disables the interactor.
Derived classes must implement OnDisable() to define specific behavior.
Restores left mouse button crosshair navigation that was blocked while the interactor was enabled.
| 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.
Crosshair navigation via left click is blocked while the interactor is enabled and restored on Disable().
| [in] | promptType | The prompt type (positive or negative) to enable this interactor for. |
|
protected |
Returns the currently active prompt type.
The active prompt type is determined by the most recent call to Enable(). Before the first call to Enable(), the default is PromptType::Positive.
| 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".
| [in] | promptType | The prompt type used to determine the cursor variant. |
|
protected |
Convenience method for accessing the DataStorage.
Retrieves the DataStorage from the associated ToolManager.
nullptr if no ToolManager has been set.| 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".
|
protected |
Returns the ToolManager associated with this interactor.
nullptr if none has been set.| 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().
Events are only forwarded when the interactor is enabled.
| [in] | event | The interaction event to handle. |
|
pure virtual |
Checks whether any interactions have occurred.
Derived classes must implement this method to determine whether the interactor has processed any interactions.
true if at least one interaction has been recorded, false otherwise. Implemented in mitk::nnInteractive::ScribbleInteractor, mitk::nnInteractive::PointInteractor, mitk::nnInteractive::LassoInteractor, and mitk::nnInteractive::BoxInteractor.
| bool mitk::nnInteractive::Interactor::IsEnabled | ( | ) | const |
|
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.
|
protectedvirtual |
Called when an interaction event is received.
Invoked only when the interactor is enabled.
Derived classes can override this method to forward the event to an internal state machine.
| [in] | event | The interaction event to handle. |
|
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.
|
protectedvirtual |
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.
|
pure virtual |
Removes the most recent interaction for the given prompt type.
Drops the last recorded prompt of promptType (the most recently placed point, box, scribble, or lasso) and its visualization. Used to undo the last interaction; the prompt type is the one that was active when that interaction was made, which is not necessarily the currently active prompt type. A no-op if no such interaction exists.
| [in] | promptType | The prompt type whose most recent interaction should be removed. |
Implemented in mitk::nnInteractive::ScribbleInteractor, mitk::nnInteractive::PointInteractor, mitk::nnInteractive::LassoInteractor, and mitk::nnInteractive::BoxInteractor.
| 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.
If the provided ToolManager is the same as the currently set one, this method is a no-op.
| [in] | toolManager | Pointer to the ToolManager to associate with this interactor. |
| Message1<bool> mitk::nnInteractive::Interactor::UpdatePreviewEvent |
Event triggered after an interaction has occurred.
Observers of this event are notified whenever a new interaction is completed (e.g., a point is placed, a box is drawn). The boolean parameter signature matches SegWithPreviewTool::UpdatePreview().
Definition at line 207 of file mitknnInteractiveInteractor.h.