Skip to content

Commit 8a682a2

Browse files
committed
[RTData] Only replot when graphs are visible
1 parent 09ff644 commit 8a682a2

File tree

8 files changed

+117
-51
lines changed

8 files changed

+117
-51
lines changed

pages/pageappadc.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,12 @@ void PageAppAdc::paramChangedDouble(QObject *src, QString name, double newParam)
9898
y.append(val);
9999
}
100100
ui->throttlePlot->graph()->setData(x, y);
101-
ui->throttlePlot->rescaleAxes();
102-
ui->throttlePlot->replot();
101+
102+
// Only rescale/replot if visible
103+
if (ui->throttlePlot->isVisible()) {
104+
ui->throttlePlot->rescaleAxes();
105+
ui->throttlePlot->replot();
106+
}
103107
}
104108
}
105109

pages/pageappbalance.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,11 @@ void PageAppBalance::timerSlot()
165165
}
166166
ui->balancePlot->graph(graphIndex++)->setData(xAxis, mAppDebug2);
167167

168-
ui->balancePlot->rescaleAxes();
169-
170-
ui->balancePlot->replot();
168+
// Only rescale/replot if visible
169+
if (ui->balancePlot->isVisible()) {
170+
ui->balancePlot->rescaleAxes();
171+
ui->balancePlot->replot();
172+
}
171173

172174
updateTextOutput();
173175
}

pages/pageappimu.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,19 @@ void PageAppImu::timerSlot()
186186
ui->gyroPlot->graph(graphIndex++)->setData(xAxis, mGyroYVec);
187187
ui->gyroPlot->graph(graphIndex++)->setData(xAxis, mGyroZVec);
188188

189-
ui->rpyPlot->rescaleAxes();
190-
ui->accelPlot->rescaleAxes();
191-
ui->gyroPlot->rescaleAxes();
192-
193-
ui->rpyPlot->replot();
194-
ui->accelPlot->replot();
195-
ui->gyroPlot->replot();
189+
// Only rescale/replot if visible
190+
if (ui->accelPlot->isVisible()) {
191+
ui->accelPlot->rescaleAxes();
192+
ui->accelPlot->replot();
193+
}
194+
if (ui->gyroPlot->isVisible()) {
195+
ui->gyroPlot->rescaleAxes();
196+
ui->gyroPlot->replot();
197+
}
198+
if (ui->rpyPlot->isVisible()) {
199+
ui->rpyPlot->rescaleAxes();
200+
ui->rpyPlot->replot();
201+
}
196202
}
197203
}
198204

pages/pageappnunchuk.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,12 @@ void PageAppNunchuk::paramChangedDouble(QObject *src, QString name, double newPa
107107
y.append(val);
108108
}
109109
ui->throttlePlot->graph()->setData(x, y);
110-
ui->throttlePlot->rescaleAxes();
111-
ui->throttlePlot->replot();
110+
111+
// Only rescale/replot if visible
112+
if (ui->throttlePlot->isVisible()) {
113+
ui->throttlePlot->rescaleAxes();
114+
ui->throttlePlot->replot();
115+
}
112116
}
113117
}
114118

pages/pageappppm.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,14 @@ void PageAppPpm::paramChangedDouble(QObject *src, QString name, double newParam)
9797
double val = Utility::throttle_curve(i, val_acc, val_brake, mode);
9898
y.append(val);
9999
}
100+
100101
ui->throttlePlot->graph()->setData(x, y);
101-
ui->throttlePlot->rescaleAxes();
102-
ui->throttlePlot->replot();
102+
103+
// Only rescale/replot if visible
104+
if (ui->throttlePlot->isVisible()) {
105+
ui->throttlePlot->rescaleAxes();
106+
ui->throttlePlot->replot();
107+
}
103108
}
104109
}
105110

pages/pageexperiments.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -593,11 +593,14 @@ void PageExperiments::plotSamples(bool exportFormat)
593593
graphIndex++;
594594
}
595595

596-
if (ui->autoscaleButton->isChecked()) {
597-
ui->plot->rescaleAxes();
598-
}
596+
// Only rescale/replot if visible
597+
if (ui->plot->isVisible()) {
598+
if (ui->autoscaleButton->isChecked()) {
599+
ui->plot->rescaleAxes();
600+
}
599601

600-
ui->plot->replot();
602+
ui->plot->replot();
603+
}
601604
}
602605

603606
void PageExperiments::victronGetCurrent()

pages/pageimu.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -201,15 +201,23 @@ void PageImu::timerSlot()
201201
ui->magPlot->graph(graphIndex++)->setData(xAxis, mMagYVec);
202202
ui->magPlot->graph(graphIndex++)->setData(xAxis, mMagZVec);
203203

204-
ui->rpyPlot->rescaleAxes();
205-
ui->accelPlot->rescaleAxes();
206-
ui->gyroPlot->rescaleAxes();
207-
ui->magPlot->rescaleAxes();
208-
209-
ui->rpyPlot->replot();
210-
ui->accelPlot->replot();
211-
ui->gyroPlot->replot();
212-
ui->magPlot->replot();
204+
// Only rescale/replot if visible
205+
if (ui->rpyPlot->isVisible()) {
206+
ui->rpyPlot->rescaleAxes();
207+
ui->rpyPlot->replot();
208+
}
209+
if (ui->accelPlot->isVisible()) {
210+
ui->accelPlot->rescaleAxes();
211+
ui->accelPlot->replot();
212+
}
213+
if (ui->gyroPlot->isVisible()) {
214+
ui->gyroPlot->rescaleAxes();
215+
ui->gyroPlot->replot();
216+
}
217+
if (ui->magPlot->isVisible()) {
218+
ui->magPlot->rescaleAxes();
219+
ui->magPlot->replot();
220+
}
213221
}
214222
}
215223

pages/pagertdata.cpp

Lines changed: 56 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,6 @@ void PageRtData::timerSlot()
318318
ui->tempPlot->graph(graphIndex)->setName("Temperature Motor");
319319
ui->tempPlot->graph(graphIndex)->setData(xAxis, mTempMotorVec);
320320
ui->tempPlot->graph(graphIndex)->setVisible(ui->tempShowMotorBox->isChecked());
321-
graphIndex++;
322321

323322
// RPM plot
324323
graphIndex = 0;
@@ -331,17 +330,36 @@ void PageRtData::timerSlot()
331330
ui->focPlot->graph(graphIndex++)->setData(xAxis, mVdVec);
332331
ui->focPlot->graph(graphIndex++)->setData(xAxis, mVqVec);
333332

333+
// Check if we should rescale the graphs
334334
if (ui->autoscaleButton->isChecked()) {
335-
ui->currentPlot->rescaleAxes();
336-
ui->tempPlot->rescaleAxes();
337-
ui->rpmPlot->rescaleAxes();
338-
ui->focPlot->rescaleAxes();
335+
// Only rescale if visible
336+
if(ui->focPlot->isVisible()) {
337+
ui->focPlot->rescaleAxes();
338+
}
339+
if(ui->tempPlot->isVisible()) {
340+
ui->tempPlot->rescaleAxes();
341+
}
342+
if(ui->rpmPlot->isVisible()) {
343+
ui->rpmPlot->rescaleAxes();
344+
}
345+
if(ui->focPlot->isVisible()) {
346+
ui->focPlot->rescaleAxes();
347+
}
339348
}
340349

341-
ui->currentPlot->replot();
342-
ui->tempPlot->replot();
343-
ui->rpmPlot->replot();
344-
ui->focPlot->replot();
350+
// Only replot if the graph is visible
351+
if(ui->focPlot->isVisible()) {
352+
ui->focPlot->replot();
353+
}
354+
if(ui->currentPlot->isVisible()) {
355+
ui->currentPlot->replot();
356+
}
357+
if(ui->tempPlot->isVisible()) {
358+
ui->tempPlot->replot();
359+
}
360+
if(ui->rpmPlot->isVisible()) {
361+
ui->rpmPlot->replot();
362+
}
345363

346364
mUpdateValPlot = false;
347365
}
@@ -359,7 +377,10 @@ void PageRtData::timerSlot()
359377
ui->posPlot->rescaleAxes();
360378
}
361379

362-
ui->posPlot->replot();
380+
// Only replot if the graph is visible
381+
if (ui->posPlot->isVisible()) {
382+
ui->posPlot->replot();
383+
}
363384

364385
mUpdatePosPlot = false;
365386
}
@@ -399,7 +420,10 @@ void PageRtData::timerSlot()
399420
ui->experimentPlot->rescaleAxes();
400421
}
401422

402-
ui->experimentPlot->replot();
423+
// Only replot if the graph is visible
424+
if (ui->experimentPlot->isVisible()) {
425+
ui->experimentPlot->replot();
426+
}
403427
mExperimentReplot = false;
404428
}
405429
}
@@ -540,17 +564,27 @@ void PageRtData::on_zoomVButton_toggled(bool checked)
540564

541565
void PageRtData::on_rescaleButton_clicked()
542566
{
543-
ui->currentPlot->rescaleAxes();
544-
ui->tempPlot->rescaleAxes();
545-
ui->rpmPlot->rescaleAxes();
546-
ui->focPlot->rescaleAxes();
547-
ui->posPlot->rescaleAxes();
548-
549-
ui->currentPlot->replot();
550-
ui->tempPlot->replot();
551-
ui->rpmPlot->replot();
552-
ui->focPlot->replot();
553-
ui->posPlot->replot();
567+
// Only rescale/replot if the graph is visible
568+
if (ui->posPlot->isVisible()) {
569+
ui->posPlot->rescaleAxes();
570+
ui->posPlot->replot();
571+
}
572+
if (ui->currentPlot->isVisible()) {
573+
ui->currentPlot->rescaleAxes();
574+
ui->currentPlot->replot();
575+
}
576+
if (ui->tempPlot->isVisible()) {
577+
ui->tempPlot->rescaleAxes();
578+
ui->tempPlot->replot();
579+
}
580+
if (ui->rpmPlot->isVisible()) {
581+
ui->rpmPlot->rescaleAxes();
582+
ui->rpmPlot->replot();
583+
}
584+
if (ui->focPlot->isVisible()) {
585+
ui->focPlot->rescaleAxes();
586+
ui->focPlot->replot();
587+
}
554588
}
555589

556590
void PageRtData::on_posInductanceButton_clicked()

0 commit comments

Comments
 (0)