Skip to content

Commit

Permalink
Add buttons for switching graphing of all bytes on/off, make timeline…
Browse files Browse the repository at this point in the history
… sync properly
  • Loading branch information
collin80 committed Dec 3, 2024
1 parent 552da7e commit 315b697
Show file tree
Hide file tree
Showing 3 changed files with 174 additions and 118 deletions.
45 changes: 42 additions & 3 deletions re/flowviewwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ FlowViewWindow::FlowViewWindow(const QVector<CANFrame> *frames, QWidget *parent)
ui->tableBytes->setColumnWidth(4, 70);
ui->tableBytes->setColumnWidth(5, 80);

//make slider output constant updates while dragging the value around
ui->timelineSlider->setTracking(true);

connect(ui->btnBackOne, SIGNAL(clicked(bool)), this, SLOT(btnBackOneClick()));
connect(ui->btnPause, SIGNAL(clicked(bool)), this, SLOT(btnPauseClick()));
connect(ui->btnReverse, SIGNAL(clicked(bool)), this, SLOT(btnReverseClick()));
Expand All @@ -109,9 +112,10 @@ FlowViewWindow::FlowViewWindow(const QVector<CANFrame> *frames, QWidget *parent)
connect(ui->graphView, SIGNAL(plottableDoubleClick(QCPAbstractPlottable*,QMouseEvent*)), this, SLOT(plottableDoubleClick(QCPAbstractPlottable*,QMouseEvent*)));
connect(ui->tableBytes, SIGNAL(cellChanged(int,int)), this, SLOT(handleTableCellChange(int,int)));
connect(ui->graphRangeSlider, &QSlider::valueChanged, this, &FlowViewWindow::graphRangeChanged);
// ui->timelineSlider->setTracking(true);
connect(ui->timelineSlider, &QSlider::sliderPressed, this, &FlowViewWindow::btnPauseClick);
connect(ui->timelineSlider, &QSlider::valueChanged, this, &FlowViewWindow::gotoFrame);
connect(ui->btnAllGraphs, SIGNAL(clicked(bool)), this, SLOT(selectAllGraphs()));
connect(ui->btnNoGraphs, SIGNAL(clicked(bool)), this, SLOT(selectNoGraphs()));

// Using lambda expression to strip away the possible filter label before passing the ID to updateDetailsWindow
connect(ui->listFrameID, &QListWidget::currentTextChanged,
Expand Down Expand Up @@ -264,6 +268,32 @@ void FlowViewWindow::handleTableCellChange(int row, int col)
}
}

void FlowViewWindow::selectAllGraphs()
{
for (int i = 0; i < 64; i++)
{
if (graphRef[i])
{
graphRef[i]->setVisible(true);
ui->tableBytes->item(i, TABLE_BYTE::GRAPH_EN)->setCheckState(Qt::Checked);
}
}
ui->graphView->replot();
}

void FlowViewWindow::selectNoGraphs()
{
for (int i = 0; i < 64; i++)
{
if (graphRef[i])
{
graphRef[i]->setVisible(false);
ui->tableBytes->item(i, TABLE_BYTE::GRAPH_EN)->setCheckState(Qt::Unchecked);
}
}
ui->graphView->replot();
}

void FlowViewWindow::setupByteTable(int bytes)
{
inhibitChangeCallback = true;
Expand Down Expand Up @@ -833,7 +863,10 @@ 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);
processNewPosition();

updateDataView();
updateGraphLocation();
}

void FlowViewWindow::updatePosition(bool forward)
Expand All @@ -850,6 +883,13 @@ void FlowViewWindow::updatePosition(bool forward)
else if (ui->cbLoopPlayback->isChecked()) currentPosition = frameCache.count() - 1;
}

processNewPosition();

ui->timelineSlider->setValue(currentPosition);
}

void FlowViewWindow::processNewPosition()
{
if (ui->cbAutoRef->isChecked())
{
memcpy(refBytes, currBytes, 64);
Expand Down Expand Up @@ -885,7 +925,6 @@ void FlowViewWindow::updatePosition(bool forward)
memcpy(currBytes, frameCache.at(currentPosition).payload().constData(), frameCache.at(currentPosition).payload().length());

if (ui->cbSync->checkState() == Qt::Checked) emit sendCenterTimeID(frameCache[currentPosition].frameId(), frameCache[currentPosition].timeStamp().microSeconds() / 1000000.0);
ui->timelineSlider->setValue(currentPosition);
}

void FlowViewWindow::updateGraphLocation()
Expand Down
3 changes: 3 additions & 0 deletions re/flowviewwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ private slots:
void graphRangeChanged(int range);
void changeGraphVisibility(int state);
void handleTableCellChange(int row, int col);
void selectAllGraphs();
void selectNoGraphs();

signals:
void sendCenterTimeID(uint32_t ID, double timestamp);
Expand Down Expand Up @@ -80,6 +82,7 @@ private slots:
void refreshIDList();
void updateFrameLabel();
void updatePosition(bool forward);
void processNewPosition();
void gotoFrame(int frame);
void updateDataView();
void removeAllGraphs();
Expand Down
244 changes: 129 additions & 115 deletions ui/flowviewwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -17,73 +17,6 @@
<property name="sizeConstraint">
<enum>QLayout::SizeConstraint::SetNoConstraint</enum>
</property>
<item row="0" column="1">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Timeline:</string>
</property>
</widget>
</item>
<item row="2" column="2">
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,0,0,0">
<item>
<widget class="QCheckBox" name="cbAutoRef">
<property name="text">
<string>Auto Reference</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbLiveMode">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Live Mode (No Playback)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbSync">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Synchronize windows</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbTimeGraph">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Graph by timestamp</string>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout"/>
</item>
</layout>
</item>
<item row="1" column="1" colspan="3">
<widget class="QSlider" name="timelineSlider">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QVBoxLayout" name="verticalLayout" stretch="1">
<item>
Expand Down Expand Up @@ -332,7 +265,134 @@
</item>
</layout>
</item>
<item row="0" column="0" rowspan="4">
<item row="3" column="1" colspan="2">
<widget class="QTableWidget" name="tableBytes">
<property name="rowCount">
<number>0</number>
</property>
<property name="columnCount">
<number>6</number>
</property>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>30</number>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Byte</string>
</property>
</column>
<column>
<property name="text">
<string>Val</string>
</property>
</column>
<column>
<property name="text">
<string>Ref</string>
</property>
</column>
<column>
<property name="text">
<string>Seek</string>
</property>
</column>
<column>
<property name="text">
<string>Graph?</string>
</property>
</column>
<column>
<property name="text">
<string>Color</string>
</property>
</column>
</widget>
</item>
<item row="2" column="2">
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,0,0,0">
<item>
<widget class="QCheckBox" name="cbAutoRef">
<property name="text">
<string>Auto Reference</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbLiveMode">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Live Mode (No Playback)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbSync">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Synchronize windows</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbTimeGraph">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Graph by timestamp</string>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout"/>
</item>
</layout>
</item>
<item row="1" column="1" colspan="3">
<widget class="QSlider" name="timelineSlider">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Timeline:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="btnAllGraphs">
<property name="text">
<string>Select All Graphs</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QPushButton" name="btnNoGraphs">
<property name="text">
<string>Deselect All Graphs</string>
</property>
</widget>
</item>
<item row="0" column="0" rowspan="5">
<layout class="QVBoxLayout" name="verticalLayout_6" stretch="0,0">
<item>
<widget class="QLabel" name="label">
Expand Down Expand Up @@ -365,7 +425,7 @@
</item>
</layout>
</item>
<item row="2" column="3" rowspan="2">
<item row="2" column="3" rowspan="3">
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="sizeConstraint">
<enum>QLayout::SizeConstraint::SetMaximumSize</enum>
Expand Down Expand Up @@ -452,52 +512,6 @@
</item>
</layout>
</item>
<item row="3" column="1" colspan="2">
<widget class="QTableWidget" name="tableBytes">
<property name="rowCount">
<number>0</number>
</property>
<property name="columnCount">
<number>6</number>
</property>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>30</number>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Byte</string>
</property>
</column>
<column>
<property name="text">
<string>Val</string>
</property>
</column>
<column>
<property name="text">
<string>Ref</string>
</property>
</column>
<column>
<property name="text">
<string>Seek</string>
</property>
</column>
<column>
<property name="text">
<string>Graph?</string>
</property>
</column>
<column>
<property name="text">
<string>Color</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<customwidgets>
Expand Down

0 comments on commit 315b697

Please sign in to comment.