From 799d2d77f02d612dfc2c8fd82c83c5109e79efeb Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Sun, 10 May 2015 12:57:51 -0400 Subject: [PATCH] Preliminaries for the flow view window. The overall form layout is now complete. --- SavvyCAN.pro | 12 +- SavvyCAN.pro.user | 2 +- candatagrid.cpp | 69 ++++ candatagrid.h | 23 ++ candatagrid.ui | 19 ++ flowviewwindow.cpp | 14 + flowviewwindow.h | 22 ++ flowviewwindow.ui | 824 +++++++++++++++++++++++++++++++++++++++++++++ mainwindow.cpp | 19 +- mainwindow.h | 3 + 10 files changed, 1002 insertions(+), 5 deletions(-) create mode 100644 candatagrid.cpp create mode 100644 candatagrid.h create mode 100644 candatagrid.ui create mode 100644 flowviewwindow.cpp create mode 100644 flowviewwindow.h create mode 100644 flowviewwindow.ui diff --git a/SavvyCAN.pro b/SavvyCAN.pro index c63df8b..0064629 100644 --- a/SavvyCAN.pro +++ b/SavvyCAN.pro @@ -21,7 +21,9 @@ SOURCES += main.cpp\ frameinfowindow.cpp \ newgraphdialog.cpp \ frameplaybackwindow.cpp \ - serialworker.cpp + serialworker.cpp \ + candatagrid.cpp \ + flowviewwindow.cpp HEADERS += mainwindow.h \ can_structs.h \ @@ -32,13 +34,17 @@ HEADERS += mainwindow.h \ frameinfowindow.h \ newgraphdialog.h \ frameplaybackwindow.h \ - serialworker.h + serialworker.h \ + candatagrid.h \ + flowviewwindow.h FORMS += mainwindow.ui \ graphingwindow.ui \ frameinfowindow.ui \ newgraphdialog.ui \ - frameplaybackwindow.ui + frameplaybackwindow.ui \ + candatagrid.ui \ + flowviewwindow.ui DISTFILES += diff --git a/SavvyCAN.pro.user b/SavvyCAN.pro.user index b32a501..f6a227a 100644 --- a/SavvyCAN.pro.user +++ b/SavvyCAN.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/candatagrid.cpp b/candatagrid.cpp new file mode 100644 index 0000000..ce15ea1 --- /dev/null +++ b/candatagrid.cpp @@ -0,0 +1,69 @@ +#include "candatagrid.h" +#include "ui_candatagrid.h" + +#include +#include + +CANDataGrid::CANDataGrid(QWidget *parent) : + QWidget(parent), + ui(new Ui::CANDataGrid) +{ + ui->setupUi(this); +} + +CANDataGrid::~CANDataGrid() +{ + delete ui; +} + +void CANDataGrid::paintEvent(QPaintEvent *event) +{ + int x, y; + QPainter painter(this); + + QRect viewport = painter.viewport(); + + int xSpan = viewport.right() - viewport.left(); + int ySpan = viewport.bottom() - viewport.top(); + + int xSector = xSpan / 10; + int ySector = ySpan / 10; + + //the whole thing is broken up into 100 chunks which are allocated as such: + //The entirety of the upper row is taken up by "BITS" + //The next row down skips two columns and then has 7 6 5 4 3 2 1 0 + //The bottom right 64 entries are the grid + //The left most column has "BYTES" written vertically down it + //the next left most column has "0 1 2 3 4 5 6 7" written down along the grid + + painter.setPen(QPen(Qt::black)); + QFont theFont; + theFont.setPixelSize(qMin(xSector, ySector) - 10); + painter.setFont(theFont); + + painter.drawText(QRect(viewport.left(), viewport.top(), xSpan, ySector), Qt::AlignCenter, tr("BITS")); + + for (x = 0; x < 8; x++) + { + painter.drawText(QRect(viewport.left() + (x+2) * xSector, viewport.top() + ySector, xSector, ySector), Qt::AlignCenter, QString::number(7-x)); + } + for (y = 0; y < 8; y++) + { + painter.drawText(QRect(viewport.left() + xSector, viewport.top() + ySector * (y + 2), xSector, ySector), Qt::AlignCenter, QString::number(y)); + } + + painter.drawText(viewport.left() + 10, viewport.top() + ySector * 4, "B"); + painter.drawText(viewport.left() + 10, viewport.top() + ySector * 5, "Y"); + painter.drawText(viewport.left() + 10, viewport.top() + ySector * 6, "T"); + painter.drawText(viewport.left() + 10, viewport.top() + ySector * 7, "E"); + painter.drawText(viewport.left() + 10, viewport.top() + ySector * 8, "S"); + + for (y = 0; y < 8; y++) + { + for (x = 0; x < 8; x++) + { + painter.drawRect(viewport.left() + (x+2) * xSector, viewport.top() + (y+2) * ySector, xSector, ySector); + + } + } +} diff --git a/candatagrid.h b/candatagrid.h new file mode 100644 index 0000000..10b1e32 --- /dev/null +++ b/candatagrid.h @@ -0,0 +1,23 @@ +#ifndef CANDATAGRID_H +#define CANDATAGRID_H + +#include + +namespace Ui { +class CANDataGrid; +} + +class CANDataGrid : public QWidget +{ + Q_OBJECT + +public: + explicit CANDataGrid(QWidget *parent = 0); + ~CANDataGrid(); + void paintEvent(QPaintEvent *event); + +private: + Ui::CANDataGrid *ui; +}; + +#endif // CANDATAGRID_H diff --git a/candatagrid.ui b/candatagrid.ui new file mode 100644 index 0000000..e1760d6 --- /dev/null +++ b/candatagrid.ui @@ -0,0 +1,19 @@ + + + CANDataGrid + + + + 0 + 0 + 812 + 608 + + + + Form + + + + + diff --git a/flowviewwindow.cpp b/flowviewwindow.cpp new file mode 100644 index 0000000..fa11e76 --- /dev/null +++ b/flowviewwindow.cpp @@ -0,0 +1,14 @@ +#include "flowviewwindow.h" +#include "ui_flowviewwindow.h" + +FlowViewWindow::FlowViewWindow(QWidget *parent) : + QDialog(parent), + ui(new Ui::FlowViewWindow) +{ + ui->setupUi(this); +} + +FlowViewWindow::~FlowViewWindow() +{ + delete ui; +} diff --git a/flowviewwindow.h b/flowviewwindow.h new file mode 100644 index 0000000..b4ffd78 --- /dev/null +++ b/flowviewwindow.h @@ -0,0 +1,22 @@ +#ifndef FLOWVIEWWINDOW_H +#define FLOWVIEWWINDOW_H + +#include + +namespace Ui { +class FlowViewWindow; +} + +class FlowViewWindow : public QDialog +{ + Q_OBJECT + +public: + explicit FlowViewWindow(QWidget *parent = 0); + ~FlowViewWindow(); + +private: + Ui::FlowViewWindow *ui; +}; + +#endif // FLOWVIEWWINDOW_H diff --git a/flowviewwindow.ui b/flowviewwindow.ui new file mode 100644 index 0000000..bb3b555 --- /dev/null +++ b/flowviewwindow.ui @@ -0,0 +1,824 @@ + + + FlowViewWindow + + + + 0 + 0 + 1078 + 621 + + + + Flow View + + + + + + + + + + + 0 + 0 + + + + Frame IDs Found: + + + + + + + + 0 + 0 + + + + + 120 + 16777215 + + + + + + + + + + + + + + Playback Control + + + + + + + + + + + + :/icons/images/NavBack.png:/icons/images/NavBack.png + + + + + + + + + + + :/icons/images/StopHS.png:/icons/images/StopHS.png + + + + + + + + + + + :/icons/images/NavForward.png:/icons/images/NavForward.png + + + + + + + + + + + + + + + :/icons/images/ReverseHS.png:/icons/images/ReverseHS.png + + + + + + + + + + + :/icons/images/PauseHS.png:/icons/images/PauseHS.png + + + + + + + + + + + :/icons/images/PlayHS.png:/icons/images/PlayHS.png + + + + + + + + + + 0 + 0 + + + + Playback Speed: + + + + + + + + + + Loop Playback + + + + + + + + 0 + 0 + + + + Current Frame: + + + + + + + + 0 + 0 + + + + X of Y + + + + + + + + + + + 0 + 0 + + + + Capture Traffic + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Auto Reference + + + + + + + + 0 + 0 + + + + Reference Values + + + + + + + + 0 + + + + + + + 1 + + + + + + + 2 + + + + + + + 3 + + + + + + + + + + + + 0 + 0 + + + + + 40 + 0 + + + + + 40 + 16777215 + + + + + 80 + 0 + + + + + + + + + 0 + 0 + + + + + 40 + 0 + + + + + 40 + 16777215 + + + + + 80 + 0 + + + + + + + + + 0 + 0 + + + + + 40 + 0 + + + + + 40 + 16777215 + + + + + 80 + 0 + + + + + + + + + 0 + 0 + + + + + 40 + 0 + + + + + 40 + 16777215 + + + + + 80 + 0 + + + + + + + + + + + + 4 + + + + + + + 5 + + + + + + + 6 + + + + + + + 7 + + + + + + + + + + + + 0 + 0 + + + + + 40 + 0 + + + + + 40 + 16777215 + + + + + + + + + 0 + 0 + + + + + 40 + 0 + + + + + 40 + 16777215 + + + + + + + + + 0 + 0 + + + + + 40 + 0 + + + + + 40 + 16777215 + + + + + + + + + 0 + 0 + + + + + 40 + 0 + + + + + 40 + 16777215 + + + + + + + + + + + + + + 0 + 0 + + + + Current Values + + + + + + + + 0 + + + + + + + 1 + + + + + + + 2 + + + + + + + 3 + + + + + + + + + + + + 0 + 0 + + + + + 40 + 0 + + + + + 40 + 16777215 + + + + + + + + + 0 + 0 + + + + + 40 + 0 + + + + + 40 + 16777215 + + + + + + + + + 0 + 0 + + + + + 40 + 0 + + + + + 40 + 16777215 + + + + + + + + + 0 + 0 + + + + + 40 + 0 + + + + + 40 + 16777215 + + + + + + + + + + + + 4 + + + + + + + 5 + + + + + + + 6 + + + + + + + 7 + + + + + + + + + + + + 0 + 0 + + + + + 40 + 0 + + + + + 40 + 16777215 + + + + + + + + + 0 + 0 + + + + + 40 + 0 + + + + + 40 + 16777215 + + + + + + + + + 0 + 0 + + + + + 40 + 0 + + + + + 40 + 16777215 + + + + + + + + + 0 + 0 + + + + + 40 + 0 + + + + + 40 + 16777215 + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + + + + + + + + + + + CANDataGrid + QWidget +
candatagrid.h
+ 1 +
+ + QCustomPlot + QWidget +
qcustomplot.h
+ 1 +
+
+ + + + +
diff --git a/mainwindow.cpp b/mainwindow.cpp index e928de1..bcd1ffb 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -14,8 +14,13 @@ can replace it as a cross platform solution. Here are things yet to do - Add flow view - ability to see bits change over time -- Ability to send frames via playback mechanism (people use this so get it working!) - Ability to use programmatic frame sending interface (only I use it and it's complicated but helpful) +- Continuous logging. But, I see no real reason why this is needed. It would only be helpful if the program were prone to crashing. SO, don't do that. + +Things that were planned for the GVRET-PC project but never completed. +Single / Multi state - The goal is to find bits that change based on toggles or discrete state items (shifters, etc) +Range state - Find things that range like accelerator pedal inputs, road speed, tach, etc +fuzzy scope - Try to find potential places where a given value might be stored - offer guesses and the program tries to find candidates for you */ @@ -70,6 +75,7 @@ MainWindow::MainWindow(QWidget *parent) : graphingWindow = NULL; frameInfoWindow = NULL; playbackWindow = NULL; + flowViewWindow = NULL; connect(ui->btnConnect, SIGNAL(clicked(bool)), this, SLOT(connButtonPress())); connect(ui->actionOpen_Log_File, SIGNAL(triggered(bool)), this, SLOT(handleLoadFile())); @@ -79,6 +85,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->actionSave_Log_File, SIGNAL(triggered(bool)), this, SLOT(handleSaveFile())); connect(ui->action_Playback, SIGNAL(triggered(bool)), this, SLOT(showPlaybackWindow())); connect(ui->btnBaudSet, SIGNAL(clicked(bool)), this, SLOT(changeBaudRates())); + connect(ui->actionFlow_View, SIGNAL(triggered(bool)), this, SLOT(showFlowViewWindow())); } MainWindow::~MainWindow() @@ -614,3 +621,13 @@ void MainWindow::showPlaybackWindow() } playbackWindow->show(); } + +void MainWindow::showFlowViewWindow() +{ + if (!flowViewWindow) + { + flowViewWindow = new FlowViewWindow(); + } + flowViewWindow->show(); + +} diff --git a/mainwindow.h b/mainwindow.h index e6a2467..8ec283d 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -8,6 +8,7 @@ #include "graphingwindow.h" #include "frameinfowindow.h" #include "frameplaybackwindow.h" +#include "flowviewwindow.h" namespace Ui { class MainWindow; @@ -29,6 +30,7 @@ private slots: void showFrameDataAnalysis(); void clearFrames(); void showPlaybackWindow(); + void showFlowViewWindow(); void changeBaudRates(); public slots: @@ -47,6 +49,7 @@ private: GraphingWindow *graphingWindow; FrameInfoWindow *frameInfoWindow; FramePlaybackWindow *playbackWindow; + FlowViewWindow *flowViewWindow; void loadCRTDFile(QString); void loadNativeCSVFile(QString); void loadGenericCSVFile(QString);