File: FormfactorCatalog.cpp

package info (click to toggle)
bornagain 23.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 103,948 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 (309 lines) | stat: -rw-r--r-- 10,685 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
//  ************************************************************************************************
//
//  BornAgain: simulate and fit reflection and scattering
//
//! @file      GUI/Model/Sample/FormfactorCatalog.cpp
//! @brief     Implements class FormfactorCatalog.
//!
//! @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/FormfactorCatalog.h"
#include "Base/Util/Assert.h"
#include "GUI/Model/Sample/FormfactorItems.h"

FormfactorItem* FormfactorCatalog::create(Type type)
{
#define CREATE(t)                                                                                  \
    case Type::t:                                                                                  \
        return new t##Item

    switch (type) {
        CREATE(BarGauss);
        CREATE(BarLorentz);
        CREATE(Bipyramid4);
        CREATE(Box);
        CREATE(CantellatedCube);
        CREATE(Cone);
        CREATE(CosineRippleBox);
        CREATE(CosineRippleGauss);
        CREATE(CosineRippleLorentz);
        CREATE(Cylinder);
        CREATE(Dodecahedron);
        CREATE(EllipsoidalCylinder);
        CREATE(Sphere);
        CREATE(Spheroid);
        CREATE(HemiEllipsoid);
        CREATE(HorizontalCylinder);
        CREATE(Icosahedron);
        CREATE(PlatonicOctahedron);
        CREATE(PlatonicTetrahedron);
        CREATE(Prism3);
        CREATE(Prism6);
        CREATE(Pyramid2);
        CREATE(Pyramid3);
        CREATE(Pyramid4);
        CREATE(Pyramid6);
        CREATE(SawtoothRippleBox);
        CREATE(SawtoothRippleGauss);
        CREATE(SawtoothRippleLorentz);
        CREATE(TruncatedCube);
        CREATE(SphericalSegment);
        CREATE(SpheroidalSegment);
    default:
        ASSERT_NEVER;
    }

#undef CREATE
}

QVector<FormfactorCatalog::Type> FormfactorCatalog::types()
{
    return {Type::BarGauss,
            Type::BarLorentz,
            Type::Bipyramid4,
            Type::Box,
            Type::CantellatedCube,
            Type::Cone,
            Type::CosineRippleBox,
            Type::CosineRippleGauss,
            Type::CosineRippleLorentz,
            Type::Cylinder,
            Type::Dodecahedron,
            Type::EllipsoidalCylinder,
            Type::Sphere,
            Type::Spheroid,
            Type::HemiEllipsoid,
            Type::HorizontalCylinder,
            Type::Icosahedron,
            Type::PlatonicOctahedron,
            Type::PlatonicTetrahedron,
            Type::Prism3,
            Type::Prism6,
            Type::Pyramid2,
            Type::Pyramid3,
            Type::Pyramid4,
            Type::Pyramid6,
            Type::SawtoothRippleBox,
            Type::SawtoothRippleGauss,
            Type::SawtoothRippleLorentz,
            Type::TruncatedCube,
            Type::SphericalSegment,
            Type::SpheroidalSegment};
}

QVector<FormfactorCatalog::Type> FormfactorCatalog::hardParticleTypes()
{
    return {Type::Bipyramid4,
            Type::Box,
            Type::CantellatedCube,
            Type::Cone,
            Type::Cylinder,
            Type::Dodecahedron,
            Type::EllipsoidalCylinder,
            Type::Sphere,
            Type::Spheroid,
            Type::HemiEllipsoid,
            Type::HorizontalCylinder,
            Type::Icosahedron,
            Type::PlatonicOctahedron,
            Type::PlatonicTetrahedron,
            Type::Prism3,
            Type::Prism6,
            Type::Pyramid2,
            Type::Pyramid3,
            Type::Pyramid4,
            Type::Pyramid6,
            Type::TruncatedCube,
            Type::SphericalSegment,
            Type::SpheroidalSegment};
}


QVector<FormfactorCatalog::Type> FormfactorCatalog::rippleTypes()
{
    return {Type::BarGauss,          Type::BarLorentz,          Type::Box,
            Type::CosineRippleBox,   Type::CosineRippleGauss,   Type::CosineRippleLorentz,
            Type::SawtoothRippleBox, Type::SawtoothRippleGauss, Type::SawtoothRippleLorentz};
}

UiInfo FormfactorCatalog::uiInfo(Type type)
{
    switch (type) {
    case Type::Pyramid2:
        return {"Anisotropic pyramid", "Truncated pyramid with a rectangular base",
                ":/images/ff/Pyramid2_64x64.png"};

    case Type::BarGauss:
        return {"BarGauss", "Rectangular cuboid", ":/images/ff/Box_64x64.png"};

    case Type::BarLorentz:
        return {"BarLorentz", "Rectangular cuboid", ":/images/ff/Box_64x64.png"};

    case Type::Box:
        return {"Box", "Rectangular cuboid", ":/images/ff/Box_64x64.png"};

    case Type::Cone:
        return {"Cone", "Truncated cone with circular base", ":/images/ff/Cone_64x64.png"};

    case Type::Pyramid6:
        return {"Pyramid6", "A truncated pyramid, based on a regular hexagon",
                ":/images/ff/Pyramid6_64x64.png"};

    case Type::Bipyramid4:
        return {"Bipyramid4",
                "Compound of two truncated pyramids with a common square base "
                "and opposite orientations",
                ":/images/ff/Bipyramid4_64x64.png"};

    case Type::Dodecahedron:
        return {"Dodecahedron", "Dodecahedron", ":/images/ff/Dodecahedron_64x64.png"};

    case Type::Cylinder:
        return {"Cylinder", "Cylinder with a circular base", ":/images/ff/Cylinder_64x64.png"};

    case Type::EllipsoidalCylinder:
        return {"Ellipsoidal cylinder", "Cylinder with an ellipse cross section",
                ":/images/ff/EllipsoidalCylinder_64x64.png"};

    case Type::Sphere:
        return {"Full sphere", "Full sphere", ":/images/ff/Sphere_64x64.png"};

    case Type::Spheroid:
        return {"Full spheroid",
                "Full spheroid, generated by rotating an ellipse around the vertical axis",
                ":/images/ff/Spheroid_64x64.png"};

    case Type::HemiEllipsoid:
        return {"Hemi ellipsoid",
                "A horizontally oriented ellipsoid, truncated at the central plane",
                ":/images/ff/HemiEllipsoid_64x64.png"};

    case Type::Icosahedron:
        return {"Icosahedron", "Icosahedron", ":/images/ff/Icosahedron_64x64.png"};

    case Type::Prism3:
        return {"Prism3", "Prism with an equilateral triangle base",
                ":/images/ff/Prism3_64x64.png"};

    case Type::Prism6:
        return {"Prism6", "Prism with a regular hexagonal base", ":/images/ff/Prism6_64x64.png"};

    case Type::Pyramid4:
        return {"Pyramid4", "Truncated pyramid with a square base",
                ":/images/ff/Pyramid4_64x64.png"};

    case Type::CosineRippleBox:
        return {"CosineRippleBox", "Particle with a cosine profile and a rectangular base",
                ":/images/ff/CosineRipple_64x64.png"};

    case Type::CosineRippleGauss:
        return {"CosineRippleGauss", "Particle with a cosine profile and a rectangular base",
                ":/images/ff/CosineRipple_64x64.png"};

    case Type::CosineRippleLorentz:
        return {"CosineRippleLorentz", "Particle with a cosine profile and a rectangular base",
                ":/images/ff/CosineRipple_64x64.png"};

    case Type::SawtoothRippleBox:
        return {"SawtoothRippleBox",
                "Particle with an asymmetric triangle profile and a rectangular base",
                ":/images/ff/SawtoothRipple_64x64.png"};

    case Type::SawtoothRippleGauss:
        return {"SawtoothRippleGauss",
                "Particle with an asymmetric triangle profile and a rectangular base",
                ":/images/ff/SawtoothRipple_64x64.png"};

    case Type::SawtoothRippleLorentz:
        return {"SawtoothRippleLorentz",
                "Particle with an asymmetric triangle profile and a rectangular base",
                ":/images/ff/SawtoothRipple_64x64.png"};

    case Type::Pyramid3:
        return {"Pyramid3",
                "Truncated polyhedron with equilateral triangle base and cropped side faces",
                ":/images/ff/Pyramid3_64x64.png"};

    case Type::TruncatedCube:
        return {"Truncated cube", "A cube whose eight vertices have been removed",
                ":/images/ff/TruncatedCube_64x64.png"};

    case Type::SphericalSegment:
        return {"Truncated sphere", "Spherical dome", ":/images/ff/SphericalSegment_64x64.png"};

    case Type::SpheroidalSegment:
        return {"Truncated spheroid", "Spheroidal dome", ":/images/ff/SpheroidalSegment_64x64.png"};

    case Type::CantellatedCube:
        return {"Cantellated cube", "A cube with truncated edges and vertices",
                ":/images/ff/CantellatedCube_64x64.png"};

    case Type::HorizontalCylinder:
        return {"Horizontal cylinder", "Cylinder with a circular base, lying in x direction",
                ":/images/ff/HorizontalCylinder_64x64.png"};

    case Type::PlatonicOctahedron:
        return {"Platonic octahedron", "Regular octahedron",
                ":/images/ff/PlatonicOctahedron_64x64.png"};

    case Type::PlatonicTetrahedron:
        return {"Platonic tetrahedron", "Regular tetrahedron",
                ":/images/ff/PlatonicTetrahedron_64x64.png"};

    default:
        ASSERT_NEVER;
    }
}

FormfactorCatalog::Type FormfactorCatalog::type(const FormfactorItem* item)
{
    ASSERT(item);

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

    RETURN_IF(BarGauss);
    RETURN_IF(BarLorentz);
    RETURN_IF(Bipyramid4);
    RETURN_IF(Box);
    RETURN_IF(CantellatedCube);
    RETURN_IF(Cone);
    RETURN_IF(CosineRippleBox);
    RETURN_IF(CosineRippleGauss);
    RETURN_IF(CosineRippleLorentz);
    RETURN_IF(Cylinder);
    RETURN_IF(Dodecahedron);
    RETURN_IF(EllipsoidalCylinder);
    RETURN_IF(Sphere);
    RETURN_IF(Spheroid);
    RETURN_IF(HemiEllipsoid);
    RETURN_IF(HorizontalCylinder);
    RETURN_IF(Icosahedron);
    RETURN_IF(PlatonicOctahedron);
    RETURN_IF(PlatonicTetrahedron);
    RETURN_IF(Prism3);
    RETURN_IF(Prism6);
    RETURN_IF(Pyramid2);
    RETURN_IF(Pyramid3);
    RETURN_IF(Pyramid4);
    RETURN_IF(Pyramid6);
    RETURN_IF(SawtoothRippleBox);
    RETURN_IF(SawtoothRippleGauss);
    RETURN_IF(SawtoothRippleLorentz);
    RETURN_IF(TruncatedCube);
    RETURN_IF(SphericalSegment);
    RETURN_IF(SpheroidalSegment);
#undef RETURN_IF
    ASSERT_NEVER;
}

QString FormfactorCatalog::menuEntry(const FormfactorItem* item)
{
    return uiInfo(type(item)).menuEntry;
}