Mantid
Loading...
Searching...
No Matches
DoubleSpinBox.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7/***************************************************************************
8 File : DoubleSpinBox.h
9 Project : QtiPlot
10 --------------------------------------------------------------------
11 * *
12 * You should have received a copy of the GNU General Public License *
13 * along with this program; if not, write to the Free Software *
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
15 * Boston, MA 02110-1301 USA *
16 * *
17 ***************************************************************************/
18#pragma once
19
20#include "DllOption.h"
21#include <map>
22
23#include <QAbstractSpinBox>
24#include <QCheckBox>
25
27// locale settings.
31class EXPORT_OPT_MANTIDQT_COMMON DoubleSpinBox : public QAbstractSpinBox {
32 Q_OBJECT
33
34public:
36
41 DoubleSpinBox(const char format = 'g', QWidget *parent = nullptr);
42
43 void setSingleStep(double val);
44 void setMaximum(double max);
45 void setMinimum(double min);
46 void setRange(double min, double max);
47
48 double getMaximum();
49 double getMinimum();
50
51 int decimals() { return d_prec; };
52 void setDecimals(int prec) {
53 if (prec >= 0)
54 d_prec = prec;
55 };
56
57 double value();
58 bool setValue(double val);
59
60 void setFormat(const char format, int prec = 1) {
61 d_format = format;
62 setDecimals(prec);
63 };
64
65 void addSpecialTextMapping(const QString &text, double value);
66
67 QString textFromValue(double value) const;
68 QValidator::State validate(QString &input, int &pos) const override;
69
70signals:
71 void valueChanged(double d);
73 void activated(DoubleSpinBox * /*_t1*/);
74
75private slots:
76 void interpretText(bool notify = true);
77
78protected:
79 void stepBy(int steps) override;
80 StepEnabled stepEnabled() const override;
81 void focusInEvent(QFocusEvent * /*event*/) override;
82
83private:
85 double d_min_val;
86 double d_max_val;
87 double d_value;
88 double d_step;
89 int d_prec;
90
91 // A set of mappins from strings which the user can enter in the box to double
92 // values
93 std::map<QString, double> m_specialTextMappings;
94};
95
97// interval.
99public:
100 enum LimitType { LeftLimit, RightLimit };
101
102 RangeLimitBox(LimitType type, QWidget *parent = nullptr);
103 void setDecimals(int prec) { d_spin_box->setDecimals(prec); };
104 double value();
105 bool isChecked() { return d_checkbox->isChecked(); };
106
107private:
109 QCheckBox *d_checkbox;
111};
#define EXPORT_OPT_MANTIDQT_COMMON
Definition: DllOption.h:15
double value
The value of the point.
Definition: FitMW.cpp:51
A QDoubleSpinBox allowing to customize numbers display with respect to.
Definition: DoubleSpinBox.h:31
void setFormat(const char format, int prec=1)
Definition: DoubleSpinBox.h:60
double d_min_val
Definition: DoubleSpinBox.h:85
void setDecimals(int prec)
Definition: DoubleSpinBox.h:52
std::map< QString, double > m_specialTextMappings
Definition: DoubleSpinBox.h:93
void valueChanged(double d)
double d_max_val
Definition: DoubleSpinBox.h:86
void activated(DoubleSpinBox *)
Signal emitted when the spin box gains focus.
A checkable DoubleSpinBox that can be used to select the limits of a double.
Definition: DoubleSpinBox.h:98
DoubleSpinBox * d_spin_box
void setDecimals(int prec)
QCheckBox * d_checkbox
LimitType d_type