BornAgain
1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
|
SpinBox for DoubleDescriptors, supporting units.
Definition at line 22 of file DoubleSpinBox.h.
Signals | |
void | baseValueChanged (double newBaseValue) |
Emitted whenever the value changes. More... | |
Public Member Functions | |
DoubleSpinBox (QWidget *parent, const DoubleDescriptor &d) | |
Create a DoubleSpinBox with the information found in a DoubleDescriptor. More... | |
Unit | baseUnit () const |
Returns the unit of the contained DoubleDescriptor. More... | |
QString | displayUnitAsString () const |
The display unit as human readable string. More... | |
void | setBaseValue (double baseValue) |
Set the base value (unit is the one of the contained descriptor). More... | |
void | setDisplayUnit (Unit displayUnit) |
Set a display unit. More... | |
void | updateValue () |
Update the shown value to the one contained in the value descriptor. More... | |
const DoubleDescriptor & | valueDescriptor () const |
The descriptor on which this spinbox operates. More... | |
Protected Member Functions | |
void | wheelEvent (QWheelEvent *event) override |
Private Member Functions | |
void | onDisplayValueChanged (double newDisplayValue) |
double | toBaseValue (double displayValue) const |
double | toDisplayValue (double baseValue) const |
Private Attributes | |
Unit | m_displayUnit = Unit::unitless |
bool | m_showUnitAsSuffix = false |
it was decided to not show the unit as a suffix. However, this may be user selectable once, therefore the code is kept and controlled by this flag More... | |
DoubleDescriptor | m_valueDescriptor |
DoubleSpinBox::DoubleSpinBox | ( | QWidget * | parent, |
const DoubleDescriptor & | d | ||
) |
Create a DoubleSpinBox with the information found in a DoubleDescriptor.
The spin box will be fully initialized (tooltip, limits, unit, current value, size policy). Furthermore, the spin box will prohibit accidental changes by the mouse wheel. Otherwise it would be dangerous if the spin box is on a scrollable form - unintended and unnoticed changes would take place when just scrolling through the form.
Definition at line 19 of file DoubleSpinBox.cpp.
References GUI::View::EditUtil::configSpinbox(), DoubleDescriptor::decimals, DoubleDescriptor::limits, m_valueDescriptor, onDisplayValueChanged(), other, setDisplayUnit(), DoubleDescriptor::tooltip, and DoubleDescriptor::unit.
Unit DoubleSpinBox::baseUnit | ( | ) | const |
Returns the unit of the contained DoubleDescriptor.
If the unit is defined as a string, this method returns Unit::other. To get the string, use valueDescriptor().unit
Definition at line 94 of file DoubleSpinBox.cpp.
References m_valueDescriptor, other, and DoubleDescriptor::unit.
Referenced by toBaseValue(), toDisplayValue(), and MultiLayerForm::updateUnits().
|
signal |
Emitted whenever the value changes.
newBaseValue is in the unit of the valueDescriptor.
Referenced by AxisPropertyEditor::AxisPropertyEditor(), RectangularDetectorEditor::RectangularDetectorEditor(), MaskEditorPropertyPanel::addMaskSpinBox(), LayerEditorUtils::addMultiPropertyToGrid(), EnvironmentEditor::createBackgroundWidgets(), DistributionSelector::createDistributionWidgets(), MinimizerSettingsWidget::createDoubleSpinbox(), IntensityDataPropertyWidget::createDoubleSpinbox(), SpecularDataPropertyWidget::createDoubleSpinbox(), FootprintCorrectionEditor::createFootprintWidgets(), ResolutionFunctionEditor::createResolutionWidgets(), DistributionSelector::createSpinBox(), DetectorAlignmentEditor::createSpinBox(), GUI::Util::createSpinBox(), PolarizationAnalysisEditor::createSpinBox(), FormLayouter::insertValue(), and onDisplayValueChanged().
QString DoubleSpinBox::displayUnitAsString | ( | ) | const |
The display unit as human readable string.
Definition at line 63 of file DoubleSpinBox.cpp.
References m_displayUnit, m_valueDescriptor, DoubleDescriptor::unit, and unitAsString().
Referenced by setDisplayUnit(), and LayerEditorUtils::updateLabelUnit().
|
private |
Definition at line 89 of file DoubleSpinBox.cpp.
References baseValueChanged(), and toBaseValue().
Referenced by DoubleSpinBox().
void DoubleSpinBox::setBaseValue | ( | double | baseValue | ) |
Set the base value (unit is the one of the contained descriptor).
Definition at line 76 of file DoubleSpinBox.cpp.
References toDisplayValue().
Referenced by SampleEditorController::setDoubleFromUndo(), and updateValue().
void DoubleSpinBox::setDisplayUnit | ( | Unit | displayUnit | ) |
Set a display unit.
The caller has to make sure that the new display unit has a conversion to/from the contained base value unit.
Definition at line 37 of file DoubleSpinBox.cpp.
References displayUnitAsString(), DoubleDescriptor::get, m_displayUnit, m_showUnitAsSuffix, m_valueDescriptor, and toDisplayValue().
Referenced by DoubleSpinBox(), and MultiLayerForm::updateUnits().
|
private |
Definition at line 58 of file DoubleSpinBox.cpp.
References baseUnit(), convert(), and m_displayUnit.
Referenced by onDisplayValueChanged().
|
private |
Definition at line 53 of file DoubleSpinBox.cpp.
References baseUnit(), convert(), and m_displayUnit.
Referenced by setBaseValue(), and setDisplayUnit().
void DoubleSpinBox::updateValue | ( | ) |
Update the shown value to the one contained in the value descriptor.
No signal will be emitted if the new value has changed.
Definition at line 102 of file DoubleSpinBox.cpp.
References DoubleDescriptor::get, m_valueDescriptor, and setBaseValue().
Referenced by AxisPropertyEditor::updateData(), and ParticleLayoutForm::updateDensityValue().
const DoubleDescriptor & DoubleSpinBox::valueDescriptor | ( | ) | const |
The descriptor on which this spinbox operates.
Definition at line 71 of file DoubleSpinBox.cpp.
References m_valueDescriptor.
Referenced by SampleEditorController::setDoubleFromUndo().
|
overrideprotected |
Definition at line 81 of file DoubleSpinBox.cpp.
|
private |
Definition at line 77 of file DoubleSpinBox.h.
Referenced by displayUnitAsString(), setDisplayUnit(), toBaseValue(), and toDisplayValue().
|
private |
it was decided to not show the unit as a suffix. However, this may be user selectable once, therefore the code is kept and controlled by this flag
Definition at line 83 of file DoubleSpinBox.h.
Referenced by setDisplayUnit().
|
private |
Definition at line 79 of file DoubleSpinBox.h.
Referenced by DoubleSpinBox(), baseUnit(), displayUnitAsString(), setDisplayUnit(), updateValue(), and valueDescriptor().