1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
|
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file GUI/Model/Sample/ProfileItems.cpp
//! @brief Implements classes Profile1DItem, Profile2DItem, and subclasses.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#include "GUI/Model/Sample/ProfileItems.h"
#include "Base/Const/Units.h"
#include "GUI/Model/Util/UtilXML.h"
namespace {
namespace Tag {
const QString Omega("Omega");
const QString OmegaX("OmegaX");
const QString OmegaY("OmegaY");
const QString Eta("Eta");
const QString Gamma("Gamma");
const QString BaseData("BaseData");
} // namespace Tag
} // namespace
Profile1DItem::Profile1DItem()
{
m_omega.init("Omega", "nm", "Half-width of the distribution", 1.0, "omega");
}
void Profile1DItem::writeTo(QXmlStreamWriter* w) const
{
m_omega.writeTo2(w, Tag::Omega);
}
void Profile1DItem::readFrom(QXmlStreamReader* r)
{
while (r->readNextStartElement()) {
QString tag = r->name().toString();
if (tag == Tag::Omega)
m_omega.readFrom2(r, tag);
else
r->skipCurrentElement();
}
}
DoubleProperties Profile1DItem::profileProperties()
{
return {&m_omega};
}
// --------------------------------------------------------------------------------------------- //
std::unique_ptr<IProfile1D> Profile1DCauchyItem::createProfile() const
{
return std::make_unique<Profile1DCauchy>(m_omega.dVal());
}
// --------------------------------------------------------------------------------------------- //
std::unique_ptr<IProfile1D> Profile1DGaussItem::createProfile() const
{
return std::make_unique<Profile1DGauss>(m_omega.dVal());
}
// --------------------------------------------------------------------------------------------- //
std::unique_ptr<IProfile1D> Profile1DGateItem::createProfile() const
{
return std::make_unique<Profile1DGate>(m_omega.dVal());
}
// --------------------------------------------------------------------------------------------- //
std::unique_ptr<IProfile1D> Profile1DTriangleItem::createProfile() const
{
return std::make_unique<Profile1DTriangle>(m_omega.dVal());
}
// --------------------------------------------------------------------------------------------- //
std::unique_ptr<IProfile1D> Profile1DCosineItem::createProfile() const
{
return std::make_unique<Profile1DCosine>(m_omega.dVal());
}
// --------------------------------------------------------------------------------------------- //
Profile1DVoigtItem::Profile1DVoigtItem()
{
m_eta.init("Eta", "", "Parameter [0,1] to balance between Cauchy (eta=0.0) and Gauss (eta=1.0)",
0.5, 3, RealLimits::limited(0.0, 1.0), "eta");
}
std::unique_ptr<IProfile1D> Profile1DVoigtItem::createProfile() const
{
return std::make_unique<Profile1DVoigt>(m_omega.dVal(), m_eta.dVal());
}
void Profile1DVoigtItem::writeTo(QXmlStreamWriter* w) const
{
XML::writeBaseElement<Profile1DItem>(w, XML::Tag::BaseData, this);
// eta
m_eta.writeTo2(w, Tag::Eta);
}
void Profile1DVoigtItem::readFrom(QXmlStreamReader* r)
{
while (r->readNextStartElement()) {
QString tag = r->name().toString();
if (tag == Tag::BaseData)
XML::readBaseElement<Profile1DItem>(r, tag, this);
else if (tag == Tag::Eta) {
m_eta.readFrom2(r, tag);
} else
r->skipCurrentElement();
}
}
DoubleProperties Profile1DVoigtItem::profileProperties()
{
return Profile1DItem::profileProperties() + DoubleProperties{&m_eta};
}
// --------------------------------------------------------------------------------------------- //
Profile2DItem::Profile2DItem()
{
m_omegaX.init("OmegaX", "nm", "Half-width of the distribution along its x-axis", 1.0, "omegaX");
m_omegaY.init("OmegaY", "nm", "Half-width of the distribution along its y-axis", 1.0, "omegaY");
m_gamma.init(
"Gamma", "deg",
"Angle in direct space between first lattice vector and x-axis of the distribution", 0.0, 2,
1.0, RealLimits::limited(0.0, 360.0), "gamma");
}
void Profile2DItem::writeTo(QXmlStreamWriter* w) const
{
m_omegaX.writeTo2(w, Tag::OmegaX);
m_omegaY.writeTo2(w, Tag::OmegaY);
m_gamma.writeTo2(w, Tag::Gamma);
}
void Profile2DItem::readFrom(QXmlStreamReader* r)
{
while (r->readNextStartElement()) {
QString tag = r->name().toString();
if (tag == Tag::OmegaX)
m_omegaX.readFrom2(r, tag);
else if (tag == Tag::OmegaY)
m_omegaY.readFrom2(r, tag);
else if (tag == Tag::Gamma)
m_gamma.readFrom2(r, tag);
else
r->skipCurrentElement();
}
}
DoubleProperties Profile2DItem::profileProperties()
{
return {&m_omegaX, &m_omegaY, &m_gamma};
}
// --------------------------------------------------------------------------------------------- //
std::unique_ptr<IProfile2D> Profile2DCauchyItem::createProfile() const
{
return std::make_unique<Profile2DCauchy>(m_omegaX.dVal(), m_omegaY.dVal(),
Units::deg2rad(m_gamma.dVal()));
}
// --------------------------------------------------------------------------------------------- //
std::unique_ptr<IProfile2D> Profile2DGaussItem::createProfile() const
{
return std::make_unique<Profile2DGauss>(m_omegaX.dVal(), m_omegaY.dVal(),
Units::deg2rad(m_gamma.dVal()));
}
// --------------------------------------------------------------------------------------------- //
std::unique_ptr<IProfile2D> Profile2DGateItem::createProfile() const
{
return std::make_unique<Profile2DGate>(m_omegaX.dVal(), m_omegaY.dVal(),
Units::deg2rad(m_gamma.dVal()));
}
// --------------------------------------------------------------------------------------------- //
std::unique_ptr<IProfile2D> Profile2DConeItem::createProfile() const
{
return std::make_unique<Profile2DCone>(m_omegaX.dVal(), m_omegaY.dVal(),
Units::deg2rad(m_gamma.dVal()));
}
// --------------------------------------------------------------------------------------------- //
Profile2DVoigtItem::Profile2DVoigtItem()
{
m_eta.init("Eta", "", "Parameter [0,1] to balance between Cauchy (eta=0.0) and Gauss (eta=1.0)",
0.5, 3, RealLimits::limited(0.0, 1.0), "eta");
}
std::unique_ptr<IProfile2D> Profile2DVoigtItem::createProfile() const
{
return std::make_unique<Profile2DVoigt>(m_omegaX.dVal(), m_omegaY.dVal(),
Units::deg2rad(m_gamma.dVal()), m_eta.dVal());
}
void Profile2DVoigtItem::writeTo(QXmlStreamWriter* w) const
{
XML::writeBaseElement<Profile2DItem>(w, XML::Tag::BaseData, this);
// eta
m_eta.writeTo2(w, Tag::Eta);
}
void Profile2DVoigtItem::readFrom(QXmlStreamReader* r)
{
while (r->readNextStartElement()) {
QString tag = r->name().toString();
if (tag == Tag::BaseData)
XML::readBaseElement<Profile2DItem>(r, tag, this);
else if (tag == Tag::Eta) {
m_eta.readFrom2(r, tag);
} else
r->skipCurrentElement();
}
}
DoubleProperties Profile2DVoigtItem::profileProperties()
{
return {&m_omegaX, &m_omegaY, &m_eta, &m_gamma};
}
|