BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
SphericalAxisEditor.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Instrument/SphericalAxisEditor.cpp
6 //! @brief Implement class SphericalAxisEditor
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 
17 #include <QDoubleSpinBox>
18 #include <QFormLayout>
19 #include <QGroupBox>
20 #include <QSpinBox>
21 
22 SphericalAxisForm::SphericalAxisForm(QFormLayout* form, QWidget* parent)
23  : QObject(parent)
24  , m_item(nullptr)
25 {
26  m_nbinsSpinBox = new QSpinBox(parent);
27  m_nbinsSpinBox->setRange(1, 65536);
28  connect(m_nbinsSpinBox, qOverload<int>(&QSpinBox::valueChanged), this,
30  form->addRow("Nbins:", m_nbinsSpinBox);
31 
32  m_minimumSpinBox = new QDoubleSpinBox(parent);
33  m_minimumSpinBox->setRange(0, 90);
34  m_minimumSpinBox->setDecimals(3);
35  m_minimumSpinBox->setSingleStep(0.01);
36  connect(m_minimumSpinBox, qOverload<double>(&QDoubleSpinBox::valueChanged), this,
38  form->addRow("Minimum [deg]:", m_minimumSpinBox);
39 
40  m_maximumSpinBox = new QDoubleSpinBox(parent);
41  m_maximumSpinBox->setRange(0, 90);
42  m_maximumSpinBox->setDecimals(3);
43  m_maximumSpinBox->setSingleStep(0.01);
44  connect(m_maximumSpinBox, qOverload<double>(&QDoubleSpinBox::valueChanged), this,
46  form->addRow("Maximum [deg]:", m_maximumSpinBox);
47 }
48 
50 {
51  m_item = item;
53  updateData();
54 }
55 
57 {
58  m_nbinsSpinBox->setEnabled(enabled);
59  m_minimumSpinBox->setEnabled(enabled);
60  m_maximumSpinBox->setEnabled(enabled);
61 }
62 
64 {
65  QSignalBlocker b1(m_nbinsSpinBox);
66  QSignalBlocker b2(m_minimumSpinBox);
67  QSignalBlocker b3(m_maximumSpinBox);
68  if (m_item) {
69  m_nbinsSpinBox->setValue(m_item->binCount());
70  m_minimumSpinBox->setValue(m_item->min());
71  m_maximumSpinBox->setValue(m_item->max());
72  } else {
73  m_nbinsSpinBox->setValue(1);
74  m_minimumSpinBox->setValue(0.0);
75  m_maximumSpinBox->setValue(0.0);
76  }
77 }
78 
80 {
81  if (m_item && m_item->binCount() != value) {
82  m_item->setBinCount(value);
83  emit dataChanged();
84  }
85 }
86 
88 {
89  if (m_item && m_item->min() != value) {
90  m_item->setLowerBound(value);
91  emit dataChanged();
92  if (m_item->max() < value)
93  m_maximumSpinBox->setValue(value);
94  }
95 }
96 
98 {
99  if (m_item && m_item->max() != value) {
100  m_item->setUpperBound(value);
101  emit dataChanged();
102  if (m_item->min() > value)
103  m_minimumSpinBox->setValue(value);
104  }
105 }
Defines various axis items.
Defines class SphericalAxisEditor.
DoubleDescriptor min(const QString &unit=QString()) const
Definition: AxesItems.cpp:41
int binCount() const
Definition: AxesItems.cpp:26
void setBinCount(size_t value)
Definition: AxesItems.cpp:31
void setLowerBound(double value)
Definition: AxesItems.cpp:48
void setUpperBound(double value)
Definition: AxesItems.cpp:65
DoubleDescriptor max(const QString &unit=QString()) const
Definition: AxesItems.cpp:58
QDoubleSpinBox * m_maximumSpinBox
void setEnabled(bool enabled)
QDoubleSpinBox * m_minimumSpinBox
void setItem(BasicAxisItem *item)
BasicAxisItem * m_item
void onMaximumValueChanged(double value)
void onNbinsValueChanged(int value)
void onMinimumValueChanged(double value)
SphericalAxisForm(QFormLayout *form, QWidget *parent)
void updateData()
Reload UI from data.