|
|
|
@ -18,18 +18,13 @@ OnroadWindow::OnroadWindow(QWidget *parent) : QWidget(parent) { |
|
|
|
|
stacked_layout->setStackingMode(QStackedLayout::StackAll); |
|
|
|
|
main_layout->addLayout(stacked_layout); |
|
|
|
|
|
|
|
|
|
QStackedLayout *road_view_layout = new QStackedLayout; |
|
|
|
|
road_view_layout->setStackingMode(QStackedLayout::StackAll); |
|
|
|
|
nvg = new NvgWindow(VISION_STREAM_ROAD, this); |
|
|
|
|
road_view_layout->addWidget(nvg); |
|
|
|
|
hud = new OnroadHud(this); |
|
|
|
|
road_view_layout->addWidget(hud); |
|
|
|
|
|
|
|
|
|
QWidget * split_wrapper = new QWidget; |
|
|
|
|
split = new QHBoxLayout(split_wrapper); |
|
|
|
|
split->setContentsMargins(0, 0, 0, 0); |
|
|
|
|
split->setSpacing(0); |
|
|
|
|
split->addLayout(road_view_layout); |
|
|
|
|
split->addWidget(nvg); |
|
|
|
|
|
|
|
|
|
stacked_layout->addWidget(split_wrapper); |
|
|
|
|
|
|
|
|
@ -57,7 +52,7 @@ void OnroadWindow::updateState(const UIState &s) { |
|
|
|
|
alerts->updateAlert(alert, bgColor); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
hud->updateState(s); |
|
|
|
|
nvg->updateState(s); |
|
|
|
|
|
|
|
|
|
if (bg != bgColor) { |
|
|
|
|
// repaint border
|
|
|
|
@ -167,15 +162,14 @@ void OnroadAlerts::paintEvent(QPaintEvent *event) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// OnroadHud
|
|
|
|
|
OnroadHud::OnroadHud(QWidget *parent) : QWidget(parent) { |
|
|
|
|
// NvgWindow
|
|
|
|
|
|
|
|
|
|
NvgWindow::NvgWindow(VisionStreamType type, QWidget* parent) : fps_filter(UI_FREQ, 3, 1. / UI_FREQ), CameraViewWidget("camerad", type, true, parent) { |
|
|
|
|
engage_img = loadPixmap("../assets/img_chffr_wheel.png", {img_size, img_size}); |
|
|
|
|
dm_img = loadPixmap("../assets/img_driver_face.png", {img_size, img_size}); |
|
|
|
|
|
|
|
|
|
connect(this, &OnroadHud::valueChanged, [=] { update(); }); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void OnroadHud::updateState(const UIState &s) { |
|
|
|
|
void NvgWindow::updateState(const UIState &s) { |
|
|
|
|
const int SET_SPEED_NA = 255; |
|
|
|
|
const SubMaster &sm = *(s.sm); |
|
|
|
|
const auto cs = sm["controlsState"].getControlsState(); |
|
|
|
@ -202,9 +196,8 @@ void OnroadHud::updateState(const UIState &s) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void OnroadHud::paintEvent(QPaintEvent *event) { |
|
|
|
|
QPainter p(this); |
|
|
|
|
p.setRenderHint(QPainter::Antialiasing); |
|
|
|
|
void NvgWindow::drawHud(QPainter &p) { |
|
|
|
|
p.save(); |
|
|
|
|
|
|
|
|
|
// Header gradient
|
|
|
|
|
QLinearGradient bg(0, header_h - (header_h / 2.5), 0, header_h); |
|
|
|
@ -246,9 +239,10 @@ void OnroadHud::paintEvent(QPaintEvent *event) { |
|
|
|
|
drawIcon(p, radius / 2 + (bdr_s * 2), rect().bottom() - footer_h / 2, |
|
|
|
|
dm_img, QColor(0, 0, 0, 70), dmActive ? 1.0 : 0.2); |
|
|
|
|
} |
|
|
|
|
p.restore(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void OnroadHud::drawText(QPainter &p, int x, int y, const QString &text, int alpha) { |
|
|
|
|
void NvgWindow::drawText(QPainter &p, int x, int y, const QString &text, int alpha) { |
|
|
|
|
QFontMetrics fm(p.font()); |
|
|
|
|
QRect init_rect = fm.boundingRect(text); |
|
|
|
|
QRect real_rect = fm.boundingRect(init_rect, 0, text); |
|
|
|
@ -258,7 +252,7 @@ void OnroadHud::drawText(QPainter &p, int x, int y, const QString &text, int alp |
|
|
|
|
p.drawText(real_rect.x(), real_rect.bottom(), text); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void OnroadHud::drawIcon(QPainter &p, int x, int y, QPixmap &img, QBrush bg, float opacity) { |
|
|
|
|
void NvgWindow::drawIcon(QPainter &p, int x, int y, QPixmap &img, QBrush bg, float opacity) { |
|
|
|
|
p.setPen(Qt::NoPen); |
|
|
|
|
p.setBrush(bg); |
|
|
|
|
p.drawEllipse(x - radius / 2, y - radius / 2, radius, radius); |
|
|
|
@ -266,11 +260,6 @@ void OnroadHud::drawIcon(QPainter &p, int x, int y, QPixmap &img, QBrush bg, flo |
|
|
|
|
p.drawPixmap(x - img_size / 2, y - img_size / 2, img); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// NvgWindow
|
|
|
|
|
|
|
|
|
|
NvgWindow::NvgWindow(VisionStreamType type, QWidget* parent) : fps_filter(UI_FREQ, 3, 1. / UI_FREQ), CameraViewWidget("camerad", type, true, parent) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void NvgWindow::initializeGL() { |
|
|
|
|
CameraViewWidget::initializeGL(); |
|
|
|
@ -377,12 +366,15 @@ void NvgWindow::drawLead(QPainter &painter, const cereal::ModelDataV2::LeadDataV |
|
|
|
|
void NvgWindow::paintGL() { |
|
|
|
|
CameraViewWidget::paintGL(); |
|
|
|
|
|
|
|
|
|
UIState *s = uiState(); |
|
|
|
|
if (s->worldObjectsVisible()) { |
|
|
|
|
QPainter painter(this); |
|
|
|
|
painter.setRenderHint(QPainter::Antialiasing); |
|
|
|
|
painter.setPen(Qt::NoPen); |
|
|
|
|
|
|
|
|
|
drawHud(painter); |
|
|
|
|
|
|
|
|
|
UIState *s = uiState(); |
|
|
|
|
if (s->worldObjectsVisible()) { |
|
|
|
|
|
|
|
|
|
drawLaneLines(painter, s); |
|
|
|
|
|
|
|
|
|
if (s->scene.longitudinal_control) { |
|
|
|
|