|
Medical Imaging Interaction Toolkit
2026.06.00
Medical Imaging Interaction Toolkit
|
Base class of all tools used by mitk::ToolManager. More...
#include <mitkTool.h>


Public Types | |
| typedef mitk::Label::PixelType | DefaultSegmentationDataType |
Public Types inherited from mitk::EventStateMachine | |
| typedef itk::SmartPointer< StateMachineState > | StateMachineStateType |
Public Member Functions | |
| mitkClassMacro (Tool, EventStateMachine) | |
| virtual us::ModuleResource | GetCursorIconResource () const |
| Returns the cursor icon of the tool wrapped by a usModuleResource. More... | |
| virtual us::ModuleResource | GetIconResource () const |
| Returns the tool button icon of the tool wrapped by a usModuleResource. More... | |
| virtual const char * | GetName () const =0 |
| Returns the name of this tool. Make it short! More... | |
| virtual mitk::Label::AlgorithmType | GetAlgorithmType () const |
| Returns the intrinsic algorithm type of this tool, used to stamp label provenance. More... | |
| virtual const char * | GetGroup () const |
| Name of a group. More... | |
| virtual bool | IsEligibleForAutoInit () const |
| Returns whether this tool is eligible for auto-initialization by ToolManager. More... | |
| virtual void | InitializeStateMachine () |
| Initializes the state machine for this tool based on the interaction type. More... | |
| virtual itk::Object::Pointer | GetGUI (const std::string &toolkitPrefix, const std::string &toolkitPostfix) |
| Interface for GUI creation. More... | |
| virtual NodePredicateBase::ConstPointer | GetReferenceDataPreference () const |
| Returns a predicate describing valid reference data for this tool. More... | |
| virtual NodePredicateBase::ConstPointer | GetWorkingDataPreference () const |
| Returns a predicate describing valid working data for this tool. More... | |
| virtual bool | CanHandle (const BaseData *referenceData, const BaseData *workingData) const |
| Checks if a tool can handle the given reference data and optional working data. More... | |
| virtual bool | ConfirmBeforeDeactivation () |
| Method call to invoke a dialog box just before exiting. More... | |
Public Member Functions inherited from mitk::EventStateMachine | |
| mitkClassMacro (EventStateMachine, InteractionEventHandler) | |
| bool | LoadStateMachine (const std::string &filename, const us::Module *module=nullptr) |
| Load a state machine pattern from an XML resource file. More... | |
| bool | HandleEvent (InteractionEvent *event, DataNode *dataNode) |
| Process an incoming interaction event. More... | |
| void | EnableUndo (bool enable) |
| Enable or disable the undo mechanism for this state machine. More... | |
| void | EnableInteraction (bool enable) |
| Enable or disable the state machine. More... | |
Public Member Functions inherited from mitk::InteractionEventHandler | |
| mitkClassMacroItkParent (InteractionEventHandler, itk::Object) | |
| bool | SetEventConfig (const std::string &filename, const us::Module *module=nullptr) |
| Loads a configuration from an XML resource. More... | |
| bool | SetEventConfig (const EventConfig &config) |
| Loads a configuration from an EventConfig object. More... | |
| EventConfig | GetEventConfig () const |
| Returns the current configuration. More... | |
| bool | AddEventConfig (const std::string &filename, const us::Module *module=nullptr) |
| This method extends the configuration. More... | |
| bool | AddEventConfig (const EventConfig &config) |
| This method extends the configuration. The configuration from the EventConfig object is loaded and only the ones conflicting are replaced by the new one. This way several configurations can be combined. More... | |
Public Member Functions inherited from mitk::InteractionEventObserver | |
| InteractionEventObserver () | |
| virtual | ~InteractionEventObserver () |
| void | Disable () |
| Disable this observer so it no longer receives notifications. More... | |
| void | Enable () |
| Enable this observer so it receives notifications. More... | |
| bool | IsEnabled () const |
| Check whether this observer is currently enabled. More... | |
Public Attributes | |
| Message | GUIProcessEventsMessage |
| To let GUI process new events (e.g. qApp->processEvents() ) More... | |
| Message1< std::string > | ErrorMessage |
| To send error messages (to be shown by some GUI) More... | |
| Message1< bool > | CurrentlyBusy |
| To send whether the tool is busy (to be shown by some GUI) More... | |
| Message1< std::string > | GeneralMessage |
| To send general messages (to be shown by some GUI) More... | |
Protected Member Functions | |
| virtual void | SetToolManager (ToolManager *) |
| ToolManager * | GetToolManager () const |
| mitk::DataStorage * | GetDataStorage () const |
| void | ConnectActionsAndFunctions () override |
| virtual void | Activated () |
| Called when the tool gets activated. More... | |
| virtual void | Deactivated () |
| Called when the tool gets deactivated. More... | |
| Tool (const char *, const us::Module *interactorModule=nullptr) | |
| ~Tool () override | |
| void | Notify (InteractionEvent *interactionEvent, bool isHandled) override |
| Called by the Dispatcher to notify this observer about an InteractionEvent. More... | |
| bool | FilterEvents (InteractionEvent *, DataNode *) override |
Protected Member Functions inherited from mitk::EventStateMachine | |
| EventStateMachine () | |
| ~EventStateMachine () override | |
| void | AddActionFunction (const std::string &action, const ActionFunctionDelegate &delegate) |
| void | AddConditionFunction (const std::string &condition, const ConditionFunctionDelegate &delegate) |
| StateMachineState * | GetCurrentState () const |
| void | ResetToStartState () |
| ResetToStartState Reset state machine to it initial starting state. More... | |
| virtual bool | CheckCondition (const StateMachineCondition &condition, const InteractionEvent *interactionEvent) |
| virtual void | ExecuteAction (StateMachineAction *action, InteractionEvent *interactionEvent) |
| void | SetMouseCursor (const char *xpm[], int hotspotX, int hotspotY) |
| Sets the specified mouse cursor. More... | |
| void | ResetMouseCursor () |
| Resets the mouse cursor to its original state. More... | |
| StateMachineTransition * | GetExecutableTransition (InteractionEvent *event) |
| Returns the executable transition for the given event. More... | |
Protected Member Functions inherited from mitk::InteractionEventHandler | |
| InteractionEventHandler () | |
| ~InteractionEventHandler () override | |
| PropertyList::Pointer | GetAttributes () const |
| std::string | MapToEventVariant (InteractionEvent *interactionEvent) |
| virtual void | ConfigurationChanged () |
Protected Attributes | |
| std::string | m_EventConfig |
| Let subclasses change their event configuration. More... | |
Protected Attributes inherited from mitk::EventStateMachine | |
| bool | m_IsActive |
| UndoController * | m_UndoController |
| bool | m_UndoEnabled |
Additional Inherited Members | |
Protected Types inherited from mitk::EventStateMachine | |
| typedef MessageAbstractDelegate2< StateMachineAction *, InteractionEvent *, void > | ActionFunctionDelegate |
| typedef MessageAbstractDelegate1< const InteractionEvent *, bool > | ConditionFunctionDelegate |
Base class of all tools used by mitk::ToolManager.
Every tool is a mitk::EventStateMachine, which can follow any transition pattern that it likes. Every derived tool should always call SuperClass::Deactivated() at the end of its own implementation of Deactivated, because mitk::Tool resets the interaction configuration in this method. Only if you are very sure that you covered all possible things that might happen to your own tool, you should consider not to reset the configuration.
To learn about the MITK implementation of state machines in general, have a look at Interaction and Undo/Redo Concepts.
To derive a non-abstract tool, you inherit from mitk::Tool (or some other base class further down the inheritance tree), and in your own parameterless constructor (that is called from the itkFactorylessNewMacro that you use) you pass a state machine name (interactor type). Names and .xml-files for valid state machines can be found in different "Interaction" directories (which might be enhanced by you).
You have to implement at least GetName() to provide some identification. Optionally, override GetIconResource() to provide a tool button icon and GetCursorIconResource() for a custom cursor.
Each Tool knows its ToolManager, which can provide the data that the tool should work on.
$Author$
Definition at line 79 of file mitkTool.h.
Definition at line 82 of file mitkTool.h.
|
protected |
|
overrideprotected |
|
protectedvirtual |
Called when the tool gets activated.
Derived tools should call their parents implementation at the beginning of the overriding function.
Reimplemented in mitk::SegWithPreviewTool, mitk::SegTool2D, mitk::SegmentationsProcessingTool, mitk::RegionGrowingTool, mitk::PickingTool, mitk::PaintbrushTool, mitk::OtsuTool3D, mitk::MonaiLabelTool, mitk::MonaiLabel3DTool, mitk::MonaiLabel2DTool, mitk::LabelSelectionTool, mitk::GrowCutTool, mitk::FeedbackContourTool, mitk::EditableContourTool, mitk::ContourTool, and mitk::TotalSegmentatorTool.
|
virtual |
Checks if a tool can handle the given reference data and optional working data.
| [in] | referenceData | Pointer to the data that should be checked as valid reference for the tool. |
| [in] | workingData | Pointer to the data that should be checked as valid working data for this tool. This parameter can be null if no working data is specified so far. |
Reimplemented in mitk::SegWithPreviewTool.
|
virtual |
Method call to invoke a dialog box just before exiting.
The method can be reimplemented in the respective tool class with business logic on when there should be a confirmation dialog from the user before the tool exits.
Reimplemented in mitk::SegWithPreviewTool.
|
overrideprotectedvirtual |
Is called after loading a statemachine. Overwrite this function in specific interactor implementations. Connect actions and functions using the CONNECT_FUNCTION macro within this function.
Reimplemented from mitk::EventStateMachine.
|
protectedvirtual |
Called when the tool gets deactivated.
Derived tools should call their parents implementation at the end of the overriding function.
Reimplemented in mitk::SegWithPreviewTool, mitk::SegTool2D, mitk::SegmentationsProcessingTool, mitk::RegionGrowingTool, mitk::PickingTool, mitk::PaintbrushTool, mitk::MonaiLabelTool, mitk::LabelSelectionTool, mitk::GrowCutTool, mitk::FeedbackContourTool, mitk::EditableContourTool, mitk::ContourTool, and mitk::nnInteractiveTool.
|
overrideprotectedvirtual |
Implements filter scheme for events. Standard implementation accepts events from 2d and 3d windows, and rejects events if DataNode is not visible.
Overwrite this function to adapt for your own needs, for example to filter out events from 3d windows like this:
or to enforce that the interactor only reacts when the corresponding DataNode is selected in the DataManager view..
Reimplemented from mitk::EventStateMachine.
|
virtual |
Returns the intrinsic algorithm type of this tool, used to stamp label provenance.
Base default is MANUAL: the user's direct input (stroke/polygon/click) is the result. Override to SEMIAUTOMATIC when an algorithm determines the affected pixels beyond where the user directly indicated (seeds/parameters/edge-snapping); override to AUTOMATIC when the tool runs with no per-image human input. Read at the writeback choke points and passed to mitk::Label::AddToolUse together with GetName().
Reimplemented in mitk::SegWithPreviewTool, mitk::RegionGrowingTool, mitk::MonaiLabelTool, mitk::LiveWireTool2D, mitk::FillRegionBaseTool, and mitk::TotalSegmentatorTool.
|
virtual |
Returns the cursor icon of the tool wrapped by a usModuleResource.
Reimplemented in mitk::SubtractContourTool, mitk::RegionGrowingTool, mitk::LiveWireTool2D, mitk::LassoTool, mitk::LabelSelectionTool, mitk::FillRegionTool, mitk::EraseRegionTool, mitk::ErasePaintbrushTool, mitk::DrawPaintbrushTool, mitk::CloseRegionTool, and mitk::AddContourTool.
|
protected |
Returns the data storage provided by the toolmanager. May be null (e.g. if ToolManager is not set).
|
virtual |
Name of a group.
You can group several tools by assigning a group name. Graphical tool selectors might use this information to group tools. (What other reason could there be?)
Reimplemented in mitk::SegWithPreviewTool, and mitk::SegmentationsProcessingTool.
|
virtual |
Interface for GUI creation.
This is the basic interface for creation of a GUI object belonging to one tool.
Tools that support a GUI (e.g. for display/editing of parameters) should follow some rules:
|
virtual |
Returns the tool button icon of the tool wrapped by a usModuleResource.
Reimplemented in mitk::SubtractContourTool, mitk::RegionGrowingTool, mitk::PickingTool, mitk::OtsuTool3D, mitk::MonaiLabel3DTool, mitk::MonaiLabel2DTool, mitk::LiveWireTool2D, mitk::LassoTool, mitk::LabelSelectionTool, mitk::GrowCutTool, mitk::FillRegionTool, mitk::EraseRegionTool, mitk::ErasePaintbrushTool, mitk::DrawPaintbrushTool, mitk::CloseRegionTool, mitk::BinaryThresholdULTool, mitk::BinaryThresholdTool, mitk::AddContourTool, mitk::TotalSegmentatorTool, and mitk::nnInteractiveTool.
|
pure virtual |
Returns the name of this tool. Make it short!
This name has to fit into some kind of button in most applications, so take some time to think of a good name!
Implemented in mitk::SubtractContourTool, mitk::RegionGrowingTool, mitk::PickingTool, mitk::OtsuTool3D, mitk::MonaiLabel3DTool, mitk::MonaiLabel2DTool, mitk::LiveWireTool2D, mitk::LassoTool, mitk::LabelSelectionTool, mitk::GrowCutTool, mitk::FillRegionTool, mitk::EraseRegionTool, mitk::ErasePaintbrushTool, mitk::DrawPaintbrushTool, mitk::CloseRegionTool, mitk::BinaryThresholdULTool, mitk::BinaryThresholdTool, mitk::AutoCropTool, mitk::AddContourTool, mitk::TotalSegmentatorTool, and mitk::nnInteractiveTool.
|
virtual |
Returns a predicate describing valid reference data for this tool.
|
protected |
Returns the pointer to the tool manager of the tool. May be null.
|
virtual |
Returns a predicate describing valid working data for this tool.
|
virtual |
Initializes the state machine for this tool based on the interaction type.
|
virtual |
Returns whether this tool is eligible for auto-initialization by ToolManager.
Overload this method and return false to hide this tool from any ToolManager that does not explicitly initialize this tool.
| mitk::Tool::mitkClassMacro | ( | Tool | , |
| EventStateMachine | |||
| ) |
|
overrideprotectedvirtual |
Called by the Dispatcher to notify this observer about an InteractionEvent.
All registered InteractionEventObservers receive every event after it has been offered to DataInteractors. The isHandled flag indicates whether a DataInteractor has already handled the event. Observers that trigger actions should consider this flag to avoid confusing the user with multiple independent actions from one event.
To use state machine infrastructure, forward the event to HandleEvent():
| [in] | interactionEvent | The event being dispatched. |
| [in] | isHandled | True if a DataInteractor already handled this event. |
Implements mitk::InteractionEventObserver.
|
protectedvirtual |
Reimplemented in mitk::nnInteractiveTool.
| Message1<bool> mitk::Tool::CurrentlyBusy |
To send whether the tool is busy (to be shown by some GUI)
Definition at line 97 of file mitkTool.h.
| Message1<std::string> mitk::Tool::ErrorMessage |
To send error messages (to be shown by some GUI)
Definition at line 92 of file mitkTool.h.
| Message1<std::string> mitk::Tool::GeneralMessage |
To send general messages (to be shown by some GUI)
Definition at line 102 of file mitkTool.h.
| Message mitk::Tool::GUIProcessEventsMessage |
To let GUI process new events (e.g. qApp->processEvents() )
Definition at line 87 of file mitkTool.h.
|
protected |
Let subclasses change their event configuration.
Definition at line 243 of file mitkTool.h.