Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
QmitkMultiLabelManager.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 QmitkMultiLabelManager_h
14 #define QmitkMultiLabelManager_h
15 
17 
18 #include <mitkLabelSetImage.h>
19 #include <mitkDataNode.h>
20 #include <mitkNumericTypes.h>
23 
24 #include <QWidget>
25 #include <memory>
26 
27 class QCompleter;
28 class QShortcut;
29 
30 namespace Ui
31 {
32  class QmitkMultiLabelManagerControls;
33 }
34 
35 namespace mitk
36 {
37  class DataStorage;
38 }
39 
41 
43 {
44  Q_OBJECT
45 
46 public:
47  explicit QmitkMultiLabelManager(QWidget *parent = nullptr);
49 
50 
52 
57 
60 
63 
65 
66 Q_SIGNALS:
73 
82 
91  void LabelRenameRequested(mitk::Label* label, bool rename, bool& canceled) const;
92 
93 public Q_SLOTS:
94 
100  void SetSelectedLabels(const LabelValueVectorType& selectedLabels);
101 
108 
119 
127 
129 
131 
133 
134  virtual void setEnabled(bool enabled);
135 
136  QStringList &GetLabelStringList();
137 
138  void SetDefaultLabelNaming(bool defaultLabelNaming);
139 
140 private Q_SLOTS:
141 
142  // LabelSet dependent
143 
144  void OnRenameLabelShortcutActivated();
145 
146  // reaction to the change of labels. If multiple labels are selected, it is ignored.
147  void OnSelectedLabelChanged(const LabelValueVectorType& labels);
148 
149  // MultiLabelSegmentation Dependent
150  void OnCreateDetailedSurface(bool);
151  void OnCreateSmoothedSurface(bool);
152  // reaction to the signal "createMask" from QmitkLabelSetTableWidget
153  void OnCreateMask(bool);
154  // reaction to the signal "createCroppedMask" from QmitkLabelSetTableWidget
155  void OnCreateCroppedMask(bool);
156 
157  void OnSavePreset();
158  void OnLoadPreset();
159 
160  void OnGoToLabel(mitk::MultiLabelSegmentation::LabelValueType label, const mitk::Point3D& position) const;
161  void OnLabelRenameRequested(mitk::Label* label, bool rename, bool& canceled) const;
162  void OnModelUpdated();
163  void OnSegmentationChanged();
164 
165 private:
166  enum TableColumns
167  {
168  NAME_COL = 0,
169  LOCKED_COL,
170  COLOR_COL,
171  VISIBLE_COL
172  };
173 
174  void WaitCursorOn();
175 
176  void WaitCursorOff();
177 
178  void RestoreOverrideCursor();
179 
180  void OnThreadedCalculationDone();
181 
182  void AddSegmentationObserver();
183  void RemoveSegmentationObserver();
184 
185  void OnLabelEvent(mitk::MultiLabelSegmentation::LabelValueType labelValue);
186  void OnGroupEvent(mitk::MultiLabelSegmentation::GroupIndexType groupIndex);
187 
188  std::unique_ptr<Ui::QmitkMultiLabelManagerControls> m_Controls;
189 
190  QStringList m_OrganColors;
191 
192  QStringList m_LabelStringList;
193 
194  QShortcut* m_AddLabelInstanceShortcut;
195 
196  bool m_ProcessingManualSelection;
197 
198  mitk::DataStorage* m_DataStorage;
199 
202  mitk::MultiLabelSegmentation::Pointer m_ObservedSegmentation;
203 
204  mitk::ITKEventObserverGuard m_LabelAddedObserver;
205  mitk::ITKEventObserverGuard m_LabelModifiedObserver;
206  mitk::ITKEventObserverGuard m_LabelRemovedObserver;
207  mitk::ITKEventObserverGuard m_GroupAddedObserver;
208  mitk::ITKEventObserverGuard m_GroupModifiedObserver;
209  mitk::ITKEventObserverGuard m_GroupRemovedObserver;
210 
211  mitk::LabelSuggestionHelper::ConstPointer m_SuggestionHelper;
212  mitk::ITKEventObserverGuard m_SuggestionObserver;
213 
214 };
215 
216 #endif
#define MITKSEGMENTATIONUI_EXPORT
Inspector widget providing a tree view on labels and groups of a MultiLabelSegmentation instance.
QmitkMultiLabelManager(QWidget *parent=nullptr)
void SetSelectedLabel(mitk::MultiLabelSegmentation::LabelValueType selectedLabel)
Selects the passed label instance and sets a new selection of the view.
LabelValueVectorType GetSelectedLabels() const
Retrieve the currently selected labels (equals the last CurrentSelectionChanged values).
void SetMultiLabelSegmentation(mitk::MultiLabelSegmentation *segmentation)
Sets the segmentation that will be used /monitored by the widget.
void SetMultiLabelNode(mitk::DataNode *node)
Sets the segmentation node that will be used /monitored by the widget.
void SetLabelSuggestionHelper(const mitk::LabelSuggestionHelper *suggestionHelper)
void CurrentSelectionChanged(const LabelValueVectorType &labels)
A signal that will be emitted if the selected labels change.
QStringList & GetLabelStringList()
void GoToLabel(mitk::MultiLabelSegmentation::LabelValueType label, const mitk::Point3D &point) const
A signal that will be emitted if the user has requested to "go to" a certain label.
void LabelRenameRequested(mitk::Label *label, bool rename, bool &canceled) const
Signal that is emitted, if a label should be (re)named and default label naming is deactivated.
~QmitkMultiLabelManager() override
virtual void setEnabled(bool enabled)
void SetSelectedLabels(const LabelValueVectorType &selectedLabels)
Transform a list label values into a model selection and set this as a new selection of the view.
const mitk::LabelSuggestionHelper * GetLabelSuggestionHelper() const
mitk::MultiLabelSegmentation::LabelValueVectorType LabelValueVectorType
void SetDataStorage(mitk::DataStorage *storage)
mitk::MultiLabelSegmentation * GetMultiLabelSegmentation() const
QmitkMultiLabelInspector * GetMultiLabelInspector() const
Returns the inspector this manager wraps. Never null after construction.
void SetDefaultLabelNaming(bool defaultLabelNaming)
mitk::DataNode * GetMultiLabelNode() const
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.
Convenience class that helps to manage the lifetime of itk event observers.
Helper class for handling label suggestions with constraint checking.
A data structure describing a label in a multi-label segmentation.
Definition: mitkLabel.h:101
MultiLabelSegmentation class for handling labels and layers in a segmentation session.
std::vector< LabelValueType > LabelValueVectorType
mitk::Label::PixelType LabelValueType
Convenience header that includes all MITK numeric types.
Find image slices visible on a given plane.