Medical Imaging Interaction Toolkit  2024.12.99-0da743f6
Medical Imaging Interaction Toolkit
QmitkLevelWindowPresetDefinitionDialog.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 QmitkLevelWindowPresetDefinitionDialog_h
14 #define QmitkLevelWindowPresetDefinitionDialog_h
15 
16 #include <MitkQtWidgetsExports.h>
17 
18 #include "ui_QmitkLevelWindowPresetDefinition.h"
19 
20 #include <QDialog>
21 #include <QSortFilterProxyModel>
22 
23 #include <map>
24 #include <string>
25 
28  public Ui::QmitkLevelWindowPresetDefinition
29 {
30  Q_OBJECT
31 
32 public:
33  QmitkLevelWindowPresetDefinitionDialog(QWidget *parent = nullptr, Qt::WindowFlags f = {});
35 
36  void setPresets(std::map<std::string, double> &level,
37  std::map<std::string, double> &window,
38  QString initLevel,
39  QString initWindow);
40 
41  std::map<std::string, double> getLevelPresets();
42 
43  std::map<std::string, double> getWindowPresets();
44 
45 protected slots:
46 
47  void addPreset();
48  void removePreset();
49  void changePreset();
50 
51  void ListViewSelectionChanged(const QItemSelection &, const QItemSelection &);
52  void sortPresets(int index);
53 
54 protected:
55  class PresetTableModel : public QAbstractTableModel
56  {
57  public:
58  struct Entry
59  {
60  std::string name;
61  double level;
62  double window;
63 
64  Entry(const std::string &n, double l, double w) : name(n), level(l), window(w) {}
65  };
66 
67  PresetTableModel(std::map<std::string, double> &levels,
68  std::map<std::string, double> &windows,
69  QObject *parent = nullptr);
70 
71  int rowCount(const QModelIndex &) const override;
72  int columnCount(const QModelIndex &) const override;
73  QVariant data(const QModelIndex &index, int) const override;
74 
75  QVariant headerData(int section, Qt::Orientation orientation, int) const override;
76 
77  void addPreset(std::string &name, double level, double window);
78  void removePreset(const QModelIndex &);
79  void changePreset(int row, std::string &name, double level, double window);
80 
81  void getLevels(std::map<std::string, double> &levels);
82  void getWindows(std::map<std::string, double> &windows);
83 
84  bool contains(std::string &name);
85 
86  Entry getPreset(const QModelIndex &) const;
87 
88  private:
89  std::vector<Entry> m_Entries;
90  };
91 
92  void resizeEvent(QResizeEvent *event) override;
93  void showEvent(QShowEvent *event) override;
94 
95  void resizeColumns();
96 
98  QSortFilterProxyModel m_SortModel;
99 };
100 
101 #endif
QmitkLevelWindowPresetDefinitionDialog::m_SortModel
QSortFilterProxyModel m_SortModel
Definition: QmitkLevelWindowPresetDefinitionDialog.h:98
QmitkLevelWindowPresetDefinitionDialog::PresetTableModel::Entry::level
double level
Definition: QmitkLevelWindowPresetDefinitionDialog.h:61
MITKQTWIDGETS_EXPORT
#define MITKQTWIDGETS_EXPORT
Definition: MitkQtWidgetsExports.h:15
QmitkLevelWindowPresetDefinitionDialog::PresetTableModel::Entry::Entry
Entry(const std::string &n, double l, double w)
Definition: QmitkLevelWindowPresetDefinitionDialog.h:64
QmitkLevelWindowPresetDefinitionDialog
Definition: QmitkLevelWindowPresetDefinitionDialog.h:27
QmitkLevelWindowPresetDefinitionDialog::PresetTableModel::Entry::name
std::string name
Definition: QmitkLevelWindowPresetDefinitionDialog.h:60
MitkQtWidgetsExports.h
QmitkLevelWindowPresetDefinitionDialog::m_TableModel
PresetTableModel * m_TableModel
Definition: QmitkLevelWindowPresetDefinitionDialog.h:97
QmitkLevelWindowPresetDefinitionDialog::PresetTableModel
Definition: QmitkLevelWindowPresetDefinitionDialog.h:55
QmitkLevelWindowPresetDefinitionDialog::PresetTableModel::Entry
Definition: QmitkLevelWindowPresetDefinitionDialog.h:58
QmitkLevelWindowPresetDefinitionDialog::PresetTableModel::Entry::window
double window
Definition: QmitkLevelWindowPresetDefinitionDialog.h:62