Skip to content
Snippets Groups Projects
Commit 445e3f14 authored by Mikhail Svechnikov's avatar Mikhail Svechnikov
Browse files

show SLD units

parent 521aa40b
No related branches found
No related tags found
2 merge requests!1610From final 20.1,!1607Show SLD units (#558)
......@@ -46,10 +46,12 @@ MaterialItem::MaterialItem()
m_beta.init("Beta", "Beta of refractive index (n = 1 - delta + i*beta)", 0.0, Unit::unitless, 3,
RealLimits::limitless(), "beta");
m_sldRe.init("SLD, real", "Real part of SLD (SLD = real - i*imag), AA^{-2}", 0.0,
Unit::unitless, 3, RealLimits::limitless(), "sldRe");
m_sldIm.init("SLD, imaginary", "Imaginary part of SLD (SLD = real - i*imag), AA^{-2}", 0.0,
Unit::unitless, 3, RealLimits::limitless(), "sldIm");
Unit sld_units = Unit::angstromMinus2;
QString sld_units_str = unitAsString(sld_units);
m_sldRe.init("SLD, real", "Real part of SLD (SLD = real - i*imag), " + sld_units_str, 0.0,
sld_units, 3, RealLimits::limitless(), "sldRe");
m_sldIm.init("SLD, imaginary", "Imaginary part of SLD (SLD = real - i*imag), " + sld_units_str,
0.0, sld_units, 3, RealLimits::limitless(), "sldIm");
m_magnetization.init("Magnetization", "Magnetization (A/m)", "A/m", "magnetization");
}
......
......@@ -28,6 +28,8 @@ DoubleLineEdit::DoubleLineEdit(QWidget* parent, const DoubleProperty& d)
m_validator->setRange(minimum, maximum, 1000);
setValidator(m_validator);
setToolTip(d.tooltip());
updateBaseValue();
connect(this, &QLineEdit::editingFinished, this, &DoubleLineEdit::onEditingFinished);
......@@ -43,6 +45,14 @@ void DoubleLineEdit::updateBaseValue()
setBaseValue(m_valueProperty.value());
}
QString DoubleLineEdit::displayUnitAsString() const
{
if (std::holds_alternative<QString>(m_valueProperty.unit()))
return std::get<QString>(m_valueProperty.unit());
return unitAsString(std::get<Unit>(m_valueProperty.unit()));
}
void DoubleLineEdit::onEditingFinished()
{
const double new_value = text().toDouble();
......
......@@ -35,6 +35,7 @@ public:
void updateBaseValue();
QString displayUnitAsString() const;
signals:
//! Emitted whenever the value changes.
//!
......
......@@ -21,6 +21,7 @@
#include "GUI/Model/Sample/ParticleItem.h"
#include "GUI/Model/Sample/ProfileItems.h"
#include "GUI/Model/Sample/RoughnessItems.h"
#include "GUI/View/Numeric/DoubleLineEdit.h"
#include "GUI/View/Numeric/DoubleSpinBox.h"
#include "GUI/View/SampleDesigner/CompoundForm.h"
#include "GUI/View/SampleDesigner/CoreAndShellForm.h"
......@@ -62,6 +63,8 @@ void LayerEditorUtils::updateLabelUnit(QLabel* label)
{
if (auto* editor = dynamic_cast<DoubleSpinBox*>(label->buddy()))
::updateLabelUnit(label, editor->displayUnitAsString());
else if (auto* editor = dynamic_cast<DoubleLineEdit*>(label->buddy()))
::updateLabelUnit(label, editor->displayUnitAsString());
}
void LayerEditorUtils::addMultiPropertyToGrid(QGridLayout* m_gridLayout, int firstCol,
......
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