BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
PolygonView.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Views/MaskWidgets/PolygonView.h
6 //! @brief Defines PolygonView class
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 
15 #ifndef BORNAGAIN_GUI_COREGUI_VIEWS_MASKWIDGETS_POLYGONVIEW_H
16 #define BORNAGAIN_GUI_COREGUI_VIEWS_MASKWIDGETS_POLYGONVIEW_H
17 
19 #include <QPolygonF>
20 
21 //! This is a View of polygon mask (represented by PolygonItem) on GraphicsScene.
22 
23 class PolygonView : public IShape2DView {
24  Q_OBJECT
25 
26 public:
27  int type() const { return MaskEditorHelper::POLYGON; }
28 
29  PolygonView();
30 
31  void addView(IShape2DView* childView, int row);
32  bool isClosedPolygon();
33  QPointF lastAddedPoint() const;
34 
35 public slots:
37  void onClosePolygonRequest(bool value);
38 
39 protected slots:
40  void update_view();
41 
42 protected:
43  void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*);
44  QVariant itemChange(GraphicsItemChange change, const QVariant& value);
45  void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
46 
47 private:
48  void update_polygon();
49  void update_points();
50  void setChildrenVisible(bool value);
52 
53  QPolygonF m_polygon;
56 };
57 
58 #endif // BORNAGAIN_GUI_COREGUI_VIEWS_MASKWIDGETS_POLYGONVIEW_H
Defines interface IShape2DView.
Main interface class for views representing MaskItems, Projections on graphics scene.
Definition: IShape2DView.h:27
This is a View of polygon mask (represented by PolygonItem) on GraphicsScene.
Definition: PolygonView.h:23
void update_view()
void onClosePolygonRequest(bool value)
Definition: PolygonView.cpp:79
bool closePolygonIfNecessary()
Returns true if there was a request to close polygon (emitted by its start point),...
Definition: PolygonView.cpp:64
void addView(IShape2DView *childView, int row)
Definition: PolygonView.cpp:32
bool m_close_polygon_request
Definition: PolygonView.h:55
QPointF lastAddedPoint() const
returns last added poligon point in scene coordinates
Definition: PolygonView.cpp:57
void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
QPolygonF m_polygon
Definition: PolygonView.h:53
void update_polygon()
Runs through all PolygonPointItem and calculate bounding rectangle.
bool makePolygonClosed()
QVariant itemChange(GraphicsItemChange change, const QVariant &value)
bool isClosedPolygon()
Definition: PolygonView.cpp:84
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
Definition: PolygonView.cpp:89
int type() const
Definition: PolygonView.h:27
void update_points()
When polygon moves as a whole thing across the scene, given method updates coordinates of PolygonPoin...
bool m_block_on_point_update
Definition: PolygonView.h:54
void setChildrenVisible(bool value)