//  ************************************************************************************************
//
//  BornAgain: simulate and fit reflection and scattering
//
//! @file      GUI/View/Plotter/PlotEventHelper.h
//! @brief     Defines class PlotEventHelper.
//!
//! @homepage  http://www.bornagainproject.org
//! @license   GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors   Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
//  ************************************************************************************************

#ifndef BORNAGAIN_GUI_VIEW_PLOTTER_PLOTEVENTHELPER_H
#define BORNAGAIN_GUI_VIEW_PLOTTER_PLOTEVENTHELPER_H

#include <QMouseEvent>
#include <QObject>
#include <memory>

class QCustomPlot;
class ScientificPlot;

//! Helps ScientificPlot to handle mouse events. Particularly, it constructs a valid
//! status string. Can be extended to play a role of event filter.

class PlotEventHelper : public QObject {
    Q_OBJECT
public:
    explicit PlotEventHelper(ScientificPlot* scientific_plot);
    ~PlotEventHelper() override;

    void setMouseTrackingEnabled(bool enable);

signals:
    void enteringPlot();
    void leavingPlot();
    void positionChanged(double x, double y);

public slots:
    void onCustomMouseMove(QMouseEvent* event);

private:
    ScientificPlot* m_plot;
    bool m_was_inside = false;
};

#endif // BORNAGAIN_GUI_VIEW_PLOTTER_PLOTEVENTHELPER_H
