Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
QmitkNewSegmentationDialog.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 QmitkNewSegmentationDialog_h
14 #define QmitkNewSegmentationDialog_h
15 
17 
18 #include <mitkColorProperty.h>
19 #include <mitkLabelSetImage.h>
20 
21 #include <vector>
22 #include <utility>
23 
24 #include <QColor>
25 #include <QDialog>
26 #include <QString>
27 #include <memory>
28 
29 namespace Ui
30 {
32 }
33 
37 {
38  Q_OBJECT
39 
40 public:
41  enum class Mode
42  {
43  NewLabel,
44  RenameLabel
45  };
46 
52  static bool DoRenameLabel(mitk::Label* label, mitk::MultiLabelSegmentation* segmentation, QWidget* parent = nullptr, Mode mode = Mode::NewLabel);
53 
55  const mitk::Label* label = nullptr, Mode mode = Mode::NewLabel, QWidget* parent = nullptr);
57 
58  QString GetName() const;
60  const mitk::Label* GetSuggestion() const;
61 
62 private slots:
63  void OnAccept();
64  void OnFinished(int result);
65  void OnSuggestionSelected();
66  void OnSuggestionDoubleClicked();
67  void OnColorButtonClicked();
68  void OnNameEdited(const QString& text);
69  void OnFilterEdited(const QString& text);
70  void OnFilterClearClicked();
71  void OnAutoFilterToggled(bool checked);
72 
73 private:
74  void InitializeDialog();
75  void SetupConnections();
76  void LoadAndApplyPreferences();
77  void UpdateUI();
78  void UpdateColorButtonBackground();
79  void UpdateNameList();
80  void UpdateSuggestionInfo();
81  void UpdateOKButton();
82  void UpdateControlStates();
83  void ApplyFilter(const QString& filterText);
84  void SelectSuggestionByName(const QString& name);
85  QString EffectiveNameFilter() const;
86  bool GetAutoFilter() const;
87 
88  std::unique_ptr<Ui::QmitkNewSegmentationDialog> m_Ui;
89 
90  Mode m_Mode;
91  bool m_EnforceSuggestions;
92 
94  mitk::Label::Pointer m_Suggestion;
95  QColor m_Color;
96  QString m_Name;
97  QString m_InitialName;
98 
99  int m_TotalSuggestions;
100  int m_VisibleSuggestions;
101 };
102 
103 #endif
QmitkNewSegmentationDialog(const mitk::MultiLabelSegmentation *labelSetImage, const mitk::Label *label=nullptr, Mode mode=Mode::NewLabel, QWidget *parent=nullptr)
const mitk::Label * GetSuggestion() const
static bool DoRenameLabel(mitk::Label *label, mitk::MultiLabelSegmentation *segmentation, QWidget *parent=nullptr, Mode mode=Mode::NewLabel)
Static helper function to (re)name a label.
mitk::Color GetColor() const
~QmitkNewSegmentationDialog() override
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.
ConstLabelVector ConstLabelVectorType
itk::RGBPixel< float > Color
Standard RGB color typedef using float components.
#define MITK_QT_SEGMENTATION