BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
ColorMapSceneAdaptor.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Mask/ColorMapSceneAdaptor.cpp
6 //! @brief Implements class ColorMapSceneAdaptor
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 
17 
19  : m_plot(nullptr)
20 {
21 }
22 
23 qreal ColorMapSceneAdaptor::toSceneX(qreal mask_x) const
24 {
25  return m_plot ? m_plot->xAxisCoordToPixel(mask_x) : mask_x;
26 }
27 
28 qreal ColorMapSceneAdaptor::toSceneY(qreal mask_y) const
29 {
30  return m_plot ? m_plot->yAxisCoordToPixel(mask_y) : mask_y;
31 }
32 
33 qreal ColorMapSceneAdaptor::fromSceneX(qreal scene_x) const
34 {
35  return m_plot ? m_plot->pixelToXaxisCoord(scene_x) : scene_x;
36 }
37 
38 qreal ColorMapSceneAdaptor::fromSceneY(qreal scene_y) const
39 {
40  return m_plot ? m_plot->pixelToYaxisCoord(scene_y) : scene_y;
41 }
42 
44 {
45  m_plot = plot;
46  if (m_plot)
47  m_plot->installEventFilter(this);
48 }
49 
50 bool ColorMapSceneAdaptor::eventFilter(QObject* object, QEvent* event)
51 {
52  Q_UNUSED(object);
53  if (event->type() == QEvent::Resize || event->type() == QEvent::UpdateRequest) {
55  emit update_request();
56  return false;
57  }
58  return true;
59 }
60 
62 {
63  return m_viewport_rectangle;
64 }
Defines class ColorMapSceneAdaptor.
Defines class ColorMap.
void setColorMapPlot(ColorMap *plot)
qreal fromSceneX(qreal scene_x) const override
convert scene x-coordinate to native mask coordinate
qreal toSceneX(qreal mask_x) const override
convert native mask x-coordinate to scene coordinate
const QRectF & viewportRectangle() const override
Returns ColorMapPlot axes rectangle (at current zoom level) in scene coordinates.
bool eventFilter(QObject *object, QEvent *event) override
qreal toSceneY(qreal mask_y) const override
convert native mask y-coordinate to scene coordinate
qreal fromSceneY(qreal scene_y) const override
convert scene y-coordinate to native mask coordinate
The ColorMap class presents 2D intensity data from IntensityDataItem as color map.
Definition: ColorMap.h:36
QRectF viewportRectangleInWidgetCoordinates()
Returns rectangle representing current axes zoom state in widget coordinates.
Definition: ColorMap.cpp:53
QRectF m_viewport_rectangle
Definition: ISceneAdaptor.h:45
void update_request()
double yAxisCoordToPixel(double axis_coordinate) const
double pixelToYaxisCoord(double pixel) const
double pixelToXaxisCoord(double pixel) const
transform widget coordinates to axes coordinates
double xAxisCoordToPixel(double axis_coordinate) const
transform axes coordinates to CustomPlot widget coordinates