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