From ffc9278380d3d40843d9f921a2a3e875ccdc6bb7 Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Tue, 17 Jan 2023 22:09:39 -0500 Subject: [PATCH] Allow hiding / showing byte graphs in Frame Info. Double click on graphs for magic. --- candatagrid.cpp | 1 + re/frameinfowindow.cpp | 31 +++++++++++++++++++++++++++++++ re/frameinfowindow.h | 1 + re/graphingwindow.cpp | 2 +- 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/candatagrid.cpp b/candatagrid.cpp index 1c908ed..bb8cf56 100644 --- a/candatagrid.cpp +++ b/candatagrid.cpp @@ -105,6 +105,7 @@ CANDataGrid::CANDataGrid(QWidget *parent) : fire[x] = QColor::fromHsl(hue, 255, 127); } + //the 0th entry should always be black and really stand out from the rest fire[0] = Qt::black; } diff --git a/re/frameinfowindow.cpp b/re/frameinfowindow.cpp index 8f6df52..cf0598d 100644 --- a/re/frameinfowindow.cpp +++ b/re/frameinfowindow.cpp @@ -164,6 +164,7 @@ void FrameInfoWindow::setupByteGraph(QCustomPlot *plot, int num) connect(plot, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(mousePress())); connect(plot, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheel())); + connect(plot, &QCustomPlot::mouseDoubleClick, this, &FrameInfoWindow::mouseDoubleClick); } void FrameInfoWindow::mousePress() @@ -197,6 +198,36 @@ void FrameInfoWindow::mouseWheel() plot->axisRect()->setRangeZoom(Qt::Horizontal|Qt::Vertical); } + +//two modes here. If none of the 8 sub graphs are hidden then hide all except the one the user +//just double clicked on. Otherwise unhide the 7 hidden ones +void FrameInfoWindow::mouseDoubleClick() +{ + QCustomPlot *plot = qobject_cast(sender()); + bool hideMode = true; + + for (int i = 0; i < 8; i++) + { + if (ui->gridLower->itemAt(i)->widget()->isHidden()) hideMode = false; + } + + if (hideMode) + { + for (int i = 0; i < 8; i++) + { + if (ui->gridLower->itemAt(i)->widget() == (plot)) qDebug() << "Idx " << i << " matched!"; + else ui->gridLower->itemAt(i)->widget()->setHidden(true); + } + } + else + { + for (int i = 0; i < 8; i++) + { + ui->gridLower->itemAt(i)->widget()->setHidden(false); + } + } +} + void FrameInfoWindow::showEvent(QShowEvent* event) { QDialog::showEvent(event); diff --git a/re/frameinfowindow.h b/re/frameinfowindow.h index db15493..c67c2a7 100644 --- a/re/frameinfowindow.h +++ b/re/frameinfowindow.h @@ -31,6 +31,7 @@ private slots: void saveDetails(); void mousePress(); void mouseWheel(); + void mouseDoubleClick(); private: Ui::FrameInfoWindow *ui; diff --git a/re/graphingwindow.cpp b/re/graphingwindow.cpp index a4c1540..b66f9a3 100644 --- a/re/graphingwindow.cpp +++ b/re/graphingwindow.cpp @@ -61,9 +61,9 @@ GraphingWindow::GraphingWindow(const QVector *frames, QWidget *parent) // connect slot that ties some axis selections together (especially opposite axes): connect(ui->graphingView, SIGNAL(selectionChangedByUser()), this, SLOT(selectionChanged())); //connect up the mouse controls - connect(ui->graphingView, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(mousePress())); connect(ui->graphingView, SIGNAL(plottableDoubleClick(QCPAbstractPlottable*,int,QMouseEvent*)), this, SLOT(plottableDoubleClick(QCPAbstractPlottable*,int,QMouseEvent*))); connect(ui->graphingView, SIGNAL(plottableClick(QCPAbstractPlottable*,int,QMouseEvent*)), this, SLOT(plottableClick(QCPAbstractPlottable*,int,QMouseEvent*))); + connect(ui->graphingView, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(mousePress())); connect(ui->graphingView, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheel())); // make bottom and left axes transfer their ranges to top and right axes: