@ -4,6 +4,7 @@
# include <QDebug>
# include <QDebug>
# include <QPainterPath>
# include <QPainterPath>
# include <QFileInfo>
# include "selfdrive/common/swaglog.h"
# include "selfdrive/common/swaglog.h"
# include "selfdrive/ui/ui.h"
# include "selfdrive/ui/ui.h"
@ -21,6 +22,8 @@ const float MAX_PITCH = 50;
const float MIN_PITCH = 0 ;
const float MIN_PITCH = 0 ;
const float MAP_SCALE = 2 ;
const float MAP_SCALE = 2 ;
const QString ICON_SUFFIX = " .png " ;
MapWindow : : MapWindow ( const QMapboxGLSettings & settings ) :
MapWindow : : MapWindow ( const QMapboxGLSettings & settings ) :
m_settings ( settings ) , velocity_filter ( 0 , 10 , 0.05 ) {
m_settings ( settings ) , velocity_filter ( 0 , 10 , 0.05 ) {
sm = new SubMaster ( { " liveLocationKalman " , " navInstruction " , " navRoute " } ) ;
sm = new SubMaster ( { " liveLocationKalman " , " navInstruction " , " navRoute " } ) ;
@ -324,6 +327,7 @@ void MapWindow::offroadTransition(bool offroad) {
}
}
MapInstructions : : MapInstructions ( QWidget * parent ) : QWidget ( parent ) {
MapInstructions : : MapInstructions ( QWidget * parent ) : QWidget ( parent ) {
is_rhd = Params ( ) . getBool ( " IsRHD " ) ;
QHBoxLayout * main_layout = new QHBoxLayout ( this ) ;
QHBoxLayout * main_layout = new QHBoxLayout ( this ) ;
main_layout - > setContentsMargins ( 11 , 50 , 11 , 11 ) ;
main_layout - > setContentsMargins ( 11 , 50 , 11 , 11 ) ;
{
{
@ -442,10 +446,22 @@ void MapInstructions::updateInstructions(cereal::NavInstruction::Reader instruct
if ( ! modifier . isEmpty ( ) ) {
if ( ! modifier . isEmpty ( ) ) {
fn + = " _ " + modifier ;
fn + = " _ " + modifier ;
}
}
fn + = + " .png " ;
fn + = ICON_SUFFIX ;
fn = fn . replace ( ' ' , ' _ ' ) ;
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 ) ;
QPixmap pix ( fn ) ;
if ( is_rhd ) {
pix = pix . transformed ( QTransform ( ) . scale ( - 1 , 1 ) ) ;
}
icon_01 - > setPixmap ( pix . scaledToWidth ( 200 , Qt : : SmoothTransformation ) ) ;
icon_01 - > setPixmap ( pix . scaledToWidth ( 200 , Qt : : SmoothTransformation ) ) ;
icon_01 - > setSizePolicy ( QSizePolicy ( QSizePolicy : : Fixed , QSizePolicy : : Fixed ) ) ;
icon_01 - > setSizePolicy ( QSizePolicy ( QSizePolicy : : Fixed , QSizePolicy : : Fixed ) ) ;
icon_01 - > setVisible ( true ) ;
icon_01 - > setVisible ( true ) ;
@ -476,7 +492,7 @@ void MapInstructions::updateInstructions(cereal::NavInstruction::Reader instruct
fn + = " turn_straight " ;
fn + = " turn_straight " ;
}
}
QPixmap pix ( fn + " .png " ) ;
QPixmap pix ( fn + ICON_SUFFIX ) ;
auto icon = new QLabel ;
auto icon = new QLabel ;
int wh = active ? 125 : 75 ;
int wh = active ? 125 : 75 ;
icon - > setPixmap ( pix . scaled ( wh , wh , Qt : : IgnoreAspectRatio , Qt : : SmoothTransformation ) ) ;
icon - > setPixmap ( pix . scaled ( wh , wh , Qt : : IgnoreAspectRatio , Qt : : SmoothTransformation ) ) ;