From ad9f60a085a8835cc0681d7b919d57a04388208e Mon Sep 17 00:00:00 2001 From: Matthias Puchner <github@mpuchner.de> Date: Fri, 15 Oct 2021 08:23:08 +0200 Subject: [PATCH] introduce descriptor class to describe a 3D vector --- GUI/Models/VectorDescriptor.h | 41 +++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 GUI/Models/VectorDescriptor.h diff --git a/GUI/Models/VectorDescriptor.h b/GUI/Models/VectorDescriptor.h new file mode 100644 index 00000000000..cffe9629674 --- /dev/null +++ b/GUI/Models/VectorDescriptor.h @@ -0,0 +1,41 @@ +// ************************************************************************************************ +// +// BornAgain: simulate and fit reflection and scattering +// +//! @file GUI/Models/VectorDescriptor.h +//! @brief Defines class VectorDescriptor +//! +//! @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) +// +// ************************************************************************************************ + +#ifndef BORNAGAIN_GUI_MODELS_VECTORDESCRIPTOR_H +#define BORNAGAIN_GUI_MODELS_VECTORDESCRIPTOR_H + +#include "GUI/Models/DoubleDescriptor.h" +#include "GUI/Models/VectorItem.h" + +//! Describes properties of a 3D vector, consisting of three double values. +//! +//! By using this class, the underlying data scheme is hidden from the user of the data. This e.g. +//! eases SessionItem migration. The underlying implementation can be a VectorItem, a member array +//! of three doubles, three double members, or any other construction to hold the three values. +class VectorDescriptor { +public: + //! Operates on a VectorItem. + //! + //! The settings (like decimals, limits) are taken from the item. + //! Only for easier migration. Should be removed after SessionItem refactoring. + VectorDescriptor(VectorItem* item, const variant<QString, Unit>& unit) + : x(item->xItem(), unit), y(item->yItem(), unit), z(item->zItem(), unit) + { + } + DoubleDescriptor x; + DoubleDescriptor y; + DoubleDescriptor z; +}; + +#endif // BORNAGAIN_GUI_MODELS_VECTORDESCRIPTOR_H -- GitLab