From 7245cb07ffb18739855a527310ffdbc4fb0778f3 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Thu, 2 May 2024 14:03:11 +0800 Subject: [PATCH] update --- libzqt/widgetplot2d.cpp | 13 +++++++------ mainwindow.cpp | 3 ++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/libzqt/widgetplot2d.cpp b/libzqt/widgetplot2d.cpp index 0fca44f..c2f9d1a 100644 --- a/libzqt/widgetplot2d.cpp +++ b/libzqt/widgetplot2d.cpp @@ -110,12 +110,12 @@ void WidgetPlot2D::initGraphName(QStringList name) { } /* 添加数据 */ -void WidgetPlot2D::addData(QString name, double value, int offms) { +void WidgetPlot2D::addData(QString name, double value, int abs) { // 如果点击了“暂停”按钮,则不绘制图形 if (ui->pausePBtn->text() == "开始") return; // 系统当前时间 = 系统运行初始时间 + 系统运行时间 - static double start = time.hour() * 60 * 60 + time.minute() * 60 + time.second() + time.msec() / 1000.0; - double key = start + time.elapsed() / 1000.0 + offms / 1000; + static double start = 0; + double key = abs; // double start = 0; // static int key = 0; // key++; @@ -129,7 +129,7 @@ void WidgetPlot2D::addData(QString name, double value, int offms) { ui->customPlot->rescaleAxes(); } // 设置时间轴 - int timeAxis = ui->timeAxisSpin->value(); + int timeAxis = ui->customPlot->xAxis->range().size(); ui->customPlot->xAxis->setRange(key, timeAxis, Qt::AlignRight); // x轴和y轴全程显示 if (ui->fullShowCheck->isChecked()) { @@ -152,7 +152,7 @@ void WidgetPlot2D::addData(QString name, double value, int offms) { static int frameCount = 0; frameCount++; // 每2秒显示一次帧率 - if (key - lastFpsKey > 0.5) { + if (key - lastFpsKey > 50) { uint64_t sum = 0; for (int i = 0; i < ui->customPlot->plottableCount(); i++) { sum += uint64_t(ui->customPlot->graph(i)->data()->size()); @@ -440,7 +440,8 @@ void WidgetPlot2D::savePlotPng() { void WidgetPlot2D::horzScrollBarChanged(int value) { // 若全程显示,则不移动绘图坐标 if (ui->fullShowCheck->isChecked()) return; - int timeAxis = ui->timeAxisSpin->value(); + // int timeAxis = ui->timeAxisSpin->value(); + int timeAxis = ui->customPlot->xAxis->range().size(); ui->customPlot->xAxis->setRange(value, timeAxis, Qt::AlignRight); ui->customPlot->replot(); } diff --git a/mainwindow.cpp b/mainwindow.cpp index ed85920..623f940 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -290,7 +290,8 @@ void MainWindow::constructUI() { int32_t *frame = (int32_t *)heartrate_report->data; for (int i = 0; i < 50; i++) { int32_t data = frame[i]; - emit doinui_signal(QFunction([this, data, i]() { wp2d->addData("心电", data, i * 2); })); + int32_t frameIndex = heartrate_report->sample_data_index + i; + emit doinui_signal(QFunction([this, data, frameIndex]() { wp2d->addData("心电", data, frameIndex); })); } } }