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

Description

Off-specular beam editor. Operates on OffspecInstrumentItem.

Definition at line 24 of file OffspecBeamEditor.h.

Inheritance diagram for OffspecBeamEditor:
[legend]
Collaboration diagram for OffspecBeamEditor:
[legend]

Signals

void dataChanged ()
 

Public Member Functions

 OffspecBeamEditor (QWidget *parent, OffspecInstrumentItem *item)
 

Constructor & Destructor Documentation

◆ OffspecBeamEditor()

OffspecBeamEditor::OffspecBeamEditor ( QWidget *  parent,
OffspecInstrumentItem item 
)

Definition at line 29 of file OffspecBeamEditor.cpp.

30  : QGroupBox("Beam parameters", parent)
31 {
32  ASSERT(item);
33 
34  auto* vLayout = new QVBoxLayout(this);
35  vLayout->setContentsMargins(30, 8, 0, 0);
36  auto* form = new QFormLayout();
37  form->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
38  vLayout->addLayout(form);
39  auto* intensityEditor = new QLineEdit(this);
40  intensityEditor->setToolTip("Beam intensity in neutrons (or gammas per second.");
41  auto* validator = new FixupDoubleValidator(intensityEditor);
42  validator->setNotation(QDoubleValidator::ScientificNotation);
43  validator->setRange(0.0, 1e+32, 1000);
44  intensityEditor->setValidator(validator);
45  form->addRow("Intensity:", intensityEditor);
46 
47  auto* wavelengthEditor =
48  new DistributionEditor("Wavelength", MeanConfig{true}, GUI::ID::Distributions::All, this,
49  item->beamItem()->wavelengthItem());
50  vLayout->addWidget(wavelengthEditor);
51 
52  auto* inclinationEditor = new AxisPropertyEditor(this, "Inclination angle", &item->alphaAxis());
53  vLayout->addWidget(inclinationEditor);
54 
55  auto* azimuthalEditor =
56  new DistributionEditor("Azimuthal angle", MeanConfig{false}, GUI::ID::Distributions::All,
57  this, item->beamItem()->azimuthalAngleItem());
58  vLayout->addWidget(azimuthalEditor);
59 
60  intensityEditor->setText(QString::number(item->beamItem()->intensity()));
61 
63 
64  connect(wavelengthEditor, &DistributionEditor::distributionChanged, this,
66  connect(inclinationEditor, &AxisPropertyEditor::dataChanged, this,
68  connect(azimuthalEditor, &DistributionEditor::distributionChanged, this,
70 
71  // validate value while typing
72  connect(intensityEditor, &QLineEdit::textEdited, [=]() {
73  QString str = intensityEditor->text();
74  int pos;
75  if (intensityEditor->validator()->validate(str, pos) == QValidator::Acceptable) {
76  item->beamItem()->setIntensity(intensityEditor->text().toDouble());
77  emit dataChanged();
78  }
79  });
80  // if validator does not assert the input value, it says about that,
81  // and here we return to the last correct value
82  connect(validator, &FixupDoubleValidator::fixupSignal, [=]() {
83  auto* editor = qobject_cast<QLineEdit*>(validator->parent());
84  editor->setText(QString::number(item->beamItem()->intensity(), 'g'));
85  });
86 }
Use this to edit an AxisProperty.
DistributionSelector as above but contained in a GroupBox with a title and a button to open the distr...
void distributionChanged()
The FixupDoubleValidator class is a derivative of QDoubleValidator with non-empty "fixup" method....
void fixupSignal() const
static GroupBoxCollapser * installIntoGroupBox(QGroupBox *groupBox, bool expanded=true)
virtual BeamItem * beamItem() const
configuration to control how the user can enter a mean value

References GUI::ID::All, InstrumentItem::beamItem(), AxisPropertyEditor::dataChanged(), dataChanged(), DistributionEditor::distributionChanged(), FixupDoubleValidator::fixupSignal(), and GroupBoxCollapser::installIntoGroupBox().

Here is the call graph for this function:

Member Function Documentation

◆ dataChanged

void OffspecBeamEditor::dataChanged ( )
signal

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