From a0cacdfbefc96e2fa017d76882377e7758eff655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=A4berich?= Date: Thu, 3 Nov 2022 20:08:14 +0100 Subject: [PATCH] fix marker grab position --- Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp index 1477dea..a42f9a5 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp @@ -138,7 +138,8 @@ std::vector TracePlot::orderedTraces() void TracePlot::contextMenuEvent(QContextMenuEvent *event) { - auto m = markerAtPosition(event->pos()); + auto position = event->pos() - QPoint(marginLeft, marginTop); + auto m = markerAtPosition(position); QMenu *menu; if(m) { // right click on marker, execute its contextmenu @@ -422,7 +423,6 @@ void TracePlot::wheelEvent(QWheelEvent *event) Marker *TracePlot::markerAtPosition(QPoint p, bool onlyMovable) { - auto clickPoint = p - QPoint(marginLeft, marginTop); // check if click was near a marker unsigned int closestDistance = numeric_limits::max(); Marker *closestMarker = nullptr; @@ -441,7 +441,7 @@ Marker *TracePlot::markerAtPosition(QPoint p, bool onlyMovable) // invalid, skip continue; } - auto diff = markerPoint - clickPoint; + auto diff = markerPoint - p; unsigned int distance = diff.x() * diff.x() + diff.y() * diff.y(); if(distance < closestDistance) { closestDistance = distance;