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

ParameterItem: linkToDescriptor is refactored

parent 5478cf1f
No related branches found
No related tags found
1 merge request!1162rm DoubleDescriptor from code
......@@ -97,35 +97,36 @@ void ParameterItem::setTitle(const QString& title)
double ParameterItem::valueOfLink() const
{
return m_d.get();
return getPropertyValue();
}
//! Sets current value to the original PropertyItem of MultiLayerItem/InstrumentItem.
void ParameterItem::propagateValueToLink(double newValue)
{
m_d.set(newValue);
setPropertyValue(newValue);
}
void ParameterItem::linkToDescriptor(DoubleDescriptor d)
void ParameterItem::linkToProperty(DoubleProperty &d)
{
m_link = d.path();
m_d = d;
getPropertyValue = [&d](){return d.get();};
setPropertyValue = [&d](double v){d.set(v);};
m_d = d; // make a copy
}
RealLimits ParameterItem::limitsOfLink() const
{
return m_d.limits;
return m_d.limits();
}
int ParameterItem::decimalsOfLink() const
{
return m_d.decimals;
return m_d.decimals();
}
QString ParameterItem::link() const
{
return m_link;
return m_d.uid();
}
QString ParameterItem::titleForFitItem() const
......
......@@ -15,7 +15,7 @@
#ifndef BORNAGAIN_GUI_MODEL_JOB_PARAMETERTREEITEMS_H
#define BORNAGAIN_GUI_MODEL_JOB_PARAMETERTREEITEMS_H
#include "GUI/Model/Descriptor/DoubleDescriptor.h"
#include "GUI/Model/Descriptor/DoubleProperty.h"
#include <QMap>
#include <QXmlStreamReader>
......@@ -60,16 +60,17 @@ public:
QString titleForFitItem() const;
//! Links this item to the given value defined by a descriptor.
void linkToDescriptor(DoubleDescriptor d);
//! Links this item to the given value defined by a property.
void linkToProperty(DoubleProperty& d);
RealLimits limitsOfLink() const;
int decimalsOfLink() const;
private:
QString m_title;
QString m_link; //!< See docu of link()
DoubleDescriptor m_d; //!< The linked double value
DoubleProperty m_d; // a copy for the access to limits, uid, decimals
std::function<double()> getPropertyValue = nullptr;
std::function<void(double)> setPropertyValue = nullptr;
};
//! The ParameterContainerItem is a top item to hold all ParameterItem, represents an entry
......
......@@ -145,7 +145,7 @@ void ParameterTreeBuilder::addParameterItem(ParameterLabelItem* parent, DoublePr
{
auto* parameterItem = new ParameterItem(parent);
parameterItem->setTitle(labelWithUnit(label.isEmpty() ? d.label() : label, d.unit()));
parameterItem->linkToDescriptor(d);
parameterItem->linkToProperty(d);
if (m_recreateBackupValues)
m_jobItem->parameterContainerItem()->setBackupValue(parameterItem->link(), d.get());
}
......
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