|
|
@ -18,7 +18,7 @@ OnroadWindow::OnroadWindow(QWidget *parent) : QWidget(parent) { |
|
|
|
stacked_layout->setStackingMode(QStackedLayout::StackAll); |
|
|
|
stacked_layout->setStackingMode(QStackedLayout::StackAll); |
|
|
|
main_layout->addLayout(stacked_layout); |
|
|
|
main_layout->addLayout(stacked_layout); |
|
|
|
|
|
|
|
|
|
|
|
nvg = new NvgWindow(VISION_STREAM_ROAD, this); |
|
|
|
nvg = new AnnotatedCameraWidget(VISION_STREAM_ROAD, this); |
|
|
|
|
|
|
|
|
|
|
|
QWidget * split_wrapper = new QWidget; |
|
|
|
QWidget * split_wrapper = new QWidget; |
|
|
|
split = new QHBoxLayout(split_wrapper); |
|
|
|
split = new QHBoxLayout(split_wrapper); |
|
|
@ -27,7 +27,7 @@ OnroadWindow::OnroadWindow(QWidget *parent) : QWidget(parent) { |
|
|
|
split->addWidget(nvg); |
|
|
|
split->addWidget(nvg); |
|
|
|
|
|
|
|
|
|
|
|
if (getenv("DUAL_CAMERA_VIEW")) { |
|
|
|
if (getenv("DUAL_CAMERA_VIEW")) { |
|
|
|
CameraViewWidget *arCam = new CameraViewWidget("camerad", VISION_STREAM_ROAD, true, this); |
|
|
|
CameraWidget *arCam = new CameraWidget("camerad", VISION_STREAM_ROAD, true, this); |
|
|
|
split->insertWidget(0, arCam); |
|
|
|
split->insertWidget(0, arCam); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -173,16 +173,15 @@ void OnroadAlerts::paintEvent(QPaintEvent *event) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// NvgWindow
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NvgWindow::NvgWindow(VisionStreamType type, QWidget* parent) : fps_filter(UI_FREQ, 3, 1. / UI_FREQ), CameraViewWidget("camerad", type, true, parent) { |
|
|
|
AnnotatedCameraWidget::AnnotatedCameraWidget(VisionStreamType type, QWidget* parent) : fps_filter(UI_FREQ, 3, 1. / UI_FREQ), CameraWidget("camerad", type, true, parent) { |
|
|
|
pm = std::make_unique<PubMaster, const std::initializer_list<const char *>>({"uiDebug"}); |
|
|
|
pm = std::make_unique<PubMaster, const std::initializer_list<const char *>>({"uiDebug"}); |
|
|
|
|
|
|
|
|
|
|
|
engage_img = loadPixmap("../assets/img_chffr_wheel.png", {img_size, img_size}); |
|
|
|
engage_img = loadPixmap("../assets/img_chffr_wheel.png", {img_size, img_size}); |
|
|
|
dm_img = loadPixmap("../assets/img_driver_face.png", {img_size, img_size}); |
|
|
|
dm_img = loadPixmap("../assets/img_driver_face.png", {img_size, img_size}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void NvgWindow::updateState(const UIState &s) { |
|
|
|
void AnnotatedCameraWidget::updateState(const UIState &s) { |
|
|
|
const int SET_SPEED_NA = 255; |
|
|
|
const int SET_SPEED_NA = 255; |
|
|
|
const SubMaster &sm = *(s.sm); |
|
|
|
const SubMaster &sm = *(s.sm); |
|
|
|
|
|
|
|
|
|
|
@ -234,13 +233,13 @@ void NvgWindow::updateState(const UIState &s) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (s.scene.calibration_valid) { |
|
|
|
if (s.scene.calibration_valid) { |
|
|
|
CameraViewWidget::updateCalibration(s.scene.view_from_calib); |
|
|
|
CameraWidget::updateCalibration(s.scene.view_from_calib); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
CameraViewWidget::updateCalibration(DEFAULT_CALIBRATION); |
|
|
|
CameraWidget::updateCalibration(DEFAULT_CALIBRATION); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void NvgWindow::drawHud(QPainter &p) { |
|
|
|
void AnnotatedCameraWidget::drawHud(QPainter &p) { |
|
|
|
p.save(); |
|
|
|
p.save(); |
|
|
|
|
|
|
|
|
|
|
|
// Header gradient
|
|
|
|
// Header gradient
|
|
|
@ -402,7 +401,11 @@ void NvgWindow::drawHud(QPainter &p) { |
|
|
|
p.restore(); |
|
|
|
p.restore(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void NvgWindow::drawText(QPainter &p, int x, int y, const QString &text, int alpha) { |
|
|
|
|
|
|
|
|
|
|
|
// Window that shows camera view and variety of
|
|
|
|
|
|
|
|
// info drawn on top
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void AnnotatedCameraWidget::drawText(QPainter &p, int x, int y, const QString &text, int alpha) { |
|
|
|
QRect real_rect = getTextRect(p, 0, text); |
|
|
|
QRect real_rect = getTextRect(p, 0, text); |
|
|
|
real_rect.moveCenter({x, y - real_rect.height() / 2}); |
|
|
|
real_rect.moveCenter({x, y - real_rect.height() / 2}); |
|
|
|
|
|
|
|
|
|
|
@ -410,7 +413,7 @@ void NvgWindow::drawText(QPainter &p, int x, int y, const QString &text, int alp |
|
|
|
p.drawText(real_rect.x(), real_rect.bottom(), text); |
|
|
|
p.drawText(real_rect.x(), real_rect.bottom(), text); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void NvgWindow::drawIcon(QPainter &p, int x, int y, QPixmap &img, QBrush bg, float opacity) { |
|
|
|
void AnnotatedCameraWidget::drawIcon(QPainter &p, int x, int y, QPixmap &img, QBrush bg, float opacity) { |
|
|
|
p.setPen(Qt::NoPen); |
|
|
|
p.setPen(Qt::NoPen); |
|
|
|
p.setBrush(bg); |
|
|
|
p.setBrush(bg); |
|
|
|
p.drawEllipse(x - radius / 2, y - radius / 2, radius, radius); |
|
|
|
p.drawEllipse(x - radius / 2, y - radius / 2, radius, radius); |
|
|
@ -419,8 +422,8 @@ void NvgWindow::drawIcon(QPainter &p, int x, int y, QPixmap &img, QBrush bg, flo |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void NvgWindow::initializeGL() { |
|
|
|
void AnnotatedCameraWidget::initializeGL() { |
|
|
|
CameraViewWidget::initializeGL(); |
|
|
|
CameraWidget::initializeGL(); |
|
|
|
qInfo() << "OpenGL version:" << QString((const char*)glGetString(GL_VERSION)); |
|
|
|
qInfo() << "OpenGL version:" << QString((const char*)glGetString(GL_VERSION)); |
|
|
|
qInfo() << "OpenGL vendor:" << QString((const char*)glGetString(GL_VENDOR)); |
|
|
|
qInfo() << "OpenGL vendor:" << QString((const char*)glGetString(GL_VENDOR)); |
|
|
|
qInfo() << "OpenGL renderer:" << QString((const char*)glGetString(GL_RENDERER)); |
|
|
|
qInfo() << "OpenGL renderer:" << QString((const char*)glGetString(GL_RENDERER)); |
|
|
@ -430,8 +433,8 @@ void NvgWindow::initializeGL() { |
|
|
|
setBackgroundColor(bg_colors[STATUS_DISENGAGED]); |
|
|
|
setBackgroundColor(bg_colors[STATUS_DISENGAGED]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void NvgWindow::updateFrameMat() { |
|
|
|
void AnnotatedCameraWidget::updateFrameMat() { |
|
|
|
CameraViewWidget::updateFrameMat(); |
|
|
|
CameraWidget::updateFrameMat(); |
|
|
|
UIState *s = uiState(); |
|
|
|
UIState *s = uiState(); |
|
|
|
int w = width(), h = height(); |
|
|
|
int w = width(), h = height(); |
|
|
|
|
|
|
|
|
|
|
@ -448,7 +451,7 @@ void NvgWindow::updateFrameMat() { |
|
|
|
.translate(-intrinsic_matrix.v[2], -intrinsic_matrix.v[5]); |
|
|
|
.translate(-intrinsic_matrix.v[2], -intrinsic_matrix.v[5]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void NvgWindow::drawLaneLines(QPainter &painter, const UIState *s) { |
|
|
|
void AnnotatedCameraWidget::drawLaneLines(QPainter &painter, const UIState *s) { |
|
|
|
painter.save(); |
|
|
|
painter.save(); |
|
|
|
|
|
|
|
|
|
|
|
const UIScene &scene = s->scene; |
|
|
|
const UIScene &scene = s->scene; |
|
|
@ -507,7 +510,7 @@ void NvgWindow::drawLaneLines(QPainter &painter, const UIState *s) { |
|
|
|
painter.restore(); |
|
|
|
painter.restore(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void NvgWindow::drawLead(QPainter &painter, const cereal::ModelDataV2::LeadDataV3::Reader &lead_data, const QPointF &vd) { |
|
|
|
void AnnotatedCameraWidget::drawLead(QPainter &painter, const cereal::ModelDataV2::LeadDataV3::Reader &lead_data, const QPointF &vd) { |
|
|
|
painter.save(); |
|
|
|
painter.save(); |
|
|
|
|
|
|
|
|
|
|
|
const float speedBuff = 10.; |
|
|
|
const float speedBuff = 10.; |
|
|
@ -543,13 +546,13 @@ void NvgWindow::drawLead(QPainter &painter, const cereal::ModelDataV2::LeadDataV |
|
|
|
painter.restore(); |
|
|
|
painter.restore(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void NvgWindow::paintGL() { |
|
|
|
void AnnotatedCameraWidget::paintGL() { |
|
|
|
const double start_draw_t = millis_since_boot(); |
|
|
|
const double start_draw_t = millis_since_boot(); |
|
|
|
|
|
|
|
|
|
|
|
UIState *s = uiState(); |
|
|
|
UIState *s = uiState(); |
|
|
|
const cereal::ModelDataV2::Reader &model = (*s->sm)["modelV2"].getModelV2(); |
|
|
|
const cereal::ModelDataV2::Reader &model = (*s->sm)["modelV2"].getModelV2(); |
|
|
|
CameraViewWidget::setFrameId(model.getFrameId()); |
|
|
|
CameraWidget::setFrameId(model.getFrameId()); |
|
|
|
CameraViewWidget::paintGL(); |
|
|
|
CameraWidget::paintGL(); |
|
|
|
|
|
|
|
|
|
|
|
QPainter painter(this); |
|
|
|
QPainter painter(this); |
|
|
|
painter.setRenderHint(QPainter::Antialiasing); |
|
|
|
painter.setRenderHint(QPainter::Antialiasing); |
|
|
@ -587,8 +590,8 @@ void NvgWindow::paintGL() { |
|
|
|
pm->send("uiDebug", msg); |
|
|
|
pm->send("uiDebug", msg); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void NvgWindow::showEvent(QShowEvent *event) { |
|
|
|
void AnnotatedCameraWidget::showEvent(QShowEvent *event) { |
|
|
|
CameraViewWidget::showEvent(event); |
|
|
|
CameraWidget::showEvent(event); |
|
|
|
|
|
|
|
|
|
|
|
ui_update_params(uiState()); |
|
|
|
ui_update_params(uiState()); |
|
|
|
prev_draw_t = millis_since_boot(); |
|
|
|
prev_draw_t = millis_since_boot(); |
|
|
|