From a2b8f2a00d2cca0ec60de1a2091baf5a0dea5524 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=A4berich?= Date: Wed, 15 Feb 2023 20:30:37 +0100 Subject: [PATCH] Fix trace point calculation on distance X axis --- .../PC_Application/LibreVNA-GUI/Traces/tracexyplot.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/tracexyplot.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/tracexyplot.cpp index 5190e88..1f7ff56 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/tracexyplot.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/tracexyplot.cpp @@ -1090,6 +1090,9 @@ double TraceXYPlot::nearestTracePoint(Trace *t, QPoint pixel, double *distance) closestIndex = i; } } + if(xAxis.getType() == XAxis::Type::Distance) { + closestXpos = t->distanceToTime(closestXpos); + } closestDistance = sqrt(closestDistance); if(closestIndex > 0) { auto l1 = plotValueToPixel(traceToCoordinate(t, closestIndex - 1, yAxis[0]), 0); @@ -1111,12 +1114,10 @@ double TraceXYPlot::nearestTracePoint(Trace *t, QPoint pixel, double *distance) closestXpos = t->sample(closestIndex).x + (t->sample(closestIndex+1).x - t->sample(closestIndex).x) * ratio; } } - if(xAxis.getType() == XAxis::Type::Distance) { - closestXpos = t->distanceToTime(closestXpos); - } if(distance) { *distance = closestDistance; } + qDebug() << "Xpos: "<