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
|
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file GUI/Model/Sample/RotationItems.cpp
//! @brief Implements class RotationItems.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2021
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#include "GUI/Model/Sample/RotationItems.h"
#include "Base/Const/Units.h"
#include "GUI/Model/Util/UtilXML.h"
namespace {
namespace Tag {
const QString Angle("Angle");
const QString Alpha("Alpha");
const QString Beta("Beta");
const QString Gamma("Gamma");
} // namespace Tag
} // namespace
using namespace Units;
// ----------------------------------------------------------------------------
void XYZRotationItem::writeTo(QXmlStreamWriter* w) const
{
m_angle.writeTo2(w, Tag::Angle);
}
void XYZRotationItem::readFrom(QXmlStreamReader* r)
{
while (r->readNextStartElement()) {
QString tag = r->name().toString();
if (tag == Tag::Angle)
m_angle.readFrom2(r, tag);
else
r->skipCurrentElement();
}
}
// ----------------------------------------------------------------------------
XRotationItem::XRotationItem()
{
m_angle.init("Angle", "deg", "Rotation angle around x-axis", 0.0, 2, 1.0,
RealLimits::limited(0.0, 360.0), "angle");
}
unique_ptr<IRotation> XRotationItem::createRotation() const
{
return std::make_unique<RotationX>(deg2rad(m_angle.dVal()));
}
// ----------------------------------------------------------------------------
YRotationItem::YRotationItem()
{
m_angle.init("Angle", "deg", "Rotation angle around y-axis", 0.0, 2, 1.0,
RealLimits::limited(0.0, 360.0), "angle");
}
unique_ptr<IRotation> YRotationItem::createRotation() const
{
return std::make_unique<RotationY>(deg2rad(m_angle.dVal()));
}
// ----------------------------------------------------------------------------
ZRotationItem::ZRotationItem()
{
m_angle.init("Angle", "deg", "Rotation angle around z-axis", 0.0, 2, 1.0,
RealLimits::limited(0.0, 360.0), "angle");
}
unique_ptr<IRotation> ZRotationItem::createRotation() const
{
return std::make_unique<RotationZ>(deg2rad(m_angle.dVal()));
}
// ----------------------------------------------------------------------------
EulerRotationItem::EulerRotationItem()
{
m_alpha.init("Alpha", "deg", "First Euler angle in z-x'-z' sequence", 0.0, 2, 1.0,
RealLimits::limited(0.0, 360.0), "alpha");
m_beta.init("Beta", "deg", "Second Euler angle in z-x'-z' sequence", 0.0, 2, 1.0,
RealLimits::limited(0.0, 360.0), "beta");
m_gamma.init("Gamma", "deg", "Third Euler angle in z-x'-z' sequence", 0.0, 2, 1.0,
RealLimits::limited(0.0, 360.0), "gamma");
}
void EulerRotationItem::writeTo(QXmlStreamWriter* w) const
{
m_alpha.writeTo2(w, Tag::Alpha);
m_beta.writeTo2(w, Tag::Beta);
m_gamma.writeTo2(w, Tag::Gamma);
}
void EulerRotationItem::readFrom(QXmlStreamReader* r)
{
while (r->readNextStartElement()) {
QString tag = r->name().toString();
if (tag == Tag::Alpha)
m_alpha.readFrom2(r, tag);
else if (tag == Tag::Beta)
m_beta.readFrom2(r, tag);
else if (tag == Tag::Gamma)
m_gamma.readFrom2(r, tag);
else
r->skipCurrentElement();
}
}
unique_ptr<IRotation> EulerRotationItem::createRotation() const
{
return std::make_unique<RotationEuler>(deg2rad(m_alpha.dVal()), deg2rad(m_beta.dVal()),
deg2rad(m_gamma.dVal()));
}
|