Medical Imaging Interaction Toolkit  2023.12.00
Medical Imaging Interaction Toolkit
QmitkMultiLabelInspector.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 QmitkMultiLabelInspector_h
14 #define QmitkMultiLabelInspector_h
15 
17 #include <mitkWeakPointer.h>
18 
19 #include <QWidget>
20 #include <QItemSelectionModel>
22 
24 class QStyledItemDelegate;
25 class QWidgetAction;
26 
27 namespace Ui
28 {
30 }
31 
32 /*
33 * @brief This is an inspector that offers a tree view on the labels and groups of a MultiLabelSegmentation instance.
34 * It also allows some manipulation operations an the labels/groups accordin to the UI/selection state.
35 */
37 {
38  Q_OBJECT
39 
40 public:
41  QmitkMultiLabelInspector(QWidget* parent = nullptr);
43 
44  bool GetMultiSelectionMode() const;
45 
46  bool GetAllowVisibilityModification() const;
47  bool GetAllowLockModification() const;
48  bool GetAllowLabelModification() const;
51  bool GetModelManipulationOngoing() const;
52 
55 
59  LabelValueVectorType GetSelectedLabels() const;
60 
68  mitk::Label* GetCurrentLabel() const;
69 
70  enum class IndexLevelType
71  {
72  Group,
73  LabelClass,
74  LabelInstance
75  };
76 
81  IndexLevelType GetCurrentLevelType() const;
82 
89  LabelValueVectorType GetCurrentlyAffactedLabelInstances() const;
90 
95  LabelValueVectorType GetLabelInstancesOfSelectedFirstLabel() const;
96 
97 Q_SIGNALS:
103  void CurrentSelectionChanged(LabelValueVectorType labels) const;
104 
112  void GoToLabel(LabelValueType label, const mitk::Point3D& point) const;
113 
121  void LabelRenameRequested(mitk::Label* label, bool rename) const;
122 
124  void ModelUpdated() const;
125 
126 public Q_SLOTS:
127 
134  void SetSelectedLabels(const LabelValueVectorType& selectedLabels);
141  void SetSelectedLabel(mitk::LabelSetImage::LabelValueType selectedLabel);
142 
145  void SetMultiLabelSegmentation(mitk::LabelSetImage* segmentation);
146 
147  void SetMultiSelectionMode(bool multiMode);
148 
149  void SetAllowVisibilityModification(bool visiblityMod);
150  void SetAllowLockModification(bool lockMod);
151  void SetAllowLabelModification(bool labelMod);
152 
153  void SetDefaultLabelNaming(bool defaultLabelNaming);
154 
166  mitk::Label* AddNewLabelInstance();
167 
174  mitk::Label* AddNewLabel();
175 
181  void DeleteLabelInstance();
182 
188  void DeleteLabel();
189 
193  mitk::Label* AddNewGroup();
194 
199  void RemoveGroup();
200 
201  void SetVisibilityOfAffectedLabels(bool visible) const;
202  void SetLockOfAffectedLabels(bool visible) const;
203 
204 protected:
205  void Initialize();
206  void OnModelReset();
207 
210 
212  QStyledItemDelegate* m_LockItemDelegate;
213  QStyledItemDelegate* m_ColorItemDelegate;
214  QStyledItemDelegate* m_VisibilityItemDelegate;
215 
216  Ui::QmitkMultiLabelInspector* m_Controls;
217 
218  LabelValueVectorType GetSelectedLabelsFromSelectionModel() const;
219  void UpdateSelectionModel(const LabelValueVectorType& selectedLabels);
220 
223  mitk::Label* GetFirstSelectedLabelObject() const;
224 
225  mitk::Label* AddNewLabelInternal(const mitk::LabelSetImage::GroupIndexType& containingGroup);
226 
229  mitk::Label* AddNewLabelInstanceInternal(mitk::Label* templateLabel);
230 
231  void RemoveGroupInternal(const mitk::LabelSetImage::GroupIndexType& groupID);
232  void DeleteLabelInternal(const LabelValueVectorType& labelValues);
233 
234 private Q_SLOTS:
244  void OnChangeModelSelection(const QItemSelection& selected, const QItemSelection& deselected);
245 
246  void OnContextMenuRequested(const QPoint&);
247 
248  void OnAddLabel();
249  void OnAddLabelInstance();
250  void OnDeleteGroup();
251  void OnDeleteAffectedLabel();
252  void OnDeleteLabels(bool);
253  void OnClearLabels(bool);
254  void OnMergeLabels(bool);
255 
256  void OnRenameLabel(bool);
257  void OnClearLabel(bool);
258 
259  void OnUnlockAffectedLabels();
260  void OnLockAffectedLabels();
261 
262  void OnSetAffectedLabelsVisible();
263  void OnSetAffectedLabelsInvisible();
264  void OnSetOnlyActiveLabelVisible(bool);
265 
266  void OnItemDoubleClicked(const QModelIndex& index);
267 
268  void WaitCursorOn() const;
269  void WaitCursorOff() const;
270  void RestoreOverrideCursor() const;
271 
272  void PrepareGoToLabel(LabelValueType labelID) const;
273 
274  QWidgetAction* CreateOpacityAction();
275 
276 private:
277  bool m_ShowVisibility = true;
278  bool m_ShowLock = true;
279  bool m_ShowOther = false;
280 
285  bool m_AllowVisibilityModification = true;
286 
289  bool m_AllowLockModification = true;
290 
293  bool m_AllowLabelModification = false;
294 
295  bool m_DefaultLabelNaming = true;
296 
297  bool m_ModelManipulationOngoing = false;
298 };
299 
300 #endif
MITKSEGMENTATIONUI_EXPORT
#define MITKSEGMENTATIONUI_EXPORT
Definition: MitkSegmentationUIExports.h:15
QmitkMultiLabelInspector::m_LastValidSelectedLabels
LabelValueVectorType m_LastValidSelectedLabels
Definition: QmitkMultiLabelInspector.h:211
QmitkMultiLabelInspector::m_ColorItemDelegate
QStyledItemDelegate * m_ColorItemDelegate
Definition: QmitkMultiLabelInspector.h:213
QmitkMultiLabelInspector::LabelValueType
mitk::LabelSetImage::LabelValueType LabelValueType
Definition: QmitkMultiLabelInspector.h:53
QmitkMultiLabelInspector::LabelValueVectorType
mitk::LabelSetImage::LabelValueVectorType LabelValueVectorType
Definition: QmitkMultiLabelInspector.h:54
QmitkMultiLabelTreeModel
Definition: QmitkMultiLabelTreeModel.h:31
QmitkMultiLabelInspector::m_LockItemDelegate
QStyledItemDelegate * m_LockItemDelegate
Definition: QmitkMultiLabelInspector.h:212
QmitkMultiLabelInspector::m_Model
QmitkMultiLabelTreeModel * m_Model
Definition: QmitkMultiLabelInspector.h:208
QmitkMultiLabelTreeModel.h
QmitkMultiLabelInspector::m_VisibilityItemDelegate
QStyledItemDelegate * m_VisibilityItemDelegate
Definition: QmitkMultiLabelInspector.h:214
Ui
Definition: BlueBerryExampleLauncherDialog.h:21
mitk::Label
A data structure describing a label.
Definition: mitkLabel.h:29
mitk::Point< ScalarType, 3 >
QmitkMultiLabelInspector::m_Controls
Ui::QmitkMultiLabelInspector * m_Controls
Definition: QmitkMultiLabelInspector.h:216
mitk::Image::Pointer
itk::SmartPointer< Self > Pointer
Definition: mitkImage.h:81
mitkWeakPointer.h
QmitkMultiLabelInspector
Definition: QmitkMultiLabelInspector.h:36
MitkSegmentationUIExports.h
QmitkMultiLabelInspector::m_Segmentation
mitk::LabelSetImage::Pointer m_Segmentation
Definition: QmitkMultiLabelInspector.h:209
mitk::LabelSetImage::GroupIndexType
std::size_t GroupIndexType
Definition: mitkLabelSetImage.h:61
mitk::LabelSetImage::LabelValueVectorType
std::vector< LabelValueType > LabelValueVectorType
Definition: mitkLabelSetImage.h:66
mitk::LabelSetImage
LabelSetImage class for handling labels and layers in a segmentation session.
Definition: mitkLabelSetImage.h:29
QmitkMultiLabelInspector::IndexLevelType
IndexLevelType
Definition: QmitkMultiLabelInspector.h:70
mitk::LabelSetImage::LabelValueType
mitk::Label::PixelType LabelValueType
Definition: mitkLabelSetImage.h:62