BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
SphericalDetectorItem.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Models/SphericalDetectorItem.cpp
6 //! @brief Implements class SphericalDetectorItem
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 "Base/Const/Units.h"
19 
20 const QString SphericalDetectorItem::P_PHI_AXIS = "Phi axis";
21 const QString SphericalDetectorItem::P_ALPHA_AXIS = "Alpha axis";
22 
24 {
25  auto phiAxis = addProperty<BasicAxisItem>(P_PHI_AXIS);
26  phiAxis->getItem(BasicAxisItem::P_TITLE)->setVisible(false);
27  phiAxis->setLowerBound(-1.0);
28  phiAxis->setUpperBound(1.0);
29 
30  phiAxis->getItem(BasicAxisItem::P_NBINS)->setToolTip("Number of phi-axis bins");
31  phiAxis->getItem(BasicAxisItem::P_MIN_DEG)->setToolTip("Low edge of first phi-bin (in deg)");
32  phiAxis->getItem(BasicAxisItem::P_MAX_DEG)->setToolTip("Upper edge of last phi-bin (in deg)");
33 
34  auto alphaAxis = addProperty<BasicAxisItem>(P_ALPHA_AXIS);
35  alphaAxis->getItem(BasicAxisItem::P_TITLE)->setVisible(false);
36  alphaAxis->setLowerBound(0.0);
37  alphaAxis->setUpperBound(2.0);
38 
39  alphaAxis->getItem(BasicAxisItem::P_NBINS)->setToolTip("Number of alpha-axis bins");
40  alphaAxis->getItem(BasicAxisItem::P_MIN_DEG)
41  ->setToolTip("Low edge of first alpha-bin (in deg)");
42  alphaAxis->getItem(BasicAxisItem::P_MAX_DEG)
43  ->setToolTip("Upper edge of last alpha-bin (in deg)");
44 
46 }
47 
48 std::unique_ptr<IDetector2D> SphericalDetectorItem::createDomainDetector() const
49 {
50  int n_x = phiAxisItem()->binCount();
51  double x_min = Units::deg2rad(phiAxisItem()->lowerBound());
52  double x_max = Units::deg2rad(phiAxisItem()->upperBound());
53 
54  int n_y = alphaAxisItem()->binCount();
55  double y_min = Units::deg2rad(alphaAxisItem()->lowerBound());
56  double y_max = Units::deg2rad(alphaAxisItem()->upperBound());
57 
58  return std::make_unique<SphericalDetector>(n_x, x_min, x_max, n_y, y_min, y_max);
59 }
60 
62 {
63  return phiAxisItem()->binCount();
64 }
65 
67 {
68  return alphaAxisItem()->binCount();
69 }
70 
72 {
73  phiAxisItem()->setBinCount(nx);
74 }
75 
77 {
79 }
80 
82 {
83  return item<BasicAxisItem>(P_PHI_AXIS);
84 }
85 
87 {
88  return item<BasicAxisItem>(P_PHI_AXIS);
89 }
90 
92 {
93  return item<BasicAxisItem>(P_ALPHA_AXIS);
94 }
95 
97 {
98  return item<BasicAxisItem>(P_ALPHA_AXIS);
99 }
100 
102 {
103  return Units::deg;
104 }
Defines various axis items.
Defines class SphericalDetectorItem.
Defines class SphericalDetector.
Defines some unit conversion factors and other constants in namespace Units.
void setBinCount(int value)
Definition: AxesItems.cpp:37
static const QString P_NBINS
Definition: AxesItems.h:26
static const QString P_MAX_DEG
Definition: AxesItems.h:28
static const QString P_TITLE
Definition: AxesItems.h:29
int binCount() const
Definition: AxesItems.cpp:32
static const QString P_MIN_DEG
Definition: AxesItems.h:27
void register_resolution_function()
void setXSize(int nx) override
sets the size of x-axis of the detector
int xSize() const override
returns the size of x-axis of the detector
double axesToDomainUnitsFactor() const override
Scales the values provided by axes (to perform deg->rad conversion on the way to domain).
static const QString P_ALPHA_AXIS
const BasicAxisItem * alphaAxisItem() const
int ySize() const override
returns the size of y-axis of the detector
const BasicAxisItem * phiAxisItem() const
static const QString P_PHI_AXIS
void setYSize(int ny) override
sets the size of y-axis of the detector
std::unique_ptr< IDetector2D > createDomainDetector() const override
double deg2rad(double angle)
Definition: Units.h:59
static constexpr double deg
Definition: Units.h:46