#ifndef ONEEYEMAP_H #define ONEEYEMAP_H #include #include #include #include "spdlog/spdlog.h" #include "EyeMapInfo.h" namespace Ui { class OneEyeMap; } class OneEyeMap : public QWidget { Q_OBJECT public: explicit OneEyeMap(QWidget *parent = nullptr); ~OneEyeMap(); /* 根据通道号获取数据指针 */ void getEyeDataPtrFromOscData(int channel); /* 设置序号 */ void setNum(int num) { m_info.num = num; } /* 获取序号 */ int getNum() { return m_info.num; } /* 设置标题 */ void setTitle(const QString &title); /* 获取标题 */ QString getTitle() { return m_info.title; } /* 设置颜色 */ void setTitleBarColor(const QColor &color); /* 获取颜色 */ QColor getTitleBarColor() { return m_info.titleBarColor; } /* 设置是否显示 */ void setShow(bool isShow); /* 获取是否显示 */ bool getShow() { return m_info.isShow; } /* 设置通道信息 */ void setChannelInfo(const OneChannelInfo &info) { m_info.channelInfo = info; } /* 获取通道信息 */ OneChannelInfo& getChannelInfo() { return m_info.channelInfo; } /* 设置电压值 */ void setVoltageRange(OscVoltageRange range); /* 获取电压值 */ OscVoltageRange getVoltageRange() { return m_info.voltageRange; } /* 设置时间刻度 */ void setTimeGridValue(OscTimeGridValue value) { m_info.tGridValue = value; } /* 获取时间刻度 */ OscTimeGridValue getTimeGridValue() { return m_info.tGridValue; } /* 更新组件信息 */ void updateInfo(const OneEyeMapInfo &info); /* 只更新设置个数页面的信息 */ void updateSettingNum(const OneEyeMapInfo &info); signals: void signal_update(); private slots: void do_update(); protected: void paintEvent(QPaintEvent *event) override; /* 缩放事件 */ void resizeEvent(QResizeEvent *event) override; private: /* 绘制刻度值区域 */ void drawScaleValue(QPainter &painter); /* 绘制刻度 */ void drawScale(QPainter &painter); /* 绘制眼图区域 */ void drawEyeMap(QPainter &painter); /* 获取一个格子的电压值 */ inline QString getVScaleValue(int index); /* 获取一个时间值 */ inline QString getTimeValue(int index); private: Ui::OneEyeMap *ui; std::shared_ptr m_logger = nullptr; /* 组件属性信息 */ // bool m_isShow = false; /* 是否显示 */ // int m_num; /* 序号 */ // QString m_title; /* 标题 */ // QColor m_color; /* 颜色 */ OneEyeMapInfo m_info; /* 组件信息 */ QTimer m_timer; /* 眼图显示布局 */ QRect m_rectScaleValue; /* 刻度值区域 */ QRect m_rectEyeMap; /* 眼图区域 */ int m_leftMargin = 0; /* 眼图距离刻度区域的左边距 */ int m_topMargin = 0; /* 眼图距离刻度区域的上边距 */ int m_rightMargin = 0; /* 眼图距离刻度区域的右边距 */ int m_bottomMargin = 0; /* 眼图距离刻度区域的下边距 */ int m_hScaleNum = 0; /* 水平刻度 */ int m_vScaleNum = 0; /* 垂直刻度 */ /* 眼图属性 */ // OscVoltageRange m_cRange = OscVoltageRange::CR_2V5; /* 通道输入档位 */ // OscTimeGridValue m_tGridValue = OscTimeGridValue::TGV_200NS; /* 时间刻度值 */ EyeMapMatrix* m_eyeMapMatrix = nullptr; /* 眼图矩阵,从外面获取 */ }; #endif // ONEEYEMAP_H