From 26df0173e8aa354f6f255d551d1295de733f16ee Mon Sep 17 00:00:00 2001 From: "Brian T. Rice" Date: Sat, 13 Mar 2021 16:33:54 -0800 Subject: [PATCH] GraphingWindow: add a menu option --- re/graphingwindow.cpp | 11 +++++++++++ re/graphingwindow.h | 1 + 2 files changed, 12 insertions(+) diff --git a/re/graphingwindow.cpp b/re/graphingwindow.cpp index 8056276..97e622b 100644 --- a/re/graphingwindow.cpp +++ b/re/graphingwindow.cpp @@ -586,6 +586,13 @@ void GraphingWindow::removeAllGraphs() } } +void GraphingWindow::rescaleToData() +{ + ui->graphingView->xAxis->rescale(true); + ui->graphingView->yAxis->rescale(true); + ui->graphingView->replot(); +} + void GraphingWindow::toggleFollowMode() { followGraphEnd = !followGraphEnd; @@ -627,6 +634,10 @@ void GraphingWindow::contextMenuRequest(QPoint pos) } menu->addSeparator(); menu->addAction(tr("Reset View"), this, SLOT(resetView())); + if (ui->graphingView->graphCount() > 0) + { + menu->addAction(tr("Rescale to data"), this, SLOT(rescaleToData())); + } menu->addAction(tr("Zoom In"), this, SLOT(zoomIn())); menu->addAction(tr("Zoom Out"), this, SLOT(zoomOut())); } diff --git a/re/graphingwindow.h b/re/graphingwindow.h index 664ad58..1502627 100644 --- a/re/graphingwindow.h +++ b/re/graphingwindow.h @@ -63,6 +63,7 @@ private slots: void saveSpreadsheet(); void saveDefinitions(); void loadDefinitions(); + void rescaleToData(); void toggleFollowMode(); void addNewGraph(); void createGraph(GraphParams ¶ms, bool createGraphParam = true);