mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-20 08:42:11 +08:00
ui/map_instructions: clean up lane icon selection (#29330)
* draft * revert * remove extra directions * more clean up * add todo * revert rename * I assume this is moot, but preserve behavior * spacing old-commit-hash: 52675b2739de56a9b5784ba8016791cdb5286085
This commit is contained in:
@@ -109,27 +109,21 @@ void MapInstructions::updateInstructions(cereal::NavInstruction::Reader instruct
|
||||
auto lanes = instruction.getLanes();
|
||||
for (int i = 0; i < lanes.size(); ++i) {
|
||||
bool active = lanes[i].getActive();
|
||||
|
||||
bool left = false, straight = false, right = false;
|
||||
for (auto const &direction : lanes[i].getDirections()) {
|
||||
left |= direction == cereal::NavInstruction::Direction::LEFT;
|
||||
right |= direction == cereal::NavInstruction::Direction::RIGHT;
|
||||
straight |= direction == cereal::NavInstruction::Direction::STRAIGHT;
|
||||
}
|
||||
|
||||
// active direction has precedence
|
||||
const auto active_direction = lanes[i].getActiveDirection();
|
||||
bool active_left = active_direction == cereal::NavInstruction::Direction::LEFT;
|
||||
bool active_right = active_direction == cereal::NavInstruction::Direction::RIGHT;
|
||||
|
||||
// TODO: Make more images based on active direction and combined directions
|
||||
QString fn = "lane_direction_";
|
||||
if (left && (active_left || !active)) {
|
||||
fn += "turn_left";
|
||||
} else if (right && (active_right || !active)) {
|
||||
fn += "turn_right";
|
||||
} else if (straight) {
|
||||
fn += "turn_straight";
|
||||
|
||||
// active direction has precedence
|
||||
if (active && active_direction != cereal::NavInstruction::Direction::NONE) {
|
||||
fn += "turn_" + DIRECTIONS[active_direction];
|
||||
} else {
|
||||
for (auto const &direction : lanes[i].getDirections()) {
|
||||
if (direction != cereal::NavInstruction::Direction::NONE) {
|
||||
fn += "turn_" + DIRECTIONS[direction];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!active) {
|
||||
|
||||
@@ -6,6 +6,13 @@
|
||||
|
||||
#include "cereal/gen/cpp/log.capnp.h"
|
||||
|
||||
static std::map<cereal::NavInstruction::Direction, QString> DIRECTIONS = {
|
||||
{cereal::NavInstruction::Direction::NONE, "none"},
|
||||
{cereal::NavInstruction::Direction::LEFT, "left"},
|
||||
{cereal::NavInstruction::Direction::RIGHT, "right"},
|
||||
{cereal::NavInstruction::Direction::STRAIGHT, "straight"},
|
||||
};
|
||||
|
||||
class MapInstructions : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
Reference in New Issue
Block a user