From 6e3eff356b427d2d2b13f1515516266892292d3d Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sun, 1 Aug 2021 19:52:45 +0200 Subject: [PATCH] fix demod plot on first sample, remove spurious vertical line --- client/src/proxguiqt.cpp | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/client/src/proxguiqt.cpp b/client/src/proxguiqt.cpp index 074e3b848..f45360c6e 100644 --- a/client/src/proxguiqt.cpp +++ b/client/src/proxguiqt.cpp @@ -443,9 +443,6 @@ void ProxWidget::resizeEvent(QResizeEvent *event) { //----------- Plotting int Plot::xCoordOf(int i, QRect r) { - if (i < 0) { - i = 0; - } return r.left() + (int)((i - GraphStart) * GraphPixelsPerPoint); } @@ -536,25 +533,19 @@ void Plot::PlotDemod(uint8_t *buffer, size_t len, QRect plotRect, QRect annotati painter->setPen(getColor(graphNum)); char str[5]; int absVMax = (int)(100 * 1.05 + 1); - int x = xCoordOf(DemodStart, plotRect); - int y = 0; - if (DemodStart >= 0) { - y = yCoordOf((buffer[BitStart] * 200 - 100) * -1, plotRect, absVMax); - } else { - y = yCoordOf(0, plotRect, absVMax); - } - penPath.moveTo(x, y); delta_x = 0; int clk = first_delta_x; for (int i = BitStart; i < (int)len && xCoordOf(delta_x + DemodStart, plotRect) < plotRect.right(); i++) { for (int j = 0; j < (clk) && i < (int)len && xCoordOf(DemodStart + delta_x + j, plotRect) < plotRect.right() ; j++) { - x = xCoordOf(DemodStart + delta_x + j, plotRect); + int x = xCoordOf(DemodStart + delta_x + j, plotRect); int v = buffer[i] * 200 - 100; - y = yCoordOf(v, plotRect, absVMax); - - penPath.lineTo(x, y); - + int y = yCoordOf(v, plotRect, absVMax); + if ((i == BitStart) && (j == 0)) { // First point + penPath.moveTo(x, y); + } else { + penPath.lineTo(x, y); + } if (GraphPixelsPerPoint > 10) { QRect f(QPoint(x - 3, y - 3), QPoint(x + 3, y + 3)); painter->fillRect(f, getColor(graphNum));