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

enhance VectorDescriptor

parent 20cdbde5
No related branches found
No related tags found
1 merge request!570remove SessionModel/Item from SampleModel and all related items
......@@ -25,6 +25,8 @@
//! of three doubles, three double members, or any other construction to hold the three values.
class VectorDescriptor {
public:
VectorDescriptor() = default;
//! Operates on a VectorItem.
//!
//! The settings (like decimals, limits) are taken from the item.
......@@ -74,6 +76,7 @@ public:
z.label = label + " (z)";
}
// #baMigration used?
VectorDescriptor(const QString& label, const QString& tooltip, const R3* vec,
const variant<QString, Unit>& unit)
: label(label), tooltip(tooltip)
......@@ -104,6 +107,38 @@ public:
z.path = [=] { return uid() + "z"; };
}
void init(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 tooltip; //!< Tooltip text
DoubleDescriptor x;
......
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