Browse Source

update

master
zhaohe 1 year ago
parent
commit
7245cb07ff
  1. 13
      libzqt/widgetplot2d.cpp
  2. 3
      mainwindow.cpp

13
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; 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; // double start = 0;
// static int key = 0; // static int key = 0;
// key++; // key++;
@ -129,7 +129,7 @@ void WidgetPlot2D::addData(QString name, double value, int offms) {
ui->customPlot->rescaleAxes(); ui->customPlot->rescaleAxes();
} }
// 设置时间轴 // 设置时间轴
int timeAxis = ui->timeAxisSpin->value();
int timeAxis = ui->customPlot->xAxis->range().size();
ui->customPlot->xAxis->setRange(key, timeAxis, Qt::AlignRight); ui->customPlot->xAxis->setRange(key, timeAxis, Qt::AlignRight);
// x轴和y轴全程显示 // x轴和y轴全程显示
if (ui->fullShowCheck->isChecked()) { if (ui->fullShowCheck->isChecked()) {
@ -152,7 +152,7 @@ void WidgetPlot2D::addData(QString name, double value, int offms) {
static int frameCount = 0; static int frameCount = 0;
frameCount++; frameCount++;
// 每2秒显示一次帧率 // 每2秒显示一次帧率
if (key - lastFpsKey > 0.5) {
if (key - lastFpsKey > 50) {
uint64_t sum = 0; uint64_t sum = 0;
for (int i = 0; i < ui->customPlot->plottableCount(); i++) { for (int i = 0; i < ui->customPlot->plottableCount(); i++) {
sum += uint64_t(ui->customPlot->graph(i)->data()->size()); sum += uint64_t(ui->customPlot->graph(i)->data()->size());
@ -440,7 +440,8 @@ void WidgetPlot2D::savePlotPng() {
void WidgetPlot2D::horzScrollBarChanged(int value) { void WidgetPlot2D::horzScrollBarChanged(int value) {
// 若全程显示,则不移动绘图坐标 // 若全程显示,则不移动绘图坐标
if (ui->fullShowCheck->isChecked()) return; 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->xAxis->setRange(value, timeAxis, Qt::AlignRight);
ui->customPlot->replot(); ui->customPlot->replot();
} }

3
mainwindow.cpp

@ -290,7 +290,8 @@ void MainWindow::constructUI() {
int32_t *frame = (int32_t *)heartrate_report->data; int32_t *frame = (int32_t *)heartrate_report->data;
for (int i = 0; i < 50; i++) { for (int i = 0; i < 50; i++) {
int32_t data = frame[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); }));
} }
} }
} }

Loading…
Cancel
Save