BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
Lattice2DItemCatalog.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Model/CatSample/Lattice2DItemCatalog.cpp
6 //! @brief Implements class Lattice2DItemCatalog
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::Basic:
23  return new BasicLattice2DItem();
24  case Type::Square:
25  return new SquareLattice2DItem();
26  case Type::Hexagonal:
27  return new HexagonalLattice2DItem();
28  default:
29  ASSERT(false);
30  }
31 }
32 
33 QVector<Lattice2DItemCatalog::Type> Lattice2DItemCatalog::types()
34 {
36 }
37 
39 {
40  switch (type) {
41  case Type::Basic:
42  return {"Basic", "Two dimensional lattice", ""};
43  case Type::Square:
44  return {"Square", "", ""};
45  case Type::Hexagonal:
46  return {"Hexagonal", "", ""};
47  default:
48  ASSERT(false);
49  }
50 }
51 
53 {
54  ASSERT(item);
55 
56  if (dynamic_cast<const BasicLattice2DItem*>(item))
57  return Type::Basic;
58  if (dynamic_cast<const SquareLattice2DItem*>(item))
59  return Type::Square;
60  if (dynamic_cast<const HexagonalLattice2DItem*>(item))
61  return Type::Hexagonal;
62 
63  ASSERT(false);
64 }
Defines class Lattice2DItemCatalog.
Defines classes Lattice2DItems.
static QVector< Type > types()
List of available types, sorted as expected in the UI.
static UiInfo uiInfo(Type t)
UiInfo on the given type.
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.