1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file GUI/Model/Mask/MaskCatalog.cpp
//! @brief Implements class MaskCatalog.
//!
//! @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/Mask/MaskCatalog.h"
#include "Base/Util/Assert.h"
#include "GUI/Model/Mask/MaskItems.h"
MaskItem* MaskCatalog::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(0.);
case Type::HorizontalLine:
return new HorizontalLineItem(0.);
case Type::MaskAll:
return new FullframeItem;
case Type::Ellipse:
return new EllipseItem;
}
ASSERT_NEVER;
}
QVector<MaskCatalog::Type> MaskCatalog::types()
{
return {Type::RegionOfInterest, Type::Rectangle, Type::Polygon, Type::VerticalLine,
Type::HorizontalLine, Type::MaskAll, Type::Ellipse};
}
UiInfo MaskCatalog::uiInfo(Type type)
{
switch (type) {
case Type::RegionOfInterest:
return {"Region of interest", "", ""};
case Type::Rectangle:
return {"Rectangle", "", ""};
case Type::Polygon:
return {"Polygon", "", ""};
case Type::VerticalLine:
return {"Vertical line", "", ""};
case Type::HorizontalLine:
return {"Horizontal line", "", ""};
case Type::MaskAll:
return {"Mask all", "", ""};
case Type::Ellipse:
return {"Ellipse", "", ""};
}
ASSERT_NEVER;
}
MaskCatalog::Type MaskCatalog::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 FullframeItem*>(item))
return Type::MaskAll;
if (dynamic_cast<const EllipseItem*>(item))
return Type::Ellipse;
ASSERT_NEVER;
}
|