#ifndef PLOTWIDGET_H
#define PLOTWIDGET_H
#include "qcustomplot.h"
#include "xlsxdocument.h"
#include <QtWidgets/QWidget>
#include <QScrollBar>
#include <QMetaType>
#include <QVariant>

Q_DECLARE_METATYPE(QVector<double>);

class PlotWidget : public QWidget
{
    Q_OBJECT
public:
    PlotWidget(QWidget *parent = 0);
    ~PlotWidget();

private:
    QCustomPlot *m_customPlot;
    QLabel *m_label_left;
    QLabel *m_label_right;
    QLineEdit *m_lineEdit_left;
    QLineEdit *m_lineEdit_right;
    QPushButton *m_clear_button, *m_save_button;

    QCPItemLine *m_itemLine;
    QCPItemText *m_minValueText;

    QCPItemTracer *m_tracer;

    void setupPlot();
    void plotWaterfall();

    QCPItemStraightLine *m_lineLV; //左游标
    QCPItemStraightLine *m_lineRV; //右游标
    //QCPItemStraightLine *m_lineH;

    double xValue1;
    double xValue2;
    double yValue;

    QMutex  mutex;
    int m_count_graph;

    QXlsx::Document *m_xlsx;

private slots:
    void mousePress(QMouseEvent *event);
    void mouseMove(QMouseEvent *event);
    void mouseRelease();

    void replot_xlsx_data();
    void get_coordinate_calcu();
    void clear_all_graph();
    void save_sample_quality_area_data();
    void selectionChanged();

    void show_line_cursor();
    void hide_line_cursor();

    void plot_connect_line(QVariant, QVariant);
    void show_min_point_text(double x_min, double y_min);

protected:

private:
    bool lLineV;
    bool rLineV;
    bool bLineH;
signals:
    void show_area();
    void show_tang();
    void calcu_button_enable();
    void send_line_data_to_plot(QVariant, QVariant);
    void show_min_point(double, double);
};


#endif // PLOTWIDGET_H
