File: ProfileCatalogs.cpp

package info (click to toggle)
bornagain 23.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 103,936 kB
  • sloc: cpp: 423,131; python: 40,997; javascript: 11,167; awk: 630; sh: 318; ruby: 173; xml: 130; makefile: 51; ansic: 24
file content (142 lines) | stat: -rw-r--r-- 4,484 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
//  ************************************************************************************************
//
//  BornAgain: simulate and fit reflection and scattering
//
//! @file      GUI/Model/Sample/ProfileCatalogs.cpp
//! @brief     Implements classes Profile1DCatalog, Profile2DCatalog.
//!
//! @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)
//
//  ************************************************************************************************

#include "GUI/Model/Sample/ProfileCatalogs.h"
#include "Base/Util/Assert.h"
#include "GUI/Model/Sample/ProfileItems.h"

Profile1DItem* Profile1DCatalog::create(Type type)
{
    switch (type) {
    case Type::Cauchy:
        return new Profile1DCauchyItem;
    case Type::Gauss:
        return new Profile1DGaussItem;
    case Type::Gate:
        return new Profile1DGateItem;
    case Type::Triangle:
        return new Profile1DTriangleItem;
    case Type::Cosine:
        return new Profile1DCosineItem;
    case Type::Voigt:
        return new Profile1DVoigtItem;
    default:
        ASSERT_NEVER;
    }
}

QVector<Profile1DCatalog::Type> Profile1DCatalog::types()
{
    return {Type::Cauchy, Type::Gauss, Type::Gate, Type::Triangle, Type::Cosine, Type::Voigt};
}

UiInfo Profile1DCatalog::uiInfo(Type type)
{
    switch (type) {
    case Type::Cauchy:
        return {"Cauchy 1D", "One-dimensional Cauchy probability distribution", ""};
    case Type::Gauss:
        return {"Gauss 1D", "One-dimensional Gauss probability distribution", ""};
    case Type::Gate:
        return {"Gate 1D", "One-dimensional Gate probability distribution", ""};
    case Type::Triangle:
        return {"Triangle 1D", "One-dimensional triangle probability distribution", ""};
    case Type::Cosine:
        return {"Cosine 1D", "One-dimensional Cosine probability distribution", ""};
    case Type::Voigt:
        return {"Voigt 1D", "One-dimensional pseudo-Voigt probability distribution", ""};
    default:
        ASSERT_NEVER;
    }
}

Profile1DCatalog::Type Profile1DCatalog::type(const Profile1DItem* item)
{
    ASSERT(item);

#define RETURN_IF(type)                                                                            \
    if (dynamic_cast<const Profile1D##type##Item*>(item))                                          \
    return Type::type

    RETURN_IF(Cauchy);
    RETURN_IF(Gauss);
    RETURN_IF(Gate);
    RETURN_IF(Triangle);
    RETURN_IF(Cosine);
    RETURN_IF(Voigt);
#undef RETURN_IF

    ASSERT_NEVER;
}

/* --------------------------------------------------------------------------------------------- */

Profile2DItem* Profile2DCatalog::create(Type type)
{
    switch (type) {
    case Type::Cauchy:
        return new Profile2DCauchyItem;
    case Type::Gauss:
        return new Profile2DGaussItem;
    case Type::Gate:
        return new Profile2DGateItem;
    case Type::Cone:
        return new Profile2DConeItem;
    case Type::Voigt:
        return new Profile2DVoigtItem;
    default:
        ASSERT_NEVER;
    }
}

QVector<Profile2DCatalog::Type> Profile2DCatalog::types()
{
    return {Type::Cauchy, Type::Gauss, Type::Gate, Type::Cone, Type::Voigt};
}

UiInfo Profile2DCatalog::uiInfo(Type type)
{
    switch (type) {
    case Type::Cauchy:
        return {"Cauchy 2D", "Two-dimensional Cauchy probability distribution", ""};
    case Type::Gauss:
        return {"Gauss 2D", "Two-dimensional Gauss probability distribution", ""};
    case Type::Gate:
        return {"Gate 2D", "Two-dimensional Gate probability distribution", ""};
    case Type::Cone:
        return {"Cone 2D", "Two-dimensional Cone probability distribution", ""};
    case Type::Voigt:
        return {"Voigt 2D", "Two-dimensional pseudo-Voigt probability distribution", ""};
    default:
        ASSERT_NEVER;
    }
}

Profile2DCatalog::Type Profile2DCatalog::type(const Profile2DItem* item)
{
    ASSERT(item);

    if (dynamic_cast<const Profile2DCauchyItem*>(item))
        return Type::Cauchy;
    if (dynamic_cast<const Profile2DGaussItem*>(item))
        return Type::Gauss;
    if (dynamic_cast<const Profile2DGateItem*>(item))
        return Type::Gate;
    if (dynamic_cast<const Profile2DConeItem*>(item))
        return Type::Cone;
    if (dynamic_cast<const Profile2DVoigtItem*>(item))
        return Type::Voigt;

    ASSERT_NEVER;
}