chart_file.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #ifndef CHART_FILE_H
  2. #define CHART_FILE_H
  3. #include <QWidget>
  4. #include <QChart>
  5. #include <QLineSeries>
  6. #include <QVector>
  7. #include <QTimer>
  8. #include <QStandardItemModel>
  9. #include <QCheckBox>
  10. #include <QValueAxis>
  11. #include <QChartView>
  12. #include "code/tree/tree_model_set.h"
  13. //QT_USE_NAMESPACE
  14. namespace Ui {
  15. class chart_file;
  16. }
  17. class chart_file : public QWidget
  18. {
  19. Q_OBJECT
  20. public:
  21. explicit chart_file(QWidget *parent = nullptr);
  22. ~chart_file();
  23. void setTreeModel(tree_model_set *model); // 接受 tree_model_set 实例
  24. void setPointsNum(int num);
  25. void addChartData(float time, float *pointsDis);
  26. signals:
  27. void treeItemClicked(const QModelIndex &index);
  28. private:
  29. Ui::chart_file *ui;
  30. void wheelEvent(QWheelEvent *event);
  31. tree_model_set *treeModel; // 保存 tree_model_set 实例的指针
  32. void initUI();
  33. void initChart();
  34. void initSlot();
  35. void initTable(int pointsNumber);
  36. void initFontColor();
  37. void handleTreeItemClicked(const QModelIndex &index);
  38. void initReadData();
  39. void addData();
  40. QChartView *chartView;
  41. QChart *chart;
  42. QLineSeries *series[8];
  43. int pointsSize;//用于画曲线的数据点数
  44. float *time;
  45. float *point1;
  46. float *point2;
  47. int pointsNum;
  48. float **tempDis;//store dis,mini dis, max dis for every points;
  49. QTimer *timer;
  50. quint16 count;
  51. private slots:
  52. void timerSlot();
  53. void selectAll();
  54. void invertSelect();
  55. void checkboxChanged();
  56. private:
  57. QVector<QCheckBox *> checkBoxVector;
  58. QString strColor[9];
  59. QVector<QColor> colorTable;
  60. QStandardItemModel *model;
  61. QValueAxis *axisX;
  62. QValueAxis *axisY;
  63. void addTableData(float **pointsDis);
  64. void on_btn_clear_clicked();
  65. void on_btn_save_clicked();
  66. };
  67. #endif // CHART_FILE_H