Skip to content

Commit

Permalink
Add selection of graph charts and slider to change chart range to flo…
Browse files Browse the repository at this point in the history
…w view
  • Loading branch information
viktorgino committed Nov 26, 2021
1 parent c663f26 commit 7dae14e
Show file tree
Hide file tree
Showing 3 changed files with 296 additions and 71 deletions.
41 changes: 39 additions & 2 deletions re/flowviewwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ 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);

// 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 @@ -234,6 +243,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);
Expand All @@ -243,6 +267,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());
Expand Down Expand Up @@ -623,6 +652,14 @@ 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()
Expand Down Expand Up @@ -800,9 +837,9 @@ void FlowViewWindow::updatePosition(bool forward)
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())
{
Expand Down
3 changes: 3 additions & 0 deletions re/flowviewwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define FLOWVIEWWINDOW_H

#include <QDialog>
#include <QLocale>
#include "qcustomplot.h"
#include "can_structs.h"

Expand Down Expand Up @@ -38,6 +39,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);
Expand Down
Loading

0 comments on commit 7dae14e

Please sign in to comment.