#ifndef CHART_FILE_H
#define CHART_FILE_H

#include <QWidget>
#include <QChart>
#include <QLineSeries>
#include <QVector>
#include <QTimer>
#include <QStandardItemModel>
#include <QCheckBox>
#include <QValueAxis>
#include <QChartView>
#include <QDir> 
#include <QFileInfo>

#include "src/message/message_dialog.h"
//QT_USE_NAMESPACE

namespace Ui {
class chart_file;
}

class chart_file : public QWidget
{
    Q_OBJECT

public:
    explicit chart_file(QWidget *parent = nullptr);
    ~chart_file();

    void setPointsNum(int num);
    void addChartData(float time, float *pointsDis);



private:
    Ui::chart_file *ui;
    void wheelEvent(QWheelEvent *event);

    void initUI();
    void initChart();
    void initSlot();
    void initTable(int pointsNumber);
    void initFontColor();


    void initReadData();
    void add_read_data();
    int read_time;
  
    void addData();
    QChartView *chartView;
    QChart *chart;
    QLineSeries *series[8];
    int pointsSize;//用于画曲线的数据点数


    float *time;
    float *point1;
    float *point2;
    int pointsNum;

    float **tempDis;//store dis,mini dis, max dis for every points;

    QTimer *timer;

    quint16 count;
    quint16 line_now_count;
    quint16 line_last_count;



private slots:
    void timerSlot();
    int getFileNum(QString path);
    void selectAll();
    void invertSelect();
    void checkboxChanged();



private:

    QVector<QCheckBox *> checkBoxVector;
    QString strColor[9];
    QVector<QColor> colorTable;
    QStandardItemModel *model;

    QValueAxis *axisX;
    QValueAxis *axisY;

    void addTableData(float **pointsDis);
    void on_btn_clear_clicked();
    void on_btn_save_clicked();


};

#endif // CHART_FILE_H
