BornAgain  1.19.0
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/coregui/Models/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 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
16 #include "Base/Const/Units.h"
18 
19 // ----------------------------------------------------------------------------
20 
21 const QString XRotationItem::P_ANGLE = "Angle";
22 
24 {
25  setToolTip("Particle rotation around x-axis");
26  addProperty(P_ANGLE, 0.0)->setToolTip("Rotation angle around x-axis in degrees");
27 }
28 
29 std::unique_ptr<IRotation> XRotationItem::createRotation() const
30 {
31  double alpha = Units::deg2rad(getItemValue(P_ANGLE).toDouble());
32  return std::make_unique<RotationX>(alpha);
33 }
34 
35 // ----------------------------------------------------------------------------
36 
37 const QString YRotationItem::P_ANGLE = "Angle";
38 
40 {
41  setToolTip("Particle rotation around y-axis");
42  addProperty(P_ANGLE, 0.0)->setToolTip("Rotation angle around y-axis in degrees");
43 }
44 
45 std::unique_ptr<IRotation> YRotationItem::createRotation() const
46 {
47  double alpha = Units::deg2rad(getItemValue(P_ANGLE).toDouble());
48  return std::make_unique<RotationY>(alpha);
49 }
50 
51 // ----------------------------------------------------------------------------
52 
53 const QString ZRotationItem::P_ANGLE = "Angle";
54 
56 {
57  setToolTip("Particle rotation around z-axis");
58  addProperty(P_ANGLE, 0.0)->setToolTip("Rotation angle around z-axis in degrees");
59 }
60 
61 std::unique_ptr<IRotation> ZRotationItem::createRotation() const
62 {
63  double alpha = Units::deg2rad(getItemValue(P_ANGLE).toDouble());
64  return std::make_unique<RotationZ>(alpha);
65 }
66 
67 // ----------------------------------------------------------------------------
68 
69 const QString EulerRotationItem::P_ALPHA = "Alpha";
70 const QString EulerRotationItem::P_BETA = "Beta";
71 const QString EulerRotationItem::P_GAMMA = "Gamma";
72 
74 {
75  setToolTip("Sequence of three rotations following Euler angles \n"
76  "notation z-x'-z'");
77  addProperty(P_ALPHA, 0.0)->setToolTip("First Euler anle in z-x'-z' sequence in degrees");
78  addProperty(P_BETA, 0.0)->setToolTip("Second Euler anle in z-x'-z' sequence in degrees");
79  addProperty(P_GAMMA, 0.0)->setToolTip("Third Euler anle in z-x'-z' sequence in degrees");
80 }
81 
82 std::unique_ptr<IRotation> EulerRotationItem::createRotation() const
83 {
84  double alpha = Units::deg2rad(getItemValue(P_ALPHA).toDouble());
85  double beta = Units::deg2rad(getItemValue(P_BETA).toDouble());
86  double gamma = Units::deg2rad(getItemValue(P_GAMMA).toDouble());
87  return std::make_unique<RotationEuler>(alpha, beta, gamma);
88 }
Defines class RotationItems.
Defines IRotation classes.
Defines some unit conversion factors and other constants in namespace Units.
static const QString P_BETA
Definition: RotationItems.h:52
static const QString P_ALPHA
Definition: RotationItems.h:51
std::unique_ptr< IRotation > createRotation() const
static const QString P_GAMMA
Definition: RotationItems.h:53
SessionItem * addProperty(const QString &name, const QVariant &variant)
Add new property item and register new tag.
QVariant getItemValue(const QString &tag) const
Directly access value of item under given tag.
SessionItem & setToolTip(const QString &tooltip)
static const QString P_ANGLE
Definition: RotationItems.h:30
std::unique_ptr< IRotation > createRotation() const
static const QString P_ANGLE
Definition: RotationItems.h:37
std::unique_ptr< IRotation > createRotation() const
static const QString P_ANGLE
Definition: RotationItems.h:44
std::unique_ptr< IRotation > createRotation() const
double deg2rad(double angle)
Definition: Units.h:59