Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef QMITKLEVELWINDOWPRESETDEFINITIONDIALOG_H_
18 #define QMITKLEVELWINDOWPRESETDEFINITIONDIALOG_H_
19 
20 #include <MitkQtWidgetsExports.h>
21 
22 #include "ui_QmitkLevelWindowPresetDefinition.h"
23 
24 #include <QDialog>
25 #include <QSortFilterProxyModel>
26 
27 #include <map>
28 #include <string>
29 
32  public Ui::QmitkLevelWindowPresetDefinition
33 {
34  Q_OBJECT
35 
36 public:
37  QmitkLevelWindowPresetDefinitionDialog(QWidget *parent = nullptr, Qt::WindowFlags f = nullptr);
39 
40  void setPresets(std::map<std::string, double> &level,
41  std::map<std::string, double> &window,
42  QString initLevel,
43  QString initWindow);
44 
45  std::map<std::string, double> getLevelPresets();
46 
47  std::map<std::string, double> getWindowPresets();
48 
49 protected slots:
50 
51  void addPreset();
52  void removePreset();
53  void changePreset();
54 
55  void ListViewSelectionChanged(const QItemSelection &, const QItemSelection &);
56  void sortPresets(int index);
57 
58 protected:
59  class PresetTableModel : public QAbstractTableModel
60  {
61  public:
62  struct Entry
63  {
64  std::string name;
65  double level;
66  double window;
67 
68  Entry(const std::string &n, double l, double w) : name(n), level(l), window(w) {}
69  };
70 
71  PresetTableModel(std::map<std::string, double> &levels,
72  std::map<std::string, double> &windows,
73  QObject *parent = nullptr);
74 
75  int rowCount(const QModelIndex &) const override;
76  int columnCount(const QModelIndex &) const override;
77  QVariant data(const QModelIndex &index, int) const override;
78 
79  QVariant headerData(int section, Qt::Orientation orientation, int) const override;
80 
81  void addPreset(std::string &name, double level, double window);
82  void removePreset(const QModelIndex &);
83  void changePreset(int row, std::string &name, double level, double window);
84 
85  void getLevels(std::map<std::string, double> &levels);
86  void getWindows(std::map<std::string, double> &windows);
87 
88  bool contains(std::string &name);
89 
90  Entry getPreset(const QModelIndex &) const;
91 
92  private:
93  std::vector<Entry> m_Entries;
94  };
95 
96  void resizeEvent(QResizeEvent *event) override;
97  void showEvent(QShowEvent *event) override;
98 
99  void resizeColumns();
100 
102  QSortFilterProxyModel m_SortModel;
103 };
104 
105 #endif /*QMITKLEVELWINDOWPRESETDEFINITIONDIALOG_H_*/
#define MITKQTWIDGETS_EXPORT