BornAgain  1.19.0
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/coregui/Views/MaskWidgets/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_COREGUI_VIEWS_MASKWIDGETS_SIZEHANDLEELEMENT_H
16 #define BORNAGAIN_GUI_COREGUI_VIEWS_MASKWIDGETS_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 { return MaskEditorHelper::SIZEHANDLE; }
31 
42  };
43 
45 
46  SizeHandleElement(EHandleLocation pointType, QGraphicsObject* parent = 0);
47 
48  QRectF boundingRect() const;
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*);
64  void mousePressEvent(QGraphicsSceneMouseEvent* event);
65  void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
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_COREGUI_VIEWS_MASKWIDGETS_SIZEHANDLEELEMENT_H
Defines class MaskEditorHelper.
Size handle on top of RectangleView represented as small circle or small rectangle.
EHandleLocation m_handleLocation
static QMap< EHandleLocation, EHandleType > m_location_to_type
static QMap< EHandleLocation, Qt::CursorShape > m_cursors
SizeHandleElement(EHandleLocation pointType, QGraphicsObject *parent=0)
void mousePressEvent(QGraphicsSceneMouseEvent *event)
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
QRectF boundingRect() const
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
virtual void update_view()
static QMap< EHandleLocation, EHandleLocation > m_opposite_handle_location
EHandleType getHandleType() const
EHandleLocation getHandleLocation() const
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
EHandleLocation getOppositeHandleLocation() const