Add timeline slider to flow view

This commit is contained in:
Viktor Verebelyi
2021-11-26 05:24:54 +00:00
parent 907312f12d
commit c69f77630a
3 changed files with 331 additions and 230 deletions
+21
View File
@@ -114,6 +114,10 @@ FlowViewWindow::FlowViewWindow(const QVector<CANFrame> *frames, QWidget *parent)
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,
[this](QString itemText)
@@ -664,6 +668,7 @@ void FlowViewWindow::changeID(QString newID)
void FlowViewWindow::btnBackOneClick()
{
ui->cbLiveMode->setChecked(false);
playbackTimer->stop(); //pushing this button halts automatic playback
playbackActive = false;
@@ -673,6 +678,7 @@ void FlowViewWindow::btnBackOneClick()
void FlowViewWindow::btnPauseClick()
{
ui->cbLiveMode->setChecked(false);
playbackActive = false;
playbackTimer->stop();
updateDataView();
@@ -680,6 +686,7 @@ void FlowViewWindow::btnPauseClick()
void FlowViewWindow::btnReverseClick()
{
ui->cbLiveMode->setChecked(false);
playbackActive = true;
playbackForward = false;
playbackTimer->start();
@@ -687,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;
@@ -701,6 +709,7 @@ void FlowViewWindow::btnStopClick()
void FlowViewWindow::btnPlayClick()
{
ui->cbLiveMode->setChecked(false);
playbackActive = true;
playbackForward = true;
playbackTimer->start();
@@ -708,6 +717,7 @@ void FlowViewWindow::btnPlayClick()
void FlowViewWindow::btnFwdOneClick()
{
ui->cbLiveMode->setChecked(false);
playbackTimer->stop();
playbackActive = false;
updatePosition(true);
@@ -773,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])
@@ -789,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)
{
@@ -832,6 +852,7 @@ 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()
+2
View File
@@ -3,6 +3,7 @@
#include <QDialog>
#include <QLocale>
#include <QSlider>
#include "qcustomplot.h"
#include "can_structs.h"
@@ -68,6 +69,7 @@ private:
void refreshIDList();
void updateFrameLabel();
void updatePosition(bool forward);
void gotoFrame(int frame);
void updateDataView();
void removeAllGraphs();
void createGraph(int);
+308 -230
View File
@@ -6,63 +6,66 @@
<rect>
<x>0</x>
<y>0</y>
<width>1078</width>
<height>623</height>
<width>906</width>
<height>568</height>
</rect>
</property>
<property name="windowTitle">
<string>Flow View</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,1,0,200">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout_6" stretch="1,1">
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Frame IDs Found:</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="listFrameID">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>120</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
</layout>
<layout class="QGridLayout" name="gridLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<item row="1" column="1" colspan="3">
<widget class="QSlider" name="timelineSlider">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0,0">
<item row="2" column="1">
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,1,0,0,0">
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<property name="title">
<string>Playback Control</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="flat">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="btnBackOne">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
@@ -74,6 +77,18 @@
</item>
<item>
<widget class="QPushButton" name="btnStop">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
@@ -85,6 +100,18 @@
</item>
<item>
<widget class="QPushButton" name="btnForwardOne">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
@@ -100,6 +127,18 @@
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="btnReverse">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
@@ -111,6 +150,18 @@
</item>
<item>
<widget class="QPushButton" name="btnPause">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
@@ -122,6 +173,18 @@
</item>
<item>
<widget class="QPushButton" name="btnPlay">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
@@ -148,6 +211,18 @@
</item>
<item>
<widget class="QSpinBox" name="spinPlayback">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<property name="maximum">
<number>5000</number>
</property>
@@ -197,6 +272,12 @@
</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>
@@ -217,6 +298,12 @@
</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>
@@ -237,8 +324,8 @@
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item row="2" column="2">
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,0,0,0,0">
<item>
<widget class="QCheckBox" name="cbAutoRef">
<property name="text">
@@ -300,12 +387,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
@@ -328,12 +409,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
@@ -356,12 +431,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
@@ -384,12 +453,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
@@ -448,12 +511,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
@@ -470,12 +527,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
@@ -492,12 +543,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
@@ -514,12 +559,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
@@ -587,12 +626,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
@@ -609,12 +642,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
@@ -631,12 +658,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
@@ -653,12 +674,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
@@ -711,12 +726,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
@@ -733,12 +742,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
@@ -755,12 +758,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
@@ -777,12 +774,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
@@ -798,6 +789,12 @@
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Data Seek Values</string>
</property>
@@ -844,12 +841,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
@@ -1034,6 +1025,12 @@
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="check_0">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
@@ -1088,6 +1085,12 @@
</item>
<item row="0" column="3">
<widget class="QCheckBox" name="check_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
@@ -1142,6 +1145,12 @@
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="check_1">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
@@ -1196,6 +1205,12 @@
</item>
<item row="0" column="2">
<widget class="QCheckBox" name="check_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
@@ -1250,6 +1265,12 @@
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="check_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
@@ -1304,6 +1325,12 @@
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="check_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
@@ -1358,6 +1385,12 @@
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="check_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
@@ -1412,6 +1445,12 @@
</item>
<item row="1" column="3">
<widget class="QCheckBox" name="check_7">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
@@ -1468,92 +1507,131 @@
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item row="2" column="3">
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="CANDataGrid" name="flowView" native="true"/>
</item>
<item>
<widget class="QCustomPlot" name="graphView" native="true"/>
</item>
<item>
<layout class="QFormLayout" name="formLayout"/>
</item>
<item>
<widget class="QFrame" name="horizontalFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5" stretch="0,0">
<item>
<widget class="QLabel" name="label_29">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Chart range</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="rangeValue">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>50</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QSlider" name="graphRangeSlider">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>500</number>
</property>
<property name="value">
<number>50</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>10</number>
</property>
</widget>
</item>
</layout>
<widget class="CANDataGrid" name="flowView" native="true"/>
</item>
<item>
<widget class="QCustomPlot" name="graphView" native="true"/>
</item>
<item>
<layout class="QFormLayout" name="formLayout"/>
</item>
<item>
<widget class="QFrame" name="horizontalFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5" stretch="0,0">
<item>
<widget class="QLabel" name="label_29">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Chart range</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="rangeValue">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>50</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QSlider" name="graphRangeSlider">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>500</number>
</property>
<property name="value">
<number>50</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>10</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Timeline:</string>
</property>
</widget>
</item>
<item row="0" column="0" rowspan="3">
<layout class="QVBoxLayout" name="verticalLayout_6" stretch="0,0">
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Frame IDs Found:</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="listFrameID">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>120</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
</layout>
</item>