BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
FormFactorItemCatalog.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Model/CatSample/FormFactorItemCatalog.cpp
6 //! @brief Implements class FormFactorItemCatalog
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 
16 #include "Base/Util/Assert.h"
18 
20 {
21 #define CREATE(t) \
22  case Type::t: \
23  return new t##Item()
24 
25  switch (type) {
26  CREATE(BarGauss);
27  CREATE(BarLorentz);
28  CREATE(Bipyramid4);
29  CREATE(Box);
30  CREATE(CantellatedCube);
31  CREATE(Cone);
32  CREATE(CosineRippleBox);
33  CREATE(CosineRippleGauss);
34  CREATE(CosineRippleLorentz);
35  CREATE(Cylinder);
36  CREATE(Dodecahedron);
37  CREATE(EllipsoidalCylinder);
38  CREATE(Sphere);
39  CREATE(Spheroid);
40  CREATE(HemiEllipsoid);
41  CREATE(HorizontalCylinder);
42  CREATE(Icosahedron);
43  CREATE(PlatonicOctahedron);
44  CREATE(PlatonicTetrahedron);
45  CREATE(Prism3);
46  CREATE(Prism6);
47  CREATE(Pyramid2);
48  CREATE(Pyramid3);
49  CREATE(Pyramid4);
50  CREATE(Pyramid6);
51  CREATE(SawtoothRippleBox);
52  CREATE(SawtoothRippleGauss);
53  CREATE(SawtoothRippleLorentz);
54  CREATE(TruncatedCube);
55  CREATE(TruncatedSphere);
56  CREATE(TruncatedSpheroid);
57  default:
58  ASSERT(false);
59  }
60 
61 #undef CREATE
62 }
63 
64 QVector<FormFactorItemCatalog::Type> FormFactorItemCatalog::types()
65 {
66  return {Type::BarGauss,
69  Type::Box,
71  Type::Cone,
97 }
98 
99 QVector<FormFactorItemCatalog::Type> FormFactorItemCatalog::hardParticleTypes()
100 {
101  return {Type::Bipyramid4,
102  Type::Box,
104  Type::Cone,
108  Type::Sphere,
115  Type::Prism3,
116  Type::Prism6,
124 }
125 
126 
127 QVector<FormFactorItemCatalog::Type> FormFactorItemCatalog::rippleTypes()
128 {
132 }
133 
135 {
136  switch (type) {
137  case Type::Pyramid2:
138  return {"Anisotropic pyramid", "Truncated pyramid with a rectangular base",
139  ":/SampleDesignerToolbox/images/ff_Pyramid2_64x64.png"};
140 
141  case Type::BarGauss:
142  return {"BarGauss", "Rectangular cuboid",
143  ":/SampleDesignerToolbox/images/ff_Box_64x64.png"};
144 
145  case Type::BarLorentz:
146  return {"BarLorentz", "Rectangular cuboid",
147  ":/SampleDesignerToolbox/images/ff_Box_64x64.png"};
148 
149  case Type::Box:
150  return {"Box", "Rectangular cuboid", ":/SampleDesignerToolbox/images/ff_Box_64x64.png"};
151 
152  case Type::Cone:
153  return {"Cone", "Truncated cone with circular base",
154  ":/SampleDesignerToolbox/images/ff_Cone_64x64.png"};
155 
156  case Type::Pyramid6:
157  return {"Pyramid6", "A truncated pyramid, based on a regular hexagon",
158  ":/SampleDesignerToolbox/images/ff_Pyramid6_64x64.png"};
159 
160  case Type::Bipyramid4:
161  return {"Bipyramid4",
162  "Compound of two truncated pyramids with a common square base "
163  "and opposite orientations",
164  ":/SampleDesignerToolbox/images/ff_Bipyramid4_64x64.png"};
165 
166  case Type::Dodecahedron:
167  return {"Dodecahedron", "Dodecahedron",
168  ":/SampleDesignerToolbox/images/ff_Dodecahedron_64x64.png"};
169 
170  case Type::Cylinder:
171  return {"Cylinder", "Cylinder with a circular base",
172  ":/SampleDesignerToolbox/images/ff_Cylinder_64x64.png"};
173 
175  return {"Ellipsoidal cylinder", "Cylinder with an ellipse cross section",
176  ":/SampleDesignerToolbox/images/ff_EllipsoidalCylinder_64x64.png"};
177 
178  case Type::Sphere:
179  return {"Full sphere", "Full sphere",
180  ":/SampleDesignerToolbox/images/ff_Sphere_64x64.png"};
181 
182  case Type::Spheroid:
183  return {"Full spheroid",
184  "Full spheroid, generated by rotating an ellipse around the vertical axis",
185  ":/SampleDesignerToolbox/images/ff_Spheroid_64x64.png"};
186 
187  case Type::HemiEllipsoid:
188  return {"Hemi ellipsoid",
189  "A horizontally oriented ellipsoid, truncated at the central plane",
190  ":/SampleDesignerToolbox/images/ff_HemiEllipsoid_64x64.png"};
191 
192  case Type::Icosahedron:
193  return {"Icosahedron", "Icosahedron",
194  ":/SampleDesignerToolbox/images/ff_Icosahedron_64x64.png"};
195 
196  case Type::Prism3:
197  return {"Prism3", "Prism with an equilateral triangle base",
198  ":/SampleDesignerToolbox/images/ff_Prism3_64x64.png"};
199 
200  case Type::Prism6:
201  return {"Prism6", "Prism with a regular hexagonal base",
202  ":/SampleDesignerToolbox/images/ff_Prism6_64x64.png"};
203 
204  case Type::Pyramid4:
205  return {"Pyramid4", "Truncated pyramid with a square base",
206  ":/SampleDesignerToolbox/images/ff_Pyramid4_64x64.png"};
207 
209  return {"CosineRippleBox", "Particle with a cosine profile and a rectangular base",
210  ":/SampleDesignerToolbox/images/ff_CosineRipple_64x64.png"};
211 
213  return {"CosineRippleGauss", "Particle with a cosine profile and a rectangular base",
214  ":/SampleDesignerToolbox/images/ff_CosineRipple_64x64.png"};
215 
217  return {"CosineRippleLorentz", "Particle with a cosine profile and a rectangular base",
218  ":/SampleDesignerToolbox/images/ff_CosineRipple_64x64.png"};
219 
221  return {"SawtoothRippleBox",
222  "Particle with an asymmetric triangle profile and a rectangular base",
223  ":/SampleDesignerToolbox/images/ff_SawtoothRipple_64x64.png"};
224 
226  return {"SawtoothRippleGauss",
227  "Particle with an asymmetric triangle profile and a rectangular base",
228  ":/SampleDesignerToolbox/images/ff_SawtoothRipple_64x64.png"};
229 
231  return {"SawtoothRippleLorentz",
232  "Particle with an asymmetric triangle profile and a rectangular base",
233  ":/SampleDesignerToolbox/images/ff_SawtoothRipple_64x64.png"};
234 
235  case Type::Pyramid3:
236  return {"Pyramid3",
237  "Truncated polyhedron with equilateral triangle base and cropped side faces",
238  ":/SampleDesignerToolbox/images/ff_Pyramid3_64x64.png"};
239 
240  case Type::TruncatedCube:
241  return {"Truncated cube", "A cube whose eight vertices have been removed",
242  ":/SampleDesignerToolbox/images/ff_TruncatedCube_64x64.png"};
243 
245  return {"Truncated sphere", "Spherical dome",
246  ":/SampleDesignerToolbox/images/ff_TruncatedSphere_64x64.png"};
247 
249  return {"Truncated spheroid", "Spheroidal dome",
250  ":/SampleDesignerToolbox/images/ff_TruncatedSpheroid_64x64.png"};
251 
253  return {"Cantellated cube", "A cube with truncated edges and vertices",
254  ":/SampleDesignerToolbox/images/ff_CantellatedCube_64x64.png"};
255 
257  return {"Horizontal cylinder", "Cylinder with a circular base, lying in x direction",
258  ":/SampleDesignerToolbox/images/ff_HorizontalCylinder_64x64.png"};
259 
261  return {"Platonic octahedron", "Regular octahedron",
262  ":/SampleDesignerToolbox/images/ff_PlatonicOctahedron_64x64.png"};
263 
265  return {"Platonic tetrahedron", "Regular tetrahedron",
266  ":/SampleDesignerToolbox/images/ff_PlatonicTetrahedron_64x64.png"};
267 
268  default:
269  ASSERT(false);
270  }
271 }
272 
274 {
275  ASSERT(item);
276 
277 #define CHECK(type) \
278  if (dynamic_cast<const type##Item*>(item)) \
279  return Type::type
280 
281  CHECK(BarGauss);
282  CHECK(BarLorentz);
283  CHECK(Bipyramid4);
284  CHECK(Box);
285  CHECK(CantellatedCube);
286  CHECK(Cone);
287  CHECK(CosineRippleBox);
288  CHECK(CosineRippleGauss);
289  CHECK(CosineRippleLorentz);
290  CHECK(Cylinder);
291  CHECK(Dodecahedron);
292  CHECK(EllipsoidalCylinder);
293  CHECK(Sphere);
294  CHECK(Spheroid);
295  CHECK(HemiEllipsoid);
296  CHECK(HorizontalCylinder);
297  CHECK(Icosahedron);
298  CHECK(PlatonicOctahedron);
299  CHECK(PlatonicTetrahedron);
300  CHECK(Prism3);
301  CHECK(Prism6);
302  CHECK(Pyramid2);
303  CHECK(Pyramid3);
304  CHECK(Pyramid4);
305  CHECK(Pyramid6);
306  CHECK(SawtoothRippleBox);
307  CHECK(SawtoothRippleGauss);
308  CHECK(SawtoothRippleLorentz);
309  CHECK(TruncatedCube);
310  CHECK(TruncatedSphere);
311  CHECK(TruncatedSpheroid);
312 #undef CHECK
313  ASSERT(false);
314 }
315 
317 {
318  return uiInfo(type(item)).menuEntry;
319 }
#define CHECK(type)
#define CREATE(t)
Defines class FormFactorItemCatalog.
Defines FormFactorItems classes.
static QVector< Type > types()
Available types of interference items.
static QString menuEntry(const FormFactorItem *item)
static FormFactorItem * create(Type type)
Creates the item of the given type.
static QVector< Type > hardParticleTypes()
static UiInfo uiInfo(Type t)
UiInfo on the given type.
static Type type(const FormFactorItem *item)
Returns the enum type of the given item.
static QVector< Type > rippleTypes()