diff --git a/GUI/Model/Descriptor/DoubleProperty.cpp b/GUI/Model/Descriptor/DoubleProperty.cpp index 57465934db4ce536e2e12868dcd6bb7d3bec376c..6475d591099fa20f9fea623212d3100710f10df8 100644 --- a/GUI/Model/Descriptor/DoubleProperty.cpp +++ b/GUI/Model/Descriptor/DoubleProperty.cpp @@ -22,14 +22,14 @@ using std::variant; void DoubleProperty::init(const QString& label, const QString& tooltip, double value, const variant<QString, Unit>& unit, const QString& uidPrefix) { - init(label, tooltip, value, unit, 3 /*decimals*/, RealLimits::nonnegative(), uidPrefix); + init(label, tooltip, value, unit, 3, RealLimits::nonnegative(), uidPrefix); } void DoubleProperty::init(const QString& label, const QString& tooltip, double value, const variant<QString, Unit>& unit, uint decimals, const RealLimits& limits, const QString& uidPrefix) { - init(label, tooltip, value, unit, decimals, 0.01 /*step*/, limits, uidPrefix); + init(label, tooltip, value, unit, decimals, 0.01, limits, uidPrefix); } void DoubleProperty::init(const QString& label, const QString& tooltip, double value, diff --git a/GUI/Model/Descriptor/VectorProperty.cpp b/GUI/Model/Descriptor/VectorProperty.cpp index e823a19d6115427f2b9aaf7a2e9b5a6a45aaf173..1bda49c6f37aa2032e4167aefe8133b22f56fc65 100644 --- a/GUI/Model/Descriptor/VectorProperty.cpp +++ b/GUI/Model/Descriptor/VectorProperty.cpp @@ -32,8 +32,7 @@ using std::variant; void VectorProperty::init(const QString& label, const QString& tooltip, const variant<QString, Unit>& unit, const QString& uidPrefix) { - init(label, tooltip, R3(0.0, 0.0, 0.0), unit, 3 /*decimals*/, 0.01 /*step*/, - RealLimits::limitless(), uidPrefix); + init(label, tooltip, R3(0.0, 0.0, 0.0), unit, 3, 0.01, RealLimits::limitless(), uidPrefix); } void VectorProperty::init(const QString& label, const QString& tooltip, const R3& value, diff --git a/GUI/Model/Sample/FormFactorItems.cpp b/GUI/Model/Sample/FormFactorItems.cpp index c046faef325e57187d210265193f13b8c38e067c..c827854615f432f992f1ea400e36f124e1ba0cf4 100644 --- a/GUI/Model/Sample/FormFactorItems.cpp +++ b/GUI/Model/Sample/FormFactorItems.cpp @@ -46,7 +46,8 @@ Pyramid2Item::Pyramid2Item() m_length.init("Length", "Length of the rectangular base", 16.0, Unit::nanometer, "length"); m_width.init("Width", "Width of the rectangular base", 16.0, Unit::nanometer, "width"); m_height.init("Height", "Height of pyramid", 16.0, Unit::nanometer, "height"); - m_alpha.init("Alpha", "Dihedral angle between base and facet", 80.0, Unit::degree, "alpha"); + m_alpha.init("Alpha", "Dihedral angle between base and facet", 80.0, Unit::degree, 2, 0.1, + RealLimits::limited(0.0, 90.0), "alpha"); } std::unique_ptr<IFormFactor> Pyramid2Item::createFormFactor() const @@ -136,8 +137,8 @@ ConeItem::ConeItem() { m_radius.init("Radius", "Radius of the base", 8.0, Unit::nanometer, "radius"); m_height.init("Height", "Height of the cone", 16.0, Unit::nanometer, "height"); - m_alpha.init("Alpha", "Angle between the base and the side surface", 65.0, Unit::degree, - "alpha"); + m_alpha.init("Alpha", "Angle between the base and the side surface", 65.0, Unit::degree, 2, 0.1, + RealLimits::limited(0.0, 90.0), "alpha"); } std::unique_ptr<IFormFactor> ConeItem::createFormFactor() const @@ -160,7 +161,8 @@ Pyramid6Item::Pyramid6Item() m_baseEdge.init("Base edge", "Edge of the regular hexagonal base", 8.0, Unit::nanometer, "baseEdge"); m_height.init("Height", "Height of a truncated pyramid", 16.0, Unit::nanometer, "height"); - m_alpha.init("Alpha", "Dihedral angle between base and facet", 70.0, Unit::degree, "alpha"); + m_alpha.init("Alpha", "Dihedral angle between base and facet", 70.0, Unit::degree, 2, 0.1, + RealLimits::limited(0.0, 90.0), "alpha"); } std::unique_ptr<IFormFactor> Pyramid6Item::createFormFactor() const @@ -189,7 +191,8 @@ Bipyramid4Item::Bipyramid4Item() m_heightRatio.init("Height ratio", "Ratio of heights of top to bottom pyramids", 0.7, Unit::unitless, 3, RealLimits::lowerLimited(0.0), "heightRatio"); - m_alpha.init("Alpha", "Dihedral angle between base and facets", 70.0, Unit::degree, "alpha"); + m_alpha.init("Alpha", "Dihedral angle between base and facets", 70.0, Unit::degree, 2, 0.1, + RealLimits::limited(0.0, 90.0), "alpha"); } std::unique_ptr<IFormFactor> Bipyramid4Item::createFormFactor() const @@ -360,8 +363,8 @@ Pyramid4Item::Pyramid4Item() { m_baseEdge.init("Base edge", "Length of the square base", 16.0, Unit::nanometer, "baseEdge"); m_height.init("Height", "Height of the pyramid", 16.0, Unit::nanometer, "height"); - m_alpha.init("Alpha", "Dihedral angle between the base and a side face", 65.0, Unit::degree, - "alpha"); + m_alpha.init("Alpha", "Dihedral angle between the base and a side face", 65.0, Unit::degree, 2, + 0.1, RealLimits::limited(0.0, 90.0), "alpha"); } std::unique_ptr<IFormFactor> Pyramid4Item::createFormFactor() const @@ -530,7 +533,8 @@ Pyramid3Item::Pyramid3Item() m_baseEdge.init("Base edge", "Length of one edge of the equilateral triangular base", 14.0, Unit::nanometer, "baseEdge"); m_height.init("Height", "Height of the tetrahedron", 16.0, Unit::nanometer, "height"); - m_alpha.init("Alpha", "Dihedral angle between base and facet", 80.0, Unit::degree, "alpha"); + m_alpha.init("Alpha", "Dihedral angle between base and facet", 80.0, Unit::degree, 2, 0.1, + RealLimits::limited(0.0, 90.0), "alpha"); } std::unique_ptr<IFormFactor> Pyramid3Item::createFormFactor() const diff --git a/GUI/Model/Sample/InterferenceItems.cpp b/GUI/Model/Sample/InterferenceItems.cpp index 817b17edf50ad4d63acf6176dc4a00b74f5e1df2..6f6ebe0cc890c284184a70dfbf2cacaa615e5358 100644 --- a/GUI/Model/Sample/InterferenceItems.cpp +++ b/GUI/Model/Sample/InterferenceItems.cpp @@ -199,7 +199,7 @@ InterferenceHardDiskItem::InterferenceHardDiskItem() { m_radius.init("Radius", "Hard disk radius", 5.0, Unit::nanometer, "radius"); m_density.init("Total particle density", "Particle density in particles per area", 0.002, - Unit::nanometerMinus2, 5 /* decimals */, 0.0001 /* step */, + Unit::nanometerMinus2, 6 /* decimals */, 0.0001 /* step */, RealLimits::nonnegative(), "density"); } diff --git a/GUI/Model/Sample/Lattice2DItems.cpp b/GUI/Model/Sample/Lattice2DItems.cpp index d88fdc090206fc1e2b9ee6271cc83fc51bbfb204..f09ca27047fb65697dc70899001e0f2a3f06889e 100644 --- a/GUI/Model/Sample/Lattice2DItems.cpp +++ b/GUI/Model/Sample/Lattice2DItems.cpp @@ -34,7 +34,7 @@ Lattice2DItem::Lattice2DItem() { m_latticeRotationAngle.init( "Xi", "Rotation of lattice with respect to x-axis of reference frame (beam direction)", 0.0, - Unit::degree, "xi"); + Unit::degree, 2, 1.0, RealLimits::limited(0.0, 360.0), "xi"); } double Lattice2DItem::unitCellArea() const @@ -50,7 +50,8 @@ BasicLattice2DItem::BasicLattice2DItem() "len1"); m_length2.init("LatticeLength2", "Length of second lattice vector", 20.0, Unit::nanometer, "len2"); - m_angle.init("Angle", "Angle between lattice vectors", 90.0, Unit::degree, "angle"); + m_angle.init("Angle", "Angle between lattice vectors", 90.0, Unit::degree, 2, 1.0, + RealLimits::limited(0, 180.0), "angle"); } std::unique_ptr<Lattice2D> BasicLattice2DItem::createLattice() const diff --git a/GUI/Model/Sample/ParticleLayoutItem.cpp b/GUI/Model/Sample/ParticleLayoutItem.cpp index 3ba10c2b5ad1bbd39b3c256f53b49b07498486c9..59958e53c75b1ff1f28845306c57c00c89818f24 100644 --- a/GUI/Model/Sample/ParticleLayoutItem.cpp +++ b/GUI/Model/Sample/ParticleLayoutItem.cpp @@ -37,7 +37,7 @@ ParticleLayoutItem::ParticleLayoutItem(const MaterialItems* materials) m_ownDensity.init("Total particle density", "Number of particles per area (particle surface density).\n " "Should be defined for disordered and 1d-ordered particle collections.", - 0.0005, Unit::nanometerMinus2, 10 /* decimals */, 0.0001 /* step */, + 0.0005, Unit::nanometerMinus2, 6 /* decimals */, 0.0001 /* step */, RealLimits::nonnegative(), "density"); m_interference.init("Interference function", ""); diff --git a/GUI/Model/Sample/ProfileItems.cpp b/GUI/Model/Sample/ProfileItems.cpp index 3f9d785c65ce92bc9a6e7fbe9e0d6b25fde0f812..8d040fc59033f007bdc91749eebc42f3dbc31a7c 100644 --- a/GUI/Model/Sample/ProfileItems.cpp +++ b/GUI/Model/Sample/ProfileItems.cpp @@ -115,7 +115,7 @@ Profile2DItem::Profile2DItem() m_gamma.init( "Gamma", "Angle in direct space between first lattice vector and x-axis of the distribution", 0.0, - Unit::degree, "gamma"); + Unit::degree, 2, 1.0, RealLimits::limited(0.0, 360.0), "gamma"); } void Profile2DItem::serialize(Streamer& s) diff --git a/GUI/Model/Sample/RotationItems.cpp b/GUI/Model/Sample/RotationItems.cpp index 5a03280f38336d00def9112b574f881456d358df..397137ee825f76ee33db0b2b477fe9096ed43958 100644 --- a/GUI/Model/Sample/RotationItems.cpp +++ b/GUI/Model/Sample/RotationItems.cpp @@ -54,7 +54,8 @@ 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, 1.0, + RealLimits::limited(0.0, 360.0), "angle"); } unique_ptr<IRotation> XRotationItem::createRotation() const @@ -66,7 +67,8 @@ unique_ptr<IRotation> XRotationItem::createRotation() const YRotationItem::YRotationItem() { - m_angle.init("Angle", "Rotation angle around y-axis", 0.0, Unit::degree, "angle"); + m_angle.init("Angle", "Rotation angle around y-axis", 0.0, Unit::degree, 2, 1.0, + RealLimits::limited(0.0, 360.0), "angle"); } unique_ptr<IRotation> YRotationItem::createRotation() const @@ -78,7 +80,8 @@ unique_ptr<IRotation> YRotationItem::createRotation() const ZRotationItem::ZRotationItem() { - m_angle.init("Angle", "Rotation angle around z-axis", 0.0, Unit::degree, "angle"); + m_angle.init("Angle", "Rotation angle around z-axis", 0.0, Unit::degree, 2, 1.0, + RealLimits::limited(0.0, 360.0), "angle"); } unique_ptr<IRotation> ZRotationItem::createRotation() const @@ -90,9 +93,12 @@ unique_ptr<IRotation> ZRotationItem::createRotation() const EulerRotationItem::EulerRotationItem() { - m_alpha.init("Alpha", "First Euler angle in z-x'-z' sequence", 0.0, Unit::degree, "alpha"); - m_beta.init("Beta", "Second Euler angle in z-x'-z' sequence", 0.0, Unit::degree, "beta"); - m_gamma.init("Gamma", "Third Euler angle in z-x'-z' sequence", 0.0, Unit::degree, "gamma"); + m_alpha.init("Alpha", "First Euler angle in z-x'-z' sequence", 0.0, Unit::degree, 2, 1.0, + RealLimits::limited(0.0, 360.0), "alpha"); + m_beta.init("Beta", "Second Euler angle in z-x'-z' sequence", 0.0, Unit::degree, 2, 1.0, + RealLimits::limited(0.0, 360.0), "beta"); + m_gamma.init("Gamma", "Third Euler angle in z-x'-z' sequence", 0.0, Unit::degree, 2, 1.0, + RealLimits::limited(0.0, 360.0), "gamma"); } void EulerRotationItem::serialize(Streamer& s) 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/Mask/MaskEditorPropertyPanel.cpp b/GUI/View/Mask/MaskEditorPropertyPanel.cpp index 5531901f660f40fe48cf1f29dbfdfce83e633348..79d71c18bfd8768bbaa9e79386444a28d0888cce 100644 --- a/GUI/View/Mask/MaskEditorPropertyPanel.cpp +++ b/GUI/View/Mask/MaskEditorPropertyPanel.cpp @@ -250,7 +250,7 @@ void MaskEditorPropertyPanel::addMaskSpinBox(const QString& label, function<doub const RealLimits& limits) { QDoubleSpinBox* spinBox = new QDoubleSpinBox; - GUI::View::EditUtil::configSpinbox(spinBox, 3 /*decimals*/, limits); + GUI::View::EditUtil::configSpinbox(spinBox, 3, limits); spinBox->setValue(getter()); connect(spinBox, &QDoubleSpinBox::valueChanged, this, 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); });