From 9f64eabd9fe452030aad0a31feddb46d2e168f62 Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Sun, 3 Sep 2017 13:46:02 -0400 Subject: [PATCH] Add openGL mode to flowview, add histogram graphing to frame info window (also openGL accelerated if you choose) --- config.h | 2 +- re/flowviewwindow.cpp | 12 +++++++++++ re/flowviewwindow.h | 1 + re/frameinfowindow.cpp | 45 +++++++++++++++++++++++++++++++++++++++++- re/frameinfowindow.h | 1 + ui/flowviewwindow.ui | 16 +++++++-------- ui/frameinfowindow.ui | 13 +++++++++++- 7 files changed, 79 insertions(+), 11 deletions(-) diff --git a/config.h b/config.h index ce9dad3..1c2fbc8 100644 --- a/config.h +++ b/config.h @@ -1,7 +1,7 @@ #ifndef CONFIG #define CONFIG -#define VERSION 175 +#define VERSION 176 //try to keep this in sync. //SavvyCAN will complain if you connect a GVRET board with a revision diff --git a/re/flowviewwindow.cpp b/re/flowviewwindow.cpp index 2b24f6f..d359119 100644 --- a/re/flowviewwindow.cpp +++ b/re/flowviewwindow.cpp @@ -62,6 +62,17 @@ FlowViewWindow::FlowViewWindow(const QVector *frames, QWidget *parent) //ui->graphView->xAxis->setTickStep(5.0); //ui->graphView->xAxis->setSubTickCount(0); + if (openGLMode) + { + ui->graphView->setAntialiasedElements(QCP::aeAll); + ui->graphView->setOpenGl(true); + } + else + { + ui->graphView->setOpenGl(false); + ui->graphView->setAntialiasedElements(QCP::aeNone); + } + connect(ui->btnBackOne, SIGNAL(clicked(bool)), this, SLOT(btnBackOneClick())); connect(ui->btnPause, SIGNAL(clicked(bool)), this, SLOT(btnPauseClick())); connect(ui->btnReverse, SIGNAL(clicked(bool)), this, SLOT(btnReverseClick())); @@ -146,6 +157,7 @@ void FlowViewWindow::readSettings() } secondsMode = settings.value("Main/TimeSeconds", false).toBool(); + openGLMode = settings.value("Main/UseOpenGL", false).toBool(); } void FlowViewWindow::writeSettings() diff --git a/re/flowviewwindow.h b/re/flowviewwindow.h index 165a13e..4b4d662 100644 --- a/re/flowviewwindow.h +++ b/re/flowviewwindow.h @@ -55,6 +55,7 @@ private: bool playbackForward; static const QColor graphColors[8]; bool secondsMode; + bool openGLMode; QVector x[8], y[8]; QCPGraph *graphRef[8]; diff --git a/re/frameinfowindow.cpp b/re/frameinfowindow.cpp index 4ba4433..0ac0cd6 100644 --- a/re/frameinfowindow.cpp +++ b/re/frameinfowindow.cpp @@ -17,6 +17,31 @@ FrameInfoWindow::FrameInfoWindow(const QVector *frames, QWidget *paren connect(MainWindow::getReference(), &MainWindow::framesUpdated, this, &FrameInfoWindow::updatedFrames); connect(ui->btnSave, &QAbstractButton::clicked, this, &FrameInfoWindow::saveDetails); + + ui->graphHistogram->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectAxes | + QCP::iSelectLegend | QCP::iSelectPlottables); + + ui->graphHistogram->xAxis->setRange(0, 63); + ui->graphHistogram->yAxis->setRange(0, 100); + ui->graphHistogram->axisRect()->setupFullAxesBox(); + + ui->graphHistogram->xAxis->setLabel("Bits"); + ui->graphHistogram->yAxis->setLabel("Instances"); + + ui->graphHistogram->legend->setVisible(false); + + if (useOpenGL) + { + ui->graphHistogram->setAntialiasedElements(QCP::aeAll); + //ui->graphingView->setNoAntialiasingOnDrag(true); + ui->graphHistogram->setOpenGl(true); + } + else + { + ui->graphHistogram->setOpenGl(false); + ui->graphHistogram->setAntialiasedElements(QCP::aeNone); + } + } void FrameInfoWindow::showEvent(QShowEvent* event) @@ -50,6 +75,7 @@ void FrameInfoWindow::readSettings() resize(settings.value("FrameInfo/WindowSize", QSize(794, 494)).toSize()); move(settings.value("FrameInfo/WindowPos", QPoint(50, 50)).toPoint()); } + useOpenGL = settings.value("Main/UseOpenGL", false).toBool(); } void FrameInfoWindow::writeSettings() @@ -121,6 +147,8 @@ void FrameInfoWindow::updateDetailsWindow(QString newID) int maxData[8]; int dataHistogram[256][8]; int bitfieldHistogram[64]; + QVector graphX, graphY; + double maxY = -1000.0; uint8_t changedBits[8]; uint8_t referenceBits[8]; QTreeWidgetItem *baseNode, *dataBase, *histBase, *tempItem; @@ -300,7 +328,7 @@ void FrameInfoWindow::updateDetailsWindow(QString newID) tempItem->setText(0, QString::number(d) + "/0x" + QString::number(d, 16) +" (" + Utility::formatByteAsBinary(d) +") -> " + QString::number(dataHistogram[d][c])); histBase->addChild(tempItem); } - } + } } dataBase = new QTreeWidgetItem(); @@ -312,10 +340,25 @@ void FrameInfoWindow::updateDetailsWindow(QString newID) + QString::number(c % 8) + ") :" + QString::number(bitfieldHistogram[c])); dataBase->addChild(tempItem); + graphX.append(c); + graphY.append(bitfieldHistogram[c]); + if (bitfieldHistogram[c] > maxY) maxY = bitfieldHistogram[c]; } baseNode->addChild(dataBase); ui->treeDetails->insertTopLevelItem(0, baseNode); + ui->graphHistogram->clearGraphs(); + ui->graphHistogram->addGraph(); + ui->graphHistogram->graph()->setData(graphX, graphY); + ui->graphHistogram->graph()->setLineStyle(QCPGraph::lsStepLeft); //connect points with lines + QBrush graphBrush; + graphBrush.setColor(Qt::red); + graphBrush.setStyle(Qt::SolidPattern); + ui->graphHistogram->graph()->setPen(Qt::NoPen); + ui->graphHistogram->graph()->setBrush(graphBrush); + ui->graphHistogram->yAxis->setRange(0, maxY * 1.02); + ui->graphHistogram->axisRect()->setupFullAxesBox(); + ui->graphHistogram->replot(); } else { diff --git a/re/frameinfowindow.h b/re/frameinfowindow.h index 67bbb44..a841de4 100644 --- a/re/frameinfowindow.h +++ b/re/frameinfowindow.h @@ -32,6 +32,7 @@ private: QList foundID; QList frameCache; const QVector *modelFrames; + bool useOpenGL; void refreshIDList(); void closeEvent(QCloseEvent *event); diff --git a/ui/flowviewwindow.ui b/ui/flowviewwindow.ui index 81ddf9f..b9034ba 100644 --- a/ui/flowviewwindow.ui +++ b/ui/flowviewwindow.ui @@ -7,7 +7,7 @@ 0 0 1078 - 621 + 623 @@ -67,7 +67,7 @@ - + :/icons/images/NavBack.png:/icons/images/NavBack.png @@ -78,7 +78,7 @@ - + :/icons/images/StopHS.png:/icons/images/StopHS.png @@ -89,7 +89,7 @@ - + :/icons/images/NavForward.png:/icons/images/NavForward.png @@ -104,7 +104,7 @@ - + :/icons/images/ReverseHS.png:/icons/images/ReverseHS.png @@ -115,7 +115,7 @@ - + :/icons/images/PauseHS.png:/icons/images/PauseHS.png @@ -126,7 +126,7 @@ - + :/icons/images/PlayHS.png:/icons/images/PlayHS.png @@ -1389,7 +1389,7 @@ - + diff --git a/ui/frameinfowindow.ui b/ui/frameinfowindow.ui index 2b82ef0..2104576 100644 --- a/ui/frameinfowindow.ui +++ b/ui/frameinfowindow.ui @@ -13,7 +13,7 @@ Detailed Frame Information - + @@ -72,8 +72,19 @@ + + + + + + QCustomPlot + QWidget +
qcustomplot.h
+ 1 +
+