Skip to content
Snippets Groups Projects
Commit 2fe58ee8 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

rm GUI/Support/Type/Unit.h

parent 92a772ae
No related branches found
No related tags found
1 merge request!2003In GUI, remove option to switch beteen nm and angstrom, degrees and radians.
......@@ -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*>;
......
// ************************************************************************************************
//
// 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
......@@ -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());
}
......@@ -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.
//!
......
......@@ -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"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment