BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
IShape2DView.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Mask/IShape2DView.h
6 //! @brief Defines interface IShape2DView.
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_ISHAPE2DVIEW_H
16 #define BORNAGAIN_GUI_VIEW_MASK_ISHAPE2DVIEW_H
17 
19 #include <QGraphicsObject>
20 
21 class SessionItem;
22 class ISceneAdaptor;
23 class QPainter;
24 
25 //! Main interface class for views representing MaskItems, Projections on graphics scene.
26 
27 class IShape2DView : public QGraphicsObject {
28  Q_OBJECT
29 
30 public:
31  int type() const override { return MaskEditorHelper::IMASKVIEW; }
32 
33  QRectF boundingRect() const override;
34 
35  virtual SessionItem* parameterizedItem() const = 0;
36 
37  void setSceneAdaptor(const ISceneAdaptor* adaptor);
38 
39  virtual void addView(IShape2DView* childView, int row = 0);
40 
41 protected slots:
42  //! update visual appearance of view (triggered by ISceneAdaptor)
43  virtual void update_view() = 0;
44  virtual void onChangedX() {}
45  virtual void onChangedY() {}
46  virtual void onPropertyChange() {}
47 
48 protected:
49  explicit IShape2DView(SessionItem* item);
50 
51  void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) override;
52 
53  //! Returns the shape with all masking already applied.
54  QPainterPath maskedShape() const;
55 
56  qreal toSceneX(qreal value) const;
57  qreal toSceneY(qreal value) const;
58 
59  //! convert scene coordinates to ColorMap plot coordinates
60  qreal fromSceneX(qreal value) const;
61  qreal fromSceneY(qreal value) const;
62  void setBlockOnProperty(bool value);
63  bool blockOnProperty() const;
64 
65  void disconnectFromItem(SessionItem* item);
66 
70 
71 private:
72  void onItemPropertyChange(const QString& propertyName);
73  virtual void onItemDestroyed() = 0;
74 };
75 
76 #endif // BORNAGAIN_GUI_VIEW_MASK_ISHAPE2DVIEW_H
Defines class MaskEditorHelper.
Interface to adapt MaskItems coordinates (expressed in units of IntensityDataItem) to/from scene coor...
Definition: ISceneAdaptor.h:24
Main interface class for views representing MaskItems, Projections on graphics scene.
Definition: IShape2DView.h:27
virtual void onPropertyChange()
Definition: IShape2DView.h:46
virtual void addView(IShape2DView *childView, int row=0)
virtual SessionItem * parameterizedItem() const =0
virtual void onItemDestroyed()=0
virtual void onChangedX()
Definition: IShape2DView.h:44
virtual void update_view()=0
update visual appearance of view (triggered by ISceneAdaptor)
const ISceneAdaptor * m_adaptor
Definition: IShape2DView.h:67
qreal toSceneX(qreal value) const
QRectF boundingRect() const override
qreal fromSceneY(qreal value) const
void setBlockOnProperty(bool value)
void disconnectFromItem(SessionItem *item)
QPainterPath maskedShape() const
Returns the shape with all masking already applied.
bool blockOnProperty() const
void onItemPropertyChange(const QString &propertyName)
qreal fromSceneX(qreal value) const
convert scene coordinates to ColorMap plot coordinates
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override
void setSceneAdaptor(const ISceneAdaptor *adaptor)
virtual void onChangedY()
Definition: IShape2DView.h:45
qreal toSceneY(qreal value) const
bool m_block_on_property_change
Definition: IShape2DView.h:69
QRectF m_bounding_rect
Definition: IShape2DView.h:68
IShape2DView(SessionItem *item)
int type() const override
Definition: IShape2DView.h:31
Base class for a GUI data item.
Definition: SessionItem.h:204