BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
ResolutionFunctionItemCatalog.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Model/CatDevice/ResolutionFunctionItemCatalog.cpp
6 //! @brief Implements class ResolutionFunctionItemCatalog
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 ResolutionFunctionItemCatalog::create(Type type, const std::variant<QString, Unit>& unit)
21 {
22  switch (type) {
23  case Type::None: {
24  auto* p = new ResolutionFunctionNoneItem();
25  p->setUnit(unit);
26  return p;
27  }
28  case Type::Gaussian: {
29  auto* p = new ResolutionFunction2DGaussianItem();
30  p->setUnit(unit);
31  return p;
32  }
33  }
34  ASSERT(false);
35 }
36 
37 QVector<ResolutionFunctionItemCatalog::Type> ResolutionFunctionItemCatalog::types()
38 {
39  return {Type::None, Type::Gaussian};
40 }
41 
43 {
44  switch (type) {
45  case Type::None:
46  return {"None", ""};
47  case Type::Gaussian:
48  return {"2D Gaussian", ""};
49  }
50  ASSERT(false);
51 }
52 
55 {
56  if (dynamic_cast<const ResolutionFunctionNoneItem*>(item))
57  return Type::None;
58  if (dynamic_cast<const ResolutionFunction2DGaussianItem*>(item))
59  return Type::Gaussian;
60 
61  ASSERT(false);
62 }
Defines class ResolutionFunctionItemCatalog.
Defines family of ResolutionFunctionItem.
static Type type(const ResolutionFunctionItem *item)
Returns the enum type of the given item.
static UiInfo uiInfo(Type t)
UiInfo on the given type.
static ResolutionFunctionItem * create(Type type, const std::variant< QString, Unit > &unit=Unit::unitless)
Creates the item of the given type.
static QVector< Type > types()
Available types of items.