BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
SliderSettingsWidget.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Fit/SliderSettingsWidget.cpp
6 //! @brief Implements class SliderSettingsWidget
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 
16 #include <QCheckBox>
17 #include <QGroupBox>
18 #include <QHBoxLayout>
19 #include <QLabel>
20 #include <QRadioButton>
21 #include <QVBoxLayout>
22 
24  : QWidget(parent)
25  , m_currentSliderRange(100.0)
26  , m_radio1(nullptr)
27  , m_radio2(nullptr)
28  , m_radio3(nullptr)
29  , m_lockzCheckBox(nullptr)
30 {
31  // tuning selectors
32  QString tooltip("Allows to tune sample parameters within +/- of given range \nwith the help of "
33  "the slider.");
34 
35  auto* label = new QLabel("Tuning:");
36  label->setToolTip(tooltip);
37 
38  m_radio1 = new QRadioButton("10%");
39  m_radio1->setAutoExclusive(true);
40  m_radio1->setToolTip(tooltip);
41  connect(m_radio1, &QRadioButton::clicked, this, &SliderSettingsWidget::rangeChanged);
42 
43  m_radio2 = new QRadioButton("100%");
44  m_radio2->setChecked(true);
45  m_radio2->setAutoExclusive(true);
46  m_radio2->setToolTip(tooltip);
47  connect(m_radio2, &QRadioButton::clicked, this, &SliderSettingsWidget::rangeChanged);
48 
49  m_radio3 = new QRadioButton("1000%");
50  m_radio3->setAutoExclusive(true);
51  m_radio3->setToolTip(tooltip);
52  connect(m_radio3, &QRadioButton::clicked, this, &SliderSettingsWidget::rangeChanged);
53 
54  // Fix z-axis
55  m_lockzCheckBox = new QCheckBox("Lock-Z");
56  m_lockzCheckBox->setToolTip(
57  "Preserve (min, max) range of intensity axis during parameter tuning.");
58  connect(m_lockzCheckBox, &QCheckBox::stateChanged, this, &SliderSettingsWidget::onLockZChanged);
59 
60  auto* hbox = new QHBoxLayout;
61 
62  hbox->addWidget(label);
63  hbox->addWidget(m_radio1);
64  hbox->addWidget(m_radio2);
65  hbox->addWidget(m_radio3);
66  hbox->addStretch(1);
67  hbox->addWidget(m_lockzCheckBox);
68 
69  setLayout(hbox);
70 }
71 
73 {
74  if (m_radio1->isChecked())
75  m_currentSliderRange = 10.0;
76  else if (m_radio2->isChecked())
77  m_currentSliderRange = 100.0;
78  else if (m_radio3->isChecked())
79  m_currentSliderRange = 1000.0;
80 
82 }
83 
85 {
86  if (state == Qt::Unchecked)
87  emit lockzChanged(false);
88  else if (state == Qt::Checked)
89  emit lockzChanged(true);
90 }
Defines class SliderSettingsWidget.
void sliderRangeFactorChanged(double value)
void lockzChanged(bool value)
void onLockZChanged(int state)
SliderSettingsWidget(QWidget *parent=nullptr)