#include "PlotBloodOxygenWave.h"
#include "MCustomAssembly.h"
#include "MCycleCurveData.h"
#include "MPlotMagnifier.h"
#include "QwtPlotDefine.h"
#include "MPlotWaveCurve.h"
#include <QDebug>
#include <QElapsedTimer>
#include <QTimerEvent>
#include <qwt_plot.h>
#include <qwt_plot_grid.h>
#include <qwt_plot_marker.h>
#include <qwt_legend.h>
#include <qwt_plot_panner.h>
#include <qwt_plot_zoomer.h>
#include <qwt_plot_curve.h>
#include <qwt_plot_directpainter.h>
#include <qwt_symbol.h>
#include <qwt_picker_machine.h>
#include <windows.h>
void CALLBACK TimerCallback(PVOID lpParameter, BOOLEAN TimerOrWaitFired);
class PlotBloodOxygenWave::PrivateData
{
public:
MPlotMagnifier *pMagnifier = nullptr;
QwtPanner *pPanner = nullptr;
QwtPicker *pPicker = nullptr;
MPlotWaveCurve *pPOCurve = nullptr;
MCycleCurveData *pWaveData = nullptr;
QwtPlotDirectPainter *pDirectPainter = nullptr;
QwtInterval interval;
unsigned m_uSamplingRate = 33;
int DrawTimerId = 0;
HANDLE hTimer = NULL;
QElapsedTimer elapsed;
unsigned uPlotIntervalCount = 0;
EDrawStatus eStatus = EDS_UNKNOWN;
unsigned uReservePointRatio = 66;
~PrivateData()
{
if (pDirectPainter)
{
delete pDirectPainter;
pDirectPainter = nullptr;
}
}
};
PlotBloodOxygenWave::PlotBloodOxygenWave(QwtPlot *plot) :
QObject(plot)
{
m_pPlot = plot;
m_uDrawCounter = 0;
m_uDataCheckCounter = 0;
m_uDataCheckInterval = 30;
data = new PrivateData;
data->pWaveData = new MCycleCurveData();
data->pDirectPainter = new QwtPlotDirectPainter;
data->interval.setMaxValue(5000);
data->elapsed.start();
}
PlotBloodOxygenWave::~PlotBloodOxygenWave()
{
m_pPlot = nullptr;
delete data;
data = nullptr;
}
void PlotBloodOxygenWave::SetParam(unsigned uSamplingRate, double dXAxisWidth, unsigned uPlotIntervalTime)
{
data->m_uSamplingRate = uSamplingRate;
data->pWaveData->SetParam(uSamplingRate, dXAxisWidth);
dXAxisWidth *= 1000;
if (dXAxisWidth > 1000 && dXAxisWidth != data->interval.width() )
{
data->interval.setMaxValue(data->interval.minValue() + dXAxisWidth);
m_pPlot->setAxisScale(QwtPlot::xBottom, data->interval.minValue(), data->interval.maxValue());
}
unsigned uIntervalTime = data->pWaveData->GetTimeInterval();
unsigned uPlotIntervalCount = round( uPlotIntervalTime / uIntervalTime);
if(uPlotIntervalCount > 0 && uPlotIntervalCount != data->uPlotIntervalCount)
{
data->uPlotIntervalCount = uPlotIntervalCount;
}
if (data->hTimer)
{
::ChangeTimerQueueTimer(NULL, data->hTimer, uIntervalTime, uIntervalTime);
}
if(data->DrawTimerId) //如果开启了绘制定时器,则重置
{
killTimer(data->DrawTimerId);
data->DrawTimerId = startTimer( uIntervalTime );
}
if (EDS_UNKNOWN != data->eStatus)
{
m_pPlot->replot();
}
}
void PlotBloodOxygenWave::BuildPlot()
{
InitPlot();
//AddPlotGrid();
// AddLegend();
//AddPanner();
//AddPicker();
AddWaveCurve();
data->eStatus = EDS_STOP;
}
void PlotBloodOxygenWave::Start()
{
if (EDS_START != data->eStatus)
{
data->eStatus = EDS_START;
data->elapsed.restart();
unsigned uTimerInterval = data->pWaveData->GetTimeInterval();
if (!::CreateTimerQueueTimer(&data->hTimer, NULL, TimerCallback, this, uTimerInterval, uTimerInterval, WT_EXECUTEDEFAULT))
{
qDebug() << QString::fromLocal8Bit("创建脉氧波取值定时器失败!");
data->hTimer = nullptr;
}
data->DrawTimerId = startTimer(uTimerInterval);
}
}
void PlotBloodOxygenWave::Stop()
{
if (EDS_START == data->eStatus)
{
data->eStatus = EDS_STOP;
if (data->hTimer)
::DeleteTimerQueueTimer(nullptr, data->hTimer, INVALID_HANDLE_VALUE);
data->hTimer = nullptr;
killTimer(data->DrawTimerId);
data->DrawTimerId = 0;
}
}
void PlotBloodOxygenWave::Reset()
{
data->pWaveData->Reset();
data->interval = data->pWaveData->GetXAxisInterval();
m_pPlot->setAxisScale(QwtPlot::xBottom, data->interval.minValue(), data->interval.maxValue());
}
void PlotBloodOxygenWave::AddWaveData(QList<unsigned char> list)
{
if (EDS_START != data->eStatus) return;
unsigned iSize = data->pWaveData->AddPendingValues(list);
if (0 != m_uDataCheckCounter++ % m_uDataCheckInterval) return; //30s检测一次
double dValue = (double)iSize / data->m_uSamplingRate;
qDebug() << QString::fromLocal8Bit("当前缓存的数据为:%1个,比值:%2")
.arg(iSize).arg(dValue);
if (dValue < 1.5) //实际只剩10条数据
{
if (1 != data->uReservePointRatio)
{
data->uReservePointRatio = 1;
m_uDataCheckInterval = 30;
unsigned uTimeInterval = data->pWaveData->GetTimeInterval() + 2;
::ChangeTimerQueueTimer(NULL, data->hTimer, uTimeInterval, uTimeInterval);
qDebug() << QString::fromLocal8Bit("当前取值间隔为:%1").arg(uTimeInterval);
}
}
else if (dValue < 2.1) //只有1秒以内数据
{
if (2 != data->uReservePointRatio)
{
data->uReservePointRatio = 2;
m_uDataCheckInterval = 30;
unsigned uTimeInterval = data->pWaveData->GetTimeInterval() + 1;
::ChangeTimerQueueTimer(NULL, data->hTimer, uTimeInterval, uTimeInterval);
qDebug() << QString::fromLocal8Bit("当前取值间隔为:%1").arg(uTimeInterval);
}
}
else if (dValue < 3.1) //只有2秒以内数据
{
if (3 != data->uReservePointRatio)
{
data->uReservePointRatio = 3;
m_uDataCheckInterval = 30;
unsigned uTimeInterval = data->pWaveData->GetTimeInterval();
::ChangeTimerQueueTimer(NULL, data->hTimer, uTimeInterval, uTimeInterval);
qDebug() << QString::fromLocal8Bit("当前取值间隔为:%1").arg(uTimeInterval);
}
}
else if (dValue < 4.1) //只有3秒以内数据
{
if (4 != data->uReservePointRatio)
{
data->uReservePointRatio = 4;
m_uDataCheckInterval = 30;
unsigned uTimeInterval = data->pWaveData->GetTimeInterval() - 1;
::ChangeTimerQueueTimer(NULL, data->hTimer, uTimeInterval, uTimeInterval);
qDebug() << QString::fromLocal8Bit("当前取值间隔为:%1").arg(uTimeInterval);
}
}
else if (dValue < 5.1) //实际大于4秒数据
{
if( 5 != data->uReservePointRatio)
{
data->uReservePointRatio = 5;
m_uDataCheckInterval = 30;
unsigned uTimeInterval = data->pWaveData->GetTimeInterval() - 2;
::ChangeTimerQueueTimer(NULL, data->hTimer, uTimeInterval, uTimeInterval);
qDebug() << QString::fromLocal8Bit("当前取值间隔为:%1").arg(uTimeInterval);
}
}
else if(10 != data->uReservePointRatio)
{
data->uReservePointRatio = 10;
m_uDataCheckInterval = 6;
unsigned uTimeInterval = data->pWaveData->GetTimeInterval() - 10;
::ChangeTimerQueueTimer(NULL, data->hTimer, uTimeInterval, uTimeInterval);
qDebug() << QString::fromLocal8Bit("当前取值间隔为:%1").arg(uTimeInterval);
}
}
void PlotBloodOxygenWave::DrawHistoryData(quint64 ulStartTime, QVector<unsigned char> list)
{
data->eStatus = EDS_HISTORY;
data->pWaveData->AddHistoryData(ulStartTime, list);
//刷新坐标轴
QwtInterval interval = data->pWaveData->GetXAxisInterval();
data->interval = QwtInterval(interval.maxValue() - data->interval.width(), interval.maxValue());
m_pPlot->setAxisScale(QwtPlot::xBottom, data->interval.minValue(), data->interval.maxValue());
data->pPOCurve->SetCurrentPoint(-1);
//重绘
m_pPlot->replot();
}
void PlotBloodOxygenWave::InitPlot()
{
//设置标题
// m_pPlot->setTitle("My Project");
//设置画布或背景
m_pPlot->setCanvas( new MCanvas() );
m_pPlot->setCanvasBackground(Qt::white);
//设置坐标轴的名称
// m_pPlot->setAxisTitle(QwtPlot::xBottom, QStringLiteral("X轴"));
//
没有合适的资源?快使用搜索试试~ 我知道了~
QT用QWT绘制心电图、脉氧饱和度波形图、波形图
共52个文件
dll:24个
h:11个
cpp:10个
1星 需积分: 50 143 下载量 129 浏览量
2019-07-08
16:48:51
上传
评论 5
收藏 11.19MB RAR 举报
温馨提示
QT用QWT绘制动态脉氧饱和度波形图,也适用于心电图。历史波形图的查看,放大和平移的限制。
资源推荐
资源详情
资源评论
收起资源包目录
QwtPlotComponent.rar (52个子文件)
QwtPlotComponent
QwtPlotComponent.vcxproj.filters 4KB
MPlotWaveCurve.cpp 1KB
MSamplingThread.h 769B
QwtPlotComponent.vcxproj.user 941B
PlotBloodOxygenWave.h 2KB
MSamplingThread.cpp 988B
PlotPulseOxygen.cpp 9KB
MCustomAssembly.h 4KB
MPlotMagnifier.cpp 2KB
qwtPlotManage.h 2KB
MainWindow.ui 9KB
qwtPlotManage.cpp 8KB
MCurveData.h 1KB
QwtPlotComponent.sln 1KB
MainWindow.h 834B
main.cpp 203B
QwtPlotComponent.pro 1KB
QwtPlotComponent.vcxproj 13KB
MainWindow.cpp 4KB
lib
QwtPlotComponent.exe 90KB
iconengines
qsvgicon.dll 29KB
libGLESV2.dll 1.53MB
Qt5SerialPort.dll 58KB
libEGL.dll 10KB
Qt5Svg.dll 246KB
qwt.dll 924KB
imageformats
qwbmp.dll 18KB
qjpeg.dll 238KB
qtiff.dll 306KB
qtga.dll 18KB
qico.dll 25KB
qgif.dll 24KB
qicns.dll 30KB
qsvg.dll 19KB
qwebp.dll 317KB
Qt5Network.dll 836KB
platforms
qwindows.dll 989KB
D3Dcompiler_47.dll 3.31MB
Qt5Core.dll 4.48MB
Qt5PrintSupport.dll 262KB
opengl32sw.dll 14.52MB
Qt5Widgets.dll 4.28MB
Qt5OpenGL.dll 267KB
Qt5Gui.dll 4.8MB
QwtPlotDefine.h 94B
MPlotWaveCurve.h 486B
PlotPulseOxygen.h 1KB
MCycleCurveData.h 311B
MPlotMagnifier.h 448B
MCycleCurveData.cpp 1008B
PlotBloodOxygenWave.cpp 13KB
MCurveData.cpp 4KB
共 52 条
- 1
资源评论
- W0011234567892020-12-01一堆的报错!
- c686c6862021-11-10没有qwt_plot.h文件。很一般的资源。
lxj434368832
- 粉丝: 56
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功