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

Description

Describes properties of a uint 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 uint member, or any other construction to hold a uint value.

Definition at line 36 of file UIntDescriptor.h.

Collaboration diagram for UIntDescriptor:
[legend]

Public Member Functions

 UIntDescriptor ()=default
 
 UIntDescriptor (const QString &label, const uint *var, const variant< QString, Unit > &unit)
 
 UIntDescriptor (const QString &label, SessionItem *item, const variant< QString, Unit > &unit)
 Operates on a session item. The settings (like limits) are taken from the session item. Only for easier migration. Should be removed after SessionItem refactoring. More...
 
 UIntDescriptor (SessionItem *item, const variant< QString, Unit > &unit)
 Operates on a session item. The settings (like limits) are taken from the session item. Only for easier migration. Should be removed after SessionItem refactoring. More...
 
 operator uint () const
 Return the current value of the handled parameter. More...
 

Public Attributes

function< uint()> 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(uint)> set = nullptr
 function to set the value More...
 
QString tooltip
 Tooltip text. More...
 
variant< QString, Unitunit = Unit::unitless
 Unit of the value (internal unit only!) More...
 

Private Member Functions

 UIntDescriptor (const QString &label, const QString &tooltip, function< void(uint)> setter, function< uint()> getter, const variant< QString, Unit > &unit)
 Operates on any kind of storage (e.g. session items), by using setter/getter methods limits is set to nonnegative. More...
 
 UIntDescriptor (QString label, QString tooltip, const RealLimits &limits, function< void(uint)> setter, function< uint()> getter, const variant< QString, Unit > &unit)
 Operates on any kind of storage (e.g. session items), by using setter/getter methods. More...
 

Constructor & Destructor Documentation

◆ UIntDescriptor() [1/6]

UIntDescriptor::UIntDescriptor ( )
default

◆ UIntDescriptor() [2/6]

UIntDescriptor::UIntDescriptor ( SessionItem item,
const variant< QString, Unit > &  unit 
)

Operates on a session item. The settings (like limits) are taken from the session item. Only for easier migration. Should be removed after SessionItem refactoring.

Definition at line 28 of file UIntDescriptor.cpp.

29  : UIntDescriptor(item->displayName(), item, unit)
30 {
31 }
QString displayName() const
Get display name of item, append index if ambigue.
UIntDescriptor()=default
variant< QString, Unit > unit
Unit of the value (internal unit only!)

◆ UIntDescriptor() [3/6]

UIntDescriptor::UIntDescriptor ( const QString &  label,
SessionItem item,
const variant< QString, Unit > &  unit 
)

Operates on a session item. The settings (like limits) are taken from the session item. Only for easier migration. Should be removed after SessionItem refactoring.

Definition at line 20 of file UIntDescriptor.cpp.

23  label, item->toolTip(), item->limits(), [=](int d) { item->setValue(d); },
24  [=]() { return item->value().toInt(); }, unit)
25 {
26 }
QString toolTip() const
RealLimits limits() const
QString label
A label text (short, no trailing colon)

References SessionItem::setValue().

Here is the call graph for this function:

◆ UIntDescriptor() [4/6]

UIntDescriptor::UIntDescriptor ( const QString &  label,
const uint *  var,
const variant< QString, Unit > &  unit 
)

Definition at line 52 of file UIntDescriptor.cpp.

55  label, "", RealLimits::nonnegative(), [=](uint v) { *const_cast<uint*>(var) = v; },
56  [=] { return *var; }, unit)
57 {
58 }

◆ UIntDescriptor() [5/6]

UIntDescriptor::UIntDescriptor ( QString  label,
QString  tooltip,
const RealLimits &  limits,
function< void(uint)>  setter,
function< uint()>  getter,
const variant< QString, Unit > &  unit 
)
private

Operates on any kind of storage (e.g. session items), by using setter/getter methods.

Definition at line 40 of file UIntDescriptor.cpp.

43  : label(std::move(label))
44  , tooltip(std::move(tooltip))
45  , limits(limits)
46  , set(std::move(setter))
47  , get(std::move(getter))
48  , unit(unit)
49 {
50 }
function< void(uint)> set
function to set the value
QString tooltip
Tooltip text.
RealLimits limits
Limits of the value.
function< uint()> get
function to get the current value

◆ UIntDescriptor() [6/6]

UIntDescriptor::UIntDescriptor ( const QString &  label,
const QString &  tooltip,
function< void(uint)>  setter,
function< uint()>  getter,
const variant< QString, Unit > &  unit 
)
private

Operates on any kind of storage (e.g. session items), by using setter/getter methods limits is set to nonnegative.

Definition at line 33 of file UIntDescriptor.cpp.

36  : UIntDescriptor(label, tooltip, RealLimits::nonnegative(), setter, getter, unit)
37 {
38 }

Member Function Documentation

◆ operator uint()

UIntDescriptor::operator uint ( ) const

Return the current value of the handled parameter.

Definition at line 60 of file UIntDescriptor.cpp.

61 {
62  return get();
63 }

Member Data Documentation

◆ get

function<uint()> UIntDescriptor::get = nullptr

function to get the current value

Definition at line 70 of file UIntDescriptor.h.

Referenced by GUI::Util::createSpinBox(), MinimizerSettingsWidget::createSpinbox(), and UIntProperty::init().

◆ label

QString UIntDescriptor::label

A label text (short, no trailing colon)

Definition at line 66 of file UIntDescriptor.h.

Referenced by FormLayouter::addValue(), GUI::Util::createSpinBox(), and UIntProperty::init().

◆ limits

RealLimits UIntDescriptor::limits

Limits of the value.

Definition at line 68 of file UIntDescriptor.h.

Referenced by GUI::Util::createSpinBox(), MinimizerSettingsWidget::createSpinbox(), and UIntProperty::init().

◆ path

function<QString()> UIntDescriptor::path = nullptr

Path describing this value. Used e.g. for undo/redo.

Definition at line 72 of file UIntDescriptor.h.

Referenced by UIntProperty::init().

◆ set

function<void(uint)> UIntDescriptor::set = nullptr

◆ tooltip

QString UIntDescriptor::tooltip

◆ unit

variant<QString, Unit> UIntDescriptor::unit = Unit::unitless

Unit of the value (internal unit only!)

Definition at line 71 of file UIntDescriptor.h.

Referenced by GUI::Util::createSpinBox(), and UIntProperty::init().


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