BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
modelutils.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file gui2/model/modelutils.h
6 //! @brief Defines class CLASS?
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2020
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_GUI2_MODEL_MODELUTILS_H
16 #define BORNAGAIN_GUI2_MODEL_MODELUTILS_H
17 
18 #include "darefl_export.h"
19 #include <string>
20 #include <vector>
21 
22 namespace ModelView {
23 class GraphItem;
24 class Data1DItem;
25 class ExternalProperty;
26 } // namespace ModelView
27 
28 namespace gui2 {
29 
30 class ExperimentalDataModel;
31 
32 namespace Utils {
33 
34 //! Returns property representing given graph.
35 //! Used to link with the graph from various editors.
37 
38 //! Returns vector of properties representing GraphItem content of the model.
39 DAREFLCORE_EXPORT std::vector<ModelView::ExternalProperty>
40 CreateGraphProperties(ExperimentalDataModel* model);
41 
42 //! Finds the property with the same `id` in given vector and returns it.
43 DAREFLCORE_EXPORT ModelView::ExternalProperty
44 FindProperty(const std::vector<ModelView::ExternalProperty>& properties, const std::string& id);
45 
46 //! Returns vector representing elementwise 2*(a-b)/(a+b) difference over two vectors.
47 //! Resulting vector will have size equal to min(a.size(), b.size())
48 DAREFLCORE_EXPORT std::vector<double> CreateDiffVector(const std::vector<double>& a,
49  const std::vector<double>& b);
50 
51 //! Make target item represent difference of two Data1DItems. Target will get an axis as in data1.
52 DAREFLCORE_EXPORT void SetDifference(const ModelView::Data1DItem* data1,
53  const ModelView::Data1DItem* data2,
54  ModelView::Data1DItem* target);
55 } // namespace Utils
56 
57 } // namespace gui2
58 
59 #endif // BORNAGAIN_GUI2_MODEL_MODELUTILS_H
The ExternalProperty class defines custom QVariant property to carry the text, color and an identifie...
Represents one-dimensional data (axis and values).
Definition: data1ditem.h:30
Property to carry text, color and identifier.
One-dimensional graph representation of Data1DItem.
Definition: graphitem.h:29
materialitems.h Collection of materials to populate MaterialModel.
DAREFLCORE_EXPORT std::vector< double > CreateDiffVector(const std::vector< double > &a, const std::vector< double > &b)
Returns vector representing elementwise 2*(a-b)/(a+b) difference over two vectors.
Definition: modelutils.cpp:66
DAREFLCORE_EXPORT ModelView::ExternalProperty CreateProperty(const ModelView::GraphItem *graph)
Returns property representing given graph.
Definition: modelutils.cpp:39
DAREFLCORE_EXPORT void SetDifference(const ModelView::Data1DItem *data1, const ModelView::Data1DItem *data2, ModelView::Data1DItem *target)
Make target item represent difference of two Data1DItems. Target will get an axis as in data1.
Definition: modelutils.cpp:78
DAREFLCORE_EXPORT ModelView::ExternalProperty FindProperty(const std::vector< ModelView::ExternalProperty > &properties, const std::string &id)
Finds the property with the same id in given vector and returns it.
Definition: modelutils.cpp:56
DAREFLCORE_EXPORT std::vector< ModelView::ExternalProperty > CreateGraphProperties(ExperimentalDataModel *model)
Returns vector of properties representing GraphItem content of the model.
Definition: modelutils.cpp:46
Based on Qt example "codeeditor" Copyright (C) 2016 The Qt Company Ltd.
Definition: app_constants.h:20