BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
RectangleBaseView.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Mask/RectangleBaseView.h
6 //! @brief Defines RectangleBaseView 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_RECTANGLEBASEVIEW_H
16 #define BORNAGAIN_GUI_VIEW_MASK_RECTANGLEBASEVIEW_H
17 
20 #include <QMap>
21 
22 //! Base view for all rectangular-like masks.
23 
25  Q_OBJECT
26 
27 public:
28  int type() const override { return MaskEditorHelper::RECTANGLEBASE; }
29 
30  explicit RectangleBaseView(SessionItem* item);
31 
32 private slots:
33  void onSizeHandleElementRequest(bool going_to_resize);
34 
35 protected:
36  QVariant itemChange(GraphicsItemChange change, const QVariant& value) override;
37  void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
38  void update_view() override;
39 
40  virtual void update_bounding_rect();
41  virtual void update_position() = 0;
42  virtual QRectF mask_rectangle() = 0;
43  virtual qreal left() const = 0;
44  virtual qreal right() const = 0;
45  virtual qreal top() const = 0;
46  virtual qreal bottom() const = 0;
47 
48  qreal width() const;
49  qreal height() const;
50 
52  QRectF m_mask_rect; //!< mask rectangle in scene coordinates
53  QMap<SizeHandleElement::EHandleLocation, SizeHandleElement*> m_resize_handles;
54  //!< coordinates of corner opposite to the grip corner at the moment it first clicked
55  //!< in scene coordinates
58 };
59 
60 #endif // BORNAGAIN_GUI_VIEW_MASK_RECTANGLEBASEVIEW_H
Defines interface IShape2DView.
Defines SizeHandleElement class.
Main interface class for views representing MaskItems, Projections on graphics scene.
Definition: IShape2DView.h:27
Base view for all rectangular-like masks.
virtual qreal right() const =0
virtual QRectF mask_rectangle()=0
SizeHandleElement * m_activeHandleElement
virtual qreal top() const =0
QRectF m_mask_rect
mask rectangle in scene coordinates
qreal width() const
Returns width of the rectangle.
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
void onSizeHandleElementRequest(bool going_to_resize)
triggered by SizeHandleElement
int type() const override
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override
Track if item selected/deselected and show/hide size handles.
virtual void update_position()=0
QMap< SizeHandleElement::EHandleLocation, SizeHandleElement * > m_resize_handles
coordinates of corner opposite to the grip corner at the moment it first clicked in scene coordinates
virtual void update_bounding_rect()
updates view's bounding rectangle using item properties
void update_view() override
update visual appearance of view (triggered by ISceneAdaptor)
QPointF m_resize_opposite_origin
virtual qreal left() const =0
RectangleBaseView(SessionItem *item)
virtual qreal bottom() const =0
Base class for a GUI data item.
Definition: SessionItem.h:204
Size handle on top of RectangleView represented as small circle or small rectangle....