BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
DetectorEditor.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Instrument/DetectorEditor.cpp
6 //! @brief Implements class DetectorEditor
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 
23 #include <QFormLayout>
24 
25 
26 DetectorEditor::DetectorEditor(QWidget* parent, Instrument2DItem* instrument)
27  : QGroupBox("Detector parameters", parent)
28  , m_instrument(instrument)
29 {
30  ASSERT(instrument);
31  m_formLayout = new QFormLayout(this);
32 
33  auto* detectorTypeCombo =
34  GUI::Util::createSelectionCombo(this, instrument->detectorSelection(), [=](int) {
35  createDetectorWidgets();
36  emit dataChanged();
37  });
38  m_formLayout->addRow("Detector:", detectorTypeCombo);
39 
41 
43 }
44 
46 {
47  while (m_formLayout->rowCount() > 1)
48  m_formLayout->removeRow(1);
49 
50  auto* detectorItem = m_instrument->detectorSelection().currentItem();
51  if (auto* rect = dynamic_cast<RectangularDetectorItem*>(detectorItem)) {
52  auto* editor = new RectangularDetectorEditor(this, rect);
53  m_formLayout->addRow(editor);
54  connect(editor, &RectangularDetectorEditor::dataChanged, this,
56  } else if (auto* spher = dynamic_cast<SphericalDetectorItem*>(detectorItem)) {
57  auto* editor = new SphericalDetectorEditor(this, spher);
58  m_formLayout->addRow(editor);
60  } else
61  ASSERT(false);
62 }
Defines class DetectorEditor.
Defines class GroupBoxCollapser.
Defines class InstrumentItem and all its children.
Defines class RectangularDetectorEditor.
Defines class RectangularDetectorItem.
Defines class SphericalDetectorEditor.
Defines class SphericalDetectorItem.
Defines GUI::Util namespace.
void dataChanged()
void createDetectorWidgets()
DetectorEditor(QWidget *parent, Instrument2DItem *item)
QFormLayout * m_formLayout
Instrument2DItem * m_instrument
static GroupBoxCollapser * installIntoGroupBox(QGroupBox *groupBox, bool expanded=true)
SelectionDescriptor< DetectorItem * > detectorSelection() const
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