diff --git a/GUI/Model/Sample/RotationItems.cpp b/GUI/Model/Sample/RotationItems.cpp index 5a03280f38336d00def9112b574f881456d358df..402b68868f4f0f3597a9ae2d2e744bec3cbbe469 100644 --- a/GUI/Model/Sample/RotationItems.cpp +++ b/GUI/Model/Sample/RotationItems.cpp @@ -54,7 +54,7 @@ void XYZRotationItem::serialize(Streamer& s) XRotationItem::XRotationItem() { - m_angle.init("Angle", "Rotation angle around x-axis", 0.0, Unit::degree, "angle"); + m_angle.init("Angle", "Rotation angle around x-axis", 0.0, Unit::degree, 2 /*decimals*/, 1.0 /*step*/, RealLimits::limitless(), "angle"); } unique_ptr<IRotation> XRotationItem::createRotation() const diff --git a/GUI/View/Common/DoubleSpinBox.cpp b/GUI/View/Common/DoubleSpinBox.cpp index d172a9a6a5b115673b41ba52dda93218f573a7af..6fe4ce1f66edd75f176f98f24122084fe65e2b35 100644 --- a/GUI/View/Common/DoubleSpinBox.cpp +++ b/GUI/View/Common/DoubleSpinBox.cpp @@ -16,12 +16,10 @@ #include "GUI/View/Tool/EditUtil.h" #include <QWheelEvent> -DoubleSpinBox::DoubleSpinBox(DoubleProperty& d, bool easyScrollable, int precision, double stepSize, - QWidget* parent) +DoubleSpinBox::DoubleSpinBox(DoubleProperty& d, bool easyScrollable, QWidget* parent) : QDoubleSpinBox(parent) , m_valueProperty(d) , easyScrollable(easyScrollable) - , m_precision(precision) { setFocusPolicy(Qt::StrongFocus); GUI::View::EditUtil::configSpinbox(this, d.decimals(), d.limits()); @@ -35,7 +33,7 @@ DoubleSpinBox::DoubleSpinBox(DoubleProperty& d, bool easyScrollable, int precisi QObject::connect(this, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &DoubleSpinBox::onDisplayValueChanged); - setSingleStep(stepSize); + setSingleStep(m_valueProperty.step()); } void DoubleSpinBox::setDisplayUnit(Unit displayUnit) { @@ -116,8 +114,3 @@ void DoubleSpinBox::updateValue() QSignalBlocker b(this); setBaseValue(m_valueProperty.value()); } - -QString DoubleSpinBox::textFromValue(double val) const -{ - return QString::number(val, 'f', m_precision); -} diff --git a/GUI/View/Common/DoubleSpinBox.h b/GUI/View/Common/DoubleSpinBox.h index ee036ebefa72f98d99714f82e2583ffe7c981cf4..d3b77fdf231379b93ed22a5e22c360f44434ba97 100644 --- a/GUI/View/Common/DoubleSpinBox.h +++ b/GUI/View/Common/DoubleSpinBox.h @@ -27,8 +27,7 @@ public: //! Furthermore, the spin box will prohibit accidental changes by the mouse wheel. Otherwise it //! would be dangerous if the spin box is on a scrollable form - unintended and unnoticed //! changes would take place when just scrolling through the form. - DoubleSpinBox(DoubleProperty& d, bool easyScrollable = false, int precision = 2, - double singleStepSize = 0.1, QWidget* parent = nullptr); + DoubleSpinBox(DoubleProperty& d, bool easyScrollable = false, QWidget* parent = nullptr); //! Set a display unit. //! //! The caller has to make sure that the new display unit has a conversion to/from the contained @@ -81,14 +80,6 @@ private: //! it was decided to not show the unit as a suffix. However, this may be user //! selectable once, therefore the code is kept and controlled by this flag bool m_showUnitAsSuffix = false; - - //! stores the decimal places used for displaying the value. A user can still - //! type more decimal places, these places will get rounded up to the places allowed. - const int m_precision; - - // QDoubleSpinBox interface -public: - QString textFromValue(double val) const override; }; diff --git a/GUI/View/SampleDesigner/LayerEditorUtils.cpp b/GUI/View/SampleDesigner/LayerEditorUtils.cpp index 1dad353d05b13d872bd1c9411efc089da80a5b89..d199c2af404089edc83316bbf8c93e103556ef83 100644 --- a/GUI/View/SampleDesigner/LayerEditorUtils.cpp +++ b/GUI/View/SampleDesigner/LayerEditorUtils.cpp @@ -84,12 +84,7 @@ void LayerEditorUtils::addMultiPropertyToGrid(QGridLayout* m_gridLayout, int fir { int col = firstCol; for (auto* d : valueProperties) { - DoubleSpinBox* editor; - if (d->label() == "Angle") - editor = new DoubleSpinBox(*d, false, 1, 1.0); - else - editor = new DoubleSpinBox(*d); - + DoubleSpinBox* editor = new DoubleSpinBox(*d); QObject::connect(editor, &DoubleSpinBox::baseValueChanged, [setNewValue, d](double newValue) { setNewValue(newValue, *d); });