BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
ResolutionFunctionEditor.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Instrument/ResolutionFunctionEditor.cpp
6 //! @brief Implements class ResolutionFunctionEditor
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 #include <QGroupBox>
23 
25  : QGroupBox("Resolution function", parent)
26  , m_unit(unit)
27  , m_item(item)
28 {
29  ASSERT(item);
30  setProperty("subgroup", true); // for stylesheet addressing
31  m_formLayout = new QFormLayout(this);
32  m_formLayout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
33 
34  auto* typeCombo =
36  createResolutionWidgets();
37  emit dataChanged();
38  });
39  m_formLayout->addRow("Type:", typeCombo);
40 
42 
44 }
45 
47 {
48  while (m_formLayout->rowCount() > 1)
49  m_formLayout->removeRow(1);
50 
51  auto* resFunction = m_item->resolutionFunctionSelection().currentItem();
52  if (auto* p = dynamic_cast<ResolutionFunction2DGaussianItem*>(resFunction)) {
53  auto* sigmaXSpinBox = GUI::Util::createSpinBox(m_formLayout, p->sigmaX());
54  auto* sigmaYSpinBox = GUI::Util::createSpinBox(m_formLayout, p->sigmaY());
55 
56  connect(sigmaXSpinBox, qOverload<double>(&DoubleSpinBox::baseValueChanged),
57  [=](double newValue) {
58  p->setSigmaX(newValue);
59  emit dataChanged();
60  });
61 
62  connect(sigmaYSpinBox, qOverload<double>(&DoubleSpinBox::baseValueChanged),
63  [=](double newValue) {
64  p->setSigmaY(newValue);
65  emit dataChanged();
66  });
67  }
68 }
Defines classes DetectorItems.
Defines class DoubleSpinBox.
Defines class GroupBoxCollapser.
A widget for editing the alignment of a detector.
Defines family of ResolutionFunctionItem.
Defines GUI::Util namespace.
SelectionDescriptor< ResolutionFunctionItem * > resolutionFunctionSelection() const
void baseValueChanged(double newBaseValue)
Emitted whenever the value changes.
static GroupBoxCollapser * installIntoGroupBox(QGroupBox *groupBox, bool expanded=true)
ResolutionFunctionEditor(Unit unit, QWidget *parent, DetectorItem *item)
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
QSpinBox * createSpinBox(QWidget *parent, const UIntDescriptor &d, std::function< void(uint)> slot=nullptr)
Create a spin box with the information found in a UIntDescriptor.
Definition: WidgetUtils.cpp:24