From 194e1dffd81bea8c6f46a97a4bcb47f062964795 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 4 May 2023 21:16:44 -0700 Subject: [PATCH] clean up --- selfdrive/ui/qt/onroad.cc | 55 +++------------------------------------ 1 file changed, 3 insertions(+), 52 deletions(-) diff --git a/selfdrive/ui/qt/onroad.cc b/selfdrive/ui/qt/onroad.cc index 4cc18090b9..ce2bca2be7 100644 --- a/selfdrive/ui/qt/onroad.cc +++ b/selfdrive/ui/qt/onroad.cc @@ -527,31 +527,13 @@ void AnnotatedCameraWidget::drawLaneLines(QPainter &painter, const UIState *s) { const float MAX_UI_POINTS = 8; - qDebug() << "\n"; - int i2 = 0; - while (i2 < right_points.length()) { - qDebug() << "new i:" << i2 << "len points:" << right_points.length(); - - i2 += (i2 < right_points.length() - 2) ? 2 : 1; - } - qDebug() << " "; - -// int i = 0; - -// int drawn = 0; - - - // Filter out points out of frame QVector valid_points; std::copy_if(right_points.begin(), right_points.end(), std::back_inserter(valid_points), [&](const QPointF &point) { return point.y() >= 0 && point.y() <= height(); }); qDebug() << "valid_points len:" << valid_points.length() << "right_points len:" << right_points.length(); -// float cur_pos = 0; -// while (cur_pos < ) - - int drawn2 = 0; + int drawn = 0; int final_idx = 0; if (!valid_points.isEmpty()) { for (int p = 0; p < MAX_UI_POINTS; p++) { @@ -562,7 +544,7 @@ void AnnotatedCameraWidget::drawLaneLines(QPainter &painter, const UIState *s) { const auto &acceleration = sm["uiPlan"].getUiPlan().getAccel(); if (i >= acceleration.size()) break; - drawn2 += 1; + drawn += 1; // flip so 0 is bottom of frame float lin_grad_point = (height() - valid_points[i].y()) / height(); @@ -577,43 +559,12 @@ void AnnotatedCameraWidget::drawLaneLines(QPainter &painter, const UIState *s) { float lightness = interp1d(saturation, 0.0, 1.0, 0.95, 0.62); // lighter when grey float alpha = interp1d(lin_grad_point, 0.75 / 2., 0.75, 0.4, 0.0); // matches previous alpha fade bg.setColorAt(lin_grad_point, QColor::fromHslF(path_hue / 360., saturation, lightness, alpha)); - // i += ((right_points.length() - drawn) > MAX_UI_POINTS ? fmax((right_points.length() - drawn) / MAX_UI_POINTS, 1) : 1); if (i == valid_points.length() - 1) break; } assert(final_idx == (valid_points.length() - 1)); - assert(drawn2 <= MAX_UI_POINTS); + assert(drawn <= MAX_UI_POINTS); } -// while (i < right_points.length()) { -// qDebug() << "i:" << i << "len points:" << right_points.length(); -// const auto &acceleration = sm["uiPlan"].getUiPlan().getAccel(); -// if (i >= acceleration.size()) break; -// -// // Some points are out of frame -// if (right_points[i].y() < 0 || right_points[i].y() > height()) { -// i += 1; -// qDebug() << "skipping"; -// continue; -// } -// drawn += 1; -// -// // flip so 0 is bottom of frame -// float lin_grad_point = (height() - right_points[i].y()) / height(); -// -// // speed up: 120, slow down: 0 -// float path_hue = fmax(fmin(60 + acceleration[i] * 35, 120), 0); -// // FIXME: painter.drawPolygon can be slow if hue is not rounded -// path_hue = int(path_hue * 100 + 0.5) / 100; -// -// float saturation = fmin(fabs(acceleration[i] * 1.5), 1); -// float lightness = interp1d(saturation, 0.0, 1.0, 0.95, 0.62); // lighter when grey -// float alpha = interp1d(lin_grad_point, 0.75 / 2., 0.75, 0.4, 0.0); // matches previous alpha fade -// bg.setColorAt(lin_grad_point, QColor::fromHslF(path_hue / 360., saturation, lightness, alpha)); -//// i += ((right_points.length() - drawn) > MAX_UI_POINTS ? fmax((right_points.length() - drawn) / MAX_UI_POINTS, 1) : 1); -// i += fmax((right_points.length() - drawn) / MAX_UI_POINTS, 1); -// } -// qDebug() << "total pts drawn:" << drawn; - } else { bg.setColorAt(0.0, QColor::fromHslF(148 / 360., 0.94, 0.51, 0.4)); bg.setColorAt(0.5, QColor::fromHslF(112 / 360., 1.0, 0.68, 0.35));