BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
GUI::View::EditUtil Namespace Reference

Functions

void configScientificDoubleEdit (QLineEdit *edit, const RealLimits &limits)
 
void configSpinbox (QDoubleSpinBox *spinBox, int decimals, const RealLimits &limits)
 

Function Documentation

◆ configScientificDoubleEdit()

void GUI::View::EditUtil::configScientificDoubleEdit ( QLineEdit *  edit,
const RealLimits &  limits 
)

Definition at line 33 of file EditUtil.cpp.

34 {
35  auto* validator = new QDoubleValidator(0.0, 1e+200, 1000, edit);
36  validator->setNotation(QDoubleValidator::ScientificNotation);
37 
38  const double minimum =
39  limits.hasLowerLimit() ? std::max(limits.lowerLimit(), -1e+200) : -1e+200;
40  const double maximum =
41  limits.hasUpperLimit() ? std::min(limits.upperLimit(), +1e+200) : +1e+200;
42  validator->setRange(minimum, maximum, 1000);
43 
44  edit->setValidator(validator);
45 }

Referenced by MaterialEditorDialog::MaterialEditorDialog().

◆ configSpinbox()

void GUI::View::EditUtil::configSpinbox ( QDoubleSpinBox *  spinBox,
int  decimals,
const RealLimits &  limits 
)

Definition at line 47 of file EditUtil.cpp.

49 {
50  spinBox->setMaximum(std::numeric_limits<double>::max());
51  spinBox->setMinimum(std::numeric_limits<double>::lowest());
52 
53  if (limits.hasLowerLimit())
54  spinBox->setMinimum(limits.lowerLimit());
55  if (limits.hasUpperLimit())
56  spinBox->setMaximum(limits.upperLimit());
57 
58  spinBox->setDecimals(decimals);
59  spinBox->setSingleStep(singleStep(decimals));
60 }

Referenced by DoubleSpinBox::DoubleSpinBox(), MaterialEditorDialog::MaterialEditorDialog(), and GUI::Util::createScientificSpinBox().