BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
FootprintCorrectionEditor.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Instrument/FootprintCorrectionEditor.cpp
6 //! @brief Implements class FootprintCorrectionEditor
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
21 #include <QFormLayout>
22 
24  : QGroupBox("Footprint correction", parent)
25  , m_item(item)
26 {
27  ASSERT(item);
28  setProperty("subgroup", true); // for stylesheet addressing
29  m_formLayout = new QFormLayout(this);
30  m_formLayout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
31  auto* typeCombo = GUI::Util::createSelectionCombo(this, item->footprintSelection(), [=](int) {
32  createFootprintWidgets();
33  emit dataChanged();
34  });
35  m_formLayout->addRow("Type:", typeCombo);
36 
38 
40 }
41 
43 {
44  while (m_formLayout->rowCount() > 1)
45  m_formLayout->removeRow(1);
46 
47  auto* footprintItem = m_item->footprintSelection().currentItem();
48  if (auto* square = dynamic_cast<FootprintSquareItem*>(footprintItem)) {
49  auto* spinbox = new DoubleSpinBox(this, square->squareFootprintValue());
50  spinbox->setSingleStep(0.01);
51  m_formLayout->addRow("Width ratio:", spinbox);
52  connect(spinbox, qOverload<double>(&DoubleSpinBox::baseValueChanged), [=](double newValue) {
53  square->setSquareFootprintValue(newValue);
54  emit dataChanged();
55  });
56  } else if (auto* gauss = dynamic_cast<FootprintGaussianItem*>(footprintItem)) {
57  auto* spinbox = new DoubleSpinBox(this, gauss->gaussianFootprintValue());
58  spinbox->setSingleStep(0.01);
59  m_formLayout->addRow("Width ratio:", spinbox);
60  connect(spinbox, qOverload<double>(&DoubleSpinBox::baseValueChanged), [=](double newValue) {
61  gauss->setGaussianFootprintValue(newValue);
62  emit dataChanged();
63  });
64  }
65 }
Defines class DoubleSpinBox.
Defines class FootprintCorrectionEditor.
Declares FootprintItem classes.
Defines class GroupBoxCollapser.
Defines class InstrumentItem and all its children.
Defines GUI::Util namespace.
SpinBox for DoubleDescriptors, supporting units.
Definition: DoubleSpinBox.h:22
void baseValueChanged(double newBaseValue)
Emitted whenever the value changes.
FootprintCorrectionEditor(QWidget *parent, SpecularBeamItem *item)
static GroupBoxCollapser * installIntoGroupBox(QGroupBox *groupBox, bool expanded=true)
SelectionDescriptor< FootprintItem * > footprintSelection() const
Definition: BeamItems.cpp:166
QComboBox * createSelectionCombo(QWidget *parent, const SelectionDescriptor< T > d, std::function< void(int)> slot=nullptr)
Create a combo box with the information found in a selection descriptor.
Definition: WidgetUtils.h:45