BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
DistributionItemCatalog.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Model/CatDevice/DistributionItemCatalog.cpp
6 //! @brief Implements class DistributionItemCatalog
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::None:
23  return new DistributionNoneItem();
24  case Type::Gate:
25  return new DistributionGateItem();
26  case Type::Lorentz:
27  return new DistributionLorentzItem();
28  case Type::Gaussian:
29  return new DistributionGaussianItem();
30  case Type::LogNormal:
31  return new DistributionLogNormalItem();
32  case Type::Cosine:
33  return new DistributionCosineItem();
34  case Type::Trapezoid:
35  return new DistributionTrapezoidItem();
36  }
37  ASSERT(false);
38 }
39 
40 QVector<DistributionItemCatalog::Type> DistributionItemCatalog::types()
41 {
44 }
45 
46 QVector<DistributionItemCatalog::Type> DistributionItemCatalog::symmetricTypes()
47 {
49 }
50 
52 {
53  switch (type) {
54  case Type::None:
55  return {"None", "", ""};
56  case Type::Gate:
57  return {"Gate", "", ""};
58  case Type::Lorentz:
59  return {"Lorentz", "", ""};
60  case Type::Gaussian:
61  return {"Gaussian", "", ""};
62  case Type::LogNormal:
63  return {"Log Normal", "", ""};
64  case Type::Cosine:
65  return {"Cosine", "", ""};
66  case Type::Trapezoid:
67  return {"Trapezoid", "", ""};
68  }
69  ASSERT(false);
70 }
71 
73 {
74  if (dynamic_cast<const DistributionNoneItem*>(item))
75  return Type::None;
76  if (dynamic_cast<const DistributionGateItem*>(item))
77  return Type::Gate;
78  if (dynamic_cast<const DistributionLorentzItem*>(item))
79  return Type::Lorentz;
80  if (dynamic_cast<const DistributionGaussianItem*>(item))
81  return Type::Gaussian;
82  if (dynamic_cast<const DistributionLogNormalItem*>(item))
83  return Type::LogNormal;
84  if (dynamic_cast<const DistributionCosineItem*>(item))
85  return Type::Cosine;
86  if (dynamic_cast<const DistributionTrapezoidItem*>(item))
87  return Type::Trapezoid;
88 
89  ASSERT(false);
90 }
Defines class DistributionItemCatalog.
Defines class DistributionItem and several subclasses.
static QVector< Type > symmetricTypes()
Types of symmetric distributions.
static Type type(const DistributionItem *item)
Returns the enum type of the given item.
static UiInfo uiInfo(Type t)
UiInfo on the given type.
static DistributionItem * create(Type type)
Creates the item of the given type.
static QVector< Type > types()
Available types of items.