BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
Lattice2DItems.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Model/Sample/Lattice2DItems.cpp
6 //! @brief Implements classes Lattice2DItems
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"
17 #include "Base/Util/Assert.h"
19 #include "Sample/Lattice/Lattice2D.h"
20 
22 {
24  "Xi", "Rotation of lattice with respect to x-axis of reference frame (beam direction)", 0.0,
25  Unit::degree, "xi");
26 }
27 
29 {
30  return createLattice()->unitCellArea();
31 }
32 
34 {
36 }
37 
39 {
41 }
42 
43 // --------------------------------------------------------------------------------------------- //
44 
46 {
47  m_length1.init("LatticeLength1", "Length of first lattice vector", 20.0, Unit::nanometer,
48  "len1");
49  m_length2.init("LatticeLength2", "Length of second lattice vector", 20.0, Unit::nanometer,
50  "len2");
51  m_angle.init("Angle", "Angle between lattice vectors", 90.0, Unit::degree, "angle");
52 }
53 
54 std::unique_ptr<Lattice2D> BasicLattice2DItem::createLattice() const
55 {
56  return std::make_unique<BasicLattice2D>(m_length1, m_length2, Units::deg2rad(m_angle),
57  Units::deg2rad(latticeRotationAngle()));
58 }
59 
61 {
62  s.assertVersion(0);
67 }
68 
70 {
71  return m_length1;
72 }
73 
74 void BasicLattice2DItem::setLatticeLength1(const double length1)
75 {
76  m_length1.set(length1);
77 }
78 
80 {
81  return m_length2;
82 }
83 
84 void BasicLattice2DItem::setLatticeLength2(const double length2)
85 {
86  m_length2.set(length2);
87 }
88 
90 {
91  return m_angle;
92 }
93 
94 void BasicLattice2DItem::setLatticeAngle(const double angle)
95 {
96  m_angle.set(angle);
97 }
98 
99 // --------------------------------------------------------------------------------------------- //
100 
102 {
103  m_length.init("LatticeLength", "Length of first and second lattice vectors", 20.0,
104  Unit::nanometer, "len");
105 }
106 
107 std::unique_ptr<Lattice2D> SquareLattice2DItem::createLattice() const
108 {
109  return std::make_unique<SquareLattice2D>(m_length, Units::deg2rad(latticeRotationAngle()));
110 }
111 
113 {
114  s.assertVersion(0);
117 }
118 
120 {
121  return m_length;
122 }
123 
124 void SquareLattice2DItem::setLatticeLength(const double length)
125 {
126  m_length.set(length);
127 }
128 
129 // --------------------------------------------------------------------------------------------- //
130 
132 {
133  m_length.init("LatticeLength", "Length of first and second lattice vectors", 20.0,
134  Unit::nanometer, "len");
135 }
136 
137 std::unique_ptr<Lattice2D> HexagonalLattice2DItem::createLattice() const
138 {
139  return std::make_unique<HexagonalLattice2D>(m_length, Units::deg2rad(latticeRotationAngle()));
140 }
141 
143 {
144  s.assertVersion(0);
147 }
148 
150 {
151  return m_length;
152 }
153 
155 {
156  m_length.set(length);
157 }
Defines classes Lattice2DItems.
Defines class Streamer.
@ nanometer
@ degree
DoubleProperty m_angle
DoubleDescriptor latticeAngle() const
std::unique_ptr< Lattice2D > createLattice() const override
void setLatticeLength2(double length2)
DoubleProperty m_length1
DoubleDescriptor latticeLength2() const
DoubleDescriptor latticeLength1() const
void setLatticeLength1(double length1)
void setLatticeAngle(double angle)
void serialize(Streamer &s) override
DoubleProperty m_length2
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)
DoubleProperty m_length
DoubleDescriptor latticeLength() const
std::unique_ptr< Lattice2D > createLattice() const override
void serialize(Streamer &s) override
void setLatticeLength(double length)
void setLatticeRotationAngle(double angle)
double unitCellArea() const
virtual std::unique_ptr< Lattice2D > createLattice() const =0
DoubleDescriptor latticeRotationAngle() const
DoubleProperty m_latticeRotationAngle
DoubleDescriptor latticeLength() const
std::unique_ptr< Lattice2D > createLattice() const override
void setLatticeLength(double length)
void serialize(Streamer &s) override
DoubleProperty m_length
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)