Skip to content

Commit

Permalink
Fix bugs in bisector window, add bus number as a bisecting option,
Browse files Browse the repository at this point in the history
allow upper/lower radio buttons to switch text for more clarify as to
what they do.
  • Loading branch information
collin80 committed Nov 30, 2022
1 parent 76b9737 commit 5e7ac12
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 3 deletions.
61 changes: 58 additions & 3 deletions bisectwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ BisectWindow::BisectWindow(const QVector<CANFrame> *frames, QWidget *parent) :
connect(ui->slidePercentage, &QSlider::sliderReleased, this, &BisectWindow::updatePercentText);
connect(ui->editFrameNumber, &QLineEdit::editingFinished, this, &BisectWindow::updateFrameNumSlider);
connect(ui->editPercentage, &QLineEdit::editingFinished, this, &BisectWindow::updatePercentSlider);
connect(ui->rbFrameNumber, &QRadioButton::toggled, this, &BisectWindow::updateSectionsText);
connect(ui->rbPercentage, &QRadioButton::toggled, this, &BisectWindow::updateSectionsText);
connect(ui->rbBusNum, &QRadioButton::toggled, this, &BisectWindow::updateSectionsText);
connect(ui->rbIDRange, &QRadioButton::toggled, this, &BisectWindow::updateSectionsText);

installEventFilter(this);

updateSectionsText();
}

BisectWindow::~BisectWindow()
Expand Down Expand Up @@ -61,6 +68,31 @@ bool BisectWindow::eventFilter(QObject *obj, QEvent *event)
return false;
}

void BisectWindow::updateSectionsText()
{
if (ui->rbBusNum->isChecked())
{
ui->rbLowerSection->setText("Only this bus");
ui->rbUpperSection->setText("Not this bus");
}
if (ui->rbFrameNumber->isChecked())
{
ui->rbLowerSection->setText("Up to this frame number");
ui->rbUpperSection->setText("After this frame number");
}
if (ui->rbIDRange->isChecked())
{
ui->rbLowerSection->setText("Inside the ID range");
ui->rbUpperSection->setText("Outside the ID range");
}
if (ui->rbPercentage->isChecked())
{
ui->rbLowerSection->setText("Up to this percentage into the file");
ui->rbUpperSection->setText("After this percentage into the file");
}

}

void BisectWindow::refreshIDList()
{
int id;
Expand Down Expand Up @@ -112,11 +144,12 @@ void BisectWindow::handleCalculateButton()
{
splitFrames.clear();
bool saveLower = ui->rbLowerSection->isChecked();
int targetFrameNum;
int targetFrameNum = 0;
if (ui->rbFrameNumber->isChecked() || ui->rbPercentage->isChecked())
{
if (ui->rbFrameNumber->isChecked()) targetFrameNum = ui->slideFrameNumber->value();
else targetFrameNum = modelFrames->count() * ui->slidePercentage->value() / 10000;
else targetFrameNum = modelFrames->count() * (ui->slidePercentage->value() / 10000.0);
qDebug() << "Target frame num " << targetFrameNum;
if (saveLower)
{
for (int i = 0; i < targetFrameNum; i++) splitFrames.append(modelFrames->at(i));
Expand All @@ -132,7 +165,29 @@ void BisectWindow::handleCalculateButton()
uint32_t upperID = Utility::ParseStringToNum2(ui->cbIDUpper->currentText());
for (int i = 0; i < modelFrames->count(); i++)
{
if (modelFrames->at(i).frameId() >= lowerID && modelFrames->at(i).frameId() <= upperID) splitFrames.append(modelFrames->at(i));
if (modelFrames->at(i).frameId() >= lowerID && modelFrames->at(i).frameId() <= upperID)
{
if (saveLower) splitFrames.append(modelFrames->at(i));
}
else
{
if (!saveLower) splitFrames.append(modelFrames->at(i));
}
}
}
else if (ui->rbBusNum->isChecked())
{
int targetBus = Utility::ParseStringToNum(ui->editBusNum->text());
for (int i = 0; i < modelFrames->count(); i++)
{
if (modelFrames->at(i).bus == targetBus)
{
if (saveLower) splitFrames.append(modelFrames->at(i));
}
else
{
if (!saveLower) splitFrames.append(modelFrames->at(i));
}
}
}
refreshFrameNumbers();
Expand Down
1 change: 1 addition & 0 deletions bisectwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ private slots:
void updatePercentSlider();
void updateFrameNumText();
void updatePercentText();
void updateSectionsText();

private:
Ui::BisectWindow *ui;
Expand Down
14 changes: 14 additions & 0 deletions ui/bisectwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,20 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QRadioButton" name="rbBusNum">
<property name="text">
<string>Bus Number</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="editBusNum"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>
Expand Down

0 comments on commit 5e7ac12

Please sign in to comment.