BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
RectangularDetectorEditor.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Instrument/RectangularDetectorEditor.cpp
6 //! @brief Implements class RectangularDetectorEditor
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 <QFormLayout>
23 #include <QGridLayout>
24 #include <QGroupBox>
25 #include <QSpinBox>
26 #include <QVBoxLayout>
27 
29  RectangularDetectorItem* detector)
30  : QWidget(parent)
31 {
32  ASSERT(detector);
33 
34  auto* grid = new QGridLayout(this);
35  grid->setColumnStretch(0, 1);
36  grid->setColumnStretch(1, 1);
37  grid->setColumnStretch(2, 1);
38 
39  // -- x-axis controls
40  auto* xAxisGroupBox = new QGroupBox("X axis", this);
41  xAxisGroupBox->setProperty("subgroup", true); // for stylesheet addressing
42  auto* xAxisFormLayout = new QFormLayout(xAxisGroupBox);
43 
44  auto* xAxisNbinsSpinBox = new QSpinBox(xAxisGroupBox);
45  xAxisNbinsSpinBox->setRange(1, 65536);
46  xAxisNbinsSpinBox->setValue(detector->xSize());
47  xAxisFormLayout->addRow("Nbins:", xAxisNbinsSpinBox);
48 
49  auto* widthSpinBox = new DoubleSpinBox(xAxisGroupBox, detector->width());
50  xAxisFormLayout->addRow("Width [mm]:", widthSpinBox);
51 
52  connect(xAxisNbinsSpinBox, qOverload<int>(&QSpinBox::valueChanged), [=](int newValue) {
53  detector->setXSize(newValue);
54  emit dataChanged();
55  });
56 
57  connect(widthSpinBox, qOverload<double>(&DoubleSpinBox::baseValueChanged),
58  [=](double newValue) {
59  detector->setWidth(newValue);
60  emit dataChanged();
61  });
62  grid->addWidget(xAxisGroupBox, 1, 0);
64 
65 
66  // -- y-axis controls
67  auto* yAxisGroupBox = new QGroupBox("Y axis", this);
68  yAxisGroupBox->setProperty("subgroup", true); // for stylesheet addressing
69  auto* yAxisFormLayout = new QFormLayout(yAxisGroupBox);
70 
71  auto* yAxisNbinsSpinBox = new QSpinBox(yAxisGroupBox);
72  yAxisNbinsSpinBox->setRange(1, 65536);
73  yAxisNbinsSpinBox->setValue(detector->ySize());
74  yAxisFormLayout->addRow("Nbins:", yAxisNbinsSpinBox);
75 
76  auto* heightSpinBox = new DoubleSpinBox(yAxisGroupBox, detector->height());
77  yAxisFormLayout->addRow("Height [mm]:", heightSpinBox);
78 
79  connect(yAxisNbinsSpinBox, qOverload<int>(&QSpinBox::valueChanged), [=](int newValue) {
80  detector->setYSize(newValue);
81  emit dataChanged();
82  });
83 
84  connect(heightSpinBox, qOverload<double>(&DoubleSpinBox::baseValueChanged),
85  [=](double newValue) {
86  detector->setHeight(newValue);
87  emit dataChanged();
88  });
89  grid->addWidget(yAxisGroupBox, 1, 1);
91 
92  // -- resolution function
93  auto* resolutionFunctionEditor =
95  grid->addWidget(resolutionFunctionEditor, 1, 2);
96 
97  connect(resolutionFunctionEditor, &ResolutionFunctionEditor::dataChanged, this,
99 
100  // alignment selector editors
101  auto* alignmentEditor = new DetectorAlignmentEditor(this, detector);
102  grid->addWidget(alignmentEditor, 2, 0, 1, 3);
103 
104  connect(alignmentEditor, &DetectorAlignmentEditor::dataChanged, this,
106 }
Defines various axis items.
A widget for editing the alignment of a detector.
Defines class DoubleSpinBox.
Defines class GroupBoxCollapser.
Defines class RectangularDetectorEditor.
Defines class RectangularDetectorItem.
A widget for editing the alignment of a detector.
Widget for selecting the alignment of a detector (combo box) and input of the corresponding values.
SpinBox for DoubleDescriptors, supporting units.
Definition: DoubleSpinBox.h:22
void baseValueChanged(double newBaseValue)
Emitted whenever the value changes.
static GroupBoxCollapser * installIntoGroupBox(QGroupBox *groupBox, bool expanded=true)
RectangularDetectorEditor(QWidget *parent, RectangularDetectorItem *item)
int ySize() const override
Returns the size of y-axis of the detector.
void setXSize(size_t nx) override
sets the size of x-axis of the detector
void setYSize(size_t ny) override
sets the size of y-axis of the detector
int xSize() const override
Returns the size of x-axis of the detector.
Widget for selecting the resolution function of a detector (combo box) and input of the corresponding...