#ifndef FRMPLOT_H #define FRMPLOT_H #include #include "qcustomplot.h" class QLabel; class SelectWidget; namespace Ui { class frmPlot; } class frmPlot : public QWidget { Q_OBJECT public: explicit frmPlot(QWidget *parent = 0); ~frmPlot(); protected: void showEvent(QShowEvent *); bool eventFilter(QObject *watched, QEvent *event); private: Ui::frmPlot *ui; bool modeMax; //处于放大模式 bool modeMin; //处于缩小模式 bool modeMove; //处于平移模式 int maxX; //X轴数据个数 int maxY; //Y轴数据个数 int scal; //缩放倍数 QString xUnit; //X轴单位 QString yUnit; //Y轴单位 QString value; //右上角显示的当前值 QTimer *timer; //模拟数据定时器 QCustomPlot *customPlot; QVector keys; //横坐标索引 QVector values; //横坐标数据 QVector labs; //横坐标字符串 QLabel *labXUnit; //X轴单位 QLabel *labYUnit; //Y轴单位 QLabel *labValue; //XY轴当前数据点值 QList selectWidgets; private slots: void initForm(); void initPlot(); void initData(); void loadData(); void resetMode(); private slots: void btnClicked(int parentIndex, int childIndex); void clearFocus(); void widgetPressed(QWidget *widget); public slots: //设置X轴最大值 void setMaxX(int maxX); //设置Y轴最大值 void setMaxY(int maxY); //添加数据 void appendData(double data); //设置X轴单位 void setXUnit(const QString &xUnit); //设置Y轴单位 void setYUnit(const QString &yUnit); //设置当前XY值 void setValue(const QString &value); void setValue(double x, double y); //保存数据和图像 void saveData(const QString &fileName); }; #endif // FRMPLOT_H