Medical Imaging Interaction Toolkit  2023.12.99-7a59bd54
Medical Imaging Interaction Toolkit
QmitkNumberPropertyEditor.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 #ifndef QmitkNumberPropertyEditor_h
13 #define QmitkNumberPropertyEditor_h
14 
16 #include <QSpinBox>
17 #include <mitkProperties.h>
18 #include <mitkPropertyObserver.h>
19 
22 {
23  Q_OBJECT
24  Q_PROPERTY(short decimalPlaces READ getDecimalPlaces WRITE setDecimalPlaces)
25  Q_PROPERTY(bool showPercent READ getShowPercent WRITE setShowPercent)
26  Q_PROPERTY(int minValue READ minValue WRITE setMinValue)
27  Q_PROPERTY(int maxValue READ maxValue WRITE setMaxValue)
28 
29 public:
30  QmitkNumberPropertyEditor(mitk::IntProperty *, QWidget *parent);
31  QmitkNumberPropertyEditor(mitk::FloatProperty *, QWidget *parent);
32  QmitkNumberPropertyEditor(mitk::DoubleProperty *, QWidget *parent);
33 
34  ~QmitkNumberPropertyEditor() override;
35 
36  short getDecimalPlaces() const;
37  void setDecimalPlaces(short);
38 
39  bool getShowPercent() const;
40  void setShowPercent(bool);
41 
42  int minValue() const;
43  void setMinValue(int);
44  int maxValue() const;
45  void setMaxValue(int);
46  double doubleValue() const;
47  void setDoubleValue(double);
48 
49 protected:
50  void initialize();
51 
52  QString textFromValue(int) const override;
53  int valueFromText(const QString &) const override;
54 
55  void PropertyChanged() override;
56  void PropertyRemoved() override;
57 
58  void DisplayNumber();
59 
60  union {
64  };
65 
66  const int m_DataType;
67 
68  short m_DecimalPlaces; // how many decimal places are shown
69  double m_FactorPropertyToSpinbox; // internal conversion factor. neccessary because spinbox ranges work only with ints
70  double m_FactorSpinboxToDisplay; // internal conversion factor. neccessary because spinbox ranges work only with ints
71  bool m_ShowPercents; // whether values are given in percent (0.5 -> 50%)
72 
73 protected slots:
74 
75  void onValueChanged(int);
76 
77 private:
78  void adjustFactors(short, bool);
79 
80  bool m_SelfChangeLock;
81 };
82 
83 #endif
MITKQTWIDGETSEXT_EXPORT
#define MITKQTWIDGETSEXT_EXPORT
Definition: MitkQtWidgetsExtExports.h:15
QmitkNumberPropertyEditor::m_IntProperty
mitk::GenericProperty< int > * m_IntProperty
Definition: QmitkNumberPropertyEditor.h:61
QmitkNumberPropertyEditor::m_DecimalPlaces
short m_DecimalPlaces
Definition: QmitkNumberPropertyEditor.h:68
mitk::GenericProperty< int >
QmitkNumberPropertyEditor
Definition: QmitkNumberPropertyEditor.h:21
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
QmitkNumberPropertyEditor::m_DoubleProperty
mitk::GenericProperty< double > * m_DoubleProperty
Definition: QmitkNumberPropertyEditor.h:63
QmitkNumberPropertyEditor::m_FloatProperty
mitk::GenericProperty< float > * m_FloatProperty
Definition: QmitkNumberPropertyEditor.h:62
QmitkNumberPropertyEditor::m_ShowPercents
bool m_ShowPercents
Definition: QmitkNumberPropertyEditor.h:71
mitk::PropertyEditor
Definition: mitkPropertyObserver.h:67
QmitkNumberPropertyEditor::m_FactorPropertyToSpinbox
double m_FactorPropertyToSpinbox
Definition: QmitkNumberPropertyEditor.h:69
QmitkNumberPropertyEditor::m_DataType
const int m_DataType
Definition: QmitkNumberPropertyEditor.h:66
mitkPropertyObserver.h
MitkQtWidgetsExtExports.h
QmitkNumberPropertyEditor::m_FactorSpinboxToDisplay
double m_FactorSpinboxToDisplay
Definition: QmitkNumberPropertyEditor.h:70
mitkProperties.h