fix: coloring in timemodel. Fastest lap was not colored green if a not valid faster lap exists
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
// V3 STM32F07
|
||||
|
||||
#define PORT_PATH "/dev/ttyACM0"
|
||||
//#define PORT_PATH "/dev/pts/4"
|
||||
|
||||
using namespace std;
|
||||
// not needed anymore -> usb
|
||||
|
||||
@@ -80,20 +80,29 @@ QColor TimeModel::getColor(const QVector<QVector<int>> data, const int col,
|
||||
}
|
||||
|
||||
QVector<int> compare;
|
||||
if (col == 3) { // lap time
|
||||
for (int i = 0; i <= row; i++) {
|
||||
if (data.at(i).size() > col) {
|
||||
if (data.at(i).size() > col &&
|
||||
data.at(i).at(col) > this->minimumTimes.at(col) &&
|
||||
data.at(i).at(0) > this->minimumTimes.at(0) &&
|
||||
data.at(i).at(1) > this->minimumTimes.at(1) &&
|
||||
data.at(i).at(2) > this->minimumTimes.at(2)) {
|
||||
compare.append(data.at(i).at(col));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (int i = 0; i <= row; i++) {
|
||||
if (data.at(i).size() > col &&
|
||||
data.at(i).at(col) > this->minimumTimes.at(col)) {
|
||||
compare.append(data.at(i).at(col));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (data.at(row).at(col) ==
|
||||
getMin(compare)) { // at least personal best time
|
||||
if (col < 3) { // sector time
|
||||
// std::cout << this->topTime.size() <<
|
||||
// std::endl;
|
||||
if (this->topTime.size() >
|
||||
col) { // absolute top time exists
|
||||
// std::cout << "local besttime"
|
||||
// << std::endl;
|
||||
if (this->topTime.size() > col) {
|
||||
if (this->topTime.at(col) >= data.at(row).at(col)) {
|
||||
return QColor(Qt::magenta);
|
||||
}
|
||||
@@ -125,9 +134,13 @@ QColor TimeModel::getColor(const QVector<QVector<int>> data, const int col,
|
||||
|
||||
int TimeModel::getMin(const QVector<int> x) const {
|
||||
int min = 9999;
|
||||
if (x.size() > 0) {
|
||||
min = x.at(0);
|
||||
|
||||
// find first matching minimum
|
||||
for (auto i : x) {
|
||||
min = i;
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 1; i < x.size(); i++) {
|
||||
if (x.at(i) < min) {
|
||||
min = x.at(i);
|
||||
|
||||
Reference in New Issue
Block a user