From 4eef1f1bff3c1494eb9a9ddd96beea135ea140d1 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Mon, 5 Oct 2020 10:07:16 +0200 Subject: [PATCH] Trim: GraphPixelsPerPoint mush remain a power of zoom_offset --- client/src/proxguiqt.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/client/src/proxguiqt.cpp b/client/src/proxguiqt.cpp index 0e791d77a..15b96a16a 100644 --- a/client/src/proxguiqt.cpp +++ b/client/src/proxguiqt.cpp @@ -689,13 +689,19 @@ void Plot::Move(int offset) { void Plot::Trim(void) { uint32_t lref, rref; + const double zoom_offset = 1.148698354997035; // 2**(1/5) if ((CursorAPos == 0) || (CursorBPos == 0)) { // if we don't have both cursors set lref = GraphStart; rref = GraphStop; } else { lref = CursorAPos < CursorBPos ? CursorAPos : CursorBPos; rref = CursorAPos < CursorBPos ? CursorBPos : CursorAPos; - GraphPixelsPerPoint = GraphPixelsPerPoint * (GraphStop - GraphStart) / (rref - lref); + // GraphPixelsPerPoint mush remain a power of zoom_offset + double GPPPtarget = GraphPixelsPerPoint * (GraphStop - GraphStart) / (rref - lref); + while (GraphPixelsPerPoint < GPPPtarget) { + GraphPixelsPerPoint *= zoom_offset; + } + GraphPixelsPerPoint /= zoom_offset; CursorAPos -= lref; CursorBPos -= lref; }