Skip to content
Snippets Groups Projects
Commit 32bc356a authored by Matthias Puchner's avatar Matthias Puchner
Browse files

add MaskItemCatalog

parent a45c9c5c
No related branches found
No related tags found
1 merge request!624Remove SessionItem from Instrument items
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file GUI/Model/MakeItem/MaskItemCatalog.cpp
//! @brief Implements class MaskItemCatalog
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2022
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#include "GUI/Model/MakeItem/MaskItemCatalog.h"
#include "Base/Util/Assert.h"
#include "GUI/Model/Item/MaskItems.h"
MaskItem* MaskItemCatalog::create(Type type)
{
switch (type) {
case Type::RegionOfInterest:
return new RegionOfInterestItem();
case Type::Rectangle:
return new RectangleItem();
case Type::Polygon:
return new PolygonItem();
case Type::VerticalLine:
return new VerticalLineItem();
case Type::HorizontalLine:
return new HorizontalLineItem();
case Type::MaskAll:
return new MaskAllItem();
}
ASSERT(false);
}
QVector<MaskItemCatalog::Type> MaskItemCatalog::types()
{
return {Type::RegionOfInterest, Type::Rectangle, Type::Polygon,
Type::VerticalLine, Type::HorizontalLine, Type::MaskAll};
}
MaskItemCatalog::Type MaskItemCatalog::type(const MaskItem* item)
{
if (dynamic_cast<const RegionOfInterestItem*>(item)) // has to be before test for Rectangle!
return Type::RegionOfInterest;
if (dynamic_cast<const RectangleItem*>(item))
return Type::Rectangle;
if (dynamic_cast<const PolygonItem*>(item))
return Type::Polygon;
if (dynamic_cast<const VerticalLineItem*>(item))
return Type::VerticalLine;
if (dynamic_cast<const HorizontalLineItem*>(item))
return Type::HorizontalLine;
if (dynamic_cast<const MaskAllItem*>(item))
return Type::MaskAll;
ASSERT(false);
}
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file GUI/Model/MakeItem/MaskItemCatalog.h
//! @brief Defines class MaskItemCatalog
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2022
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#ifndef BORNAGAIN_GUI_MODEL_MAKEITEM_MASKITEMCATALOG_H
#define BORNAGAIN_GUI_MODEL_MAKEITEM_MASKITEMCATALOG_H
#include <QString>
#include <QVector>
class MaskItem;
class MaskItemCatalog {
public:
using CatalogedType = MaskItem;
// Do not change the numbering! It is serialized!
enum class Type : uint8_t {
RegionOfInterest = 0,
Rectangle = 1,
Polygon = 2,
VerticalLine = 3,
HorizontalLine = 4,
MaskAll = 5
};
//! Creates the item of the given type.
static MaskItem* create(Type type);
//! Available types of items.
static QVector<Type> types();
//! Returns the enum type of the given item.
static Type type(const MaskItem* item);
};
#endif // BORNAGAIN_GUI_MODEL_MAKEITEM_MASKITEMCATALOG_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment