wip
This commit is contained in:
@@ -759,52 +759,12 @@ void AnnotatedCameraWidget::drawLaneLines(QPainter &painter, const UIState *s) {
|
||||
painter.restore();
|
||||
}
|
||||
|
||||
void AnnotatedCameraWidget::drawDriverState(QPainter &painter, const UIState *s) {
|
||||
// painter.save();
|
||||
|
||||
// // base icon
|
||||
// int offset = UI_BORDER_SIZE + btn_size / 2;
|
||||
// int x = rightHandDM ? width() - offset : offset;
|
||||
// x += onroadDistanceButton ? 250 : 0;
|
||||
// offset += showAlwaysOnLateralStatusBar || showConditionalExperimentalStatusBar || roadNameUI ? 25 : 0;
|
||||
// int y = height() - offset;
|
||||
// float opacity = dmActive ? 0.65 : 0.2;
|
||||
// drawIcon(painter, QPoint(x, y), dm_img, blackColor(70), opacity);
|
||||
|
||||
// // face
|
||||
// QPointF face_kpts_draw[std::size(default_face_kpts_3d)];
|
||||
// float kp;
|
||||
// for (int i = 0; i < std::size(default_face_kpts_3d); ++i) {
|
||||
// kp = (scene.face_kpts_draw[i].v[2] - 8) / 120 + 1.0;
|
||||
// face_kpts_draw[i] = QPointF(scene.face_kpts_draw[i].v[0] * kp + x, scene.face_kpts_draw[i].v[1] * kp + y);
|
||||
// }
|
||||
|
||||
// painter.setPen(QPen(QColor::fromRgbF(1.0, 1.0, 1.0, opacity), 5.2, Qt::SolidLine, Qt::RoundCap));
|
||||
// painter.drawPolyline(face_kpts_draw, std::size(default_face_kpts_3d));
|
||||
|
||||
// // tracking arcs
|
||||
// const int arc_l = 133;
|
||||
// const float arc_t_default = 6.7;
|
||||
// const float arc_t_extend = 12.0;
|
||||
// QColor arc_color = QColor::fromRgbF(0.545 - 0.445 * s->engaged(),
|
||||
// 0.545 + 0.4 * s->engaged(),
|
||||
// 0.545 - 0.285 * s->engaged(),
|
||||
// 0.4 * (1.0 - dm_fade_state));
|
||||
// float delta_x = -scene.driver_pose_sins[1] * arc_l / 2;
|
||||
// float delta_y = -scene.driver_pose_sins[0] * arc_l / 2;
|
||||
// painter.setPen(QPen(arc_color, arc_t_default+arc_t_extend*fmin(1.0, scene.driver_pose_diff[1] * 5.0), Qt::SolidLine, Qt::RoundCap));
|
||||
// painter.drawArc(QRectF(std::fmin(x + delta_x, x), y - arc_l / 2, fabs(delta_x), arc_l), (scene.driver_pose_sins[1]>0 ? 90 : -90) * 16, 180 * 16);
|
||||
// painter.setPen(QPen(arc_color, arc_t_default+arc_t_extend*fmin(1.0, scene.driver_pose_diff[0] * 5.0), Qt::SolidLine, Qt::RoundCap));
|
||||
// painter.drawArc(QRectF(x - arc_l / 2, std::fmin(y + delta_y, y), arc_l, fabs(delta_y)), (scene.driver_pose_sins[0]>0 ? 0 : 180) * 16, 180 * 16);
|
||||
|
||||
// painter.restore();
|
||||
}
|
||||
|
||||
void AnnotatedCameraWidget::drawLead(QPainter &painter, const cereal::ModelDataV2::LeadDataV3::Reader &lead_data, const QPointF &vd, const float v_ego) {
|
||||
painter.save();
|
||||
|
||||
const float speedBuff = currentHolidayTheme != 0 || customColors != 0 ? 25. : 10.; // Make the center of the chevron appear sooner if a theme is active
|
||||
const float leadBuff = currentHolidayTheme != 0 || customColors != 0 ? 100. : 40.; // Make the center of the chevron appear sooner if a theme is active
|
||||
const float speedBuff = customColors != 0 ? 25. : 10.; // Make the center of the chevron appear sooner if a theme is active
|
||||
const float leadBuff = customColors != 0 ? 100. : 40.; // Make the center of the chevron appear sooner if a theme is active
|
||||
const float d_rel = lead_data.getX()[0];
|
||||
const float v_rel = lead_data.getV()[0] - v_ego;
|
||||
|
||||
@@ -937,7 +897,6 @@ void AnnotatedCameraWidget::paintEvent(QPaintEvent *event) {
|
||||
// DMoji
|
||||
if (!hideBottomIcons && (sm.rcv_frame("driverStateV2") > s->scene.started_frame)) {
|
||||
update_dmonitoring(s, sm["driverStateV2"].getDriverStateV2(), dm_fade_state, rightHandDM);
|
||||
drawDriverState(painter, s);
|
||||
}
|
||||
|
||||
drawHud(painter);
|
||||
@@ -974,58 +933,13 @@ void AnnotatedCameraWidget::initializeFrogPilotWidgets() {
|
||||
// QSpacerItem *spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
// bottom_layout->addItem(spacer);
|
||||
|
||||
compass_img = new Compass(this);
|
||||
// bottom_layout->addWidget(compass_img);
|
||||
|
||||
main_layout->addLayout(bottom_layout);
|
||||
|
||||
themeConfiguration = {
|
||||
{1, {"frog_theme", QColor(23, 134, 68, 242), {{0.0, QBrush(QColor::fromHslF(144 / 360., 0.71, 0.31, 0.9))},
|
||||
{0.5, QBrush(QColor::fromHslF(144 / 360., 0.71, 0.31, 0.5))},
|
||||
{1.0, QBrush(QColor::fromHslF(144 / 360., 0.71, 0.31, 0.1))}}}},
|
||||
{2, {"tesla_theme", QColor(0, 72, 255, 255), {{0.0, QBrush(QColor::fromHslF(223 / 360., 1.0, 0.5, 0.9))},
|
||||
{0.5, QBrush(QColor::fromHslF(223 / 360., 1.0, 0.5, 0.5))},
|
||||
{1.0, QBrush(QColor::fromHslF(223 / 360., 1.0, 0.5, 0.1))}}}},
|
||||
{3, {"stalin_theme", QColor(255, 0, 0, 255), {{0.0, QBrush(QColor::fromHslF(0 / 360., 1.0, 0.5, 0.9))},
|
||||
{0.5, QBrush(QColor::fromHslF(0 / 360., 1.0, 0.5, 0.5))},
|
||||
{1.0, QBrush(QColor::fromHslF(0 / 360., 1.0, 0.5, 0.1))}}}},
|
||||
};
|
||||
|
||||
holidayThemeConfiguration = {
|
||||
{1, {"april_fools", QColor(255, 165, 0, 255), {{0.0, QBrush(QColor::fromHslF(39 / 360., 1.0, 0.5, 0.9))},
|
||||
{0.5, QBrush(QColor::fromHslF(39 / 360., 1.0, 0.5, 0.5))},
|
||||
{1.0, QBrush(QColor::fromHslF(39 / 360., 1.0, 0.5, 0.1))}}}},
|
||||
{2, {"christmas", QColor(0, 72, 255, 255), {{0.0, QBrush(QColor::fromHslF(223 / 360., 1.0, 0.5, 0.9))},
|
||||
{0.5, QBrush(QColor::fromHslF(223 / 360., 1.0, 0.5, 0.5))},
|
||||
{1.0, QBrush(QColor::fromHslF(223 / 360., 1.0, 0.5, 0.1))}}}},
|
||||
{3, {"cinco_de_mayo", QColor(0, 104, 71, 255), {{0.0, QBrush(QColor::fromHslF(161 / 360., 1.0, 0.2, 0.9))},
|
||||
{0.5, QBrush(QColor::fromHslF(161 / 360., 1.0, 0.2, 0.5))},
|
||||
{1.0, QBrush(QColor::fromHslF(161 / 360., 1.0, 0.2, 0.1))}}}},
|
||||
{4, {"easter", QColor(200, 150, 200, 255), {{0.0, QBrush(QColor::fromHslF(300 / 360., 0.31, 0.69, 0.9))},
|
||||
{0.5, QBrush(QColor::fromHslF(300 / 360., 0.31, 0.69, 0.5))},
|
||||
{1.0, QBrush(QColor::fromHslF(300 / 360., 0.31, 0.69, 0.1))}}}},
|
||||
{5, {"fourth_of_july", QColor(0, 72, 255, 255), {{0.0, QBrush(QColor::fromHslF(223 / 360., 1.0, 0.5, 0.9))},
|
||||
{0.5, QBrush(QColor::fromHslF(223 / 360., 1.0, 0.5, 0.5))},
|
||||
{1.0, QBrush(QColor::fromHslF(223 / 360., 1.0, 0.5, 0.1))}}}},
|
||||
{6, {"halloween", QColor(255, 0, 0, 255), {{0.0, QBrush(QColor::fromHslF(0 / 360., 1.0, 0.5, 0.9))},
|
||||
{0.5, QBrush(QColor::fromHslF(0 / 360., 1.0, 0.5, 0.5))},
|
||||
{1.0, QBrush(QColor::fromHslF(0 / 360., 1.0, 0.5, 0.1))}}}},
|
||||
{7, {"new_years_day", QColor(23, 134, 68, 242), {{0.0, QBrush(QColor::fromHslF(144 / 360., 0.71, 0.31, 0.9))},
|
||||
{0.5, QBrush(QColor::fromHslF(144 / 360., 0.71, 0.31, 0.5))},
|
||||
{1.0, QBrush(QColor::fromHslF(144 / 360., 0.71, 0.31, 0.1))}}}},
|
||||
{8, {"st_patricks_day", QColor(0, 128, 0, 255), {{0.0, QBrush(QColor::fromHslF(120 / 360., 1.0, 0.25, 0.9))},
|
||||
{0.5, QBrush(QColor::fromHslF(120 / 360., 1.0, 0.25, 0.5))},
|
||||
{1.0, QBrush(QColor::fromHslF(120 / 360., 1.0, 0.25, 0.1))}}}},
|
||||
{9, {"thanksgiving", QColor(255, 0, 0, 255), {{0.0, QBrush(QColor::fromHslF(0 / 360., 1.0, 0.5, 0.9))},
|
||||
{0.5, QBrush(QColor::fromHslF(0 / 360., 1.0, 0.5, 0.5))},
|
||||
{1.0, QBrush(QColor::fromHslF(0 / 360., 1.0, 0.5, 0.1))}}}},
|
||||
{10, {"valentines_day", QColor(23, 134, 68, 242), {{0.0, QBrush(QColor::fromHslF(144 / 360., 0.71, 0.31, 0.9))},
|
||||
{0.5, QBrush(QColor::fromHslF(144 / 360., 0.71, 0.31, 0.5))},
|
||||
{1.0, QBrush(QColor::fromHslF(144 / 360., 0.71, 0.31, 0.1))}}}},
|
||||
{11, {"world_frog_day", QColor(23, 134, 68, 242), {{0.0, QBrush(QColor::fromHslF(144 / 360., 0.71, 0.31, 0.9))},
|
||||
{0.5, QBrush(QColor::fromHslF(144 / 360., 0.71, 0.31, 0.5))},
|
||||
{1.0, QBrush(QColor::fromHslF(144 / 360., 0.71, 0.31, 0.1))}}}},
|
||||
};
|
||||
};
|
||||
|
||||
animationTimer = new QTimer(this);
|
||||
connect(animationTimer, &QTimer::timeout, this, [this] {
|
||||
@@ -1053,8 +967,6 @@ void AnnotatedCameraWidget::updateFrogPilotWidgets() {
|
||||
|
||||
cameraView = scene.camera_view;
|
||||
|
||||
compass = scene.compass;
|
||||
|
||||
conditionalStatus = scene.conditional_status;
|
||||
showConditionalExperimentalStatusBar = scene.show_cem_status_bar;
|
||||
|
||||
@@ -1089,21 +1001,14 @@ void AnnotatedCameraWidget::updateFrogPilotWidgets() {
|
||||
turnSignalLeft = scene.turn_signal_left;
|
||||
turnSignalRight = scene.turn_signal_right;
|
||||
|
||||
if (currentHolidayTheme != scene.current_holiday_theme || customSignals != scene.custom_signals) {
|
||||
currentHolidayTheme = scene.current_holiday_theme;
|
||||
if (customSignals != scene.custom_signals) {
|
||||
customSignals = scene.custom_signals;
|
||||
|
||||
QString themePath;
|
||||
|
||||
if (currentHolidayTheme != 0) {
|
||||
themePath = QString("../frogpilot/assets/holiday_themes/%1/images").arg(
|
||||
holidayThemeConfiguration.find(currentHolidayTheme) != holidayThemeConfiguration.end() ?
|
||||
std::get<0>(holidayThemeConfiguration[currentHolidayTheme]) : "");
|
||||
} else {
|
||||
themePath = QString("../frogpilot/assets/custom_themes/%1/images").arg(
|
||||
themeConfiguration.find(customSignals) != themeConfiguration.end() ?
|
||||
std::get<0>(themeConfiguration[customSignals]) : "");
|
||||
}
|
||||
|
||||
themePath = QString("../frogpilot/assets/custom_themes/%1/images").arg(
|
||||
themeConfiguration.find(customSignals) != themeConfiguration.end() ?
|
||||
std::get<0>(themeConfiguration[customSignals]) : "");
|
||||
|
||||
const QStringList imagePaths = {
|
||||
themePath + "/turn_signal_1.png",
|
||||
@@ -1140,12 +1045,6 @@ void AnnotatedCameraWidget::paintFrogPilotWidgets(QPainter &p) {
|
||||
drawSLCConfirmation(p);
|
||||
}
|
||||
|
||||
// bool enableCompass = compass && !hideBottomIcons;
|
||||
// compass_img->setVisible(enableCompass);
|
||||
// if (enableCompass) {
|
||||
// compass_img->updateState();
|
||||
// bottom_layout->setAlignment(compass_img, (rightHandDM ? Qt::AlignLeft : Qt::AlignRight));
|
||||
// }
|
||||
|
||||
// bool enableDistanceButton = onroadDistanceButton && !hideBottomIcons;
|
||||
// distance_btn->setVisible(enableDistanceButton);
|
||||
@@ -1164,112 +1063,6 @@ void AnnotatedCameraWidget::paintFrogPilotWidgets(QPainter &p) {
|
||||
recorder_btn->setVisible(false);
|
||||
}
|
||||
|
||||
Compass::Compass(QWidget *parent) : QWidget(parent), scene(uiState()->scene) {
|
||||
// setFixedSize(btn_size * 1.5, btn_size * 1.5);
|
||||
|
||||
// compassSize = btn_size;
|
||||
// circleOffset = compassSize / 2;
|
||||
// degreeLabelOffset = circleOffset + 25;
|
||||
// innerCompass = compassSize / 2;
|
||||
|
||||
// x = (btn_size * 1.5) / 2 + 20;
|
||||
// y = (btn_size * 1.5) / 2;
|
||||
|
||||
// compassInnerImg = loadPixmap("../frogpilot/assets/other_images/compass_inner.png", QSize(compassSize / 1.75, compassSize / 1.75));
|
||||
|
||||
// staticElements = QPixmap(size());
|
||||
// staticElements.fill(Qt::transparent);
|
||||
// QPainter p(&staticElements);
|
||||
|
||||
// p.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);
|
||||
|
||||
// QPen whitePen(Qt::white, 2);
|
||||
// p.setPen(whitePen);
|
||||
|
||||
// p.setOpacity(1.0);
|
||||
// p.setBrush(QColor(0, 0, 0, 100));
|
||||
// p.drawEllipse(x - circleOffset, y - circleOffset, circleOffset * 2, circleOffset * 2);
|
||||
|
||||
// p.setBrush(Qt::NoBrush);
|
||||
// p.drawEllipse(x - (innerCompass + 5), y - (innerCompass + 5), (innerCompass + 5) * 2, (innerCompass + 5) * 2);
|
||||
// p.drawEllipse(x - degreeLabelOffset, y - degreeLabelOffset, degreeLabelOffset * 2, degreeLabelOffset * 2);
|
||||
|
||||
// QPainterPath outerCircle, innerCircle;
|
||||
// outerCircle.addEllipse(x - degreeLabelOffset, y - degreeLabelOffset, degreeLabelOffset * 2, degreeLabelOffset * 2);
|
||||
// innerCircle.addEllipse(x - circleOffset, y - circleOffset, compassSize, compassSize);
|
||||
// p.fillPath(outerCircle.subtracted(innerCircle), Qt::black);
|
||||
}
|
||||
|
||||
void Compass::updateState() {
|
||||
// if (bearingDeg != scene.bearing_deg) {
|
||||
// update();
|
||||
// bearingDeg = scene.bearing_deg;
|
||||
// }
|
||||
}
|
||||
|
||||
void Compass::paintEvent(QPaintEvent *event) {
|
||||
// QPainter p(this);
|
||||
// p.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);
|
||||
|
||||
// bearingDeg = fmod(bearingDeg, 360);
|
||||
// if (bearingDeg < 0) {
|
||||
// bearingDeg += 360;
|
||||
// }
|
||||
|
||||
// p.drawPixmap(0, 0, staticElements);
|
||||
|
||||
// p.translate(x, y);
|
||||
// p.rotate(bearingDeg);
|
||||
// p.drawPixmap(-compassInnerImg.width() / 2, -compassInnerImg.height() / 2, compassInnerImg);
|
||||
// p.rotate(-bearingDeg);
|
||||
// p.translate(-x, -y);
|
||||
|
||||
// QFont font = InterFont(10, QFont::Normal);
|
||||
// for (int i = 0; i < 360; i += 15) {
|
||||
// bool isBold = abs(i - bearingDeg) <= 7;
|
||||
// font.setWeight(isBold ? QFont::Bold : QFont::Normal);
|
||||
// p.setFont(font);
|
||||
// p.setPen(QPen(Qt::white, i % 90 == 0 ? 2 : 1));
|
||||
|
||||
// p.save();
|
||||
// p.translate(x, y);
|
||||
// p.rotate(i);
|
||||
// p.drawLine(0, -(compassSize / 2 - (i % 90 == 0 ? 12 : 8)), 0, -(compassSize / 2));
|
||||
// p.translate(0, -(compassSize / 2 + 12));
|
||||
// p.rotate(-i);
|
||||
// p.drawText(QRect(-20, -10, 40, 20), Qt::AlignCenter, QString::number(i));
|
||||
// p.restore();
|
||||
// }
|
||||
|
||||
// p.setFont(InterFont(20, QFont::Bold));
|
||||
// std::map<QString, std::tuple<QPair<float, float>, int, QColor>> directionInfo = {
|
||||
// {"N", {{292.5, 67.5}, Qt::AlignTop | Qt::AlignHCenter, Qt::white}},
|
||||
// {"E", {{22.5, 157.5}, Qt::AlignRight | Qt::AlignVCenter, Qt::white}},
|
||||
// {"S", {{112.5, 247.5}, Qt::AlignBottom | Qt::AlignHCenter, Qt::white}},
|
||||
// {"W", {{202.5, 337.5}, Qt::AlignLeft | Qt::AlignVCenter, Qt::white}}
|
||||
// };
|
||||
// int directionOffset = 20;
|
||||
|
||||
// for (auto &item : directionInfo) {
|
||||
// QString direction = item.first;
|
||||
// auto &[range, alignmentFlag, color] = item.second;
|
||||
// auto &[minRange, maxRange] = range;
|
||||
|
||||
// QRect textRect(x - innerCompass + directionOffset, y - innerCompass + directionOffset, innerCompass * 2 - 2 * directionOffset, innerCompass * 2 - 2 * directionOffset);
|
||||
|
||||
// bool isInRange = false;
|
||||
// if (minRange > maxRange) {
|
||||
// isInRange = bearingDeg >= minRange || bearingDeg <= maxRange;
|
||||
// } else {
|
||||
// isInRange = bearingDeg >= minRange && bearingDeg <= maxRange;
|
||||
// }
|
||||
|
||||
// p.setOpacity(isInRange ? 1.0 : 0.2);
|
||||
// p.setPen(QPen(color));
|
||||
// p.drawText(textRect, alignmentFlag, direction);
|
||||
// }
|
||||
}
|
||||
|
||||
DistanceButton::DistanceButton(QWidget *parent) : QPushButton(parent), scene(uiState()->scene) {
|
||||
// setFixedSize(btn_size * 1.5, btn_size * 1.5);
|
||||
|
||||
|
||||
@@ -38,30 +38,6 @@ private:
|
||||
UIScene &scene;
|
||||
};
|
||||
|
||||
class Compass : public QWidget {
|
||||
public:
|
||||
explicit Compass(QWidget *parent = nullptr);
|
||||
|
||||
void updateState();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
private:
|
||||
UIScene &scene;
|
||||
|
||||
// int bearingDeg;
|
||||
// int circleOffset;
|
||||
// int compassSize;
|
||||
// int degreeLabelOffset;
|
||||
// int innerCompass;
|
||||
// int x;
|
||||
// int y;
|
||||
|
||||
QPixmap compassInnerImg;
|
||||
QPixmap staticElements;
|
||||
};
|
||||
|
||||
class DistanceButton : public QPushButton {
|
||||
public:
|
||||
explicit DistanceButton(QWidget *parent = nullptr);
|
||||
@@ -158,7 +134,6 @@ private:
|
||||
Params paramsMemory{"/dev/shm/params"};
|
||||
UIScene &scene;
|
||||
|
||||
Compass *compass_img;
|
||||
DistanceButton *distance_btn;
|
||||
PedalIcons *pedal_icons;
|
||||
ScreenRecorder *recorder_btn;
|
||||
@@ -168,7 +143,6 @@ private:
|
||||
bool alwaysOnLateralActive;
|
||||
bool blindSpotLeft;
|
||||
bool blindSpotRight;
|
||||
bool compass;
|
||||
bool experimentalMode;
|
||||
bool leadInfo;
|
||||
bool onroadDistanceButton;
|
||||
@@ -224,7 +198,6 @@ protected:
|
||||
void drawLaneLines(QPainter &painter, const UIState *s);
|
||||
void drawLead(QPainter &painter, const cereal::ModelDataV2::LeadDataV3::Reader &lead_data, const QPointF &vd, const float v_ego);
|
||||
void drawHud(QPainter &p);
|
||||
void drawDriverState(QPainter &painter, const UIState *s);
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
inline QColor redColor(int alpha = 255) { return QColor(201, 34, 49, alpha); }
|
||||
inline QColor whiteColor(int alpha = 255) { return QColor(255, 255, 255, alpha); }
|
||||
|
||||
@@ -197,7 +197,6 @@ typedef struct UIScene {
|
||||
bool blind_spot_left;
|
||||
bool blind_spot_path;
|
||||
bool blind_spot_right;
|
||||
bool compass;
|
||||
bool conditional_experimental;
|
||||
bool disable_smoothing_mtsc;
|
||||
bool disable_smoothing_vtsc;
|
||||
|
||||
Reference in New Issue
Block a user