From 00f797f931c97239797558595b5979da3f859c56 Mon Sep 17 00:00:00 2001 From: concordia Date: Thu, 2 May 2024 21:29:10 -0500 Subject: [PATCH] wip --- selfdrive/ui/qt/onroad.cc | 29 +++++++++++++++-------------- selfdrive/ui/ui.h | 4 ++-- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/selfdrive/ui/qt/onroad.cc b/selfdrive/ui/qt/onroad.cc index cc5a7cc..76f85e3 100644 --- a/selfdrive/ui/qt/onroad.cc +++ b/selfdrive/ui/qt/onroad.cc @@ -828,7 +828,8 @@ void AnnotatedCameraWidget::drawLaneLines(QPainter &painter, const UIState *s) { int base_red = 150; // Dark red component int base_green = 150; // Minimal green component int base_blue = 150; // Minimal blue component - float base_alpha = 0.4; // 60% opacity + float path_alpha = 0.75; // 60% opacity + float other_alpha = 0.75; // 60% opacity QColor baseColor(base_red, base_green, base_blue); @@ -886,7 +887,7 @@ void AnnotatedCameraWidget::drawLaneLines(QPainter &painter, const UIState *s) { float adjusted_lightness = util::map_val(adjusted_saturation, 0.f, 1.f, static_cast(_l), 0.95f); // Using base lightness as a starting point // Calculate dynamic alpha based on lin_grad_point - float dynamic_alpha = util::map_val(lin_grad_point, 0.75f / 2.f, 0.75f, base_alpha, 0.f); + float dynamic_alpha = util::map_val(lin_grad_point, 0.75f / 2.f, 0.75f, path_alpha, 0.f); QColor final_color = QColor::fromHslF(static_cast(_h / 360.f), adjusted_saturation, adjusted_lightness, dynamic_alpha); bg.setColorAt(lin_grad_point, final_color); @@ -895,9 +896,9 @@ void AnnotatedCameraWidget::drawLaneLines(QPainter &painter, const UIState *s) { } } else { - bg.setColorAt(0.0, QColor(baseColor.red(), baseColor.green(), baseColor.blue(), static_cast(base_alpha * 255 * 0.4))); - bg.setColorAt(0.5, QColor(baseColor.red(), baseColor.green(), baseColor.blue(), static_cast(base_alpha * 255 * 0.35))); - bg.setColorAt(1.0, QColor(baseColor.red(), baseColor.green(), baseColor.blue(), static_cast(base_alpha * 255 * 0.0))); + bg.setColorAt(0.0, QColor(baseColor.red(), baseColor.green(), baseColor.blue(), static_cast(other_alpha * 255 * 0.4))); + bg.setColorAt(0.5, QColor(baseColor.red(), baseColor.green(), baseColor.blue(), static_cast(other_alpha * 255 * 0.35))); + bg.setColorAt(1.0, QColor(baseColor.red(), baseColor.green(), baseColor.blue(), static_cast(other_alpha * 255 * 0.0))); } painter.setBrush(bg); @@ -907,14 +908,14 @@ void AnnotatedCameraWidget::drawLaneLines(QPainter &painter, const UIState *s) { QLinearGradient pe(0, height(), 0, 0); if (alwaysOnLateralActive) { QColor color = bg_colors[STATUS_ALWAYS_ON_LATERAL_ACTIVE]; - pe.setColorAt(0.0, QColor(color.red(), color.green(), color.blue(), static_cast(base_alpha * 255))); - pe.setColorAt(0.5, QColor(color.red(), color.green(), color.blue(), static_cast(base_alpha * 255 * 0.5))); - pe.setColorAt(1.0, QColor(color.red(), color.green(), color.blue(), static_cast(base_alpha * 255 * 0.1))); + pe.setColorAt(0.0, QColor(color.red(), color.green(), color.blue(), static_cast(other_alpha * 255))); + pe.setColorAt(0.5, QColor(color.red(), color.green(), color.blue(), static_cast(other_alpha * 255 * 0.5))); + pe.setColorAt(1.0, QColor(color.red(), color.green(), color.blue(), static_cast(other_alpha * 255 * 0.1))); } else if (conditionalStatus == 1 || conditionalStatus == 3 || conditionalStatus == 5 || experimentalMode) { QColor color = bg_colors[STATUS_EXPERIMENTAL_ACTIVE]; - pe.setColorAt(0.0, QColor(color.red(), color.green(), color.blue(), static_cast(base_alpha * 255))); - pe.setColorAt(0.5, QColor(color.red(), color.green(), color.blue(), static_cast(base_alpha * 255 * 0.5))); - pe.setColorAt(1.0, QColor(color.red(), color.green(), color.blue(), static_cast(base_alpha * 255 * 0.1))); + pe.setColorAt(0.0, QColor(color.red(), color.green(), color.blue(), static_cast(other_alpha * 255))); + pe.setColorAt(0.5, QColor(color.red(), color.green(), color.blue(), static_cast(other_alpha * 255 * 0.5))); + pe.setColorAt(1.0, QColor(color.red(), color.green(), color.blue(), static_cast(other_alpha * 255 * 0.1))); } else if (trafficModeActive) { pe.setColorAt(0.0, QColor::fromHslF(355 / 360., 0.71, 0.46, 1.0)); pe.setColorAt(0.5, QColor::fromHslF(355 / 360., 0.71, 0.46, 0.5)); @@ -925,9 +926,9 @@ void AnnotatedCameraWidget::drawLaneLines(QPainter &painter, const UIState *s) { pe.setColorAt(1.0, QColor::fromHslF(205 / 360., 0.85, 0.56, 0.1)); } else { QColor color = bg_colors[STATUS_ENGAGED]; - pe.setColorAt(0.0, QColor(color.red(), color.green(), color.blue(), static_cast(base_alpha * 255))); - pe.setColorAt(0.5, QColor(color.red(), color.green(), color.blue(), static_cast(base_alpha * 255 * 0.5))); - pe.setColorAt(1.0, QColor(color.red(), color.green(), color.blue(), static_cast(base_alpha * 255 * 0.1))); + pe.setColorAt(0.0, QColor(color.red(), color.green(), color.blue(), static_cast(other_alpha * 255))); + pe.setColorAt(0.5, QColor(color.red(), color.green(), color.blue(), static_cast(other_alpha * 255 * 0.5))); + pe.setColorAt(1.0, QColor(color.red(), color.green(), color.blue(), static_cast(other_alpha * 255 * 0.1))); } QPainterPath path; diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index 4420787..d9d512e 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -18,7 +18,7 @@ #include "selfdrive/ui/qt/network/wifi_manager.h" #include "system/hardware/hw.h" -const int UI_BORDER_SIZE = 30; +const int UI_BORDER_SIZE = 20; // clearpilot const int UI_HEADER_HEIGHT = 420; const int UI_FREQ = 20; // Hz @@ -26,7 +26,7 @@ const int BACKLIGHT_OFFROAD = 50; typedef cereal::CarControl::HUDControl::AudibleAlert AudibleAlert; const float MIN_DRAW_DISTANCE = 10.0; -const float MAX_DRAW_DISTANCE = 100.0; +const float MAX_DRAW_DISTANCE = 100.0; // clearpilot constexpr mat3 DEFAULT_CALIBRATION = {{ 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0 }}; constexpr mat3 FCAM_INTRINSIC_MATRIX = (mat3){{2648.0, 0.0, 1928.0 / 2, 0.0, 2648.0, 1208.0 / 2,