Skip to content

Commit 5e7ac12

Browse files
committed
Fix bugs in bisector window, add bus number as a bisecting option,
allow upper/lower radio buttons to switch text for more clarify as to what they do.
1 parent 76b9737 commit 5e7ac12

File tree

3 files changed

+73
-3
lines changed

3 files changed

+73
-3
lines changed

bisectwindow.cpp

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@ BisectWindow::BisectWindow(const QVector<CANFrame> *frames, QWidget *parent) :
2525
connect(ui->slidePercentage, &QSlider::sliderReleased, this, &BisectWindow::updatePercentText);
2626
connect(ui->editFrameNumber, &QLineEdit::editingFinished, this, &BisectWindow::updateFrameNumSlider);
2727
connect(ui->editPercentage, &QLineEdit::editingFinished, this, &BisectWindow::updatePercentSlider);
28+
connect(ui->rbFrameNumber, &QRadioButton::toggled, this, &BisectWindow::updateSectionsText);
29+
connect(ui->rbPercentage, &QRadioButton::toggled, this, &BisectWindow::updateSectionsText);
30+
connect(ui->rbBusNum, &QRadioButton::toggled, this, &BisectWindow::updateSectionsText);
31+
connect(ui->rbIDRange, &QRadioButton::toggled, this, &BisectWindow::updateSectionsText);
32+
2833
installEventFilter(this);
34+
35+
updateSectionsText();
2936
}
3037

3138
BisectWindow::~BisectWindow()
@@ -61,6 +68,31 @@ bool BisectWindow::eventFilter(QObject *obj, QEvent *event)
6168
return false;
6269
}
6370

71+
void BisectWindow::updateSectionsText()
72+
{
73+
if (ui->rbBusNum->isChecked())
74+
{
75+
ui->rbLowerSection->setText("Only this bus");
76+
ui->rbUpperSection->setText("Not this bus");
77+
}
78+
if (ui->rbFrameNumber->isChecked())
79+
{
80+
ui->rbLowerSection->setText("Up to this frame number");
81+
ui->rbUpperSection->setText("After this frame number");
82+
}
83+
if (ui->rbIDRange->isChecked())
84+
{
85+
ui->rbLowerSection->setText("Inside the ID range");
86+
ui->rbUpperSection->setText("Outside the ID range");
87+
}
88+
if (ui->rbPercentage->isChecked())
89+
{
90+
ui->rbLowerSection->setText("Up to this percentage into the file");
91+
ui->rbUpperSection->setText("After this percentage into the file");
92+
}
93+
94+
}
95+
6496
void BisectWindow::refreshIDList()
6597
{
6698
int id;
@@ -112,11 +144,12 @@ void BisectWindow::handleCalculateButton()
112144
{
113145
splitFrames.clear();
114146
bool saveLower = ui->rbLowerSection->isChecked();
115-
int targetFrameNum;
147+
int targetFrameNum = 0;
116148
if (ui->rbFrameNumber->isChecked() || ui->rbPercentage->isChecked())
117149
{
118150
if (ui->rbFrameNumber->isChecked()) targetFrameNum = ui->slideFrameNumber->value();
119-
else targetFrameNum = modelFrames->count() * ui->slidePercentage->value() / 10000;
151+
else targetFrameNum = modelFrames->count() * (ui->slidePercentage->value() / 10000.0);
152+
qDebug() << "Target frame num " << targetFrameNum;
120153
if (saveLower)
121154
{
122155
for (int i = 0; i < targetFrameNum; i++) splitFrames.append(modelFrames->at(i));
@@ -132,7 +165,29 @@ void BisectWindow::handleCalculateButton()
132165
uint32_t upperID = Utility::ParseStringToNum2(ui->cbIDUpper->currentText());
133166
for (int i = 0; i < modelFrames->count(); i++)
134167
{
135-
if (modelFrames->at(i).frameId() >= lowerID && modelFrames->at(i).frameId() <= upperID) splitFrames.append(modelFrames->at(i));
168+
if (modelFrames->at(i).frameId() >= lowerID && modelFrames->at(i).frameId() <= upperID)
169+
{
170+
if (saveLower) splitFrames.append(modelFrames->at(i));
171+
}
172+
else
173+
{
174+
if (!saveLower) splitFrames.append(modelFrames->at(i));
175+
}
176+
}
177+
}
178+
else if (ui->rbBusNum->isChecked())
179+
{
180+
int targetBus = Utility::ParseStringToNum(ui->editBusNum->text());
181+
for (int i = 0; i < modelFrames->count(); i++)
182+
{
183+
if (modelFrames->at(i).bus == targetBus)
184+
{
185+
if (saveLower) splitFrames.append(modelFrames->at(i));
186+
}
187+
else
188+
{
189+
if (!saveLower) splitFrames.append(modelFrames->at(i));
190+
}
136191
}
137192
}
138193
refreshFrameNumbers();

bisectwindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ private slots:
3030
void updatePercentSlider();
3131
void updateFrameNumText();
3232
void updatePercentText();
33+
void updateSectionsText();
3334

3435
private:
3536
Ui::BisectWindow *ui;

ui/bisectwindow.ui

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,20 @@
107107
</item>
108108
</layout>
109109
</item>
110+
<item>
111+
<layout class="QHBoxLayout" name="horizontalLayout_2">
112+
<item>
113+
<widget class="QRadioButton" name="rbBusNum">
114+
<property name="text">
115+
<string>Bus Number</string>
116+
</property>
117+
</widget>
118+
</item>
119+
<item>
120+
<widget class="QLineEdit" name="editBusNum"/>
121+
</item>
122+
</layout>
123+
</item>
110124
</layout>
111125
</widget>
112126
</item>

0 commit comments

Comments
 (0)