添加OpenCv
This commit is contained in:
66
PublicFunctions/CurvePlotWidget - 副本.h
Normal file
66
PublicFunctions/CurvePlotWidget - 副本.h
Normal file
@@ -0,0 +1,66 @@
|
||||
#ifndef CURVEPLOTWIDGET_H
|
||||
#define CURVEPLOTWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QVector>
|
||||
#include <QColor>
|
||||
#include <QMap>
|
||||
#include <QElapsedTimer>
|
||||
|
||||
struct CurveCfg
|
||||
{
|
||||
QString name; // 图例
|
||||
double yMax; // y 满量程
|
||||
QColor normal; // 绿色(正常)
|
||||
QColor warning; // 橙色(警告)
|
||||
QColor fault; // 红色(故障)
|
||||
double thWarning; // 警告阈值
|
||||
double thFault; // 故障阈值
|
||||
};
|
||||
|
||||
class CurvePlotWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CurvePlotWidget(QWidget *parent = nullptr);
|
||||
|
||||
/* x 轴总时长(秒) */
|
||||
void setTimeRange(double secs);
|
||||
|
||||
/* 添加一条曲线 */
|
||||
void initCurve(int id, const CurveCfg &cfg);
|
||||
|
||||
/* 清空所有曲线 */
|
||||
void clearAllCurves();
|
||||
|
||||
/* 追加数据,yValue 为物理量,timeStamp 为 QDateTime::toMSecsSinceEpoch()/1000.0 */
|
||||
void appendPoint(int curveId, double timeStamp, double yValue);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
private:
|
||||
struct Curve
|
||||
{
|
||||
CurveCfg cfg;
|
||||
QVector<double> tBuf;
|
||||
QVector<double> yBuf;
|
||||
int head = 0;
|
||||
};
|
||||
|
||||
double m_tRange = 10.0; // 总时长(秒)
|
||||
int m_xMax = 72000; // 内部缓冲区点数
|
||||
int m_topMargin = 40; // 顶部留图例
|
||||
int m_bottomMargin = 25; // X 轴
|
||||
int m_leftMargin = 35; // Y 轴
|
||||
int m_rightMargin = 10;
|
||||
|
||||
QMap<int, Curve> m_curves;
|
||||
double m_t0 = 0; // 第一条数据的时间基准
|
||||
bool m_t0set = false;
|
||||
|
||||
QPointF mapToWidget(double t, double y, const Curve &c) const;
|
||||
};
|
||||
|
||||
#endif // CURVEPLOTWIDGET_H
|
||||
Reference in New Issue
Block a user