BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
MaskItemCatalog.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Model/CatDevice/MaskItemCatalog.cpp
6 //! @brief Implements class MaskItemCatalog
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2022
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
16 #include "Base/Util/Assert.h"
18 
20 {
21  switch (type) {
23  return new RegionOfInterestItem();
24  case Type::Rectangle:
25  return new RectangleItem();
26  case Type::Polygon:
27  return new PolygonItem();
28  case Type::VerticalLine:
29  return new VerticalLineItem();
31  return new HorizontalLineItem();
32  case Type::MaskAll:
33  return new MaskAllItem();
34  }
35  ASSERT(false);
36 }
37 
38 QVector<MaskItemCatalog::Type> MaskItemCatalog::types()
39 {
42 }
43 
45 {
46  if (dynamic_cast<const RegionOfInterestItem*>(item)) // has to be before test for Rectangle!
48  if (dynamic_cast<const RectangleItem*>(item))
49  return Type::Rectangle;
50  if (dynamic_cast<const PolygonItem*>(item))
51  return Type::Polygon;
52  if (dynamic_cast<const VerticalLineItem*>(item))
53  return Type::VerticalLine;
54  if (dynamic_cast<const HorizontalLineItem*>(item))
55  return Type::HorizontalLine;
56  if (dynamic_cast<const MaskAllItem*>(item))
57  return Type::MaskAll;
58 
59  ASSERT(false);
60 }
Defines class MaskItemCatalog.
Defines MaskItems classes.
static QVector< Type > types()
Available types of items.
static MaskItem * create(Type type)
Creates the item of the given type.
static Type type(const MaskItem *item)
Returns the enum type of the given item.
A base class for all mask items.
Definition: MaskItems.h:27