Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 49 additions & 11 deletions tools/ld-analyse/blacksnranalysisdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "ui_blacksnranalysisdialog.h"

#include <QPen>
#include <QTimer>
#include <algorithm>
#include <algorithm>

Expand All @@ -27,14 +28,14 @@ BlackSnrAnalysisDialog::BlackSnrAnalysisDialog(QWidget *parent) :
plot->updateTheme();
ui->verticalLayout->addWidget(plot);

// Set up curves and marker
blackCurve = plot->addCurve("Black SNR");
// Set up series and marker
blackSeries = plot->addSeries("Black SNR");
// Theme-aware color: white in dark mode, black in light mode
QColor dataColor = PlotWidget::isDarkTheme() ? Qt::white : Qt::black;
blackCurve->setPen(QPen(dataColor, 2));
blackSeries->setPen(QPen(dataColor, 2));

trendCurve = plot->addCurve("Trend line");
trendCurve->setPen(QPen(Qt::red, 2));
trendSeries = plot->addSeries("Trend line");
trendSeries->setPen(QPen(Qt::red, 2));

plotMarker = plot->addMarker();
plotMarker->setStyle(PlotMarker::VLine);
Expand All @@ -46,6 +47,14 @@ BlackSnrAnalysisDialog::BlackSnrAnalysisDialog(QWidget *parent) :
// Set the default number of frames
numberOfFrames = 0;

// Set up update throttling timer
updateTimer = new QTimer(this);
updateTimer->setSingleShot(true);
updateTimer->setInterval(16); // ~60fps max update rate
connect(updateTimer, &QTimer::timeout, this, &BlackSnrAnalysisDialog::onUpdateTimerTimeout);
hasPendingUpdate = false;
pendingFrameNumber = 0;

// Connect to plot area changed signal
connect(plot, &PlotWidget::plotAreaChanged, this, &BlackSnrAnalysisDialog::onPlotAreaChanged);
}
Expand Down Expand Up @@ -106,12 +115,12 @@ void BlackSnrAnalysisDialog::finishUpdate(qint32 _currentFrameNumber)
plot->setAxisRange(Qt::Horizontal, 0, numberOfFrames);
plot->setAxisRange(Qt::Vertical, 20, maxY);

// Set the black curve data
blackCurve->setData(blackPoints);
// Set the black series data
blackSeries->setData(blackPoints);

// Generate and set the trend line
generateTrendLine();
trendCurve->setData(trendPoints);
trendSeries->setData(trendPoints);

// Set the frame marker position
plotMarker->setPosition(QPointF(static_cast<double>(_currentFrameNumber), (maxY + 20) / 2));
Expand All @@ -120,11 +129,40 @@ void BlackSnrAnalysisDialog::finishUpdate(qint32 _currentFrameNumber)
plot->replot();
}

// Method to update the frame marker
// Method to update the frame marker (throttled for performance)
void BlackSnrAnalysisDialog::updateFrameMarker(qint32 _currentFrameNumber)
{
plotMarker->setPosition(QPointF(static_cast<double>(_currentFrameNumber), (maxY + 20) / 2));
plot->replot();
// Always store the pending frame number
pendingFrameNumber = _currentFrameNumber;
hasPendingUpdate = true;

// Skip timer start if dialog is not visible - update will happen on show
if (!isVisible()) return;

// Start or restart the timer
if (!updateTimer->isActive()) {
updateTimer->start();
}
}

void BlackSnrAnalysisDialog::onUpdateTimerTimeout()
{
if (!hasPendingUpdate) return;

plotMarker->setPosition(QPointF(static_cast<double>(pendingFrameNumber), (maxY + 20) / 2));
// No need to call plot->replot() - marker update() handles the redraw

hasPendingUpdate = false;
}

void BlackSnrAnalysisDialog::showEvent(QShowEvent *event)
{
QDialog::showEvent(event);

// Force immediate marker update if we have a pending position
if (hasPendingUpdate) {
onUpdateTimerTimeout();
}
}

void BlackSnrAnalysisDialog::onPlotAreaChanged()
Expand Down
14 changes: 12 additions & 2 deletions tools/ld-analyse/blacksnranalysisdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <cmath>

#include <QDialog>
#include <QTimer>
#include <QShowEvent>
#include "plotwidget.h"
#include "lddecodemetadata.h"

Expand All @@ -34,23 +36,31 @@ class BlackSnrAnalysisDialog : public QDialog
void finishUpdate(qint32 _currentFrameNumber);
void updateFrameMarker(qint32 _currentFrameNumber);

protected:
void showEvent(QShowEvent *event) override;

private slots:
void onPlotAreaChanged();
void onUpdateTimerTimeout();

private:
void removeChartContents();
void generateTrendLine();

Ui::BlackSnrAnalysisDialog *ui;
PlotWidget *plot;
PlotCurve *blackCurve;
PlotCurve *trendCurve;
PlotSeries *blackSeries;
PlotSeries *trendSeries;
PlotMarker *plotMarker;

double maxY;
qint32 numberOfFrames;
QVector<QPointF> blackPoints;
QVector<QPointF> trendPoints;

QTimer *updateTimer;
qint32 pendingFrameNumber;
bool hasPendingUpdate;
QVector<double> tlPoint;
};

Expand Down
55 changes: 47 additions & 8 deletions tools/ld-analyse/dropoutanalysisdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include <QPen>
#include <QDebug>
#include <QTimer>
#include <cmath>

DropoutAnalysisDialog::DropoutAnalysisDialog(QWidget *parent) :
Expand All @@ -27,9 +28,10 @@ DropoutAnalysisDialog::DropoutAnalysisDialog(QWidget *parent) :
plot->updateTheme();
ui->verticalLayout->addWidget(plot);

// Set up curve and marker
curve = plot->addCurve("Dropout Length");
curve->setPen(QPen(Qt::red, 1));
// Set up series and marker
series = plot->addSeries("Dropout Length");
series->setPen(QPen(Qt::red, 1));
series->setStyle(PlotSeries::Bars);

plotMarker = plot->addMarker();
plotMarker->setStyle(PlotMarker::VLine);
Expand All @@ -41,6 +43,14 @@ DropoutAnalysisDialog::DropoutAnalysisDialog(QWidget *parent) :
// Set the default number of frames
numberOfFrames = 0;

// Set up update throttling timer
updateTimer = new QTimer(this);
updateTimer->setSingleShot(true);
updateTimer->setInterval(16); // ~60fps max update rate
connect(updateTimer, &QTimer::timeout, this, &DropoutAnalysisDialog::onUpdateTimerTimeout);
hasPendingUpdate = false;
pendingFrameNumber = 0;

// Connect to plot area changed signal
connect(plot, &PlotWidget::plotAreaChanged, this, &DropoutAnalysisDialog::onPlotAreaChanged);
}
Expand Down Expand Up @@ -98,8 +108,8 @@ void DropoutAnalysisDialog::finishUpdate(qint32 _currentFrameNumber)

// Set the dropout curve data with theme-aware color
QColor dataColor = PlotWidget::isDarkTheme() ? Qt::yellow : Qt::darkMagenta;
curve->setPen(QPen(dataColor, 2));
curve->setData(points);
series->setPen(QPen(dataColor, 2));
series->setData(points);

// Set the frame marker position
plotMarker->setPosition(QPointF(static_cast<double>(_currentFrameNumber), yMax / 2));
Expand All @@ -108,12 +118,41 @@ void DropoutAnalysisDialog::finishUpdate(qint32 _currentFrameNumber)
plot->replot();
}

// Method to update the frame marker
// Method to update the frame marker (throttled for performance)
void DropoutAnalysisDialog::updateFrameMarker(qint32 _currentFrameNumber)
{
// Always store the pending frame number
pendingFrameNumber = _currentFrameNumber;
hasPendingUpdate = true;

// Skip timer start if dialog is not visible - update will happen on show
if (!isVisible()) return;

// Start or restart the timer
if (!updateTimer->isActive()) {
updateTimer->start();
}
}

void DropoutAnalysisDialog::onUpdateTimerTimeout()
{
if (!hasPendingUpdate) return;

double yMax = (maxY < 10) ? 10 : ceil(maxY + (maxY * 0.1));
plotMarker->setPosition(QPointF(static_cast<double>(_currentFrameNumber), yMax / 2));
plot->replot();
plotMarker->setPosition(QPointF(static_cast<double>(pendingFrameNumber), yMax / 2));
// No need to call plot->replot() - marker update() handles the redraw

hasPendingUpdate = false;
}

void DropoutAnalysisDialog::showEvent(QShowEvent *event)
{
QDialog::showEvent(event);

// Force immediate marker update if we have a pending position
if (hasPendingUpdate) {
onUpdateTimerTimeout();
}
}

void DropoutAnalysisDialog::onPlotAreaChanged()
Expand Down
12 changes: 11 additions & 1 deletion tools/ld-analyse/dropoutanalysisdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#define DROPOUTANALYSISDIALOG_H

#include <QDialog>
#include <QTimer>
#include <QShowEvent>
#include "plotwidget.h"
#include "lddecodemetadata.h"

Expand All @@ -32,20 +34,28 @@ class DropoutAnalysisDialog : public QDialog
void finishUpdate(qint32 _currentFrameNumber);
void updateFrameMarker(qint32 _currentFrameNumber);

protected:
void showEvent(QShowEvent *event) override;

private slots:
void onPlotAreaChanged();
void onUpdateTimerTimeout();

private:
void removeChartContents();

Ui::DropoutAnalysisDialog *ui;
PlotWidget *plot;
PlotCurve *curve;
PlotSeries *series;
PlotMarker *plotMarker;

double maxY;
qint32 numberOfFrames;
QVector<QPointF> points;

QTimer *updateTimer;
qint32 pendingFrameNumber;
bool hasPendingUpdate;
};

#endif // DROPOUTANALYSISDIALOG_H
Loading