From 5a302cc602d4474b94bacdec99f4f85a1bf363cc Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Sun, 5 Jul 2015 13:36:06 -0400 Subject: [PATCH] Added support for seconds mode to graphing view. --- graphingwindow.cpp | 36 ++++++++++++++++++++++++++++++++---- graphingwindow.h | 3 ++- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/graphingwindow.cpp b/graphingwindow.cpp index a3e89cf..4aad980 100644 --- a/graphingwindow.cpp +++ b/graphingwindow.cpp @@ -27,7 +27,9 @@ GraphingWindow::GraphingWindow(const QVector *frames, QWidget *parent) ui->graphingView->xAxis->setLabel("Time Axis"); ui->graphingView->yAxis->setLabel("Value Axis"); ui->graphingView->xAxis->setNumberFormat("f"); - ui->graphingView->xAxis->setNumberPrecision(0); + if (secondsMode) ui->graphingView->xAxis->setNumberPrecision(6); + else ui->graphingView->xAxis->setNumberPrecision(0); + ui->graphingView->legend->setVisible(true); QFont legendFont = font(); legendFont.setPointSize(10); @@ -89,6 +91,7 @@ void GraphingWindow::readSettings() resize(settings.value("Graphing/WindowSize", QSize(800, 600)).toSize()); move(settings.value("Graphing/WindowPos", QPoint(50, 50)).toPoint()); } + secondsMode = settings.value("Main/TimeSeconds", false).toBool(); } void GraphingWindow::writeSettings() @@ -401,7 +404,14 @@ void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam) { tempVal = tempVal - 256; } - x[j] = frameCache[j].timestamp; + if (secondsMode) + { + x[j] = (double)(frameCache[j].timestamp) / 1000000.0; + } + else + { + x[j] = frameCache[j].timestamp; + } y[j] = (tempVal + params.bias) * params.scale; if (y[j] < yminval) yminval = y[j]; if (y[j] > ymaxval) ymaxval = y[j]; @@ -434,7 +444,16 @@ void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam) } tempValue = (float)tempValInt; - x[j] = frameCache[j].timestamp; + + if (secondsMode) + { + x[j] = (double)(frameCache[j].timestamp) / 1000000.0; + } + else + { + x[j] = frameCache[j].timestamp; + } + y[j] = (tempValue + params.bias) * params.scale; if (y[j] < yminval) yminval = y[j]; if (y[j] > ymaxval) ymaxval = y[j]; @@ -465,7 +484,16 @@ void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam) } tempValue = (float)tempValInt; - x[j] = frameCache[j].timestamp; + + if (secondsMode) + { + x[j] = (double)(frameCache[j].timestamp) / 1000000.0; + } + else + { + x[j] = frameCache[j].timestamp; + } + y[j] = (tempValue + params.bias) * params.scale; if (y[j] < yminval) yminval = y[j]; if (y[j] > ymaxval) ymaxval = y[j]; diff --git a/graphingwindow.h b/graphingwindow.h index 1b1b504..04ff2d9 100644 --- a/graphingwindow.h +++ b/graphingwindow.h @@ -56,7 +56,8 @@ private: const QVector *modelFrames; QList graphParams; QPen selectedPen; - bool needScaleSetup; //do we need to set x,y graphing extents?s + bool needScaleSetup; //do we need to set x,y graphing extents? + bool secondsMode; void showParamsDialog(int idx); void closeEvent(QCloseEvent *event);