Medical Imaging Interaction Toolkit  2025.12.02
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 
26 class QCompleter;
27 class QShortcut;
28 
29 namespace Ui
30 {
31  class QmitkMultiLabelManagerControls;
32 }
33 
34 namespace mitk
35 {
36  class DataStorage;
37 }
38 
40 {
41  Q_OBJECT
42 
43 public:
44  explicit QmitkMultiLabelManager(QWidget *parent = nullptr);
46 
47 
49 
54 
57 
59 
60 Q_SIGNALS:
67 
76 
85  void LabelRenameRequested(mitk::Label* label, bool rename, bool& canceled) const;
86 
87 public Q_SLOTS:
88 
94  void SetSelectedLabels(const LabelValueVectorType& selectedLabels);
95 
102 
113 
121 
123 
125 
127 
128  virtual void setEnabled(bool enabled);
129 
130  QStringList &GetLabelStringList();
131 
132  void SetDefaultLabelNaming(bool defaultLabelNaming);
133 
134 private Q_SLOTS:
135 
136  // LabelSet dependent
137 
138  void OnRenameLabelShortcutActivated();
139 
140  // reaction to the change of labels. If multiple labels are selected, it is ignored.
141  void OnSelectedLabelChanged(const LabelValueVectorType& labels);
142 
143  // MultiLabelSegmentation Dependent
144  void OnCreateDetailedSurface(bool);
145  void OnCreateSmoothedSurface(bool);
146  // reaction to the signal "createMask" from QmitkLabelSetTableWidget
147  void OnCreateMask(bool);
148  // reaction to the signal "createCroppedMask" from QmitkLabelSetTableWidget
149  void OnCreateCroppedMask(bool);
150 
151  void OnSavePreset();
152  void OnLoadPreset();
153 
154  void OnGoToLabel(mitk::MultiLabelSegmentation::LabelValueType label, const mitk::Point3D& position) const;
155  void OnLabelRenameRequested(mitk::Label* label, bool rename, bool& canceled) const;
156  void OnModelUpdated();
157  void OnSegmentationChanged();
158 
159 private:
160  enum TableColumns
161  {
162  NAME_COL = 0,
163  LOCKED_COL,
164  COLOR_COL,
165  VISIBLE_COL
166  };
167 
168  void WaitCursorOn();
169 
170  void WaitCursorOff();
171 
172  void RestoreOverrideCursor();
173 
174  void OnThreadedCalculationDone();
175 
176  void AddSegmentationObserver();
177  void RemoveSegmentationObserver();
178 
179  void OnLabelEvent(mitk::MultiLabelSegmentation::LabelValueType labelValue);
180  void OnGroupEvent(mitk::MultiLabelSegmentation::GroupIndexType groupIndex);
181 
182  Ui::QmitkMultiLabelManagerControls* m_Controls;
183 
184  QStringList m_OrganColors;
185 
186  QStringList m_LabelStringList;
187 
188  QShortcut* m_AddLabelInstanceShortcut;
189 
190  bool m_ProcessingManualSelection;
191 
192  mitk::DataStorage* m_DataStorage;
193 
194  mitk::ITKEventObserverGuard m_LabelAddedObserver;
195  mitk::ITKEventObserverGuard m_LabelModifiedObserver;
196  mitk::ITKEventObserverGuard m_LabelRemovedObserver;
197  mitk::ITKEventObserverGuard m_GroupAddedObserver;
198  mitk::ITKEventObserverGuard m_GroupModifiedObserver;
199  mitk::ITKEventObserverGuard m_GroupRemovedObserver;
200 
201  mitk::LabelSuggestionHelper::ConstPointer m_SuggestionHelper;
202  mitk::ITKEventObserverGuard m_SuggestionObserver;
203 
204 };
205 
206 #endif
#define MITKSEGMENTATIONUI_EXPORT
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
void SetDefaultLabelNaming(bool defaultLabelNaming)
mitk::DataNode * GetMultiLabelNode() const
Class for nodes of the DataTree.
Definition: mitkDataNode.h:64
Data management class that handles 'was created by' relations.
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.
Definition: mitkLabel.h:90
MultiLabelSegmentation class for handling labels and layers in a segmentation session.
std::vector< LabelValueType > LabelValueVectorType
mitk::Label::PixelType LabelValueType
Find image slices visible on a given plane.