BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
InclinationAnglesEditor.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Instrument/InclinationAnglesEditor.cpp
6 //! @brief Defines class InclinationAnglesEditor
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 
22 #include <QComboBox>
23 #include <QFormLayout>
24 
26  : QGroupBox("Inclination angles [deg]", parent)
27  , m_item(item)
28 {
29  setProperty("subgroup", true); // for stylesheet addressing
30 
31  auto* hLayout = new QHBoxLayout(this);
32  hLayout->setSpacing(50);
33  auto* gform = new QFormLayout;
34  gform->setSpacing(6);
35  hLayout->addLayout(gform);
36 
37  m_selector =
39  gform->addRow(m_selector);
40 
41  auto* typeComboBox = new QComboBox(this);
42  typeComboBox->addItem("Uniform axis");
43  typeComboBox->addItem("Non-uniform axis");
44  gform->addRow("Axis type:", typeComboBox);
45  connect(typeComboBox, qOverload<int>(&QComboBox::currentIndexChanged), this,
47 
48  m_form = new SphericalAxisForm(gform, this);
49 
50  const int idx = m_item->pointwiseAlphaAxisSelected() ? 1 : 0;
51  ASSERT(idx != -1);
52  if (idx != typeComboBox->currentIndex())
53  typeComboBox->setCurrentIndex(idx);
54  else
55  onAxisTypeSelected(idx); // trigger update manually
56  typeComboBox->setEnabled(m_item->pointwiseAlphaAxisDefined());
57 
58  m_plot = new DistributionPlot(this);
59  m_plot->setFixedSize(280, 170);
60  m_plot->setShowMouseCoords(false);
61  hLayout->addWidget(m_plot);
62  hLayout->setAlignment(m_plot, Qt::AlignTop);
63  hLayout->addStretch(1);
64 
66 
72 
73  updatePlot();
74 }
75 
77 {
78  m_form->updateData();
79 }
80 
82 {
83  if (m_item) {
84  if (index == 0 && m_item->pointwiseAlphaAxisSelected()) {
86  emit dataChanged();
87  } else if (index == 1 && !m_item->pointwiseAlphaAxisSelected()) {
89  emit dataChanged();
90  }
91 
93  m_form->setEnabled(index == 0);
94  }
95 }
96 
98 {
99  auto* d = m_selector->item()->distribution();
100  m_plot->setVisible(!dynamic_cast<const DistributionNoneItem*>(d));
101  m_plot->setItem(d);
102  m_plot->plotItem();
103 }
A widget for selecting a distribution and setting its parameters.
Defines class DistributionPlot.
Defines class GroupBoxCollapser.
Defines class InclinationAnglesEditor.
Defines pointwise axis item.
Declares the class SpecularBeamInclinationItem.
Defines class SphericalAxisEditor.
DistributionItem * distribution() const
The DistributionPlot class plots 1d functions corresponding to domain's Distribution1D.
void setShowMouseCoords(bool b)
void setItem(DistributionItem *item)
Widget for selecting a distribution (combo box) and input of the corresponding values with respect to...
BeamDistributionItem * item() const
static GroupBoxCollapser * installIntoGroupBox(QGroupBox *groupBox, bool expanded=true)
SpecularBeamInclinationItem * m_item
InclinationAnglesEditor(QWidget *parent, SpecularBeamInclinationItem *item)
DistributionSelector * m_selector
BeamInclinationAxisItem contains inclination angle axis for specular/off-specular simulations and als...
BasicAxisItem * alphaAxis() const
The currently selected axis.
bool pointwiseAlphaAxisDefined() const
True if a pointwise axis was defined.
bool pointwiseAlphaAxisSelected() const
True if pointwise axis is selected.
The form for a spherical axis: contains the bare bone widgets for the user to enter the number of bin...
void setEnabled(bool enabled)
void setItem(BasicAxisItem *item)
void updateData()
Reload UI from data.