From 223cfd2c348aa3d7b7aac3455fb845dd14447405 Mon Sep 17 00:00:00 2001 From: DevTekVE Date: Tue, 23 Jul 2024 09:54:30 +0200 Subject: [PATCH] Refactor map helper includes for SunnyPilot This update refactors the inclusion of map helper files in various source files for compatibility with SunnyPilot. This involves changes like replacing "#include selfdrive/ui/qt/maps/map_helpers.h" with "#include selfdrive/ui/sunnypilot/qt/maps/sp_priv_map_helpers.h". Added logging information in "sp_priv_onroad_home.cc" to debug the creation of map widgets. This refactoring is necessary to support map related functionalities in the SunnyPilot environment. --- selfdrive/navd/main.cc | 4 ++++ selfdrive/ui/qt/maps/map.cc | 3 ++- selfdrive/ui/qt/maps/map_eta.cc | 3 ++- selfdrive/ui/qt/maps/map_helpers.cc | 4 ++++ selfdrive/ui/qt/maps/map_instructions.cc | 3 ++- selfdrive/ui/qt/maps/map_panel.cc | 3 ++- selfdrive/ui/sunnypilot/qt/onroad/sp_priv_onroad_home.cc | 8 +++++++- 7 files changed, 23 insertions(+), 5 deletions(-) diff --git a/selfdrive/navd/main.cc b/selfdrive/navd/main.cc index 2e7b4d3b60..077fd6a0e5 100644 --- a/selfdrive/navd/main.cc +++ b/selfdrive/navd/main.cc @@ -6,7 +6,11 @@ #include "common/util.h" #include "selfdrive/ui/qt/util.h" +#ifdef SUNNYPILOT +#include "selfdrive/ui/sunnypilot/qt/maps/sp_priv_map_helpers.h" +#else #include "selfdrive/ui/qt/maps/map_helpers.h" +#endif #include "selfdrive/navd/map_renderer.h" #include "system/hardware/hw.h" diff --git a/selfdrive/ui/qt/maps/map.cc b/selfdrive/ui/qt/maps/map.cc index 3d1ec99947..48be94bb9d 100644 --- a/selfdrive/ui/qt/maps/map.cc +++ b/selfdrive/ui/qt/maps/map.cc @@ -6,11 +6,12 @@ #include #include "common/swaglog.h" -#include "selfdrive/ui/qt/maps/map_helpers.h" #include "selfdrive/ui/qt/util.h" #ifdef SUNNYPILOT #include "selfdrive/ui/sunnypilot/sp_priv_ui.h" +#include "selfdrive/ui/sunnypilot/qt/maps/sp_priv_map_helpers.h" #else +#include "selfdrive/ui/qt/maps/map_helpers.h" #include "selfdrive/ui/ui.h" #endif diff --git a/selfdrive/ui/qt/maps/map_eta.cc b/selfdrive/ui/qt/maps/map_eta.cc index 868c6ca550..335a44fdad 100644 --- a/selfdrive/ui/qt/maps/map_eta.cc +++ b/selfdrive/ui/qt/maps/map_eta.cc @@ -3,11 +3,12 @@ #include #include -#include "selfdrive/ui/qt/maps/map_helpers.h" #ifdef SUNNYPILOT #include "selfdrive/ui/sunnypilot/sp_priv_ui.h" +#include "selfdrive/ui/sunnypilot/qt/maps/sp_priv_map_helpers.h" #else #include "selfdrive/ui/ui.h" +#include "selfdrive/ui/qt/maps/map_helpers.h" #endif const float MANEUVER_TRANSITION_THRESHOLD = 10; diff --git a/selfdrive/ui/qt/maps/map_helpers.cc b/selfdrive/ui/qt/maps/map_helpers.cc index 50e1401164..a62c1cbfdf 100644 --- a/selfdrive/ui/qt/maps/map_helpers.cc +++ b/selfdrive/ui/qt/maps/map_helpers.cc @@ -1,4 +1,8 @@ +#ifdef SUNNYPILOT +#include "selfdrive/ui/sunnypilot/qt/maps/sp_priv_map_helpers.h" +#else #include "selfdrive/ui/qt/maps/map_helpers.h" +#endif #include #include diff --git a/selfdrive/ui/qt/maps/map_instructions.cc b/selfdrive/ui/qt/maps/map_instructions.cc index 6bfeefbafc..6c3d797080 100644 --- a/selfdrive/ui/qt/maps/map_instructions.cc +++ b/selfdrive/ui/qt/maps/map_instructions.cc @@ -3,11 +3,12 @@ #include #include -#include "selfdrive/ui/qt/maps/map_helpers.h" #ifdef SUNNYPILOT #include "selfdrive/ui/sunnypilot/sp_priv_ui.h" +#include "selfdrive/ui/sunnypilot/qt/maps/sp_priv_map_helpers.h" #else #include "selfdrive/ui/ui.h" +#include "selfdrive/ui/qt/maps/map_helpers.h" #endif const QString ICON_SUFFIX = ".png"; diff --git a/selfdrive/ui/qt/maps/map_panel.cc b/selfdrive/ui/qt/maps/map_panel.cc index 75dc85b01e..66ad95e185 100644 --- a/selfdrive/ui/qt/maps/map_panel.cc +++ b/selfdrive/ui/qt/maps/map_panel.cc @@ -3,13 +3,14 @@ #include #include -#include "selfdrive/ui/qt/maps/map.h" #include "selfdrive/ui/qt/maps/map_settings.h" #include "selfdrive/ui/qt/util.h" #ifdef SUNNYPILOT #include "selfdrive/ui/sunnypilot/sp_priv_ui.h" +#include "selfdrive/ui/sunnypilot/qt/maps/sp_priv_map.h" #else #include "selfdrive/ui/ui.h" +#include "selfdrive/ui/qt/maps/map.h" #endif MapPanel::MapPanel(const QMapLibre::Settings &mapboxSettings, QWidget *parent) : QFrame(parent) { diff --git a/selfdrive/ui/sunnypilot/qt/onroad/sp_priv_onroad_home.cc b/selfdrive/ui/sunnypilot/qt/onroad/sp_priv_onroad_home.cc index a39906e983..bde287399d 100644 --- a/selfdrive/ui/sunnypilot/qt/onroad/sp_priv_onroad_home.cc +++ b/selfdrive/ui/sunnypilot/qt/onroad/sp_priv_onroad_home.cc @@ -4,13 +4,15 @@ #include #ifdef ENABLE_MAPS -#include "selfdrive/ui/qt/maps/map_helpers.h" +#include "selfdrive/ui/sunnypilot/qt/maps/sp_priv_map_helpers.h" #include "selfdrive/ui/qt/maps/map_panel.h" #endif #ifdef SUNNYPILOT #include "selfdrive/ui/sunnypilot/qt/onroad/sp_priv_onroad_settings_panel.h" #endif +#include + #include "selfdrive/ui/qt/util.h" OnroadWindowSP::OnroadWindowSP(QWidget *parent) : OnroadWindow(parent) { // QObject::disconnect(uiState(), &UIState::uiUpdate, this, &OnroadWindow::updateState); @@ -64,6 +66,7 @@ void OnroadWindowSP::mousePressEvent(QMouseEvent* e) { void OnroadWindowSP::createMapWidget() { #ifdef ENABLE_MAPS + LOGD("Creating map widget"); auto m = new MapPanel(get_mapbox_settings()); map = m; @@ -101,9 +104,12 @@ void OnroadWindowSP::offroadTransition(bool offroad) { if (!offroad) { #ifdef ENABLE_MAPS + LOGD("We'd like to create the map widget, the condition is map is [%s] and hasPrime is [%s] and MAPBOX_TOKEN is [%s]", map == nullptr ? "null" : "not null", uiStateSP()->hasPrime() ? "true" : "false", MAPBOX_TOKEN.isEmpty() ? "empty" : "not empty"); if (map == nullptr && (uiStateSP()->hasPrime() || !MAPBOX_TOKEN.isEmpty())) { createMapWidget(); } +#else + LOGD("Maps are disabled"); #endif if (onroad_settings == nullptr) { createOnroadSettingsWidget();