BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
VectorDescriptor Class Reference

Description

Describes properties of a 3D vector, consisting of three double values.

By using this class, the underlying data scheme is hidden from the user of the data. This e.g. eases SessionItem migration. The underlying implementation can be a R3 vector, a member array of three doubles, three double members, or any other construction to hold the three values.

VectorProperty DoubleDescriptor

Definition at line 31 of file VectorDescriptor.h.

Collaboration diagram for VectorDescriptor:
[legend]

Public Member Functions

 VectorDescriptor ()=default
 
 VectorDescriptor (const QString &label, const QString &tooltip, const variant< QString, Unit > &unit)
 
 VectorDescriptor (const QString &label, const QString &tooltip, double *xVar, double *yVar, double *zVar, const variant< QString, Unit > &unit)
 
void init (const QString &_label, const QString &_tooltip, const R3 *vec, const variant< QString, Unit > &_unit)
 

Public Attributes

QString label
 A label text (short, no trailing colon) More...
 
QString tooltip
 Tooltip text. More...
 
function< QString()> uid
 unique id describing this value. Used e.g. for undo/redo More...
 
DoubleDescriptor x
 
DoubleDescriptor y
 
DoubleDescriptor z
 

Constructor & Destructor Documentation

◆ VectorDescriptor() [1/3]

VectorDescriptor::VectorDescriptor ( )
default

◆ VectorDescriptor() [2/3]

VectorDescriptor::VectorDescriptor ( const QString &  label,
const QString &  tooltip,
double *  xVar,
double *  yVar,
double *  zVar,
const variant< QString, Unit > &  unit 
)
inline

Definition at line 35 of file VectorDescriptor.h.

37  : label(label)
38  , tooltip(tooltip)
39  , x("X", xVar, unit)
40  , y("Y", yVar, unit)
41  , z("Z", zVar, unit)
42  {
43  x.limits = RealLimits::limitless();
44  y.limits = RealLimits::limitless();
45  z.limits = RealLimits::limitless();
46  x.decimals = 3;
47  y.decimals = 3;
48  z.decimals = 3;
49  x.tooltip = tooltip;
50  y.tooltip = tooltip;
51  z.tooltip = tooltip;
52  }
RealLimits limits
Limits of the value.
QString tooltip
Tooltip text.
int decimals
numbers of decimals to be shown in an edit control
QString tooltip
Tooltip text.
DoubleDescriptor y
DoubleDescriptor x
QString label
A label text (short, no trailing colon)
DoubleDescriptor z

References DoubleDescriptor::decimals, DoubleDescriptor::limits, DoubleDescriptor::tooltip, tooltip, x, y, and z.

◆ VectorDescriptor() [3/3]

VectorDescriptor::VectorDescriptor ( const QString &  label,
const QString &  tooltip,
const variant< QString, Unit > &  unit 
)
inline

Definition at line 54 of file VectorDescriptor.h.

56  : label(label)
57  , tooltip(tooltip)
58  {
59  x.limits = RealLimits::limitless();
60  y.limits = RealLimits::limitless();
61  z.limits = RealLimits::limitless();
62  x.decimals = 3;
63  y.decimals = 3;
64  z.decimals = 3;
65  x.tooltip = tooltip;
66  y.tooltip = tooltip;
67  z.tooltip = tooltip;
68  x.unit = unit;
69  y.unit = unit;
70  z.unit = unit;
71  x.label = "x";
72  y.label = "y";
73  z.label = "z";
74  }
variant< QString, Unit > unit
Unit of the value (internal unit only!)
QString label
A label text (short, no trailing colon)

References DoubleDescriptor::decimals, DoubleDescriptor::label, DoubleDescriptor::limits, DoubleDescriptor::tooltip, tooltip, DoubleDescriptor::unit, x, y, and z.

Member Function Documentation

◆ init()

void VectorDescriptor::init ( const QString &  _label,
const QString &  _tooltip,
const R3 *  vec,
const variant< QString, Unit > &  _unit 
)
inline

Definition at line 76 of file VectorDescriptor.h.

78  {
79  label = _label;
80  tooltip = _tooltip;
81  x.limits = RealLimits::limitless();
82  y.limits = RealLimits::limitless();
83  z.limits = RealLimits::limitless();
84  x.decimals = 3;
85  y.decimals = 3;
86  z.decimals = 3;
87  x.tooltip = tooltip;
88  y.tooltip = tooltip;
89  z.tooltip = tooltip;
90  x.unit = _unit;
91  y.unit = _unit;
92  z.unit = _unit;
93  x.label = "x";
94  y.label = "y";
95  z.label = "z";
96  x.set = [=](double v) { const_cast<R3*>(vec)->setX(v); };
97  x.get = [=]() { return vec->x(); };
98  x.path = [=] { return uid() + "x"; };
99  y.set = [=](double v) { const_cast<R3*>(vec)->setY(v); };
100  y.get = [=]() { return vec->y(); };
101  y.path = [=] { return uid() + "y"; };
102  z.set = [=](double v) { const_cast<R3*>(vec)->setZ(v); };
103  z.get = [=]() { return vec->z(); };
104  z.path = [=] { return uid() + "z"; };
105  }
function< void(double)> set
function to set the value
function< double()> get
function to get the current value
function< QString()> path
Path describing this value. Used e.g. for undo/redo.
function< QString()> uid
unique id describing this value. Used e.g. for undo/redo

References DoubleDescriptor::decimals, DoubleDescriptor::get, DoubleDescriptor::label, label, DoubleDescriptor::limits, DoubleDescriptor::path, DoubleDescriptor::set, DoubleDescriptor::tooltip, tooltip, uid, DoubleDescriptor::unit, x, y, and z.

Referenced by VectorProperty::init().

Member Data Documentation

◆ label

QString VectorDescriptor::label

◆ tooltip

QString VectorDescriptor::tooltip

Tooltip text.

Definition at line 109 of file VectorDescriptor.h.

Referenced by VectorDescriptor(), and init().

◆ uid

function<QString()> VectorDescriptor::uid

unique id describing this value. Used e.g. for undo/redo

Definition at line 113 of file VectorDescriptor.h.

Referenced by init(), VectorProperty::init(), and MaterialItem::magnetizationVector().

◆ x

◆ y

◆ z


The documentation for this class was generated from the following file: