diff --git a/flowviewwindow.cpp b/flowviewwindow.cpp index d74a749..e01809e 100644 --- a/flowviewwindow.cpp +++ b/flowviewwindow.cpp @@ -48,6 +48,13 @@ FlowViewWindow::FlowViewWindow(QVector *frames, QWidget *parent) : ui->graphView->legend->setFont(legendFont); ui->graphView->legend->setSelectedFont(legendSelectedFont); ui->graphView->legend->setSelectableParts(QCPLegend::spItems); // legend box shall not be selectable, only legend items + //ui->graphView->xAxis->setAutoSubTicks(false); + //ui->graphView->xAxis->setAutoTicks(false); + ui->graphView->xAxis->setAutoTickStep(false); + ui->graphView->xAxis->setAutoSubTicks(false); + ui->graphView->xAxis->setNumberFormat("gb"); + ui->graphView->xAxis->setTickStep(5.0); + ui->graphView->xAxis->setSubTickCount(0); connect(ui->btnBackOne, SIGNAL(clicked(bool)), this, SLOT(btnBackOneClick())); connect(ui->btnPause, SIGNAL(clicked(bool)), this, SLOT(btnPauseClick())); @@ -130,6 +137,8 @@ void FlowViewWindow::createGraph(int byteNum) int tempVal; float minval=1000000, maxval = -100000; + bool graphByTime = ui->cbTimeGraph->isChecked(); + int numEntries = frameCache.count(); QVector x(numEntries), y(numEntries); @@ -137,7 +146,16 @@ void FlowViewWindow::createGraph(int byteNum) for (int j = 0; j < numEntries; j++) { tempVal = frameCache[j].data[byteNum]; - x[j] = j; + + if (graphByTime) + { + x[j] = frameCache[j].timestamp; + } + else + { + x[j] = j; + } + y[j] = tempVal; if (y[j] < minval) minval = y[j]; if (y[j] > maxval) maxval = y[j]; @@ -203,7 +221,8 @@ void FlowViewWindow::changeID(QString newID) { createGraph(c); } - ui->graphView->replot(); + + updateGraphLocation(); memcpy(currBytes, frameCache.at(currentPosition).data, 8); memcpy(refBytes, currBytes, 8); @@ -320,8 +339,7 @@ void FlowViewWindow::updateDataView() ui->flowView->setReference(refBytes, false); ui->flowView->updateData(currBytes, true); - ui->graphView->xAxis->setRange(currentPosition - 5, currentPosition + 5); - ui->graphView->replot(); + updateGraphLocation(); updateFrameLabel(); @@ -350,4 +368,28 @@ void FlowViewWindow::updatePosition(bool forward) } +void FlowViewWindow::updateGraphLocation() +{ + int start = currentPosition - 5; + if (start < 0) start = 0; + int end = currentPosition + 5; + if (end >= frameCache.count()) end = frameCache.count() - 1; + if (ui->cbTimeGraph->isChecked()) + { + ui->graphView->xAxis->setRange(frameCache[start].timestamp, frameCache[end].timestamp); + ui->graphView->xAxis->setTickStep((frameCache[end].timestamp - frameCache[start].timestamp)/ 3.0); + ui->graphView->xAxis->setSubTickCount(0); + ui->graphView->xAxis->setNumberFormat("f"); + ui->graphView->xAxis->setNumberPrecision(0); + } + else + { + ui->graphView->xAxis->setRange(start, end); + ui->graphView->xAxis->setTickStep(5.0); + ui->graphView->xAxis->setSubTickCount(0); + ui->graphView->xAxis->setNumberFormat("gb"); + } + + ui->graphView->replot(); +} diff --git a/flowviewwindow.h b/flowviewwindow.h index 889169d..7cb7cf2 100644 --- a/flowviewwindow.h +++ b/flowviewwindow.h @@ -49,6 +49,7 @@ private: void updateDataView(); void removeAllGraphs(); void createGraph(int); + void updateGraphLocation(); }; #endif // FLOWVIEWWINDOW_H diff --git a/flowviewwindow.ui b/flowviewwindow.ui index 957d5a0..2446212 100644 --- a/flowviewwindow.ui +++ b/flowviewwindow.ui @@ -52,7 +52,7 @@ - + @@ -204,7 +204,14 @@ - Capture Traffic + Realtime Capture + + + + + + + Graph by timestamp diff --git a/graphingwindow.cpp b/graphingwindow.cpp index 49f9774..74ab87a 100644 --- a/graphingwindow.cpp +++ b/graphingwindow.cpp @@ -24,6 +24,8 @@ GraphingWindow::GraphingWindow(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); ui->graphingView->legend->setVisible(true); QFont legendFont = font(); legendFont.setPointSize(10); @@ -310,7 +312,8 @@ void GraphingWindow::addNewGraph() void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam) { int tempVal; - float minval=1000000, maxval = -100000; + float yminval=10000000, ymaxval = -1000000; + float xminval=100000000000, xmaxval = -100000000000; qDebug() << "New Graph ID: " << params.ID; qDebug() << "Start byte: " << params.startByte; @@ -337,10 +340,13 @@ void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam) { tempVal = tempVal - 256; } - x[j] = j; + x[j] = frameCache[j].timestamp; y[j] = (tempVal + params.bias) * params.scale; - if (y[j] < minval) minval = y[j]; - if (y[j] > maxval) maxval = y[j]; + if (y[j] < yminval) yminval = y[j]; + if (y[j] > ymaxval) ymaxval = y[j]; + if (x[j] < xminval) xminval = x[j]; + if (x[j] > xmaxval) xmaxval = x[j]; + } } else if (params.endByte > params.startByte) //big endian @@ -367,10 +373,12 @@ void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam) } tempValue = (float)tempValInt; - x[j] = j; + x[j] = frameCache[j].timestamp; y[j] = (tempValue + params.bias) * params.scale; - if (y[j] < minval) minval = y[j]; - if (y[j] > maxval) maxval = y[j]; + if (y[j] < yminval) yminval = y[j]; + if (y[j] > ymaxval) ymaxval = y[j]; + if (x[j] < xminval) xminval = x[j]; + if (x[j] > xmaxval) xmaxval = x[j]; } } else //little endian @@ -396,10 +404,12 @@ void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam) } tempValue = (float)tempValInt; - x[j] = j; + x[j] = frameCache[j].timestamp; y[j] = (tempValue + params.bias) * params.scale; - if (y[j] < minval) minval = y[j]; - if (y[j] > maxval) maxval = y[j]; + if (y[j] < yminval) yminval = y[j]; + if (y[j] > ymaxval) ymaxval = y[j]; + if (x[j] < xminval) xminval = x[j]; + if (x[j] > xmaxval) xmaxval = x[j]; } } ui->graphingView->addGraph(); @@ -415,8 +425,8 @@ void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam) graphPen.setWidth(1); ui->graphingView->graph()->setPen(graphPen); - ui->graphingView->xAxis->setRange(0, numEntries); - ui->graphingView->yAxis->setRange(minval, maxval); + ui->graphingView->xAxis->setRange(xminval, xmaxval); + ui->graphingView->yAxis->setRange(yminval, ymaxval); ui->graphingView->axisRect()->setupFullAxesBox(); ui->graphingView->replot(); diff --git a/mainwindow.cpp b/mainwindow.cpp index 77a0f52..e6e26a1 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -22,7 +22,7 @@ fuzzy scope - Try to find potential places where a given value might be stored - Things currently broken or in need of attention: -1. Each screen should mention which file is loaded so that it's easier to keep track of what you're doing. +1. Currently no screen supports dynamic updates when new frames come in. */ QString MainWindow::loadedFileName = ""; diff --git a/mainwindow.h b/mainwindow.h index 51dc29a..e20183a 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -14,7 +14,7 @@ #include "dbchandler.h" #include "dbcmaineditor.h" -#define VERSION 108 +#define VERSION 109 namespace Ui { class MainWindow;