BornAgain
1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
|
Describes properties of a double value which are necessary to allow GUI representation, editing the value, undo/redo, unit conversion.
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 SessionItem, a simple double member, or any other construction to hold a double value. It could also describe a value which is not even represented by an existing double, but is only a calculated value. In this case it might apply that there is no setter possible, which is still allowed as long as care is taken not trying to call the setter.
Note that this class does not provide (implement) a double value, but provide information about a double value. For implementing a double value, please see DoubleProperty.
For easy UI creation, there are functions like GUI:Util::createSpinBox() which take a descriptor and fully initialize the created spin box.
Definition at line 49 of file DoubleDescriptor.h.
Public Member Functions | |
DoubleDescriptor ()=default | |
DoubleDescriptor (const DoubleDescriptor &other)=default | |
DoubleDescriptor (const QString &label, const double *var, const variant< QString, Unit > &unit) | |
DoubleDescriptor (const QString &label, const QString &tooltip, function< void(double)> setter, function< double()> getter, const variant< QString, Unit > &unit) | |
Operates on any kind of storage (e.g. session items), by using setter/getter methods decimals is set to 3, limits is set to nonnegative. More... | |
DoubleDescriptor (const QString &label, SessionItem *item, const variant< QString, Unit > &unit) | |
Operates on a session item. The settings (like decimals, limits) are taken from the session item. Only for easier migration. Should be removed after SessionItem refactoring. More... | |
DoubleDescriptor (QString label, QString tooltip, int decimals, const RealLimits &limits, function< void(double)> setter, function< double()> getter, const variant< QString, Unit > &unit) | |
Operates on any kind of storage (e.g. session items), by using setter/getter methods. More... | |
DoubleDescriptor (SessionItem *item, const variant< QString, Unit > &unit) | |
Operates on a session item. The settings (like decimals, limits) are taken from the session item. Only for easier migration. Should be removed after SessionItem refactoring. More... | |
operator double () const | |
Return the current value of the handled parameter. More... | |
Public Attributes | |
int | decimals = 0 |
numbers of decimals to be shown in an edit control More... | |
function< double()> | get = nullptr |
function to get the current value More... | |
QString | label |
A label text (short, no trailing colon) More... | |
RealLimits | limits |
Limits of the value. More... | |
function< QString()> | path = nullptr |
Path describing this value. Used e.g. for undo/redo. More... | |
function< void(double)> | set = nullptr |
function to set the value More... | |
QString | tooltip |
Tooltip text. More... | |
variant< QString, Unit > | unit = Unit::unitless |
Unit of the value (internal unit only!) More... | |
Private Member Functions | |
DoubleDescriptor (const QString &label, const QString &tooltip, double *var, const variant< QString, Unit > &unit) | |
Operates on a double value (e.g a member variable). Decimals is set to 3, limits is set to nonnegative. More... | |
DoubleDescriptor (const QString &label, const QString &tooltip, int decimals, const RealLimits &limits, double *var, const variant< QString, Unit > &unit) | |
Operates on a double value (e.g a member variable). More... | |
|
private |
Operates on a double value (e.g a member variable).
Definition at line 51 of file DoubleDescriptor.cpp.
|
private |
Operates on a double value (e.g a member variable). Decimals is set to 3, limits is set to nonnegative.
Definition at line 44 of file DoubleDescriptor.cpp.
DoubleDescriptor::DoubleDescriptor | ( | const QString & | label, |
const QString & | tooltip, | ||
function< void(double)> | setter, | ||
function< double()> | getter, | ||
const variant< QString, Unit > & | unit | ||
) |
Operates on any kind of storage (e.g. session items), by using setter/getter methods decimals is set to 3, limits is set to nonnegative.
Definition at line 37 of file DoubleDescriptor.cpp.
DoubleDescriptor::DoubleDescriptor | ( | QString | label, |
QString | tooltip, | ||
int | decimals, | ||
const RealLimits & | limits, | ||
function< void(double)> | setter, | ||
function< double()> | getter, | ||
const variant< QString, Unit > & | unit | ||
) |
Operates on any kind of storage (e.g. session items), by using setter/getter methods.
Definition at line 21 of file DoubleDescriptor.cpp.
References path.
DoubleDescriptor::DoubleDescriptor | ( | const QString & | label, |
const double * | var, | ||
const variant< QString, Unit > & | unit | ||
) |
Definition at line 59 of file DoubleDescriptor.cpp.
DoubleDescriptor::DoubleDescriptor | ( | const QString & | label, |
SessionItem * | item, | ||
const variant< QString, Unit > & | unit | ||
) |
Operates on a session item. The settings (like decimals, limits) are taken from the session item. Only for easier migration. Should be removed after SessionItem refactoring.
Definition at line 67 of file DoubleDescriptor.cpp.
References SessionItem::setValue().
DoubleDescriptor::DoubleDescriptor | ( | SessionItem * | item, |
const variant< QString, Unit > & | unit | ||
) |
Operates on a session item. The settings (like decimals, limits) are taken from the session item. Only for easier migration. Should be removed after SessionItem refactoring.
Definition at line 79 of file DoubleDescriptor.cpp.
|
default |
|
default |
DoubleDescriptor::operator double | ( | ) | const |
Return the current value of the handled parameter.
Definition at line 84 of file DoubleDescriptor.cpp.
int DoubleDescriptor::decimals = 0 |
numbers of decimals to be shown in an edit control
Definition at line 94 of file DoubleDescriptor.h.
Referenced by DoubleSpinBox::DoubleSpinBox(), VectorDescriptor::VectorDescriptor(), GUI::Util::createScientificSpinBox(), ParameterItem::decimalsOfLink(), VectorDescriptor::init(), and DoubleProperty::init().
function<double()> DoubleDescriptor::get = nullptr |
function to get the current value
Definition at line 97 of file DoubleDescriptor.h.
Referenced by DoubleLineEdit::DoubleLineEdit(), MaskEditorPropertyPanel::addMaskSpinBox(), ParameterTreeBuilder::addParameterItem(), GUI::Util::createScientificSpinBox(), DetectorAlignmentEditor::createSpinBox(), PolarizationAnalysisEditor::createSpinBox(), VectorDescriptor::init(), DoubleProperty::init(), MaterialItem::magnetizationVector(), DoubleLineEdit::onEditingFinished(), DoubleSpinBox::setDisplayUnit(), SampleEditorController::setDouble(), InstrumentEditController::setDouble(), ParticleLayoutItem::totalDensity(), DoubleSpinBox::updateValue(), and ParameterItem::valueOfLink().
QString DoubleDescriptor::label |
A label text (short, no trailing colon)
Definition at line 92 of file DoubleDescriptor.h.
Referenced by VectorDescriptor::VectorDescriptor(), MaskEditorPropertyPanel::addMaskSpinBox(), ParameterTreeBuilder::addParameterItem(), GUI::Util::createScientificSpinBox(), GUI::Util::createSpinBox(), VectorDescriptor::init(), DoubleProperty::init(), FormLayouter::insertValue(), GUI::Util::labelWithUnit(), BasicAxisItem::max(), BasicAxisItem::min(), SampleEditorController::setDouble(), and LayerForm::updateLayerPositionDependentElements().
RealLimits DoubleDescriptor::limits |
Limits of the value.
Definition at line 95 of file DoubleDescriptor.h.
Referenced by DoubleLineEdit::DoubleLineEdit(), DoubleSpinBox::DoubleSpinBox(), VectorDescriptor::VectorDescriptor(), GUI::Util::createScientificSpinBox(), VectorDescriptor::init(), DoubleProperty::init(), ParameterItem::limitsOfLink(), and DoubleProperty::setLimits().
function<QString()> DoubleDescriptor::path = nullptr |
Path describing this value. Used e.g. for undo/redo.
Definition at line 99 of file DoubleDescriptor.h.
Referenced by DoubleDescriptor(), MaterialItem::beta(), MaterialItem::delta(), VectorDescriptor::init(), DoubleProperty::init(), ParameterItem::linkToDescriptor(), MaterialItem::magnetizationVector(), SampleEditorController::setDouble(), MaterialItem::sldIm(), MaterialItem::sldRe(), and ParticleLayoutItem::totalDensity().
function<void(double)> DoubleDescriptor::set = nullptr |
function to set the value
Definition at line 96 of file DoubleDescriptor.h.
Referenced by MaskEditorPropertyPanel::addMaskSpinBox(), MinimizerSettingsWidget::createDoubleSpinbox(), IntensityDataPropertyWidget::createDoubleSpinbox(), SpecularDataPropertyWidget::createDoubleSpinbox(), DistributionSelector::createMeanSpinBox(), DistributionSelector::createSpinBox(), VectorDescriptor::init(), DoubleProperty::init(), GUI::Transform::FromCore::itemizeSample(), MaterialItem::magnetizationVector(), ParameterItem::propagateValueToLink(), SampleEditorController::setDouble(), InstrumentEditController::setDouble(), SampleEditorController::setDoubleFromUndo(), and ParticleLayoutItem::totalDensity().
QString DoubleDescriptor::tooltip |
Tooltip text.
Definition at line 93 of file DoubleDescriptor.h.
Referenced by DoubleSpinBox::DoubleSpinBox(), VectorDescriptor::VectorDescriptor(), MinimizerSettingsWidget::createDoubleSpinbox(), IntensityDataPropertyWidget::createDoubleSpinbox(), GUI::Util::createScientificSpinBox(), VectorDescriptor::init(), DoubleProperty::init(), and DoubleProperty::setTooltip().
variant<QString, Unit> DoubleDescriptor::unit = Unit::unitless |
Unit of the value (internal unit only!)
Definition at line 98 of file DoubleDescriptor.h.
Referenced by DoubleSpinBox::DoubleSpinBox(), VectorDescriptor::VectorDescriptor(), ParameterTreeBuilder::addParameterItem(), DoubleSpinBox::baseUnit(), GUI::Util::createScientificSpinBox(), GUI::Util::createSpinBox(), DoubleSpinBox::displayUnitAsString(), VectorDescriptor::init(), DoubleProperty::init(), GUI::Util::labelWithUnit(), and DoubleProperty::setUnit().