diff --git a/GUI/Model/Descriptor/DoubleProperty.h b/GUI/Model/Descriptor/DoubleProperty.h index 07f84d2ae20d97412aada8a4eb9a4962e23648b8..fe4aa0af2b3c44d34b57d452d443baa091dffdf4 100644 --- a/GUI/Model/Descriptor/DoubleProperty.h +++ b/GUI/Model/Descriptor/DoubleProperty.h @@ -16,7 +16,6 @@ #define BORNAGAIN_GUI_MODEL_DESCRIPTOR_DOUBLEPROPERTY_H #include "Fit/Param/RealLimits.h" -#include "GUI/Support/Type/Unit.h" #include <QList> #include <QString> #include <QXmlStreamReader> @@ -41,7 +40,6 @@ public: void init(const QString& label, const QString& tooltip, double value, uint decimals, double step, const RealLimits& limits, const QString& uidPrefix); - //! Cast to the contained double value. operator double() const { return m_value; } @@ -61,8 +59,6 @@ public: QString tooltip() const { return m_tooltip; } void setTooltip(const QString& tooltip); - std::variant<QString, Unit> unit() const { return m_unit; } - RealLimits limits() const { return m_limits; } void setLimits(const RealLimits& limits); @@ -84,8 +80,6 @@ private: uint m_decimals = 3; //!< numbers of decimals to be shown in an edit control double m_step = 0.01; //!< numbers of decimals to be shown in an edit control RealLimits m_limits; //!< Limits of the value. - static constexpr std::variant<QString, Unit> m_unit = - Unit::unitless; //!< Unit of the value (internal unit only!) }; using DoubleProperties = QList<DoubleProperty*>; diff --git a/GUI/Support/Type/Unit.h b/GUI/Support/Type/Unit.h deleted file mode 100644 index 6786418ec61b0edf34d34b420a74ffbe279dcab3..0000000000000000000000000000000000000000 --- a/GUI/Support/Type/Unit.h +++ /dev/null @@ -1,39 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file GUI/Support/Type/Unit.h -//! @brief Defines class Unit -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2021 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#ifndef BORNAGAIN_GUI_SUPPORT_TYPE_UNIT_H -#define BORNAGAIN_GUI_SUPPORT_TYPE_UNIT_H - -class QString; - -//! Defines units, mainly to be able to convert between units. -//! -//! E.g. internal unit is nanometer, displayed unit is angstrom. -//! Units which do not support conversion do not have to be -//! part of the enum, since the relevant code parts support defining a -//! unit via enum or via string -enum class Unit { - unitless, - nanometer, - nanometer2, - nanometerMinus2, - angstrom, - angstrom2, - angstromMinus2, - degree, - radiant, - other //!< The unit has no enum value defined in here (e.g. when defined as an explicit string) -}; - -#endif // BORNAGAIN_GUI_SUPPORT_TYPE_UNIT_H diff --git a/GUI/View/Numeric/DoubleSpinBox.cpp b/GUI/View/Numeric/DoubleSpinBox.cpp index 02bd82560b31578d672b8a160b9fc5ce72cfe586..06adcfb81c1e1c4c27f5f26fe497982411643ca7 100644 --- a/GUI/View/Numeric/DoubleSpinBox.cpp +++ b/GUI/View/Numeric/DoubleSpinBox.cpp @@ -66,16 +66,8 @@ void DoubleSpinBox::onDisplayValueChanged(double value) emit baseValueChanged(value); } -Unit DoubleSpinBox::baseUnit() const -{ - if (std::holds_alternative<QString>(m_valueProperty.unit())) - return Unit::other; - - return std::get<Unit>(m_valueProperty.unit()); -} - void DoubleSpinBox::updateValue() { - QSignalBlocker b(this); + QSignalBlocker _(this); setBaseValue(m_valueProperty.value()); } diff --git a/GUI/View/Numeric/DoubleSpinBox.h b/GUI/View/Numeric/DoubleSpinBox.h index 525d53d02f934f9fb38a4690f11eaaba5dca5fc9..30f8a4bd00b3422a212f842fdc74f0263c3170a3 100644 --- a/GUI/View/Numeric/DoubleSpinBox.h +++ b/GUI/View/Numeric/DoubleSpinBox.h @@ -29,18 +29,11 @@ public: //! unnoticed changes would take place when just scrolling through the form. DoubleSpinBox(DoubleProperty& d, bool easyScrollable = false, QWidget* parent = nullptr); - //! Set the base value (unit is the one of the contained descriptor). + //! Set the value void setBaseValue(double baseValue); - - QString uid() const; - void setPropertyValue(double v); - //! Returns the unit of the contained DoubleProperty. - //! - //! If the unit is defined as a string, this method returns Unit::other. To get the string, use - //! valueProperty().unit - Unit baseUnit() const; + QString uid() const; //! Update the shown value to the one contained in the value descriptor. //! diff --git a/GUI/View/Numeric/NumWidgetUtil.cpp b/GUI/View/Numeric/NumWidgetUtil.cpp index 696c8fe02d4ae012bb526c2d01513ce26b719633..be2370a923323175661bb51e4c1924668ab61b4b 100644 --- a/GUI/View/Numeric/NumWidgetUtil.cpp +++ b/GUI/View/Numeric/NumWidgetUtil.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "GUI/View/Numeric/NumWidgetUtil.h" -#include "GUI/Support/Type/Unit.h" #include "GUI/Support/Util/CustomEventFilters.h" #include "GUI/View/Numeric/DoubleSpinBox.h" #include "GUI/View/Numeric/NumberUtil.h"