BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
EnvironmentEditor.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/EnvironmentEditor.cpp
6 //! @brief Implements class EnvironmentEditor
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 <QGridLayout>
22 #include <QSpacerItem>
23 
24 namespace {
25 const QString background_title("Background");
26 }
27 
28 EnvironmentEditor::EnvironmentEditor(ColumnResizer* columnResizer, QWidget* parent)
29  : SessionItemWidget(parent)
30  , m_columnResizer(columnResizer)
31  , m_backgroundEditor(new ComponentEditor(ComponentEditor::GroupWidget, background_title))
32  , m_gridLayout(new QGridLayout)
33 {
34  m_gridLayout->addWidget(m_backgroundEditor, 0, 0);
35  m_gridLayout->addWidget(LayoutUtils::placeHolder(), 0, 1);
36  m_gridLayout->addWidget(LayoutUtils::placeHolder(), 0, 2);
37 
38  auto mainLayout = new QVBoxLayout;
39  mainLayout->addLayout(m_gridLayout);
40  mainLayout->addStretch();
41  setLayout(mainLayout);
42 
46 }
47 
49 {
50  m_backgroundEditor->setItem(instrumentItem()->backgroundGroup());
51 }
52 
54 {
56 }
57 
59 {
60  auto result = dynamic_cast<InstrumentItem*>(currentItem());
61  ASSERT(result);
62  return result;
63 }
#define ASSERT(condition)
Definition: Assert.h:31
Defines class ColumnResizer.
Defines ComponentEditor class.
Defines class EnvironmentEditor.
Defines class GroupItem.
Defines InstrumentItems classes.
Defines LayoutUtils namespace.
The ColumnResizer class provides vertically aligned widgets from diferent layouts.
Definition: ColumnResizer.h:37
void addWidgetsFromGridLayout(QGridLayout *, int column)
Component editor for SessionItem.
void setItem(SessionItem *item)
QGridLayout * m_gridLayout
ComponentEditor * m_backgroundEditor
InstrumentItem * instrumentItem()
EnvironmentEditor(ColumnResizer *columnResizer, QWidget *parent=nullptr)
ColumnResizer * m_columnResizer
The SessionItemWidget class is a base for all widgets representing the content of SessionItem.
SessionItem * currentItem()
QWidget * placeHolder()
Returns empty widget to occupy place in layout.