|
|
|
@ -3,6 +3,7 @@ |
|
|
|
|
#include <eigen3/Eigen/Dense> |
|
|
|
|
|
|
|
|
|
#include <QDebug> |
|
|
|
|
#include <QDir> |
|
|
|
|
|
|
|
|
|
#include "common/transformations/coordinates.hpp" |
|
|
|
|
#include "selfdrive/ui/qt/maps/map_helpers.h" |
|
|
|
@ -411,6 +412,31 @@ MapInstructions::MapInstructions(QWidget *parent) : QWidget(parent) { |
|
|
|
|
pal.setColor(QPalette::Background, QColor(0, 0, 0, 150)); |
|
|
|
|
setAutoFillBackground(true); |
|
|
|
|
setPalette(pal); |
|
|
|
|
|
|
|
|
|
buildPixmapCache(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void MapInstructions::buildPixmapCache() { |
|
|
|
|
QDir dir("../assets/navigation"); |
|
|
|
|
for (QString fn : dir.entryList({"*" + ICON_SUFFIX}, QDir::Files)) { |
|
|
|
|
QPixmap pm(dir.filePath(fn)); |
|
|
|
|
QString key = fn.left(fn.size() - ICON_SUFFIX.length()); |
|
|
|
|
pm = pm.scaledToWidth(200, Qt::SmoothTransformation); |
|
|
|
|
|
|
|
|
|
// Maneuver icons
|
|
|
|
|
pixmap_cache[key] = pm; |
|
|
|
|
// lane direction icons
|
|
|
|
|
if (key.contains("turn_")) { |
|
|
|
|
pixmap_cache["lane_" + key] = pm.scaled({125, 125}, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// for rhd, reflect direction and then flip
|
|
|
|
|
if (key.contains("_left")) { |
|
|
|
|
pixmap_cache["rhd_" + key.replace("_left", "_right")] = pm.transformed(QTransform().scale(-1, 1)); |
|
|
|
|
} else if (key.contains("_right")) { |
|
|
|
|
pixmap_cache["rhd_" + key.replace("_right", "_left")] = pm.transformed(QTransform().scale(-1, 1)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QString MapInstructions::getDistance(float d) { |
|
|
|
@ -441,27 +467,13 @@ void MapInstructions::updateInstructions(cereal::NavInstruction::Reader instruct |
|
|
|
|
QString type = QString::fromStdString(instruction.getManeuverType()); |
|
|
|
|
QString modifier = QString::fromStdString(instruction.getManeuverModifier()); |
|
|
|
|
if (!type.isEmpty()) { |
|
|
|
|
QString fn = "../assets/navigation/direction_" + type; |
|
|
|
|
QString fn = "direction_" + type; |
|
|
|
|
if (!modifier.isEmpty()) { |
|
|
|
|
fn += "_" + modifier; |
|
|
|
|
} |
|
|
|
|
fn += ICON_SUFFIX; |
|
|
|
|
fn = fn.replace(' ', '_'); |
|
|
|
|
|
|
|
|
|
// for rhd, reflect direction and then flip
|
|
|
|
|
if (is_rhd) { |
|
|
|
|
if (fn.contains("left")) { |
|
|
|
|
fn.replace("left", "right"); |
|
|
|
|
} else if (fn.contains("right")) { |
|
|
|
|
fn.replace("right", "left"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QPixmap pix(fn); |
|
|
|
|
if (is_rhd) { |
|
|
|
|
pix = pix.transformed(QTransform().scale(-1, 1)); |
|
|
|
|
} |
|
|
|
|
icon_01->setPixmap(pix.scaledToWidth(200, Qt::SmoothTransformation)); |
|
|
|
|
bool rhd = is_rhd && (fn.contains("_left") || fn.contains("_right")); |
|
|
|
|
icon_01->setPixmap(pixmap_cache[!rhd ? fn : "rhd_" + fn]); |
|
|
|
|
icon_01->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
|
|
|
|
icon_01->setVisible(true); |
|
|
|
|
} |
|
|
|
@ -480,7 +492,7 @@ void MapInstructions::updateInstructions(cereal::NavInstruction::Reader instruct |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TODO: Make more images based on active direction and combined directions
|
|
|
|
|
QString fn = "../assets/navigation/direction_"; |
|
|
|
|
QString fn = "lane_direction_"; |
|
|
|
|
if (left) { |
|
|
|
|
fn += "turn_left"; |
|
|
|
|
} else if (right) { |
|
|
|
@ -497,7 +509,7 @@ void MapInstructions::updateInstructions(cereal::NavInstruction::Reader instruct |
|
|
|
|
if (!label->parentWidget()) { |
|
|
|
|
lane_layout->addWidget(label); |
|
|
|
|
} |
|
|
|
|
label->setPixmap(loadPixmap(fn + ICON_SUFFIX, {125, 125}, Qt::IgnoreAspectRatio)); |
|
|
|
|
label->setPixmap(pixmap_cache[fn]); |
|
|
|
|
label->setVisible(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|