From aa34714b426f846ea05739e7c448ca666aea482c Mon Sep 17 00:00:00 2001 From: Kumar <36933347+rav4kumar@users.noreply.github.com> Date: Sat, 28 Sep 2024 19:14:48 -0700 Subject: [PATCH] ui: refactor rocket ui (#435) rockettttt --- .../sunnypilot/qt/onroad/annotated_camera.cc | 47 +++++-------------- 1 file changed, 13 insertions(+), 34 deletions(-) diff --git a/selfdrive/ui/sunnypilot/qt/onroad/annotated_camera.cc b/selfdrive/ui/sunnypilot/qt/onroad/annotated_camera.cc index 4b8d41d725..e10e1d583a 100644 --- a/selfdrive/ui/sunnypilot/qt/onroad/annotated_camera.cc +++ b/selfdrive/ui/sunnypilot/qt/onroad/annotated_camera.cc @@ -1290,46 +1290,25 @@ void AnnotatedCameraWidgetSP::drawDriverState(QPainter &painter, const UIStateSP } void AnnotatedCameraWidgetSP::rocketFuel(QPainter &p) { + UIState *s = uiState(); + float accel = (*s->sm)["carControl"].getCarControl().getActuators().getAccel(); + int widgetHeight = rect().height(); + float halfHeightAbs = std::abs(accel) * widgetHeight / 2.0f; + const float scannerWidth = 15; + QRect scannerRect; - static const int ct_n = 1; - static float ct; - - int rect_w = rect().width(); - int rect_h = rect().height(); - - const int n = 15 + 1; //Add one off screen due to timing issues - static float t[n]; - int dim_n = (sin(ct / 5) + 1) * (n - 0.01); - t[dim_n] = 1.0; - t[(int)(ct/ct_n)] = 1.0; - - UIStateSP *s = uiStateSP(); - float vc_accel0 = (*s->sm)["carState"].getCarState().getAEgo(); - static float vc_accel; - vc_accel = vc_accel + (vc_accel0 - vc_accel) / 5; - float hha = 0; - if (vc_accel > 0) { - hha = 0.85 - 0.1 / vc_accel; // only extend up to 85% + if (accel > 0) { p.setBrush(QColor(0, 245, 0, 200)); - } - if (vc_accel < 0) { - hha = 0.85 + 0.1 / vc_accel; // only extend up to 85% - p.setBrush(QColor(245, 0, 0, 200)); - } - if (hha < 0) { - hha = 0; - } - hha = hha * rect_h; - float wp = 28; - if (vc_accel > 0) { - QRect ra = QRect(rect_w - wp, rect_h / 2 - hha / 2, wp, hha / 2); - p.drawRect(ra); + scannerRect = QRect(0, widgetHeight / 2 - halfHeightAbs, scannerWidth, halfHeightAbs); } else { - QRect ra = QRect(rect_w - wp, rect_h / 2, wp, hha / 2); - p.drawRect(ra); + p.setBrush(QColor(245, 0, 0, 200)); + scannerRect = QRect(0, widgetHeight / 2, scannerWidth, halfHeightAbs); } + + p.drawRect(scannerRect); } + void AnnotatedCameraWidgetSP::drawLead(QPainter &painter, const cereal::RadarState::LeadData::Reader &lead_data, const QPointF &vd, int num, const cereal::CarState::Reader &car_data, int chevron_data) { painter.save();