BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
GISASDetectorEditor.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Views/InstrumentWidgets/GISASDetectorEditor.cpp
6 //! @brief Implements class GISASDetectorEditor
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 <QVBoxLayout>
22 
24  : SessionItemWidget(parent)
25  , m_detectorTypeEditor(
26  new ComponentEditor(ComponentEditor::PlainWidget | ComponentEditor::W_NoChildren))
27  , m_detectorPresenter(new DetectorPresenter)
28 {
29  auto mainLayout = new QVBoxLayout;
30  mainLayout->addWidget(m_detectorTypeEditor);
31  mainLayout->addWidget(m_detectorPresenter);
32  mainLayout->addStretch();
33  setLayout(mainLayout);
34 }
35 
37 {
39  [this](const QString& name) {
42  },
43  this);
44 
45  m_detectorTypeEditor->setItem(instrumentItem()->detectorGroup());
47 }
48 
50 {
52 }
53 
55 {
56  auto result = dynamic_cast<Instrument2DItem*>(currentItem());
57  ASSERT(result);
58  return result;
59 }
60 
61 //! Shows detector editor corresponding to the currently selected detector in detectorGroup.
62 
64 {
65  m_detectorPresenter->setItem(instrumentItem()->detectorItem());
66 }
#define ASSERT(condition)
Definition: Assert.h:31
Defines ComponentEditor class.
Defines classes DetectorItems.
Defines class DetectorPresenter.
Defines class GISASDetectorEditor.
Defines class GroupItem.
Defines InstrumentItems classes.
Component editor for SessionItem.
void setItem(SessionItem *item)
Contains stack of detector editors and the logic to show proper editor for certain type of detector i...
ComponentEditor * m_detectorTypeEditor
DetectorPresenter * m_detectorPresenter
GISASDetectorEditor(QWidget *parent=nullptr)
void updateDetectorPresenter()
Shows detector editor corresponding to the currently selected detector in detectorGroup.
Instrument2DItem * instrumentItem()
static const QString P_DETECTOR
void setOnPropertyChange(std::function< void(QString)> f, const void *caller=0)
Definition: ModelMapper.cpp:35
The SessionItemWidget class is a base for all widgets representing the content of SessionItem.
SessionItem * currentItem()
virtual void setItem(SessionItem *item)
ModelMapper * mapper()
Returns the current model mapper of this item. Creates new one if necessary.
QString const & name(EShape k)
Definition: particles.cpp:21