@@ -25,7 +25,14 @@ BisectWindow::BisectWindow(const QVector<CANFrame> *frames, QWidget *parent) :
25
25
connect (ui->slidePercentage , &QSlider::sliderReleased, this , &BisectWindow::updatePercentText);
26
26
connect (ui->editFrameNumber , &QLineEdit::editingFinished, this , &BisectWindow::updateFrameNumSlider);
27
27
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
+
28
33
installEventFilter (this );
34
+
35
+ updateSectionsText ();
29
36
}
30
37
31
38
BisectWindow::~BisectWindow ()
@@ -61,6 +68,31 @@ bool BisectWindow::eventFilter(QObject *obj, QEvent *event)
61
68
return false ;
62
69
}
63
70
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
+
64
96
void BisectWindow::refreshIDList ()
65
97
{
66
98
int id;
@@ -112,11 +144,12 @@ void BisectWindow::handleCalculateButton()
112
144
{
113
145
splitFrames.clear ();
114
146
bool saveLower = ui->rbLowerSection ->isChecked ();
115
- int targetFrameNum;
147
+ int targetFrameNum = 0 ;
116
148
if (ui->rbFrameNumber ->isChecked () || ui->rbPercentage ->isChecked ())
117
149
{
118
150
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;
120
153
if (saveLower)
121
154
{
122
155
for (int i = 0 ; i < targetFrameNum; i++) splitFrames.append (modelFrames->at (i));
@@ -132,7 +165,29 @@ void BisectWindow::handleCalculateButton()
132
165
uint32_t upperID = Utility::ParseStringToNum2 (ui->cbIDUpper ->currentText ());
133
166
for (int i = 0 ; i < modelFrames->count (); i++)
134
167
{
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
+ }
136
191
}
137
192
}
138
193
refreshFrameNumbers ();
0 commit comments