BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
ProfileItems.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Model/Sample/ProfileItems.cpp
6 //! @brief Implements Profile1DItem's classes
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"
18 
20 {
21  m_omega.init("Omega", "Half-width of the distribution", 1.0, Unit::nanometer, "omega");
22 }
23 
25 {
26  s.assertVersion(0);
28 }
29 
31 {
32  return m_omega;
33 }
34 
36 {
37  return {omega()};
38 }
39 
40 // --------------------------------------------------------------------------------------------- //
41 
42 std::unique_ptr<IProfile1D> Profile1DCauchyItem::createProfile() const
43 {
44  return std::make_unique<Profile1DCauchy>(omega());
45 }
46 
47 // --------------------------------------------------------------------------------------------- //
48 
49 std::unique_ptr<IProfile1D> Profile1DGaussItem::createProfile() const
50 {
51  return std::make_unique<Profile1DGauss>(omega());
52 }
53 
54 // --------------------------------------------------------------------------------------------- //
55 
56 std::unique_ptr<IProfile1D> Profile1DGateItem::createProfile() const
57 {
58  return std::make_unique<Profile1DGate>(omega());
59 }
60 
61 // --------------------------------------------------------------------------------------------- //
62 
63 std::unique_ptr<IProfile1D> Profile1DTriangleItem::createProfile() const
64 {
65  return std::make_unique<Profile1DTriangle>(omega());
66 }
67 
68 // --------------------------------------------------------------------------------------------- //
69 
70 std::unique_ptr<IProfile1D> Profile1DCosineItem::createProfile() const
71 {
72  return std::make_unique<Profile1DCosine>(omega());
73 }
74 
75 // --------------------------------------------------------------------------------------------- //
76 
78 {
79  m_eta.init("Eta", "Parameter [0,1] to balance between Cauchy (eta=0.0) and Gauss (eta=1.0)",
80  0.5, Unit::unitless, 3, RealLimits::limited(0.0, 1.0), "eta");
81 }
82 
83 std::unique_ptr<IProfile1D> Profile1DVoigtItem::createProfile() const
84 {
85  return std::make_unique<Profile1DVoigt>(omega(), m_eta);
86 }
87 
89 {
90  s.assertVersion(0);
93 }
94 
96 {
97  return m_eta;
98 }
99 
101 {
103 }
104 
105 // --------------------------------------------------------------------------------------------- //
106 
108 {
109  m_omegaX.init("OmegaX", "Half-width of the distribution along its x-axis", 1.0, Unit::nanometer,
110  "omegaX");
111  m_omegaY.init("OmegaY", "Half-width of the distribution along its y-axis", 1.0, Unit::nanometer,
112  "omegaY");
113  m_gamma.init(
114  "Gamma",
115  "Angle in direct space between first lattice vector and x-axis of the distribution", 0.0,
116  Unit::degree, "gamma");
117 }
118 
120 {
121  s.assertVersion(0);
125 }
126 
128 {
129  return m_omegaX;
130 }
131 
132 void Profile2DItem::setOmegaX(const double omega_x)
133 {
134  m_omegaX.set(omega_x);
135 }
136 
138 {
139  return m_omegaY;
140 }
141 
142 void Profile2DItem::setOmegaY(const double omega_y)
143 {
144  m_omegaY.set(omega_y);
145 }
146 
148 {
149  return m_gamma;
150 }
151 
152 void Profile2DItem::setGamma(const double gamma)
153 {
154  m_gamma.set(gamma);
155 }
156 
158 {
159  return {omegaX(), omegaY(), gamma()};
160 }
161 
162 // --------------------------------------------------------------------------------------------- //
163 
164 std::unique_ptr<IProfile2D> Profile2DCauchyItem::createProfile() const
165 {
166  return std::make_unique<Profile2DCauchy>(omegaX(), omegaY(), Units::deg2rad(gamma()));
167 }
168 
169 // --------------------------------------------------------------------------------------------- //
170 
171 std::unique_ptr<IProfile2D> Profile2DGaussItem::createProfile() const
172 {
173  return std::make_unique<Profile2DGauss>(omegaX(), omegaY(), Units::deg2rad(gamma()));
174 }
175 
176 // --------------------------------------------------------------------------------------------- //
177 
178 std::unique_ptr<IProfile2D> Profile2DGateItem::createProfile() const
179 {
180  return std::make_unique<Profile2DGate>(omegaX(), omegaY(), Units::deg2rad(gamma()));
181 }
182 
183 // --------------------------------------------------------------------------------------------- //
184 
185 std::unique_ptr<IProfile2D> Profile2DConeItem::createProfile() const
186 {
187  return std::make_unique<Profile2DCone>(omegaX(), omegaY(), Units::deg2rad(gamma()));
188 }
189 
190 // --------------------------------------------------------------------------------------------- //
191 
193 {
194  m_eta.init("Eta", "Parameter [0,1] to balance between Cauchy (eta=0.0) and Gauss (eta=1.0)",
195  0.5, Unit::unitless, 3, RealLimits::limited(0.0, 1.0), "eta");
196 }
197 
198 std::unique_ptr<IProfile2D> Profile2DVoigtItem::createProfile() const
199 {
200  return std::make_unique<Profile2DVoigt>(omegaX(), omegaY(), Units::deg2rad(gamma()), m_eta);
201 }
202 
204 {
205  s.assertVersion(0);
210 }
211 
213 {
214  return m_eta;
215 }
216 
218 {
219  m_eta.set(eta);
220 }
221 
223 {
224  return {omegaX(), omegaY(), eta(), gamma()};
225 }
QList< DoubleDescriptor > DoubleDescriptors
Defines Profile1DItem's classes.
Defines class Streamer.
@ unitless
@ nanometer
@ degree
Describes properties of a double value which are necessary to allow GUI representation,...
void set(double d)
Set the contained value.
void init(const QString &label, const QString &tooltip, double value, const variant< QString, Unit > &unit, const QString &persistentTag)
std::unique_ptr< IProfile1D > createProfile() const override
std::unique_ptr< IProfile1D > createProfile() const override
std::unique_ptr< IProfile1D > createProfile() const override
std::unique_ptr< IProfile1D > createProfile() const override
virtual DoubleDescriptors valueDescriptors() const
virtual void serialize(Streamer &s)
DoubleProperty m_omega
Definition: ProfileItems.h:42
DoubleDescriptor omega() const
std::unique_ptr< IProfile1D > createProfile() const override
std::unique_ptr< IProfile1D > createProfile() const override
DoubleDescriptor eta() const
DoubleProperty m_eta
Definition: ProfileItems.h:80
void serialize(Streamer &s) override
DoubleDescriptors valueDescriptors() const override
std::unique_ptr< IProfile2D > createProfile() const override
std::unique_ptr< IProfile2D > createProfile() const override
std::unique_ptr< IProfile2D > createProfile() const override
std::unique_ptr< IProfile2D > createProfile() const override
virtual DoubleDescriptors valueDescriptors() const
DoubleProperty m_omegaX
Definition: ProfileItems.h:104
DoubleDescriptor omegaX() const
void setOmegaX(double omega_x)
DoubleDescriptor gamma() const
DoubleProperty m_omegaY
Definition: ProfileItems.h:105
void setOmegaY(double omega_y)
DoubleProperty m_gamma
Definition: ProfileItems.h:106
virtual void serialize(Streamer &s)
DoubleDescriptor omegaY() const
void setGamma(double gamma)
DoubleDescriptors valueDescriptors() const override
void serialize(Streamer &s) override
void setEta(double eta)
DoubleDescriptor eta() const
std::unique_ptr< IProfile2D > createProfile() const override
DoubleProperty m_eta
Definition: ProfileItems.h:141
Supports serialization to or deserialization from QXmlStream.
Definition: Streamer.h:36
void assertVersion(unsigned expectedVersion) const
As reader, throws DeserializationException unless the expected version is read. As writer,...
Definition: Streamer.cpp:26
void rwProperty(Streamer &s, DoubleProperty &d)