|
@ -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(); |
|
|
} |
|
|
} |