BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
ProjectionsWidget.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Projection/ProjectionsWidget.cpp
6 //! @brief Implements class ProjectionsWidget
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 
18 #include <QTabWidget>
19 #include <QVBoxLayout>
20 
21 namespace {
22 
23 const int horizontal_projection_tab = 0;
24 const int vertical_projection_tab = 1;
25 
26 } // namespace
27 
29  : SessionItemWidget(parent)
30  , m_xProjection(new ProjectionsPlot(HorizontalLineItem::M_TYPE))
31  , m_yProjection(new ProjectionsPlot(VerticalLineItem::M_TYPE))
32  , m_tabWidget(new QTabWidget)
33 {
34  auto* layout = new QVBoxLayout;
35  layout->setMargin(0);
36  layout->setSpacing(0);
37 
38  m_tabWidget->setTabPosition(QTabWidget::North);
39  m_tabWidget->insertTab(HORIZONTAL, m_xProjection, "Horizontal");
40  m_tabWidget->insertTab(VERTICAL, m_yProjection, "Vertical");
41 
42  layout->addWidget(m_tabWidget);
43  setLayout(layout);
44 
45  setConnected(true);
46 }
47 
49 {
50  SessionItemWidget::setItem(intensityItem);
51  m_xProjection->setItem(intensityItem);
52  m_yProjection->setItem(intensityItem);
53 }
54 
55 void ProjectionsWidget::onActivityModeChanged(MaskEditorFlags::Activity value)
56 {
57  setConnected(false);
58 
60  m_tabWidget->setCurrentIndex(horizontal_projection_tab);
61  else if (value == MaskEditorFlags::VERTICAL_LINE_MODE)
62  m_tabWidget->setCurrentIndex(vertical_projection_tab);
63 
64  setConnected(true);
65 }
66 
67 void ProjectionsWidget::onMarginsChanged(double left, double right)
68 {
69  m_xProjection->onMarginsChanged(left, right);
70  m_yProjection->onMarginsChanged(left, right);
71 }
72 
74 {
75  if (tab_index == horizontal_projection_tab)
77  else if (tab_index == vertical_projection_tab)
79 }
80 
81 void ProjectionsWidget::setConnected(bool isConnected)
82 {
83  if (isConnected)
84  connect(m_tabWidget, &QTabWidget::currentChanged, this, &ProjectionsWidget::onTabChanged);
85  else
86  disconnect(m_tabWidget, &QTabWidget::currentChanged, this,
88 }
Defines MaskItems classes.
Defines class ProjectionsPlot.
Defines class ProjectionsWidget.
A customplot based widget to display projections of IntensityDataItem on X,Y axes.
void onMarginsChanged(double left, double right)
void changeActivityRequest(MaskEditorFlags::Activity value)
ProjectionsWidget(QWidget *parent=nullptr)
void onActivityModeChanged(MaskEditorFlags::Activity value)
ProjectionsPlot * m_yProjection
void onTabChanged(int tab_index)
void setConnected(bool isConnected)
QTabWidget * m_tabWidget
ProjectionsPlot * m_xProjection
void onMarginsChanged(double left, double right)
void setItem(SessionItem *intensityItem) override
The SessionItemWidget class is a base for all widgets representing the content of SessionItem....
virtual void setItem(SessionItem *item)
Base class for a GUI data item.
Definition: SessionItem.h:204