Skip to content
Snippets Groups Projects
Commit 0480d60c authored by Matthias Puchner's avatar Matthias Puchner
Browse files

enhance VectorDescriptor to support R3 and a uid

parent 6bd6ce26
No related branches found
No related tags found
1 merge request!570remove SessionModel/Item from SampleModel and all related items
...@@ -74,11 +74,42 @@ public: ...@@ -74,11 +74,42 @@ public:
z.label = label + " (z)"; z.label = label + " (z)";
} }
VectorDescriptor(const QString& label, const QString& tooltip, const R3* vec,
const variant<QString, Unit>& unit)
: label(label), tooltip(tooltip)
{
x.limits = RealLimits::limitless();
y.limits = RealLimits::limitless();
z.limits = RealLimits::limitless();
x.decimals = 3;
y.decimals = 3;
z.decimals = 3;
x.tooltip = tooltip;
y.tooltip = tooltip;
z.tooltip = tooltip;
x.unit = unit;
y.unit = unit;
z.unit = unit;
x.label = label + " (x)";
y.label = label + " (y)";
z.label = label + " (z)";
x.set = [=](double v) { const_cast<R3*>(vec)->setX(v); };
x.get = [=]() { return vec->x(); };
x.path = [=] { return uid() + "x"; };
y.set = [=](double v) { const_cast<R3*>(vec)->setY(v); };
y.get = [=]() { return vec->y(); };
y.path = [=] { return uid() + "y"; };
z.set = [=](double v) { const_cast<R3*>(vec)->setZ(v); };
z.get = [=]() { return vec->z(); };
z.path = [=] { return uid() + "z"; };
}
QString label; //!< A label text (short, no trailing colon) QString label; //!< A label text (short, no trailing colon)
QString tooltip; //!< Tooltip text QString tooltip; //!< Tooltip text
DoubleDescriptor x; DoubleDescriptor x;
DoubleDescriptor y; DoubleDescriptor y;
DoubleDescriptor z; DoubleDescriptor z;
function<QString()> uid; //<! unique id describing this value. Used e.g. for undo/redo
}; };
#endif // BORNAGAIN_GUI_MODEL_TYPES_VECTORDESCRIPTOR_H #endif // BORNAGAIN_GUI_MODEL_TYPES_VECTORDESCRIPTOR_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