BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
MaskViewFactory.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Mask/MaskViewFactory.cpp
6 //! @brief Implements class MaskViewFactory
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
19 #include "GUI/Util/Error.h"
27 
28 #include <boost/polymorphic_cast.hpp>
29 
30 using boost::polymorphic_downcast;
31 
33 {
34  IShape2DView* result(nullptr);
35 
36  if (item->hasModelType<MaskContainerItem>())
37  result = new MaskContainerView(polymorphic_downcast<MaskContainerItem*>(item));
38 
39  else if (item->hasModelType<ProjectionContainerItem>())
40  result = new MaskContainerView(polymorphic_downcast<ProjectionContainerItem*>(item));
41 
42 
43  else if (item->hasModelType<RectangleItem>())
44  result = new RectangleView(polymorphic_downcast<RectangleItem*>(item));
45 
46 
47  else if (item->hasModelType<PolygonItem>())
48  result = new PolygonView(polymorphic_downcast<PolygonItem*>(item));
49 
50 
51  else if (item->hasModelType<PolygonPointItem>())
52  result = new PolygonPointView(polymorphic_downcast<PolygonPointItem*>(item));
53 
54 
55  else if (item->hasModelType<VerticalLineItem>())
56  result = new VerticalLineView(polymorphic_downcast<VerticalLineItem*>(item));
57 
58 
59  else if (item->hasModelType<HorizontalLineItem>())
60  result = new HorizontalLineView(polymorphic_downcast<HorizontalLineItem*>(item));
61 
62 
63  else if (item->hasModelType<EllipseItem>())
64  result = new EllipseView(polymorphic_downcast<EllipseItem*>(item));
65 
66 
67  else if (item->hasModelType<MaskAllItem>())
68  result = new MaskAllView(polymorphic_downcast<MaskAllItem*>(item));
69 
70 
71  else if (item->hasModelType<RegionOfInterestItem>())
72  result = new RegionOfInterestView(polymorphic_downcast<RegionOfInterestItem*>(item));
73 
74 
75  else {
76  throw Error("MaskViewFactory::createSampleView() -> Error! "
77  "Can't create a view for "
78  + item->modelType());
79  }
80 
81  result->setSceneAdaptor(adaptor);
82 
83  return result;
84 }
Defines EllipseView class.
Defines error class.
Defines classes VerticalLineView and HorizontalLineView.
Defines MaskAllView class.
Defines MaskContainerView class.
Defines MaskItems classes.
Defines class MaskViewFactory.
Defines PolygonPointView class.
Defines PolygonView class.
Defines items related to projections over color map.
Defines RegionOfInterestView class.
Defines class SessionItem.
This is a View of ellipse mask (represented by EllipseItem) on GraphicsScene. Given view follows stan...
Definition: EllipseView.h:25
This is a view of HorizontalLineItem mask.
Definition: LineViews.h:55
Interface to adapt MaskItems coordinates (expressed in units of IntensityDataItem) to/from scene coor...
Definition: ISceneAdaptor.h:24
Main interface class for views representing MaskItems, Projections on graphics scene.
Definition: IShape2DView.h:27
void setSceneAdaptor(const ISceneAdaptor *adaptor)
This is a view of MaskAllItem which covers whole detector plane with mask value=true.
Definition: MaskAllView.h:24
Container holding various masks as children.
Definition: MaskItems.h:202
The MaskContainerView is nothing more than just transparent rectangle to cover axes area of ColorMapP...
static IShape2DView * createMaskView(SessionItem *item, ISceneAdaptor *adaptor=nullptr)
This is a View of polygon point for PolygonMaskItem.
This is a View of polygon mask (represented by PolygonItem) on GraphicsScene.
Definition: PolygonView.h:26
A container to hold ProjectionItems, intended to store projections of color map on X,...
This is a View of rectangular mask (represented by RectangleItem) on GraphicsScene....
Definition: RectangleView.h:25
The RegionOfInterest class represent view of RegionOfInterestItem on graphics scene.
Base class for a GUI data item.
Definition: SessionItem.h:204
bool hasModelType() const
Definition: SessionItem.h:421
QString modelType() const
Get model type.
This is a view of VerticalLineItem mask.
Definition: LineViews.h:25