BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
ProfileItemCatalogs.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Model/CatSample/ProfileItemCatalogs.cpp
6 //! @brief Implements ProfileItemCatalog classes
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  switch (type) {
22  case Type::Cauchy:
23  return new Profile1DCauchyItem();
24  case Type::Gauss:
25  return new Profile1DGaussItem();
26  case Type::Gate:
27  return new Profile1DGateItem();
28  case Type::Triangle:
29  return new Profile1DTriangleItem();
30  case Type::Cosine:
31  return new Profile1DCosineItem();
32  case Type::Voigt:
33  return new Profile1DVoigtItem();
34  default:
35  ASSERT(false);
36  }
37 }
38 
39 QVector<Profile1DItemCatalog::Type> Profile1DItemCatalog::types()
40 {
42 }
43 
45 {
46  switch (type) {
47  case Type::Cauchy:
48  return {"Cauchy 1D", "One-dimensional Cauchy probability distribution", ""};
49  case Type::Gauss:
50  return {"Gauss 1D", "One-dimensional Gauss probability distribution", ""};
51  case Type::Gate:
52  return {"Gate 1D", "One-dimensional Gate probability distribution", ""};
53  case Type::Triangle:
54  return {"Triangle 1D", "One-dimensional triangle probability distribution", ""};
55  case Type::Cosine:
56  return {"Cosine 1D", "One-dimensional Cosine probability distribution", ""};
57  case Type::Voigt:
58  return {"Voigt 1D", "One-dimensional pseudo-Voigt probability distribution", ""};
59  default:
60  ASSERT(false);
61  }
62 }
63 
65 {
66  ASSERT(item);
67 
68 #define CHECK(type) \
69  if (dynamic_cast<const Profile1D##type##Item*>(item)) \
70  return Type::type
71 
72  CHECK(Cauchy);
73  CHECK(Gauss);
74  CHECK(Gate);
75  CHECK(Triangle);
76  CHECK(Cosine);
77  CHECK(Voigt);
78 #undef CHECK
79 
80  ASSERT(false);
81 }
82 
83 /* --------------------------------------------------------------------------------------------- */
84 
86 {
87  switch (type) {
88  case Type::Cauchy:
89  return new Profile2DCauchyItem();
90  case Type::Gauss:
91  return new Profile2DGaussItem();
92  case Type::Gate:
93  return new Profile2DGateItem();
94  case Type::Cone:
95  return new Profile2DConeItem();
96  case Type::Voigt:
97  return new Profile2DVoigtItem();
98  default:
99  ASSERT(false);
100  }
101 }
102 
103 QVector<Profile2DItemCatalog::Type> Profile2DItemCatalog::types()
104 {
106 }
107 
109 {
110  switch (type) {
111  case Type::Cauchy:
112  return {"Cauchy 2D", "Two-dimensional Cauchy probability distribution", ""};
113  case Type::Gauss:
114  return {"Gauss 2D", "Two-dimensional Gauss probability distribution", ""};
115  case Type::Gate:
116  return {"Gate 2D", "Two-dimensional Gate probability distribution", ""};
117  case Type::Cone:
118  return {"Cone 2D", "Two-dimensional Cone probability distribution", ""};
119  case Type::Voigt:
120  return {"Voigt 2D", "Two-dimensional pseudo-Voigt probability distribution", ""};
121  default:
122  ASSERT(false);
123  }
124 }
125 
127 {
128  ASSERT(item);
129 
130  if (dynamic_cast<const Profile2DCauchyItem*>(item))
131  return Type::Cauchy;
132  if (dynamic_cast<const Profile2DGaussItem*>(item))
133  return Type::Gauss;
134  if (dynamic_cast<const Profile2DGateItem*>(item))
135  return Type::Gate;
136  if (dynamic_cast<const Profile2DConeItem*>(item))
137  return Type::Cone;
138  if (dynamic_cast<const Profile2DVoigtItem*>(item))
139  return Type::Voigt;
140 
141  ASSERT(false);
142 }
#define CHECK(type)
Defines ProfileItemCatalog classes.
Defines Profile1DItem's classes.
static UiInfo uiInfo(Type t)
UiInfo on the given type.
static CatalogedType * create(Type type)
Creates the item of the given type.
static QVector< Type > types()
List of available types, sorted as expected in the UI.
static Type type(const CatalogedType *item)
Returns the enum type of the given item.
static Type type(const CatalogedType *item)
Returns the enum type of the given item.
static CatalogedType * create(Type type)
Creates the item of the given type.
static UiInfo uiInfo(Type t)
UiInfo on the given type.
static QVector< Type > types()
List of available types, sorted as expected in the UI.