BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
VectorProperty.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Model/Descriptor/VectorProperty.h
6 //! @brief Defines class VectorProperty
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 
15 #ifndef BORNAGAIN_GUI_MODEL_DESCRIPTOR_VECTORPROPERTY_H
16 #define BORNAGAIN_GUI_MODEL_DESCRIPTOR_VECTORPROPERTY_H
17 
19 #include <heinz/Vectors3D.h>
20 
21 class Streamer;
22 
23 //! Holds a 3D vector of type R3 as well as additional info like label, tooltip.
24 //!
25 //! Use this as a member in your class to hold a 3D vector if you want to have support for
26 //! serialization, and if this vector is editable on the UI.
27 //!
28 //! For a more complete documentation about property classes, please refer to DoubleProperty.
29 //!
30 //! \sa VectorDescriptor
31 //! \sa DoubleProperty
32 //!
34 public:
35  void init(const QString& label, const QString& tooltip, const variant<QString, Unit>& unit,
36  const QString& persistentTag);
37 
39  operator VectorDescriptor() const { return m_descriptor; }
40  operator R3() const { return m_value; }
41  void set(const R3& d) { m_value = d; }
42  R3 get() const { return m_value; }
43 
44  QString persistentTag() const { return m_persistentTag; }
45  QString uid() const { return m_uid; }
46  void setUid(const QString& uid) { m_uid = uid; }
47 
48  R3& r3() { return m_value; }
49 
50 private:
51  R3 m_value;
52  QString m_persistentTag;
53  QString m_uid;
54 
56 };
57 
58 namespace Serialize {
60 } // namespace Serialize
61 
62 //! Add a member, a getter and a setter for a VectorProperty
63 #define VECTOR_PROPERTY(nameLower, nameUpper) \
64 protected: \
65  VectorProperty m_##nameLower; \
66  \
67 public: \
68  VectorDescriptor nameLower() const { return m_##nameLower; } \
69  void set##nameUpper(const R3& v) { m_##nameLower.set(v); }
70 ;
71 
72 
73 #endif // BORNAGAIN_GUI_MODEL_DESCRIPTOR_VECTORPROPERTY_H
Defines class VectorDescriptor.
Supports serialization to or deserialization from QXmlStream.
Definition: Streamer.h:36
Describes properties of a 3D vector, consisting of three double values.
Holds a 3D vector of type R3 as well as additional info like label, tooltip.
QString m_persistentTag
QString persistentTag() const
void set(const R3 &d)
void setUid(const QString &uid)
void init(const QString &label, const QString &tooltip, const variant< QString, Unit > &unit, const QString &persistentTag)
R3 get() const
VectorDescriptor descriptor() const
QString uid() const
VectorDescriptor m_descriptor
Functions to serialize various data types.
Definition: SessionItem.h:339
void rwProperty(Streamer &s, DoubleProperty &d)