Skip to content

Commit 28d0665

Browse files
committed
Change ld-analyse graph update logic so when dialogues are closed no processing is done and, when open, update is timer based (not every frame). Optimizes frame updates.
1 parent 6bdeb47 commit 28d0665

8 files changed

+204
-12
lines changed

tools/ld-analyse/blacksnranalysisdialog.cpp

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "ui_blacksnranalysisdialog.h"
1313

1414
#include <QPen>
15+
#include <QTimer>
1516
#include <algorithm>
1617
#include <algorithm>
1718

@@ -46,6 +47,14 @@ BlackSnrAnalysisDialog::BlackSnrAnalysisDialog(QWidget *parent) :
4647
// Set the default number of frames
4748
numberOfFrames = 0;
4849

50+
// Set up update throttling timer
51+
updateTimer = new QTimer(this);
52+
updateTimer->setSingleShot(true);
53+
updateTimer->setInterval(16); // ~60fps max update rate
54+
connect(updateTimer, &QTimer::timeout, this, &BlackSnrAnalysisDialog::onUpdateTimerTimeout);
55+
hasPendingUpdate = false;
56+
pendingFrameNumber = 0;
57+
4958
// Connect to plot area changed signal
5059
connect(plot, &PlotWidget::plotAreaChanged, this, &BlackSnrAnalysisDialog::onPlotAreaChanged);
5160
}
@@ -120,11 +129,40 @@ void BlackSnrAnalysisDialog::finishUpdate(qint32 _currentFrameNumber)
120129
plot->replot();
121130
}
122131

123-
// Method to update the frame marker
132+
// Method to update the frame marker (throttled for performance)
124133
void BlackSnrAnalysisDialog::updateFrameMarker(qint32 _currentFrameNumber)
125134
{
126-
plotMarker->setPosition(QPointF(static_cast<double>(_currentFrameNumber), (maxY + 20) / 2));
127-
plot->replot();
135+
// Always store the pending frame number
136+
pendingFrameNumber = _currentFrameNumber;
137+
hasPendingUpdate = true;
138+
139+
// Skip timer start if dialog is not visible - update will happen on show
140+
if (!isVisible()) return;
141+
142+
// Start or restart the timer
143+
if (!updateTimer->isActive()) {
144+
updateTimer->start();
145+
}
146+
}
147+
148+
void BlackSnrAnalysisDialog::onUpdateTimerTimeout()
149+
{
150+
if (!hasPendingUpdate) return;
151+
152+
plotMarker->setPosition(QPointF(static_cast<double>(pendingFrameNumber), (maxY + 20) / 2));
153+
// No need to call plot->replot() - marker update() handles the redraw
154+
155+
hasPendingUpdate = false;
156+
}
157+
158+
void BlackSnrAnalysisDialog::showEvent(QShowEvent *event)
159+
{
160+
QDialog::showEvent(event);
161+
162+
// Force immediate marker update if we have a pending position
163+
if (hasPendingUpdate) {
164+
onUpdateTimerTimeout();
165+
}
128166
}
129167

130168
void BlackSnrAnalysisDialog::onPlotAreaChanged()

tools/ld-analyse/blacksnranalysisdialog.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <cmath>
1515

1616
#include <QDialog>
17+
#include <QTimer>
18+
#include <QShowEvent>
1719
#include "plotwidget.h"
1820
#include "lddecodemetadata.h"
1921

@@ -34,8 +36,12 @@ class BlackSnrAnalysisDialog : public QDialog
3436
void finishUpdate(qint32 _currentFrameNumber);
3537
void updateFrameMarker(qint32 _currentFrameNumber);
3638

39+
protected:
40+
void showEvent(QShowEvent *event) override;
41+
3742
private slots:
3843
void onPlotAreaChanged();
44+
void onUpdateTimerTimeout();
3945

4046
private:
4147
void removeChartContents();
@@ -51,6 +57,10 @@ private slots:
5157
qint32 numberOfFrames;
5258
QVector<QPointF> blackPoints;
5359
QVector<QPointF> trendPoints;
60+
61+
QTimer *updateTimer;
62+
qint32 pendingFrameNumber;
63+
bool hasPendingUpdate;
5464
QVector<double> tlPoint;
5565
};
5666

tools/ld-analyse/dropoutanalysisdialog.cpp

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include <QPen>
1515
#include <QDebug>
16+
#include <QTimer>
1617
#include <cmath>
1718

1819
DropoutAnalysisDialog::DropoutAnalysisDialog(QWidget *parent) :
@@ -42,6 +43,14 @@ DropoutAnalysisDialog::DropoutAnalysisDialog(QWidget *parent) :
4243
// Set the default number of frames
4344
numberOfFrames = 0;
4445

46+
// Set up update throttling timer
47+
updateTimer = new QTimer(this);
48+
updateTimer->setSingleShot(true);
49+
updateTimer->setInterval(16); // ~60fps max update rate
50+
connect(updateTimer, &QTimer::timeout, this, &DropoutAnalysisDialog::onUpdateTimerTimeout);
51+
hasPendingUpdate = false;
52+
pendingFrameNumber = 0;
53+
4554
// Connect to plot area changed signal
4655
connect(plot, &PlotWidget::plotAreaChanged, this, &DropoutAnalysisDialog::onPlotAreaChanged);
4756
}
@@ -109,12 +118,41 @@ void DropoutAnalysisDialog::finishUpdate(qint32 _currentFrameNumber)
109118
plot->replot();
110119
}
111120

112-
// Method to update the frame marker
121+
// Method to update the frame marker (throttled for performance)
113122
void DropoutAnalysisDialog::updateFrameMarker(qint32 _currentFrameNumber)
114123
{
124+
// Always store the pending frame number
125+
pendingFrameNumber = _currentFrameNumber;
126+
hasPendingUpdate = true;
127+
128+
// Skip timer start if dialog is not visible - update will happen on show
129+
if (!isVisible()) return;
130+
131+
// Start or restart the timer
132+
if (!updateTimer->isActive()) {
133+
updateTimer->start();
134+
}
135+
}
136+
137+
void DropoutAnalysisDialog::onUpdateTimerTimeout()
138+
{
139+
if (!hasPendingUpdate) return;
140+
115141
double yMax = (maxY < 10) ? 10 : ceil(maxY + (maxY * 0.1));
116-
plotMarker->setPosition(QPointF(static_cast<double>(_currentFrameNumber), yMax / 2));
117-
plot->replot();
142+
plotMarker->setPosition(QPointF(static_cast<double>(pendingFrameNumber), yMax / 2));
143+
// No need to call plot->replot() - marker update() handles the redraw
144+
145+
hasPendingUpdate = false;
146+
}
147+
148+
void DropoutAnalysisDialog::showEvent(QShowEvent *event)
149+
{
150+
QDialog::showEvent(event);
151+
152+
// Force immediate marker update if we have a pending position
153+
if (hasPendingUpdate) {
154+
onUpdateTimerTimeout();
155+
}
118156
}
119157

120158
void DropoutAnalysisDialog::onPlotAreaChanged()

tools/ld-analyse/dropoutanalysisdialog.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#define DROPOUTANALYSISDIALOG_H
1313

1414
#include <QDialog>
15+
#include <QTimer>
16+
#include <QShowEvent>
1517
#include "plotwidget.h"
1618
#include "lddecodemetadata.h"
1719

@@ -32,8 +34,12 @@ class DropoutAnalysisDialog : public QDialog
3234
void finishUpdate(qint32 _currentFrameNumber);
3335
void updateFrameMarker(qint32 _currentFrameNumber);
3436

37+
protected:
38+
void showEvent(QShowEvent *event) override;
39+
3540
private slots:
3641
void onPlotAreaChanged();
42+
void onUpdateTimerTimeout();
3743

3844
private:
3945
void removeChartContents();
@@ -46,6 +52,10 @@ private slots:
4652
double maxY;
4753
qint32 numberOfFrames;
4854
QVector<QPointF> points;
55+
56+
QTimer *updateTimer;
57+
qint32 pendingFrameNumber;
58+
bool hasPendingUpdate;
4959
};
5060

5161
#endif // DROPOUTANALYSISDIALOG_H

tools/ld-analyse/visibledropoutanalysisdialog.cpp

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include <QPen>
1515
#include <QDebug>
16+
#include <QTimer>
1617
#include <cmath>
1718

1819
VisibleDropOutAnalysisDialog::VisibleDropOutAnalysisDialog(QWidget *parent) :
@@ -42,6 +43,14 @@ VisibleDropOutAnalysisDialog::VisibleDropOutAnalysisDialog(QWidget *parent) :
4243
// Set the default number of frames
4344
numberOfFrames = 0;
4445

46+
// Set up update throttling timer
47+
updateTimer = new QTimer(this);
48+
updateTimer->setSingleShot(true);
49+
updateTimer->setInterval(16); // ~60fps max update rate
50+
connect(updateTimer, &QTimer::timeout, this, &VisibleDropOutAnalysisDialog::onUpdateTimerTimeout);
51+
hasPendingUpdate = false;
52+
pendingFrameNumber = 0;
53+
4554
// Connect to plot area changed signal
4655
connect(plot, &PlotWidget::plotAreaChanged, this, &VisibleDropOutAnalysisDialog::onPlotAreaChanged);
4756
}
@@ -109,12 +118,41 @@ void VisibleDropOutAnalysisDialog::finishUpdate(qint32 _currentFrameNumber)
109118
plot->replot();
110119
}
111120

112-
// Method to update the frame marker
121+
// Method to update the frame marker (throttled for performance)
113122
void VisibleDropOutAnalysisDialog::updateFrameMarker(qint32 _currentFrameNumber)
114123
{
124+
// Always store the pending frame number
125+
pendingFrameNumber = _currentFrameNumber;
126+
hasPendingUpdate = true;
127+
128+
// Skip timer start if dialog is not visible - update will happen on show
129+
if (!isVisible()) return;
130+
131+
// Start or restart the timer
132+
if (!updateTimer->isActive()) {
133+
updateTimer->start();
134+
}
135+
}
136+
137+
void VisibleDropOutAnalysisDialog::onUpdateTimerTimeout()
138+
{
139+
if (!hasPendingUpdate) return;
140+
115141
double yMax = (maxY < 10) ? 10 : ceil(maxY + (maxY * 0.1));
116-
plotMarker->setPosition(QPointF(static_cast<double>(_currentFrameNumber), yMax / 2));
117-
plot->replot();
142+
plotMarker->setPosition(QPointF(static_cast<double>(pendingFrameNumber), yMax / 2));
143+
// No need to call plot->replot() - marker update() handles the redraw
144+
145+
hasPendingUpdate = false;
146+
}
147+
148+
void VisibleDropOutAnalysisDialog::showEvent(QShowEvent *event)
149+
{
150+
QDialog::showEvent(event);
151+
152+
// Force immediate marker update if we have a pending position
153+
if (hasPendingUpdate) {
154+
onUpdateTimerTimeout();
155+
}
118156
}
119157

120158
void VisibleDropOutAnalysisDialog::onPlotAreaChanged()

tools/ld-analyse/visibledropoutanalysisdialog.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#define VISIBLEDROPOUTANALYSISDIALOG_H
1313

1414
#include <QDialog>
15+
#include <QTimer>
16+
#include <QShowEvent>
1517
#include "plotwidget.h"
1618

1719
namespace Ui {
@@ -31,8 +33,12 @@ class VisibleDropOutAnalysisDialog : public QDialog
3133
void finishUpdate(qint32 _currentFrameNumber);
3234
void updateFrameMarker(qint32 _currentFrameNumber);
3335

36+
protected:
37+
void showEvent(QShowEvent *event) override;
38+
3439
private slots:
3540
void onPlotAreaChanged();
41+
void onUpdateTimerTimeout();
3642

3743
private:
3844
void removeChartContents();
@@ -45,6 +51,10 @@ private slots:
4551
double maxY;
4652
qint32 numberOfFrames;
4753
QVector<QPointF> points;
54+
55+
QTimer *updateTimer;
56+
qint32 pendingFrameNumber;
57+
bool hasPendingUpdate;
4858
};
4959

5060
#endif // VISIBLEDROPOUTANALYSISDIALOG_H

tools/ld-analyse/whitesnranalysisdialog.cpp

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "whitesnranalysisdialog.h"
1212
#include "ui_whitesnranalysisdialog.h"
1313

14+
#include <QTimer>
1415
#include <algorithm>
1516

1617
WhiteSnrAnalysisDialog::WhiteSnrAnalysisDialog(QWidget *parent) :
@@ -42,6 +43,14 @@ WhiteSnrAnalysisDialog::WhiteSnrAnalysisDialog(QWidget *parent) :
4243
// Set the default number of frames
4344
numberOfFrames = 0;
4445

46+
// Set up update throttling timer
47+
updateTimer = new QTimer(this);
48+
updateTimer->setSingleShot(true);
49+
updateTimer->setInterval(16); // ~60fps max update rate
50+
connect(updateTimer, &QTimer::timeout, this, &WhiteSnrAnalysisDialog::onUpdateTimerTimeout);
51+
hasPendingUpdate = false;
52+
pendingFrameNumber = 0;
53+
4554
// Connect to plot area changed signal
4655
connect(plot, &PlotWidget::plotAreaChanged, this, &WhiteSnrAnalysisDialog::onPlotAreaChanged);
4756
}
@@ -118,11 +127,40 @@ void WhiteSnrAnalysisDialog::finishUpdate(qint32 _currentFrameNumber)
118127
plot->replot();
119128
}
120129

121-
// Method to update the frame marker
130+
// Method to update the frame marker (throttled for performance)
122131
void WhiteSnrAnalysisDialog::updateFrameMarker(qint32 _currentFrameNumber)
123132
{
124-
plotMarker->setPosition(QPointF(static_cast<double>(_currentFrameNumber), (maxY + 14) / 2));
125-
plot->replot();
133+
// Always store the pending frame number
134+
pendingFrameNumber = _currentFrameNumber;
135+
hasPendingUpdate = true;
136+
137+
// Skip timer start if dialog is not visible - update will happen on show
138+
if (!isVisible()) return;
139+
140+
// Start or restart the timer
141+
if (!updateTimer->isActive()) {
142+
updateTimer->start();
143+
}
144+
}
145+
146+
void WhiteSnrAnalysisDialog::onUpdateTimerTimeout()
147+
{
148+
if (!hasPendingUpdate) return;
149+
150+
plotMarker->setPosition(QPointF(static_cast<double>(pendingFrameNumber), (maxY + 14) / 2));
151+
// No need to call plot->replot() - marker update() handles the redraw
152+
153+
hasPendingUpdate = false;
154+
}
155+
156+
void WhiteSnrAnalysisDialog::showEvent(QShowEvent *event)
157+
{
158+
QDialog::showEvent(event);
159+
160+
// Force immediate marker update if we have a pending position
161+
if (hasPendingUpdate) {
162+
onUpdateTimerTimeout();
163+
}
126164
}
127165

128166
void WhiteSnrAnalysisDialog::onPlotAreaChanged()

0 commit comments

Comments
 (0)