Merge pull request #433 from viktorgino/ui-fixes

Misc UI additions
This commit is contained in:
Collin Kidder
2021-11-28 12:40:09 -05:00
committed by GitHub
9 changed files with 817 additions and 382 deletions
+60 -2
View File
@@ -104,6 +104,19 @@ FlowViewWindow::FlowViewWindow(const QVector<CANFrame> *frames, QWidget *parent)
connect(ui->txtTrigger5, SIGNAL(textEdited(QString)), this, SLOT(updateTriggerValues()));
connect(ui->txtTrigger6, SIGNAL(textEdited(QString)), this, SLOT(updateTriggerValues()));
connect(ui->txtTrigger7, SIGNAL(textEdited(QString)), this, SLOT(updateTriggerValues()));
connect(ui->graphRangeSlider, &QSlider::valueChanged, this, &FlowViewWindow::graphRangeChanged);
connect(ui->check_0, &QCheckBox::stateChanged, this, &FlowViewWindow::changeGraphVisibility);
connect(ui->check_1, &QCheckBox::stateChanged, this, &FlowViewWindow::changeGraphVisibility);
connect(ui->check_2, &QCheckBox::stateChanged, this, &FlowViewWindow::changeGraphVisibility);
connect(ui->check_3, &QCheckBox::stateChanged, this, &FlowViewWindow::changeGraphVisibility);
connect(ui->check_4, &QCheckBox::stateChanged, this, &FlowViewWindow::changeGraphVisibility);
connect(ui->check_5, &QCheckBox::stateChanged, this, &FlowViewWindow::changeGraphVisibility);
connect(ui->check_6, &QCheckBox::stateChanged, this, &FlowViewWindow::changeGraphVisibility);
connect(ui->check_7, &QCheckBox::stateChanged, this, &FlowViewWindow::changeGraphVisibility);
// ui->timelineSlider->setTracking(true);
connect(ui->timelineSlider, &QSlider::sliderPressed, this, &FlowViewWindow::btnPauseClick);
connect(ui->timelineSlider, &QSlider::valueChanged, this, &FlowViewWindow::gotoFrame);
// Using lambda expression to strip away the possible filter label before passing the ID to updateDetailsWindow
connect(ui->listFrameID, &QListWidget::currentTextChanged,
@@ -234,6 +247,21 @@ bool FlowViewWindow::eventFilter(QObject *obj, QEvent *event)
}
}
void FlowViewWindow::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);
}
}
ui->graphView->replot();
}
}
void FlowViewWindow::gotCellClick(int x, int y)
{
int bitnum = (7-x) + (8 * y);
@@ -243,6 +271,11 @@ void FlowViewWindow::gotCellClick(int x, int y)
qDebug() << "Bit Num: " << bitnum << " Hex of trigger bits: " << QString::number(triggerBits, 16);
}
void FlowViewWindow::graphRangeChanged(int range) {
ui->rangeValue->setText(QString::number(range));
updateGraphLocation();
}
void FlowViewWindow::updateTriggerValues()
{
triggerValues[0] = Utility::ParseStringToNum(ui->txtTrigger0->text());
@@ -623,10 +656,19 @@ void FlowViewWindow::changeID(QString newID)
memcpy(refBytes, currBytes, 8);
updateDataView();
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);
}
void FlowViewWindow::btnBackOneClick()
{
ui->cbLiveMode->setChecked(false);
playbackTimer->stop(); //pushing this button halts automatic playback
playbackActive = false;
@@ -636,6 +678,7 @@ void FlowViewWindow::btnBackOneClick()
void FlowViewWindow::btnPauseClick()
{
ui->cbLiveMode->setChecked(false);
playbackActive = false;
playbackTimer->stop();
updateDataView();
@@ -643,6 +686,7 @@ void FlowViewWindow::btnPauseClick()
void FlowViewWindow::btnReverseClick()
{
ui->cbLiveMode->setChecked(false);
playbackActive = true;
playbackForward = false;
playbackTimer->start();
@@ -650,6 +694,7 @@ void FlowViewWindow::btnReverseClick()
void FlowViewWindow::btnStopClick()
{
ui->cbLiveMode->setChecked(false);
playbackTimer->stop(); //pushing this button halts automatic playback
playbackActive = false;
currentPosition = 0;
@@ -664,6 +709,7 @@ void FlowViewWindow::btnStopClick()
void FlowViewWindow::btnPlayClick()
{
ui->cbLiveMode->setChecked(false);
playbackActive = true;
playbackForward = true;
playbackTimer->start();
@@ -671,6 +717,7 @@ void FlowViewWindow::btnPlayClick()
void FlowViewWindow::btnFwdOneClick()
{
ui->cbLiveMode->setChecked(false);
playbackTimer->stop();
playbackActive = false;
updatePosition(true);
@@ -736,6 +783,9 @@ void FlowViewWindow::updateDataView()
ui->flowView->setReference(refBytes, false);
ui->flowView->updateData(currBytes, true);
ui->timelineSlider->setMaximum(frameCache.count() - 1);
ui->timelineSlider->setValue(currentPosition);
for (int i = 0; i < 8; i++)
{
if (currBytes[i] == triggerValues[i])
@@ -752,6 +802,13 @@ void FlowViewWindow::updateDataView()
}
void FlowViewWindow::gotoFrame(int frame) {
if (frameCache.count() >= frame) currentPosition = frame;
else currentPosition = 0;
if (ui->cbSync->checkState() == Qt::Checked) emit sendCenterTimeID(frameCache[currentPosition].frameId(), frameCache[currentPosition].timeStamp().microSeconds() / 1000000.0);
}
void FlowViewWindow::updatePosition(bool forward)
{
@@ -795,14 +852,15 @@ void FlowViewWindow::updatePosition(bool forward)
memcpy(currBytes, frameCache.at(currentPosition).payload().constData(), 8);
if (ui->cbSync->checkState() == Qt::Checked) emit sendCenterTimeID(frameCache[currentPosition].frameId(), frameCache[currentPosition].timeStamp().microSeconds() / 1000000.0);
ui->timelineSlider->setValue(currentPosition);
}
void FlowViewWindow::updateGraphLocation()
{
if (frameCache.count() == 0) return;
int start = currentPosition - 5;
int start = currentPosition - ui->graphRangeSlider->value();
if (start < 0) start = 0;
int end = currentPosition + 5;
int end = currentPosition + ui->graphRangeSlider->value();
if (end >= frameCache.count()) end = frameCache.count() - 1;
if (ui->cbTimeGraph->isChecked())
{
+5
View File
@@ -2,6 +2,8 @@
#define FLOWVIEWWINDOW_H
#include <QDialog>
#include <QLocale>
#include <QSlider>
#include "qcustomplot.h"
#include "can_structs.h"
@@ -38,6 +40,8 @@ private slots:
void gotCenterTimeID(int32_t ID, double timestamp);
void updateTriggerValues();
void gotCellClick(int x, int y);
void graphRangeChanged(int range);
void changeGraphVisibility(int state);
signals:
void sendCenterTimeID(uint32_t ID, double timestamp);
@@ -65,6 +69,7 @@ private:
void refreshIDList();
void updateFrameLabel();
void updatePosition(bool forward);
void gotoFrame(int frame);
void updateDataView();
void removeAllGraphs();
void createGraph(int);
+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(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<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)
{
for (int i = 0; i < indent; i++) file->write("\t");
+5
View File
@@ -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);
+5 -1
View File
@@ -65,8 +65,10 @@ QVariant SnifferModel::data(const QModelIndex &index, int role) const
{
case tc::DELTA:
return QString::number(item->getDelta(), 'f');
case tc::FREQUENCY:
return QString("%1 hz").arg(qRound(1.00 / item->getDelta()));
case tc::ID:
return QString("%1").arg(item->getId(), 5, 16, QLatin1Char(' ')).toUpper();
return "0x" + QString("%1").arg(item->getId(), 5, 16, QLatin1Char(' ')).toUpper();
default:
break;
}
@@ -148,6 +150,8 @@ QVariant SnifferModel::headerData(int section, Qt::Orientation orientation, int
{
case tc::DELTA:
return QString("Delta");
case tc::FREQUENCY:
return QString("Frequency");
case tc::ID:
return QString("ID");
default:
+20 -18
View File
@@ -82,15 +82,16 @@ void SnifferWindow::readSettings()
resize(settings.value("Sniffer/WindowSize", QSize(1100, 750)).toSize());
move(Utility::constrainedWindowPos(settings.value("Sniffer/WindowPos", QPoint(50, 50)).toPoint()));
ui->treeView->setColumnWidth(0, settings.value("Sniffer/DeltaColumn", 110).toUInt());
ui->treeView->setColumnWidth(1, settings.value("Sniffer/IDColumn", 70).toUInt());
ui->treeView->setColumnWidth(2, settings.value("Sniffer/Data0Column", 92).toUInt());
ui->treeView->setColumnWidth(3, settings.value("Sniffer/Data1Column", 92).toUInt());
ui->treeView->setColumnWidth(4, settings.value("Sniffer/Data2Column", 92).toUInt());
ui->treeView->setColumnWidth(5, settings.value("Sniffer/Data3Column", 92).toUInt());
ui->treeView->setColumnWidth(6, settings.value("Sniffer/Data4Column", 92).toUInt());
ui->treeView->setColumnWidth(7, settings.value("Sniffer/Data5Column", 92).toUInt());
ui->treeView->setColumnWidth(8, settings.value("Sniffer/Data6Column", 92).toUInt());
ui->treeView->setColumnWidth(9, settings.value("Sniffer/Data7Column", 92).toUInt());
ui->treeView->setColumnWidth(1, settings.value("Sniffer/FrequencyColumn", 110).toUInt());
ui->treeView->setColumnWidth(2, settings.value("Sniffer/IDColumn", 70).toUInt());
ui->treeView->setColumnWidth(3, settings.value("Sniffer/Data0Column", 92).toUInt());
ui->treeView->setColumnWidth(4, settings.value("Sniffer/Data1Column", 92).toUInt());
ui->treeView->setColumnWidth(5, settings.value("Sniffer/Data2Column", 92).toUInt());
ui->treeView->setColumnWidth(6, settings.value("Sniffer/Data3Column", 92).toUInt());
ui->treeView->setColumnWidth(7, settings.value("Sniffer/Data4Column", 92).toUInt());
ui->treeView->setColumnWidth(8, settings.value("Sniffer/Data5Column", 92).toUInt());
ui->treeView->setColumnWidth(9, settings.value("Sniffer/Data6Column", 92).toUInt());
ui->treeView->setColumnWidth(10, settings.value("Sniffer/Data7Column", 92).toUInt());
}
}
@@ -103,15 +104,16 @@ void SnifferWindow::writeSettings()
settings.setValue("Sniffer/WindowSize", size());
settings.setValue("Sniffer/WindowPos", pos());
settings.setValue("Sniffer/DeltaColumn", ui->treeView->columnWidth(0));
settings.setValue("Sniffer/IDColumn", ui->treeView->columnWidth(1));
settings.setValue("Sniffer/Data0Column", ui->treeView->columnWidth(2));
settings.setValue("Sniffer/Data1Column", ui->treeView->columnWidth(3));
settings.setValue("Sniffer/Data2Column", ui->treeView->columnWidth(4));
settings.setValue("Sniffer/Data3Column", ui->treeView->columnWidth(5));
settings.setValue("Sniffer/Data4Column", ui->treeView->columnWidth(6));
settings.setValue("Sniffer/Data5Column", ui->treeView->columnWidth(7));
settings.setValue("Sniffer/Data6Column", ui->treeView->columnWidth(8));
settings.setValue("Sniffer/Data7Column", ui->treeView->columnWidth(9));
settings.setValue("Sniffer/FrequencyColumn", ui->treeView->columnWidth(1));
settings.setValue("Sniffer/IDColumn", ui->treeView->columnWidth(2));
settings.setValue("Sniffer/Data0Column", ui->treeView->columnWidth(3));
settings.setValue("Sniffer/Data1Column", ui->treeView->columnWidth(4));
settings.setValue("Sniffer/Data2Column", ui->treeView->columnWidth(5));
settings.setValue("Sniffer/Data3Column", ui->treeView->columnWidth(6));
settings.setValue("Sniffer/Data4Column", ui->treeView->columnWidth(7));
settings.setValue("Sniffer/Data5Column", ui->treeView->columnWidth(8));
settings.setValue("Sniffer/Data6Column", ui->treeView->columnWidth(9));
settings.setValue("Sniffer/Data7Column", ui->treeView->columnWidth(10));
}
}
+1
View File
@@ -13,6 +13,7 @@ class snifferWindow;
enum tc
{
DELTA = 0,
FREQUENCY,
ID,
DATA_0,
DATA_1,
+594 -331
View File
File diff suppressed because it is too large Load Diff
+90 -29
View File
@@ -133,7 +133,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_6">
<widget class="QCheckBox" name="check_0">
<property name="palette">
<palette>
<active>
@@ -162,9 +162,9 @@
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>190</red>
<green>190</green>
<blue>190</blue>
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
@@ -181,10 +181,13 @@
<property name="text">
<string>0</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<widget class="QCheckBox" name="check_1">
<property name="palette">
<palette>
<active>
@@ -213,9 +216,9 @@
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>190</red>
<green>190</green>
<blue>190</blue>
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
@@ -232,10 +235,50 @@
<property name="text">
<string>1</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</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">
<font>
<pointsize>13</pointsize>
@@ -246,10 +289,13 @@
<property name="text">
<string>2</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_10">
<widget class="QCheckBox" name="check_3">
<property name="palette">
<palette>
<active>
@@ -278,9 +324,9 @@
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>190</red>
<green>190</green>
<blue>190</blue>
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
@@ -297,10 +343,13 @@
<property name="text">
<string>3</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_7">
<widget class="QCheckBox" name="check_4">
<property name="palette">
<palette>
<active>
@@ -329,9 +378,9 @@
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>190</red>
<green>190</green>
<blue>190</blue>
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
@@ -348,10 +397,13 @@
<property name="text">
<string>4</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<widget class="QCheckBox" name="check_5">
<property name="palette">
<palette>
<active>
@@ -380,9 +432,9 @@
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>190</red>
<green>190</green>
<blue>190</blue>
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
@@ -399,10 +451,13 @@
<property name="text">
<string>5</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_11">
<widget class="QCheckBox" name="check_6">
<property name="palette">
<palette>
<active>
@@ -431,9 +486,9 @@
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>190</red>
<green>190</green>
<blue>190</blue>
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
@@ -450,10 +505,13 @@
<property name="text">
<string>6</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_8">
<widget class="QCheckBox" name="check_7">
<property name="palette">
<palette>
<active>
@@ -482,9 +540,9 @@
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>190</red>
<green>190</green>
<blue>190</blue>
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
@@ -501,6 +559,9 @@
<property name="text">
<string>7</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>