Medical Imaging Interaction Toolkit  2025.12.02
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 
28 namespace Ui
29 {
31 }
32 
36 {
37  Q_OBJECT
38 
39 public:
40  enum class Mode
41  {
42  NewLabel,
43  RenameLabel
44  };
45 
51  static bool DoRenameLabel(mitk::Label* label, mitk::MultiLabelSegmentation* segmentation, QWidget* parent = nullptr, Mode mode = Mode::NewLabel);
52 
54  const mitk::Label* label = nullptr, Mode mode = Mode::NewLabel, QWidget* parent = nullptr);
56 
57  QString GetName() const;
59  const mitk::Label* GetSuggestion() const;
60 
61 private slots:
62  void OnAccept();
63  void OnFinished(int result);
64  void OnSuggestionSelected();
65  void OnSuggestionDoubleClicked();
66  void OnColorButtonClicked();
67  void OnNameEdited(const QString& text);
68  void OnFilterEdited(const QString& text);
69  void OnFilterClearClicked();
70  void OnAutoFilterToggled(bool checked);
71 
72 private:
73  void InitializeDialog();
74  void SetupConnections();
75  void LoadAndApplyPreferences();
76  void UpdateUI();
77  void UpdateColorButtonBackground();
78  void UpdateNameList();
79  void UpdateSuggestionInfo();
80  void UpdateOKButton();
81  void UpdateControlStates();
82  void ApplyFilter(const QString& filterText);
83  void SelectSuggestionByName(const QString& name);
84  bool TryPreselectMatchingSuggestion(const QString& name);
85  bool GetAutoFilter() const;
86 
87  Ui::QmitkNewSegmentationDialog* m_Ui;
88 
89  Mode m_Mode;
90  bool m_EnforceSuggestions;
91 
93  mitk::Label::Pointer m_Suggestion;
94  QColor m_Color;
95  QString m_Name;
96 
97  int m_TotalSuggestions;
98  int m_VisibleSuggestions;
99 };
100 
101 #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.
Definition: mitkLabel.h:90
MultiLabelSegmentation class for handling labels and layers in a segmentation session.
ConstLabelVector ConstLabelVectorType
itk::RGBPixel< float > Color
Color Standard RGB color typedef (float)
#define MITK_QT_SEGMENTATION