BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
PolygonPointView.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Views/MaskWidgets/PolygonPointView.cpp
6 //! @brief Implements PolygonPointView 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 
17 #include <QGraphicsSceneMouseEvent>
18 #include <QPainter>
19 
21 {
22  setFlag(QGraphicsItem::ItemIsMovable);
23  setFlag(QGraphicsItem::ItemSendsGeometryChanges);
24 }
25 
27 {
28  return QRectF(-4, -4, 8, 8);
29 }
30 
32 {
35 }
36 
38 {
39  update();
40 }
41 
43 {
44  emit propertyChanged();
45 }
46 
47 void PolygonPointView::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*)
48 {
49  painter->setRenderHints(QPainter::Antialiasing);
51  if (acceptHoverEvents() && m_on_hover) {
52  brush.setColor(Qt::red);
53  }
54  painter->setBrush(brush);
55  painter->setPen(MaskEditorHelper::getSelectionMarkerPen());
56  painter->drawEllipse(boundingRect());
57 }
58 
59 void PolygonPointView::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
60 {
61  updateParameterizedItem(event->scenePos());
62 }
63 
64 void PolygonPointView::hoverEnterEvent(QGraphicsSceneHoverEvent* event)
65 {
66  m_on_hover = true;
68  IShape2DView::hoverEnterEvent(event);
69 }
70 
71 void PolygonPointView::hoverLeaveEvent(QGraphicsSceneHoverEvent* event)
72 {
73  m_on_hover = false;
75  IShape2DView::hoverLeaveEvent(event);
76 }
Defines MaskItems classes.
Defines PolygonPointView class.
SessionItem * m_item
Definition: IShape2DView.h:65
qreal fromSceneY(qreal value) const
qreal fromSceneX(qreal value) const
convert scene coordinates to ColorMap plot coordinates
static QPen getSelectionMarkerPen()
static QBrush getSelectionMarkerBrush()
static const QString P_POSX
Definition: MaskItems.h:57
static const QString P_POSY
Definition: MaskItems.h:58
virtual void update_view()
void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void hoverEnterEvent(QGraphicsSceneHoverEvent *event)
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
void closePolygonRequest(bool)
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
QRectF boundingRect() const
void updateParameterizedItem(const QPointF &pos)
void propertyChanged()
virtual void onPropertyChange(const QString &)
void setItemValue(const QString &tag, const QVariant &variant)
Directly set value of item under given tag.