Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
QmitkSegmentationTaskListWidget.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef QmitkSegmentationTaskListWidget_h
14 #define QmitkSegmentationTaskListWidget_h
15 
16 #include <mitkForm.h>
18 
20 
22 
23 #include <QWidget>
24 
25 #include <optional>
26 #include <memory>
27 #include <filesystem>
28 
29 class QFileSystemWatcher;
30 
31 namespace Ui
32 {
34 }
35 
45 {
46  Q_OBJECT
47 
48 public:
50  explicit QmitkSegmentationTaskListWidget(QWidget* parent = nullptr);
52 
54  void SetDataStorage(mitk::DataStorage* dataStorage);
56  void CheckDataStorage(const mitk::DataNode* removedNode = nullptr);
57 
59  bool ActiveTaskIsShown() const;
63  void SaveActiveTask(bool saveAsInterimResult = false);
65  bool OnPreShutdown();
66 
67 signals:
69  void ActiveTaskChanged(const std::optional<size_t>& index);
71  void CurrentTaskChanged(const std::optional<size_t>& index);
72 
73 private:
74  void OnSelectionChanged(const QmitkSingleNodeSelectionWidget::NodeList& nodes);
75  void ResetControls();
76  void SetTaskList(mitk::SegmentationTaskList* task);
77  void ResetFileSystemWatcher();
78  void OnResultDirectoryChanged(const QString&);
79  void UpdateProgressBar();
80  void OnTaskListChanged(mitk::SegmentationTaskList* task);
81  void OnPreviousButtonClicked();
82  void OnNextButtonClicked();
83  void OnFindButtonClicked();
84  void OnCurrentTaskChanged();
85  void UpdateLoadButton();
86  void UpdateNavigationButtons();
87  void UpdateDetailsLabel();
88  void UpdateFormWidget();
89  void OnFormSubmission();
90  void UpdateStoreAndAcceptButtons();
91  void OnLoadButtonClicked();
92  mitk::DataNode* GetImageDataNode(size_t index) const;
93  void UnloadTasks(const mitk::DataNode* skip = nullptr);
94  void LoadTask(mitk::DataNode::Pointer imageNode = nullptr);
95  void SubscribeToActiveSegmentation();
96  void UnsubscribeFromActiveSegmentation();
97  void OnSegmentationModified();
98  void SetActiveTaskIndex(const std::optional<size_t>& index);
99  void SetCurrentTaskIndex(const std::optional<size_t>& index);
100  bool HandleUnsavedChanges(const QString& alternativeTitle = QString());
101  void OnUnsavedChangesSaved();
102  void OnPreviousTaskShortcutActivated();
103  void OnNextTaskShortcutActivated();
104  void OnFindTaskShortcutActivated();
105  void OnLoadTaskShortcutActivated();
106  void OnStoreInterimResultShortcutActivated();
107  void OnAcceptSegmentationShortcutActivated();
108  void OnStoreButtonClicked();
109  void OnAcceptButtonClicked();
110 
111  std::unique_ptr<Ui::QmitkSegmentationTaskListWidget> m_Ui;
112  QFileSystemWatcher* m_FileSystemWatcher;
113  mitk::DataStorage* m_DataStorage;
114  mitk::SegmentationTaskList::Pointer m_TaskList;
115  mitk::Forms::Form m_Form;
116  mitk::DataNode::Pointer m_TaskListNode;
117  mitk::DataNode* m_ImageNode;
118  mitk::DataNode* m_SegmentationNode;
119  std::optional<size_t> m_CurrentTaskIndex;
120  std::optional<size_t> m_ActiveTaskIndex;
121  std::optional<unsigned long> m_SegmentationModifiedObserverTag;
122  bool m_UnsavedChanges;
123 };
124 
125 namespace mitk
126 {
132  enum class SceneFileForm
133  {
134  Zip,
137  };
138 
153  MITKSEGMENTATIONUI_EXPORT SceneFileForm ClassifyTaskListSceneFile(const std::filesystem::path& scenePath);
154 }
155 
156 #endif
#define MITKSEGMENTATIONUI_EXPORT
Widget for managing segmentation task lists.
void LoadNextUnfinishedTask()
Loads the next unfinished task from the task list.
void CheckDataStorage(const mitk::DataNode *removedNode=nullptr)
Checks data storage consistency, optionally after a node removal.
void SetDataStorage(mitk::DataStorage *dataStorage)
Sets the data storage used for loading task data nodes.
void CurrentTaskChanged(const std::optional< size_t > &index)
Emitted when the current (browsed) task changes. The index is std::nullopt when no task is current.
void SaveActiveTask(bool saveAsInterimResult=false)
Saves the currently active task, optionally as an interim result.
bool ActiveTaskIsShown() const
Returns true if the currently active task is shown in the widget.
void ActiveTaskChanged(const std::optional< size_t > &index)
Emitted when the active task changes. The index is std::nullopt when no task is active.
bool OnPreShutdown()
Called during application shutdown; prompts for unsaved changes if needed. Returns false to cancel sh...
QmitkSegmentationTaskListWidget(QWidget *parent=nullptr)
Constructs the segmentation task list widget.
QmitkAbstractNodeSelectionWidget::NodeList NodeList
Central node class of the MITK data tree, associating a data object with properties and mappers.
Definition: mitkDataNode.h:72
Abstract data management class that organizes DataNode objects in a directed acyclic graph.
A form consisting of questions possibly divided into multiple sections/pages.
Definition: mitkForm.h:41
A list of segmentation tasks.
Find image slices visible on a given plane.
SceneFileForm
The scene file forms a Segmentation Task List accepts as a Scene.Path.
MITKSEGMENTATIONUI_EXPORT SceneFileForm ClassifyTaskListSceneFile(const std::filesystem::path &scenePath)
Classify a Segmentation Task List Scene.Path by its accepted file form.