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

Description

GISAS beam editor. Operates on GISASInstrumentItem.

Definition at line 24 of file GISASBeamEditor.h.

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

Signals

void dataChanged ()
 

Public Member Functions

 GISASBeamEditor (QWidget *parent, BeamItem *item)
 

Constructor & Destructor Documentation

◆ GISASBeamEditor()

GISASBeamEditor::GISASBeamEditor ( QWidget *  parent,
BeamItem item 
)

Definition at line 28 of file GISASBeamEditor.cpp.

29  : QGroupBox("Beam parameters", parent)
30 {
31  ASSERT(item);
32  auto* vLayout = new QVBoxLayout(this);
33  vLayout->setContentsMargins(30, 8, 0, 0);
34  auto* form = new QFormLayout();
35  form->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
36  vLayout->addLayout(form);
37  auto* intensityEditor = new QLineEdit(this);
38  intensityEditor->setToolTip("Beam intensity in neutrons (or gammas per second.");
39  auto* validator = new FixupDoubleValidator(intensityEditor);
40  validator->setNotation(QDoubleValidator::ScientificNotation);
41  validator->setRange(0.0, 1e+32, 1000);
42  intensityEditor->setValidator(validator);
43 
44  form->addRow("Intensity:", intensityEditor);
45 
46  auto* wavelengthEditor = new DistributionEditor(
47  "Wavelength", MeanConfig{true}, GUI::ID::Distributions::All, this, item->wavelengthItem());
48  vLayout->addWidget(wavelengthEditor);
49 
50  auto* inclinationEditor =
51  new DistributionEditor("Inclination angle", MeanConfig{false}, GUI::ID::Distributions::All,
52  this, item->inclinationAngleItem());
53  vLayout->addWidget(inclinationEditor);
54 
55  auto* azimuthalEditor =
56  new DistributionEditor("Azimuthal angle", MeanConfig{false}, GUI::ID::Distributions::All,
57  this, item->azimuthalAngleItem());
58  vLayout->addWidget(azimuthalEditor);
59 
60  intensityEditor->setText(QString::number(item->intensity()));
61 
63 
64  connect(wavelengthEditor, &DistributionEditor::distributionChanged, this,
66  connect(inclinationEditor, &DistributionEditor::distributionChanged, 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->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->intensity(), 'g'));
85  });
86 }
virtual BeamDistributionItem * inclinationAngleItem() const
Definition: BeamItems.cpp:77
BeamAzimuthalAngleItem * azimuthalAngleItem() const
Definition: BeamItems.cpp:92
BeamWavelengthItem * wavelengthItem() const
Definition: BeamItems.cpp:67
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)
configuration to control how the user can enter a mean value

References GUI::ID::All, BeamItem::azimuthalAngleItem(), dataChanged(), DistributionEditor::distributionChanged(), FixupDoubleValidator::fixupSignal(), BeamItem::inclinationAngleItem(), GroupBoxCollapser::installIntoGroupBox(), and BeamItem::wavelengthItem().

Here is the call graph for this function:

Member Function Documentation

◆ dataChanged

void GISASBeamEditor::dataChanged ( )
signal

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