Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::nnInteractive::ScribbleInteractor Class Reference

nnInteractive interactor for freehand brushstrokes. More...

#include <mitknnInteractiveScribbleInteractor.h>

Inheritance diagram for mitk::nnInteractive::ScribbleInteractor:
Collaboration diagram for mitk::nnInteractive::ScribbleInteractor:

Public Member Functions

 ScribbleInteractor ()
 Constructs a ScribbleInteractor with InteractionType::Scribble. More...
 
 ~ScribbleInteractor () override
 Destructor. Calls OnReset() to clean up data nodes. More...
 
bool HasInteractions () const override
 Checks whether any scribbles have been drawn. More...
 
Image::ConstPointer GetLastScribbleMask () const
 Returns the binary mask slice of the most recent brushstroke. More...
 
const InteractionBoundingBox * GetLastScribbleBoundingBox () const
 Returns the interaction bounding box for the most recent brushstroke. More...
 
void RemoveLastInteraction (PromptType promptType) override
 Removes the most recently drawn brushstroke for the given prompt type. More...
 
- Public Member Functions inherited from mitk::nnInteractive::Interactor
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...
 

Additional Inherited Members

- Public Attributes inherited from mitk::nnInteractive::Interactor
Message1< bool > UpdatePreviewEvent
 Event triggered after an interaction has occurred. More...
 
- Protected Member Functions inherited from mitk::nnInteractive::Interactor
 Interactor (InteractionType type)
 Constructs an interactor with a given type. More...
 
virtual void OnSetToolManager ()
 Called when a ToolManager is assigned. 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...
 

Detailed Description

nnInteractive interactor for freehand brushstrokes.

Each completed brushstroke is stored as a small 2D uint8 mitk::Image positioned at the stroke's slicing plane and wrapped in a DataNode that gets added to the data storage for persistent cross-slice visualization. Strokes are organized by PromptType (each completed node keeps the color of the prompt type active when it was drawn). The most recent brushstroke is also exposed as a pointer to the 2D mask plus an axis-aligned interaction bounding box in nnInteractive coordinates so the Python call can skip the full 3D volume round-trip.

Interaction is handled through an internal brush state machine that paints directly into a 2D uint8 Image – no 3D working segmentation is involved. Left mouse button display interaction (crosshair navigation) is blocked while the interactor is enabled so that brush strokes do not move the crosshair.

See also
Interactor, nnInteractiveTool

Definition at line 41 of file mitknnInteractiveScribbleInteractor.h.

Constructor & Destructor Documentation

◆ ScribbleInteractor()

mitk::nnInteractive::ScribbleInteractor::ScribbleInteractor ( )

◆ ~ScribbleInteractor()

mitk::nnInteractive::ScribbleInteractor::~ScribbleInteractor ( )
override

Destructor. Calls OnReset() to clean up data nodes.

Member Function Documentation

◆ GetLastScribbleBoundingBox()

const InteractionBoundingBox* mitk::nnInteractive::ScribbleInteractor::GetLastScribbleBoundingBox ( ) const

Returns the interaction bounding box for the most recent brushstroke.

The box is in nnInteractive's coordinate order (reverse of MITK index order): {{z_min,z_max}, {y_min,y_max}, {x_min,x_max}}.

Returns
Pointer to the bounding box, or nullptr if no brushstroke has been drawn yet.

◆ GetLastScribbleMask()

Image::ConstPointer mitk::nnInteractive::ScribbleInteractor::GetLastScribbleMask ( ) const

Returns the binary mask slice of the most recent brushstroke.

The mask is a uint8 image whose extent matches the corresponding interaction bounding box (one voxel thick along the slicing axis). Intended to be passed alongside GetLastScribbleBoundingBox() to session.add_scribble_interaction via nnInteractiveTool. Returning a smart pointer makes the lifetime explicit so callers do not need to know that the underlying member is replaced on the next stroke.

Returns
The mask Image, or a null smart pointer if no brushstroke has been drawn yet.

◆ HasInteractions()

bool mitk::nnInteractive::ScribbleInteractor::HasInteractions ( ) const
overridevirtual

Checks whether any scribbles have been drawn.

Returns
true if at least one completed brushstroke node exists for any prompt type, false otherwise.

Implements mitk::nnInteractive::Interactor.

◆ RemoveLastInteraction()

void mitk::nnInteractive::ScribbleInteractor::RemoveLastInteraction ( PromptType  promptType)
overridevirtual

Removes the most recently drawn brushstroke for the given prompt type.

Removes the last stroke overlay node of promptType from the data storage. A no-op if no stroke exists for that prompt type.

Parameters
[in]promptTypeThe prompt type whose last stroke should be removed.

Implements mitk::nnInteractive::Interactor.


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