From 907312f12d5d4059365b9a9ceffed6c523bd62b9 Mon Sep 17 00:00:00 2001 From: Viktor Verebelyi Date: Fri, 26 Nov 2021 03:34:11 +0000 Subject: [PATCH] Add selection of graph charts to Frame info window --- re/frameinfowindow.cpp | 38 ++++++++++++- re/frameinfowindow.h | 5 ++ ui/frameinfowindow.ui | 119 +++++++++++++++++++++++++++++++---------- 3 files changed, 132 insertions(+), 30 deletions(-) diff --git a/re/frameinfowindow.cpp b/re/frameinfowindow.cpp index a6508be..b545b50 100644 --- a/re/frameinfowindow.cpp +++ b/re/frameinfowindow.cpp @@ -34,6 +34,15 @@ FrameInfoWindow::FrameInfoWindow(const QVector *frames, QWidget *paren connect(MainWindow::getReference(), &MainWindow::framesUpdated, this, &FrameInfoWindow::updatedFrames); connect(ui->btnSave, &QAbstractButton::clicked, this, &FrameInfoWindow::saveDetails); + connect(ui->check_0, &QCheckBox::stateChanged, this, &FrameInfoWindow::changeGraphVisibility); + connect(ui->check_1, &QCheckBox::stateChanged, this, &FrameInfoWindow::changeGraphVisibility); + connect(ui->check_2, &QCheckBox::stateChanged, this, &FrameInfoWindow::changeGraphVisibility); + connect(ui->check_3, &QCheckBox::stateChanged, this, &FrameInfoWindow::changeGraphVisibility); + connect(ui->check_4, &QCheckBox::stateChanged, this, &FrameInfoWindow::changeGraphVisibility); + connect(ui->check_5, &QCheckBox::stateChanged, this, &FrameInfoWindow::changeGraphVisibility); + connect(ui->check_6, &QCheckBox::stateChanged, this, &FrameInfoWindow::changeGraphVisibility); + connect(ui->check_7, &QCheckBox::stateChanged, this, &FrameInfoWindow::changeGraphVisibility); + ui->graphHistogram->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectAxes | QCP::iSelectLegend | QCP::iSelectPlottables); @@ -631,7 +640,7 @@ void FrameInfoWindow::updateDetailsWindow(QString newID) ui->graphBytes->clearGraphs(); for (int graphs = 0; graphs < 8; graphs++) { - ui->graphBytes->addGraph(); + graphRef[graphs] = ui->graphBytes->addGraph(); ui->graphBytes->graph()->setData(byteGraphX, byteGraphY[graphs]); ui->graphBytes->graph()->setPen(bytePens[graphs]); } @@ -652,6 +661,15 @@ void FrameInfoWindow::updateDetailsWindow(QString newID) ui->timeHistogram->axisRect()->setupFullAxesBox(); ui->timeHistogram->rescaleAxes(); ui->timeHistogram->replot(); + + ui->check_0->setChecked(true); + ui->check_1->setChecked(true); + ui->check_2->setChecked(true); + ui->check_3->setChecked(true); + ui->check_4->setChecked(true); + ui->check_5->setChecked(true); + ui->check_6->setChecked(true); + ui->check_7->setChecked(true); } else { @@ -726,6 +744,24 @@ void FrameInfoWindow::saveDetails() } } +void FrameInfoWindow::changeGraphVisibility(int state){ + QCheckBox *sender = qobject_cast(QObject::sender()); + if(sender){ + sender->objectName(); + int graphId = sender->objectName().right(1).toInt(); + for (int k = 0; k < 8; k++) + { + if (k == graphId && graphRef[k] && graphRef[k]->data()){ + graphRef[k]->setVisible(state); + qDebug() << graphId << state << k; + } + } + qDebug() << graphId << state; + + ui->graphBytes->replot(); + } +} + void FrameInfoWindow::dumpNode(QTreeWidgetItem* item, QFile *file, int indent) { for (int i = 0; i < indent; i++) file->write("\t"); diff --git a/re/frameinfowindow.h b/re/frameinfowindow.h index 72e7a47..5196d93 100644 --- a/re/frameinfowindow.h +++ b/re/frameinfowindow.h @@ -9,6 +9,8 @@ #include "bus_protocols/j1939_handler.h" #include "dbc/dbchandler.h" +#include "qcustomplot.h" + namespace Ui { class FrameInfoWindow; } @@ -26,6 +28,7 @@ private slots: void updateDetailsWindow(QString); void updatedFrames(int); void saveDetails(); + void changeGraphVisibility(int state); private: Ui::FrameInfoWindow *ui; @@ -39,6 +42,8 @@ private: static QPen bytePens[8]; DBCHandler *dbcHandler; + QCPGraph *graphRef[8]; + void refreshIDList(); void closeEvent(QCloseEvent *event); bool eventFilter(QObject *obj, QEvent *event); diff --git a/ui/frameinfowindow.ui b/ui/frameinfowindow.ui index 28904e9..406b02a 100644 --- a/ui/frameinfowindow.ui +++ b/ui/frameinfowindow.ui @@ -133,7 +133,7 @@ - + @@ -162,9 +162,9 @@ - 190 - 190 - 190 + 120 + 120 + 120 @@ -181,10 +181,13 @@ 0 + + true + - + @@ -213,9 +216,9 @@ - 190 - 190 - 190 + 120 + 120 + 120 @@ -232,10 +235,50 @@ 1 + + true + - + + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + + + 120 + 120 + 120 + + + + + + 13 @@ -246,10 +289,13 @@ 2 + + true + - + @@ -278,9 +324,9 @@ - 190 - 190 - 190 + 120 + 120 + 120 @@ -297,10 +343,13 @@ 3 + + true + - + @@ -329,9 +378,9 @@ - 190 - 190 - 190 + 120 + 120 + 120 @@ -348,10 +397,13 @@ 4 + + true + - + @@ -380,9 +432,9 @@ - 190 - 190 - 190 + 120 + 120 + 120 @@ -399,10 +451,13 @@ 5 + + true + - + @@ -431,9 +486,9 @@ - 190 - 190 - 190 + 120 + 120 + 120 @@ -450,10 +505,13 @@ 6 + + true + - + @@ -482,9 +540,9 @@ - 190 - 190 - 190 + 120 + 120 + 120 @@ -501,6 +559,9 @@ 7 + + true +