Medical Imaging Interaction Toolkit  2026.06.00
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 
32 {
33  Q_OBJECT
34  Q_PROPERTY(short decimalPlaces READ getDecimalPlaces WRITE setDecimalPlaces)
35  Q_PROPERTY(bool showPercent READ getShowPercent WRITE setShowPercent)
36  Q_PROPERTY(int minValue READ minValue WRITE setMinValue)
37  Q_PROPERTY(int maxValue READ maxValue WRITE setMaxValue)
38 
39 public:
45  QmitkNumberPropertyEditor(mitk::IntProperty *property, QWidget *parent);
46 
52  QmitkNumberPropertyEditor(mitk::FloatProperty *property, QWidget *parent);
53 
59  QmitkNumberPropertyEditor(mitk::DoubleProperty *property, QWidget *parent);
60 
63 
68  short getDecimalPlaces() const;
69 
74  void setDecimalPlaces(short places);
75 
80  bool getShowPercent() const;
81 
86  void setShowPercent(bool showPercent);
87 
92  int minValue() const;
93 
98  void setMinValue(int value);
99 
104  int maxValue() const;
105 
110  void setMaxValue(int value);
111 
116  double doubleValue() const;
117 
122  void setDoubleValue(double value);
123 
124 protected:
125  void initialize();
126 
127  QString textFromValue(int) const override;
128  int valueFromText(const QString &) const override;
129 
130  void PropertyChanged() override;
131  void PropertyRemoved() override;
132 
134 
135  union {
139  };
140 
141  const int m_DataType;
142 
143  short m_DecimalPlaces; // how many decimal places are shown
144  double m_FactorPropertyToSpinbox; // internal conversion factor. necessary because spinbox ranges work only with ints
145  double m_FactorSpinboxToDisplay; // internal conversion factor. necessary because spinbox ranges work only with ints
146  bool m_ShowPercents; // whether values are given in percent (0.5 -> 50%)
147 
148 protected slots:
149 
150  void onValueChanged(int);
151 
152 private:
153  void adjustFactors(short, bool);
154 
155  bool m_SelfChangeLock;
156 };
157 
158 #endif
#define MITKQTWIDGETSEXT_EXPORT
A QSpinBox that edits numeric MITK properties (int, float, double).
void setShowPercent(bool showPercent)
Enable or disable percentage display (e.g. 0.5 displayed as 50%).
void setMinValue(int value)
Set the minimum allowed value.
QString textFromValue(int) const override
void PropertyChanged() override
Called when the observed property value has changed.
mitk::GenericProperty< float > * m_FloatProperty
int valueFromText(const QString &) const override
void setMaxValue(int value)
Set the maximum allowed value.
bool getShowPercent() const
Check whether values are displayed as percentages.
void PropertyRemoved() override
Called when the observed property is about to be deleted.
void setDoubleValue(double value)
Set the current value from a double.
QmitkNumberPropertyEditor(mitk::DoubleProperty *property, QWidget *parent)
Construct an editor for a double property.
QmitkNumberPropertyEditor(mitk::IntProperty *property, QWidget *parent)
Construct an editor for an integer property.
short getDecimalPlaces() const
Get the number of decimal places shown.
QmitkNumberPropertyEditor(mitk::FloatProperty *property, QWidget *parent)
Construct an editor for a float property.
int maxValue() const
Get the maximum allowed value.
void setDecimalPlaces(short places)
Set the number of decimal places (only effective for float/double properties).
mitk::GenericProperty< double > * m_DoubleProperty
int minValue() const
Get the minimum allowed value.
mitk::GenericProperty< int > * m_IntProperty
~QmitkNumberPropertyEditor() override
Destructor.
double doubleValue() const
Get the current value as a double.
Read-write observer for a mitk::BaseProperty.
Declares commonly used GenericProperty specializations for MITK.