From 539031d5b2469a611618f41148b3dd8dc87d2494 Mon Sep 17 00:00:00 2001 From: Leopixelo Date: Wed, 25 Jun 2025 14:24:14 +0200 Subject: [PATCH] do not rescale y axis of graphing window when changing graph parameters --- re/graphingwindow.cpp | 10 ++++++---- re/graphingwindow.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/re/graphingwindow.cpp b/re/graphingwindow.cpp index 5934414..647047c 100644 --- a/re/graphingwindow.cpp +++ b/re/graphingwindow.cpp @@ -1225,7 +1225,7 @@ void GraphingWindow::showParamsDialog(int idx = -1) //create a new graph with the returned parameters. GraphParams params; thisDialog->getParams(params); - createGraph(params); + createGraph(params, true, false); } delete thisDialog; } @@ -1322,7 +1322,7 @@ void GraphingWindow::appendToGraph(GraphParams ¶ms, CANFrame &frame, QVector } } -void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam) +void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam, bool recalcY) { int64_t tempVal; //64 bit temp value. double yminval=10000000.0, ymaxval = -1000000.0; @@ -1561,8 +1561,10 @@ void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam) ui->graphingView->xAxis->setRange(xminval, xmaxval); ui->graphingView->axisRect()->setupFullAxesBox(); } - //always recalculate Y range so that new graphs actually show up in view - ui->graphingView->yAxis->setRange(yminval, ymaxval); + //almost always recalculate Y range so that new graphs actually show up in view + if (recalcY) { + ui->graphingView->yAxis->setRange(yminval, ymaxval); + } ui->graphingView->replot(); } diff --git a/re/graphingwindow.h b/re/graphingwindow.h index 0735153..d82584a 100644 --- a/re/graphingwindow.h +++ b/re/graphingwindow.h @@ -56,7 +56,7 @@ public: void showEvent(QShowEvent*); public slots: - void createGraph(GraphParams ¶ms, bool createGraphParam = true); + void createGraph(GraphParams ¶ms, bool createGraphParam = true, bool recalcY = true); private slots: void titleDoubleClick(QMouseEvent *event, QCPTextElement *title);