BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
SizeHandleElement.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Mask/SizeHandleElement.h
6 //! @brief Defines SizeHandleElement 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_VIEW_MASK_SIZEHANDLEELEMENT_H
16 #define BORNAGAIN_GUI_VIEW_MASK_SIZEHANDLEELEMENT_H
17 
19 #include <QCursor>
20 #include <QGraphicsObject>
21 #include <QMap>
22 
23 //! Size handle on top of RectangleView represented as small circle or small rectangle.
24 //! Placed either in corners on in the middle of the edge.
25 
26 class SizeHandleElement : public QGraphicsObject {
27  Q_OBJECT
28 
29 public:
30  int type() const override { return MaskEditorHelper::SIZEHANDLE; }
31 
42  };
43 
45 
46  SizeHandleElement(EHandleLocation pointType, QGraphicsObject* parent = nullptr);
47 
48  QRectF boundingRect() const override;
49 
50  void updateHandleElementPosition(const QRectF& rect);
51 
54  EHandleType getHandleType() const;
55 
56 public slots:
57  virtual void update_view();
58 
59 signals:
60  void resize_request(bool going_to_resize);
61 
62 protected:
63  void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) override;
64  void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
65  void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
66 
67 private:
70  static QMap<EHandleLocation, Qt::CursorShape> m_cursors;
71  static QMap<EHandleLocation, EHandleType> m_location_to_type;
72  static QMap<EHandleLocation, EHandleLocation> m_opposite_handle_location;
73 };
74 
75 #endif // BORNAGAIN_GUI_VIEW_MASK_SIZEHANDLEELEMENT_H
Defines class MaskEditorHelper.
Size handle on top of RectangleView represented as small circle or small rectangle....
EHandleLocation m_handleLocation
QRectF boundingRect() const override
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override
SizeHandleElement(EHandleLocation pointType, QGraphicsObject *parent=nullptr)
static QMap< EHandleLocation, EHandleType > m_location_to_type
static QMap< EHandleLocation, Qt::CursorShape > m_cursors
void resize_request(bool going_to_resize)
void updateHandleElementPosition(const QRectF &rect)
set position from location type using coordinates of external rectangle
EHandleType m_handleType
virtual void update_view()
static QMap< EHandleLocation, EHandleLocation > m_opposite_handle_location
EHandleType getHandleType() const
EHandleLocation getHandleLocation() const
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
int type() const override
void mousePressEvent(QGraphicsSceneMouseEvent *event) override
EHandleLocation getOppositeHandleLocation() const