Add selection of graph charts to Frame info window

This commit is contained in:
Viktor Verebelyi
2021-11-26 03:34:11 +00:00
parent 3a4f9c6699
commit 907312f12d
3 changed files with 132 additions and 30 deletions
+37 -1
View File
@@ -34,6 +34,15 @@ FrameInfoWindow::FrameInfoWindow(const QVector<CANFrame> *frames, QWidget *paren
connect(MainWindow::getReference(), &MainWindow::framesUpdated, this, &FrameInfoWindow::updatedFrames); connect(MainWindow::getReference(), &MainWindow::framesUpdated, this, &FrameInfoWindow::updatedFrames);
connect(ui->btnSave, &QAbstractButton::clicked, this, &FrameInfoWindow::saveDetails); 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 | ui->graphHistogram->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectAxes |
QCP::iSelectLegend | QCP::iSelectPlottables); QCP::iSelectLegend | QCP::iSelectPlottables);
@@ -631,7 +640,7 @@ void FrameInfoWindow::updateDetailsWindow(QString newID)
ui->graphBytes->clearGraphs(); ui->graphBytes->clearGraphs();
for (int graphs = 0; graphs < 8; graphs++) 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()->setData(byteGraphX, byteGraphY[graphs]);
ui->graphBytes->graph()->setPen(bytePens[graphs]); ui->graphBytes->graph()->setPen(bytePens[graphs]);
} }
@@ -652,6 +661,15 @@ void FrameInfoWindow::updateDetailsWindow(QString newID)
ui->timeHistogram->axisRect()->setupFullAxesBox(); ui->timeHistogram->axisRect()->setupFullAxesBox();
ui->timeHistogram->rescaleAxes(); ui->timeHistogram->rescaleAxes();
ui->timeHistogram->replot(); 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 else
{ {
@@ -726,6 +744,24 @@ void FrameInfoWindow::saveDetails()
} }
} }
void FrameInfoWindow::changeGraphVisibility(int state){
QCheckBox *sender = qobject_cast<QCheckBox *>(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) void FrameInfoWindow::dumpNode(QTreeWidgetItem* item, QFile *file, int indent)
{ {
for (int i = 0; i < indent; i++) file->write("\t"); for (int i = 0; i < indent; i++) file->write("\t");
+5
View File
@@ -9,6 +9,8 @@
#include "bus_protocols/j1939_handler.h" #include "bus_protocols/j1939_handler.h"
#include "dbc/dbchandler.h" #include "dbc/dbchandler.h"
#include "qcustomplot.h"
namespace Ui { namespace Ui {
class FrameInfoWindow; class FrameInfoWindow;
} }
@@ -26,6 +28,7 @@ private slots:
void updateDetailsWindow(QString); void updateDetailsWindow(QString);
void updatedFrames(int); void updatedFrames(int);
void saveDetails(); void saveDetails();
void changeGraphVisibility(int state);
private: private:
Ui::FrameInfoWindow *ui; Ui::FrameInfoWindow *ui;
@@ -39,6 +42,8 @@ private:
static QPen bytePens[8]; static QPen bytePens[8];
DBCHandler *dbcHandler; DBCHandler *dbcHandler;
QCPGraph *graphRef[8];
void refreshIDList(); void refreshIDList();
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
bool eventFilter(QObject *obj, QEvent *event); bool eventFilter(QObject *obj, QEvent *event);
+90 -29
View File
@@ -133,7 +133,7 @@
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<item> <item>
<widget class="QLabel" name="label_6"> <widget class="QCheckBox" name="check_0">
<property name="palette"> <property name="palette">
<palette> <palette>
<active> <active>
@@ -162,9 +162,9 @@
<colorrole role="WindowText"> <colorrole role="WindowText">
<brush brushstyle="SolidPattern"> <brush brushstyle="SolidPattern">
<color alpha="255"> <color alpha="255">
<red>190</red> <red>120</red>
<green>190</green> <green>120</green>
<blue>190</blue> <blue>120</blue>
</color> </color>
</brush> </brush>
</colorrole> </colorrole>
@@ -181,10 +181,13 @@
<property name="text"> <property name="text">
<string>0</string> <string>0</string>
</property> </property>
<property name="checked">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_5"> <widget class="QCheckBox" name="check_1">
<property name="palette"> <property name="palette">
<palette> <palette>
<active> <active>
@@ -213,9 +216,9 @@
<colorrole role="WindowText"> <colorrole role="WindowText">
<brush brushstyle="SolidPattern"> <brush brushstyle="SolidPattern">
<color alpha="255"> <color alpha="255">
<red>190</red> <red>120</red>
<green>190</green> <green>120</green>
<blue>190</blue> <blue>120</blue>
</color> </color>
</brush> </brush>
</colorrole> </colorrole>
@@ -232,10 +235,50 @@
<property name="text"> <property name="text">
<string>1</string> <string>1</string>
</property> </property>
<property name="checked">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_9"> <widget class="QCheckBox" name="check_2">
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="font"> <property name="font">
<font> <font>
<pointsize>13</pointsize> <pointsize>13</pointsize>
@@ -246,10 +289,13 @@
<property name="text"> <property name="text">
<string>2</string> <string>2</string>
</property> </property>
<property name="checked">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_10"> <widget class="QCheckBox" name="check_3">
<property name="palette"> <property name="palette">
<palette> <palette>
<active> <active>
@@ -278,9 +324,9 @@
<colorrole role="WindowText"> <colorrole role="WindowText">
<brush brushstyle="SolidPattern"> <brush brushstyle="SolidPattern">
<color alpha="255"> <color alpha="255">
<red>190</red> <red>120</red>
<green>190</green> <green>120</green>
<blue>190</blue> <blue>120</blue>
</color> </color>
</brush> </brush>
</colorrole> </colorrole>
@@ -297,10 +343,13 @@
<property name="text"> <property name="text">
<string>3</string> <string>3</string>
</property> </property>
<property name="checked">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_7"> <widget class="QCheckBox" name="check_4">
<property name="palette"> <property name="palette">
<palette> <palette>
<active> <active>
@@ -329,9 +378,9 @@
<colorrole role="WindowText"> <colorrole role="WindowText">
<brush brushstyle="SolidPattern"> <brush brushstyle="SolidPattern">
<color alpha="255"> <color alpha="255">
<red>190</red> <red>120</red>
<green>190</green> <green>120</green>
<blue>190</blue> <blue>120</blue>
</color> </color>
</brush> </brush>
</colorrole> </colorrole>
@@ -348,10 +397,13 @@
<property name="text"> <property name="text">
<string>4</string> <string>4</string>
</property> </property>
<property name="checked">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_4"> <widget class="QCheckBox" name="check_5">
<property name="palette"> <property name="palette">
<palette> <palette>
<active> <active>
@@ -380,9 +432,9 @@
<colorrole role="WindowText"> <colorrole role="WindowText">
<brush brushstyle="SolidPattern"> <brush brushstyle="SolidPattern">
<color alpha="255"> <color alpha="255">
<red>190</red> <red>120</red>
<green>190</green> <green>120</green>
<blue>190</blue> <blue>120</blue>
</color> </color>
</brush> </brush>
</colorrole> </colorrole>
@@ -399,10 +451,13 @@
<property name="text"> <property name="text">
<string>5</string> <string>5</string>
</property> </property>
<property name="checked">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_11"> <widget class="QCheckBox" name="check_6">
<property name="palette"> <property name="palette">
<palette> <palette>
<active> <active>
@@ -431,9 +486,9 @@
<colorrole role="WindowText"> <colorrole role="WindowText">
<brush brushstyle="SolidPattern"> <brush brushstyle="SolidPattern">
<color alpha="255"> <color alpha="255">
<red>190</red> <red>120</red>
<green>190</green> <green>120</green>
<blue>190</blue> <blue>120</blue>
</color> </color>
</brush> </brush>
</colorrole> </colorrole>
@@ -450,10 +505,13 @@
<property name="text"> <property name="text">
<string>6</string> <string>6</string>
</property> </property>
<property name="checked">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_8"> <widget class="QCheckBox" name="check_7">
<property name="palette"> <property name="palette">
<palette> <palette>
<active> <active>
@@ -482,9 +540,9 @@
<colorrole role="WindowText"> <colorrole role="WindowText">
<brush brushstyle="SolidPattern"> <brush brushstyle="SolidPattern">
<color alpha="255"> <color alpha="255">
<red>190</red> <red>120</red>
<green>190</green> <green>120</green>
<blue>190</blue> <blue>120</blue>
</color> </color>
</brush> </brush>
</colorrole> </colorrole>
@@ -501,6 +559,9 @@
<property name="text"> <property name="text">
<string>7</string> <string>7</string>
</property> </property>
<property name="checked">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>