BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
ISceneAdaptor.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Mask/ISceneAdaptor.h
6 //! @brief Defines interface class ISceneAdaptor
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_ISCENEADAPTOR_H
16 #define BORNAGAIN_GUI_VIEW_MASK_ISCENEADAPTOR_H
17 
18 #include <QObject>
19 #include <QRectF>
20 
21 //! Interface to adapt MaskItems coordinates (expressed in units of IntensityDataItem)
22 //! to/from scene coordinates.
23 
24 class ISceneAdaptor : public QObject {
25  Q_OBJECT
26 public:
27  ~ISceneAdaptor() override = default;
28 
29  //! convert native mask x-coordinate to scene coordinate
30  virtual qreal toSceneX(qreal) const = 0;
31  //! convert native mask y-coordinate to scene coordinate
32  virtual qreal toSceneY(qreal) const = 0;
33  //! convert scene x-coordinate to native mask coordinate
34  virtual qreal fromSceneX(qreal) const = 0;
35  //! convert scene y-coordinate to native mask coordinate
36  virtual qreal fromSceneY(qreal) const = 0;
37 
38  //! Returns viewport rectangle in scene coordinates
39  virtual const QRectF& viewportRectangle() const { return m_viewport_rectangle; }
40 
41 signals:
43 
44 protected:
46 };
47 
49  Q_OBJECT
50 public:
51  DefaultSceneAdaptor() = default;
52  qreal toSceneX(qreal value) const override { return value; }
53  qreal toSceneY(qreal value) const override { return value; }
54  qreal fromSceneX(qreal value) const override { return value; }
55  qreal fromSceneY(qreal value) const override { return value; }
56 };
57 
58 #endif // BORNAGAIN_GUI_VIEW_MASK_ISCENEADAPTOR_H
qreal fromSceneY(qreal value) const override
convert scene y-coordinate to native mask coordinate
Definition: ISceneAdaptor.h:55
qreal toSceneY(qreal value) const override
convert native mask y-coordinate to scene coordinate
Definition: ISceneAdaptor.h:53
qreal toSceneX(qreal value) const override
convert native mask x-coordinate to scene coordinate
Definition: ISceneAdaptor.h:52
DefaultSceneAdaptor()=default
qreal fromSceneX(qreal value) const override
convert scene x-coordinate to native mask coordinate
Definition: ISceneAdaptor.h:54
Interface to adapt MaskItems coordinates (expressed in units of IntensityDataItem) to/from scene coor...
Definition: ISceneAdaptor.h:24
virtual qreal fromSceneX(qreal) const =0
convert scene x-coordinate to native mask coordinate
~ISceneAdaptor() override=default
QRectF m_viewport_rectangle
Definition: ISceneAdaptor.h:45
virtual qreal toSceneY(qreal) const =0
convert native mask y-coordinate to scene coordinate
virtual qreal fromSceneY(qreal) const =0
convert scene y-coordinate to native mask coordinate
virtual const QRectF & viewportRectangle() const
Returns viewport rectangle in scene coordinates.
Definition: ISceneAdaptor.h:39
void update_request()
virtual qreal toSceneX(qreal) const =0
convert native mask x-coordinate to scene coordinate