|
Medical Imaging Interaction Toolkit
2026.06.00
Medical Imaging Interaction Toolkit
|
GUI widget for the nnInteractiveTool segmentation tool. More...
#include <QmitknnInteractiveToolGUI.h>


Public Member Functions | |
| mitkClassMacro (QmitknnInteractiveToolGUI, QmitkSegWithPreviewToolGUIBase) | |
Public Member Functions inherited from QmitkSegWithPreviewToolGUIBase | |
| mitkClassMacro (QmitkSegWithPreviewToolGUIBase, QmitkToolGUI) | |
| Pointer | Clone () const |
| virtual bool | GetMode2D () const |
Public Member Functions inherited from QmitkToolGUI | |
| mitkClassMacroItkParent (QmitkToolGUI, itk::Object) | |
| void | SetTool (mitk::Tool *tool) |
| Associates the given tool with this GUI, emitting NewToolAssociated. More... | |
| void | SetMultiLabelInspector (QmitkMultiLabelInspector *inspector) |
| Provides the segmentation view's label inspector to this GUI. More... | |
| QmitkMultiLabelInspector * | GetMultiLabelInspector () const |
| Returns the inspector associated with this GUI, or null if none. More... | |
| void | Register () const override |
| Intentional no-op; prevents ITK reference counting from interfering with Qt ownership. More... | |
| void | UnRegister () const ITK_NOEXCEPT ITK_OVERRIDE |
| Intentional no-op; prevents ITK reference counting from interfering with Qt ownership. More... | |
| void | SetReferenceCount (int) override |
| Intentional no-op; prevents ITK reference counting from interfering with Qt ownership. More... | |
| ~QmitkToolGUI () override | |
Static Public Member Functions | |
| static Pointer | New () |
Protected Types | |
| using | InteractionType = mitk::nnInteractive::InteractionType |
| Alias for mitk::nnInteractive::InteractionType. More... | |
| using | PromptType = mitk::nnInteractive::PromptType |
| Alias for mitk::nnInteractive::PromptType. More... | |
Protected Types inherited from QmitkSegWithPreviewToolGUIBase | |
| using | EnableConfirmSegBtnFunctionType = std::function< bool(bool)> |
Protected Member Functions | |
| QmitknnInteractiveToolGUI () | |
| Constructs the GUI with confirm segmentation button disabled by default. More... | |
| ~QmitknnInteractiveToolGUI () override | |
| Destructor. Restores any override cursors and disconnects events. More... | |
| void | InitializeUI (QBoxLayout *mainLayout) override |
| Initializes the UI widgets and connects signals. More... | |
| void | InitializePromptType () |
| Initializes the prompt type button group and shortcut. More... | |
| void | InitializeInteractorButtons () |
| Initializes the interactor toggle buttons with icons and shortcuts. More... | |
| void | EnableInitializeButtons (bool enabled) |
| Enables or disables the initialize and settings buttons. More... | |
| void | OnInitializeButtonToggled (bool checked) |
| Handles the initialize button toggle event. More... | |
| void | OnSettingsButtonClicked () |
| Opens the nnInteractive preferences dialog. More... | |
| void | OnResetInteractionsButtonClicked () |
| Resets all interactions and switches to positive prompt type. More... | |
| void | OnUndoButtonClicked () |
| Undoes the last interaction and refreshes the Undo button state. More... | |
| void | OnAutoRefineCheckBoxToggled (bool checked) |
| Handles auto-refine checkbox toggle. More... | |
| void | OnAutoZoomCheckBoxToggled (bool checked) |
| Handles auto-zoom checkbox toggle. More... | |
| void | OnPromptTypeChanged () |
| Handles prompt type changes between positive and negative. More... | |
| void | OnInteractorToggled (mitk::nnInteractive::InteractionType interactionType, bool checked) |
| Handles toggling of an interactor button. More... | |
| void | OnActiveLabelChanged (const mitk::MultiLabelSegmentation::LabelValueVectorType &labels) |
| Reacts to a change of the selected label in the host's label inspector while a session is running. More... | |
| void | OnConfirmCleanUp (bool isConfirmed) |
| Handles cleanup confirmation from the tool. More... | |
| void | OnPreviewUpdated () |
| Handles the tool's PreviewUpdatedEvent. More... | |
| void | OnToolDeactivated () |
| Handles the tool's DeactivatedEvent. More... | |
| void | OnSessionEnded () |
| Handles the tool's SessionEndedEvent. More... | |
| void | OnSessionExpired () |
| Handles the tool's SessionExpiredEvent. More... | |
| void | OnHeartbeatTimeout () |
| Sends a keep-alive heartbeat to the remote nnInteractive server. More... | |
| void | UpdateModelLicenseDisplay (const std::optional< std::string > &license) |
Shows the model checkpoint license below the Initialize button, or clears it when passed std::nullopt. More... | |
| mitk::nnInteractiveTool * | GetTool () |
| Returns the connected nnInteractiveTool. More... | |
| void | UncheckOtherInteractorButtons (QPushButton *interactorButton) |
| Unchecks all interactor buttons except the specified one. More... | |
| bool | Install () |
| Checks if nnInteractive is installed and shows the install dialog if not. More... | |
Protected Member Functions inherited from QmitkSegWithPreviewToolGUIBase | |
| QmitkSegWithPreviewToolGUIBase (bool mode2D, bool enableProcessingOfAllTimeSteps=true) | |
| ~QmitkSegWithPreviewToolGUIBase () override | |
| virtual void | DisconnectOldTool (mitk::SegWithPreviewTool *oldTool) |
| virtual void | ConnectNewTool (mitk::SegWithPreviewTool *newTool) |
| void | BusyStateChanged (bool isBusy) override |
| Called when the tool's busy state changes. Override to enable/disable UI elements. More... | |
| virtual void | EnableWidgets (bool enabled) |
| template<class TTool > | |
| TTool * | GetConnectedToolAs () |
| void | SetMergeStyle (mitk::MultiLabelSegmentation::MergeStyle mergeStyle) |
| void | SetOverwriteStyle (mitk::MultiLabelSegmentation::OverwriteStyle overwriteStyle) |
| QPushButton * | GetConfirmSegmentationButton () const |
| QCheckBox * | GetPreviewVisibilityCheckBox () const |
| QLabel * | GetPreviewLabel () const |
Protected Member Functions inherited from QmitkToolGUI | |
| QmitkToolGUI ()=default | |
Additional Inherited Members | |
Signals inherited from QmitkToolGUI | |
| void | NewToolAssociated (mitk::Tool *) |
| Emitted when a new tool is associated with this GUI via SetTool(). More... | |
Protected Slots inherited from QmitkSegWithPreviewToolGUIBase | |
| void | OnNewToolAssociated (mitk::Tool *) |
| void | OnAcceptPreview () |
| void | OnPreviewOpacityChanged (int value) |
| void | OnPreviewVisibilityToggled (bool checked) |
Protected Attributes inherited from QmitkSegWithPreviewToolGUIBase | |
| EnableConfirmSegBtnFunctionType | m_EnableConfirmSegBtnFnc |
Protected Attributes inherited from QmitkToolGUI | |
| mitk::Tool::Pointer | m_Tool |
| QmitkMultiLabelInspector * | m_MultiLabelInspector |
GUI widget for the nnInteractiveTool segmentation tool.
This class provides the user interface for the nnInteractive segmentation tool. It extends QmitkSegWithPreviewToolGUIBase and manages:
Definition at line 65 of file QmitknnInteractiveToolGUI.h.
Alias for mitk::nnInteractive::InteractionType.
Definition at line 75 of file QmitknnInteractiveToolGUI.h.
|
protected |
Alias for mitk::nnInteractive::PromptType.
Definition at line 78 of file QmitknnInteractiveToolGUI.h.
|
protected |
Constructs the GUI with confirm segmentation button disabled by default.
|
overrideprotected |
Destructor. Restores any override cursors and disconnects events.
|
protected |
Enables or disables the initialize and settings buttons.
| [in] | enabled | Whether the buttons should be enabled. |
|
protected |
Returns the connected nnInteractiveTool.
|
protected |
Initializes the interactor toggle buttons with icons and shortcuts.
|
protected |
Initializes the prompt type button group and shortcut.
|
overrideprotectedvirtual |
Initializes the UI widgets and connects signals.
Sets up the form from the .ui file, initializes icons, prompt type buttons, interactor buttons, checkboxes, keyboard shortcuts, and connects all signal/slot connections.
| [in] | mainLayout | The parent layout to add the GUI widgets to. |
Reimplemented from QmitkSegWithPreviewToolGUIBase.
|
protected |
Checks if nnInteractive is installed and shows the install dialog if not.
Creates the virtual environment and installs all required packages.
true if nnInteractive is installed (or was successfully installed), false otherwise. | QmitknnInteractiveToolGUI::mitkClassMacro | ( | QmitknnInteractiveToolGUI | , |
| QmitkSegWithPreviewToolGUIBase | |||
| ) |
|
static |
|
protected |
Reacts to a change of the selected label in the host's label inspector while a session is running.
Acts only on a single-label selection and delegates to MaybeInitializeWithLabelMask(), which seeds the session from the selected label if it has content.
| [in] | labels | The now-selected label values. |
|
protected |
Handles auto-refine checkbox toggle.
| [in] | checked | Whether auto-refine should be enabled. |
|
protected |
Handles auto-zoom checkbox toggle.
| [in] | checked | Whether auto-zoom should be enabled. |
|
protected |
Handles cleanup confirmation from the tool.
| [in] | isConfirmed | Whether the cleanup was confirmed. |
|
protected |
Sends a keep-alive heartbeat to the remote nnInteractive server.
Connected to the heartbeat timer's timeout while a remote session runs. Delegates to nnInteractiveTool::Heartbeat(), which keeps the server-side lease alive and, on a definitive expiry, triggers the SessionExpiredEvent teardown path. Has no effect for local sessions.
|
protected |
Handles the initialize button toggle event.
When checked, creates the virtual environment, Python context, and installs nnInteractive if needed, then starts the inference session.
When unchecked, ends the current inference session.
| [in] | checked | Whether the button is checked. |
|
protected |
Handles toggling of an interactor button.
When checked, enables the corresponding interactor and sets an appropriate cursor. When unchecked, disables the interactor and restores the default cursor.
| [in] | interactionType | The interaction type being toggled. |
| [in] | checked | Whether the interactor should be enabled. |
|
protected |
Handles the tool's PreviewUpdatedEvent.
When "auto-confirm" is enabled, schedules an auto-click of the Confirm button on the next event-loop tick. No-op otherwise.
|
protected |
Handles prompt type changes between positive and negative.
Re-enables the currently active interactor with the new prompt type and updates the cursor accordingly.
|
protected |
Resets all interactions and switches to positive prompt type.
Also clears the auto-created-label tracking via InvalidateAutoCreatedLabel() so the next deactivation does not try to remove a label the user has effectively re-claimed by resetting.
|
protected |
Handles the tool's SessionEndedEvent.
Reverts the session-dependent UI controls (interactor toggles, prompt type, reset, settings) back to their pre-init state and re-enables the Initialize button. Fires when the user changes the time step during a 4D session, and also as part of a normal tool deactivation (where the extra UI revert is harmless because the GUI is being torn down).
|
protected |
Handles the tool's SessionExpiredEvent.
A remote session was lost server-side (idle timeout, server restart, or the server is at capacity / unreachable). The session is still live when this fires: it stops the heartbeat timer and defers teardown to the next event-loop tick (AbortSession(), which ends the session and clears the interactions and preview), then informs the user that they need to re-initialize. Deferring both the teardown and the dialog avoids re-entrancy when the event fires from within an interaction. A guard ensures a second expiry event cannot stack a duplicate teardown or dialog.
|
protected |
Opens the nnInteractive preferences dialog.
|
protected |
Handles the tool's DeactivatedEvent.
Runs on a proper user-initiated tool deactivation (as opposed to the GUI's Qt destructor, which may fire during application shutdown when observers and widgets are partially destroyed). Performs the unused- auto-label cleanup here so we never touch the segmentation from the destructor path.
|
protected |
Undoes the last interaction and refreshes the Undo button state.
Delegates to nnInteractiveTool::UndoLastInteraction(), which reverts the most recent interaction (single-level) and removes its prompt visualization.
|
protected |
Unchecks all interactor buttons except the specified one.
| [in] | interactorButton | The button to keep checked, or nullptr to uncheck all. |
|
protected |
Shows the model checkpoint license below the Initialize button, or clears it when passed std::nullopt.
Mirrors the napari plugin: a normal license string is shown as "Model license: <value>", the "!!MISSING!!" sentinel is shown as a red "Model license: UNKNOWN (warning!)", and an empty/absent license hides the label. Driven by the session lifecycle, so it works for local and remote sessions alike.