BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
RotationItems.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Model/Sample/RotationItems.cpp
6 //! @brief Implements class RotationItems
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2021
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
16 #include "Base/Const/Units.h"
17 #include "Base/Vector/RotMatrix.h"
19 #include "Sample/Scattering/Rotations.h"
20 
21 using namespace Units;
22 
23 // ----------------------------------------------------------------------------
24 
26 
27 RotMatrix RotationItem::rotation() const
28 {
29  auto p = createRotation();
30  return (p != nullptr) ? p->rotMatrix() : RotMatrix();
31 }
32 
33 // ----------------------------------------------------------------------------
34 
36 {
37  m_angle.init("Angle", "Rotation angle around x-axis", 0.0, Unit::degree, "angle");
38 }
39 
41 {
42  s.assertVersion(0);
43  Serialize::rwProperty(s, m_angle);
44 }
45 
46 unique_ptr<IRotation> XRotationItem::createRotation() const
47 {
48  return std::make_unique<RotationX>(deg2rad(angle()));
49 }
50 
52 {
53  return m_angle;
54 }
55 
56 // ----------------------------------------------------------------------------
57 
59 {
60  m_angle.init("Angle", "Rotation angle around y-axis", 0.0, Unit::degree, "angle");
61 }
62 
64 {
65  s.assertVersion(0);
66  Serialize::rwProperty(s, m_angle);
67 }
68 
69 unique_ptr<IRotation> YRotationItem::createRotation() const
70 {
71  return std::make_unique<RotationY>(deg2rad(angle()));
72 }
73 
75 {
76  return m_angle;
77 }
78 
79 // ----------------------------------------------------------------------------
80 
82 {
83  m_angle.init("Angle", "Rotation angle around z-axis", 0.0, Unit::degree, "angle");
84 }
85 
87 {
88  s.assertVersion(0);
89  Serialize::rwProperty(s, m_angle);
90 }
91 
92 unique_ptr<IRotation> ZRotationItem::createRotation() const
93 {
94  return std::make_unique<RotationZ>(deg2rad(angle()));
95 }
96 
98 {
99  return m_angle;
100 }
101 
102 // ----------------------------------------------------------------------------
103 
105 {
106  m_alpha.init("Alpha", "First Euler angle in z-x'-z' sequence", 0.0, Unit::degree, "alpha");
107  m_beta.init("Beta", "Second Euler angle in z-x'-z' sequence", 0.0, Unit::degree, "beta");
108  m_gamma.init("Gamma", "Third Euler angle in z-x'-z' sequence", 0.0, Unit::degree, "gamma");
109 }
110 
112 {
113  s.assertVersion(0);
114  Serialize::rwProperty(s, m_alpha);
116  Serialize::rwProperty(s, m_gamma);
117 }
118 
119 unique_ptr<IRotation> EulerRotationItem::createRotation() const
120 {
121  return std::make_unique<RotationEuler>(deg2rad(alpha()), deg2rad(beta()), deg2rad(gamma()));
122 }
123 
125 {
126  return m_alpha;
127 }
128 
130 {
131  return m_beta;
132 }
133 
135 {
136  return m_gamma;
137 }
#define m_beta
Defines class RotationItems.
Defines class Streamer.
@ degree
Describes properties of a double value which are necessary to allow GUI representation,...
unique_ptr< IRotation > createRotation() const override
DoubleDescriptor alpha() const
void serialize(Streamer &s) override
DoubleDescriptor gamma() const
DoubleDescriptor beta() const
RotMatrix rotation() const
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
unique_ptr< IRotation > createRotation() const override
void serialize(Streamer &s) override
DoubleDescriptor angle() const
DoubleDescriptor angle() const
void serialize(Streamer &s) override
unique_ptr< IRotation > createRotation() const override
DoubleDescriptor angle() const
unique_ptr< IRotation > createRotation() const override
void serialize(Streamer &s) override
void rwProperty(Streamer &s, DoubleProperty &d)