diff --git a/selfdrive/ui/qt/maps/map.cc b/selfdrive/ui/qt/maps/map.cc index ecb5c122ae..7bee7f7ca5 100644 --- a/selfdrive/ui/qt/maps/map.cc +++ b/selfdrive/ui/qt/maps/map.cc @@ -4,6 +4,7 @@ #include #include +#include #include "selfdrive/common/swaglog.h" #include "selfdrive/ui/ui.h" @@ -21,6 +22,8 @@ const float MAX_PITCH = 50; const float MIN_PITCH = 0; const float MAP_SCALE = 2; +const QString ICON_SUFFIX = ".png"; + MapWindow::MapWindow(const QMapboxGLSettings &settings) : m_settings(settings), velocity_filter(0, 10, 0.05) { sm = new SubMaster({"liveLocationKalman", "navInstruction", "navRoute"}); @@ -324,6 +327,7 @@ void MapWindow::offroadTransition(bool offroad) { } MapInstructions::MapInstructions(QWidget * parent) : QWidget(parent) { + is_rhd = Params().getBool("IsRHD"); QHBoxLayout *main_layout = new QHBoxLayout(this); main_layout->setContentsMargins(11, 50, 11, 11); { @@ -442,10 +446,22 @@ void MapInstructions::updateInstructions(cereal::NavInstruction::Reader instruct if (!modifier.isEmpty()) { fn += "_" + modifier; } - fn += + ".png"; + fn += ICON_SUFFIX; fn = fn.replace(' ', '_'); + // for rhd, reflect direction and then flip + if (is_rhd) { + if (fn.contains("left")) { + fn.replace(QString("left"), QString("right")); + } else if (fn.contains("right")) { + fn.replace(QString("right"), QString("left")); + } + } + QPixmap pix(fn); + if (is_rhd) { + pix = pix.transformed(QTransform().scale(-1, 1)); + } icon_01->setPixmap(pix.scaledToWidth(200, Qt::SmoothTransformation)); icon_01->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); icon_01->setVisible(true); @@ -476,7 +492,7 @@ void MapInstructions::updateInstructions(cereal::NavInstruction::Reader instruct fn += "turn_straight"; } - QPixmap pix(fn + ".png"); + QPixmap pix(fn + ICON_SUFFIX); auto icon = new QLabel; int wh = active ? 125 : 75; icon->setPixmap(pix.scaled(wh, wh, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); diff --git a/selfdrive/ui/qt/maps/map.h b/selfdrive/ui/qt/maps/map.h index a5e333fdf5..b74f5bf29d 100644 --- a/selfdrive/ui/qt/maps/map.h +++ b/selfdrive/ui/qt/maps/map.h @@ -36,6 +36,7 @@ private: QWidget *lane_widget; QHBoxLayout *lane_layout; bool error = false; + bool is_rhd = false; public: MapInstructions(QWidget * parent=nullptr);