wip
This commit is contained in:
@@ -29,18 +29,6 @@
|
||||
// p.restore();
|
||||
// }
|
||||
|
||||
// static void drawIconGif(QPainter &p, const QPoint ¢er, const QMovie &img, const QBrush &bg, float opacity) {
|
||||
// p.setRenderHint(QPainter::Antialiasing);
|
||||
// p.setOpacity(1.0); // bg dictates opacity of ellipse
|
||||
// p.setPen(Qt::NoPen);
|
||||
// p.setBrush(bg);
|
||||
// p.drawEllipse(center.x() - btn_size / 2, center.y() - btn_size / 2, btn_size, btn_size);
|
||||
// p.setOpacity(opacity);
|
||||
// QPixmap currentFrame = img.currentPixmap();
|
||||
// p.drawPixmap(center - QPoint(currentFrame.width() / 2, currentFrame.height() / 2), currentFrame);
|
||||
// p.setOpacity(1.0);
|
||||
// }
|
||||
|
||||
OnroadWindow::OnroadWindow(QWidget *parent) : QWidget(parent), scene(uiState()->scene) {
|
||||
QVBoxLayout *main_layout = new QVBoxLayout(this);
|
||||
main_layout->setMargin(UI_BORDER_SIZE);
|
||||
@@ -180,11 +168,9 @@ void OnroadWindow::mousePressEvent(QMouseEvent* e) {
|
||||
}
|
||||
|
||||
void OnroadWindow::offroadTransition(bool offroad) {
|
||||
|
||||
alerts->updateAlert({});
|
||||
}
|
||||
|
||||
|
||||
void OnroadWindow::paintEvent(QPaintEvent *event) {
|
||||
QPainter p(this);
|
||||
p.fillRect(rect(), QColor(bg.red(), bg.green(), bg.blue(), 255));
|
||||
@@ -347,122 +333,6 @@ void OnroadAlerts::paintEvent(QPaintEvent *event) {
|
||||
}
|
||||
}
|
||||
|
||||
// ExperimentalButton
|
||||
ExperimentalButton::ExperimentalButton(QWidget *parent) : experimental_mode(false), engageable(false), QPushButton(parent), scene(uiState()->scene) {
|
||||
setFixedSize(btn_size, btn_size + 10);
|
||||
|
||||
engage_img = loadPixmap("../assets/img_chffr_wheel.png", {img_size, img_size});
|
||||
experimental_img = loadPixmap("../assets/img_experimental.svg", {img_size, img_size});
|
||||
QObject::connect(this, &QPushButton::clicked, this, &ExperimentalButton::changeMode);
|
||||
|
||||
wheelImages = {
|
||||
{0, loadPixmap("../assets/img_chffr_wheel.png", {img_size, img_size})},
|
||||
{1, loadPixmap("../frogpilot/assets/wheel_images/lexus.png", {img_size, img_size})},
|
||||
{2, loadPixmap("../frogpilot/assets/wheel_images/toyota.png", {img_size, img_size})},
|
||||
{3, loadPixmap("../frogpilot/assets/wheel_images/frog.png", {img_size, img_size})},
|
||||
{4, loadPixmap("../frogpilot/assets/wheel_images/rocket.png", {img_size, img_size})},
|
||||
{5, loadPixmap("../frogpilot/assets/wheel_images/hyundai.png", {img_size, img_size})},
|
||||
{6, loadPixmap("../frogpilot/assets/wheel_images/stalin.png", {img_size, img_size})},
|
||||
{7, loadPixmap("../frogpilot/assets/random_events/images/firefox.png", {img_size, img_size})},
|
||||
};
|
||||
|
||||
wheelImagesGif[1] = new QMovie("../frogpilot/assets/random_events/images/weeb_wheel.gif", QByteArray(), this);
|
||||
wheelImagesGif[2] = new QMovie("../frogpilot/assets/random_events/images/tree_fiddy.gif", QByteArray(), this);
|
||||
wheelImagesGif[3] = new QMovie("../frogpilot/assets/random_events/images/great_scott.gif", QByteArray(), this);
|
||||
}
|
||||
|
||||
void ExperimentalButton::changeMode() {
|
||||
const auto cp = (*uiState()->sm)["carParams"].getCarParams();
|
||||
bool can_change = hasLongitudinalControl(cp) && params.getBool("ExperimentalModeConfirmed");
|
||||
if (can_change) {
|
||||
if (scene.conditional_experimental) {
|
||||
int override_value = (scene.conditional_status >= 1 && scene.conditional_status <= 4) ? 0 : scene.conditional_status >= 5 ? 5 : 6;
|
||||
paramsMemory.putIntNonBlocking("ConditionalStatus", override_value);
|
||||
} else {
|
||||
params.putBool("ExperimentalMode", !experimental_mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ExperimentalButton::updateState(const UIState &s, bool leadInfo) {
|
||||
// const auto cs = (*s.sm)["controlsState"].getControlsState();
|
||||
// bool eng = cs.getEngageable() || cs.getEnabled() || scene.always_on_lateral_active;
|
||||
// if ((cs.getExperimentalMode() != experimental_mode) || (eng != engageable)) {
|
||||
// engageable = eng;
|
||||
// experimental_mode = cs.getExperimentalMode();
|
||||
// update();
|
||||
// }
|
||||
|
||||
// // FrogPilot variables
|
||||
// int randomEvent = scene.current_random_event;
|
||||
|
||||
// rotatingWheel = scene.rotating_wheel;
|
||||
// wheelIcon = scene.wheel_icon;
|
||||
// wheelIconGif = 0;
|
||||
|
||||
// y_offset = leadInfo ? 10 : 0;
|
||||
|
||||
// if (randomEvent == 0 && gifLabel) {
|
||||
// delete gifLabel;
|
||||
// gifLabel = nullptr;
|
||||
// } else if (randomEvent == 1) {
|
||||
// static int rotationDegree = 0;
|
||||
// rotationDegree = (rotationDegree + 36) % 360;
|
||||
// steeringAngleDeg = rotationDegree;
|
||||
// wheelIcon = 7;
|
||||
// update();
|
||||
|
||||
// } else if (randomEvent == 2 || randomEvent == 3 || randomEvent == 4) {
|
||||
// if (!gifLabel) {
|
||||
// gifLabel = new QLabel(this);
|
||||
// QMovie *movie = wheelImagesGif[randomEvent - 1];
|
||||
// if (movie) {
|
||||
// gifLabel->setMovie(movie);
|
||||
// gifLabel->setFixedSize(img_size, img_size);
|
||||
// gifLabel->move((width() - gifLabel->width()) / 2, (height() - gifLabel->height()) / 2 + y_offset);
|
||||
// gifLabel->movie()->start();
|
||||
// }
|
||||
// }
|
||||
// gifLabel->show();
|
||||
// wheelIconGif = randomEvent - 1;
|
||||
// update();
|
||||
|
||||
// } else if (rotatingWheel && steeringAngleDeg != scene.steering_angle_deg) {
|
||||
// steeringAngleDeg = scene.steering_angle_deg;
|
||||
// update();
|
||||
// steeringAngleDeg = scene.steering_angle_deg;
|
||||
// } else if (!rotatingWheel) {
|
||||
// steeringAngleDeg = 0;
|
||||
// }
|
||||
}
|
||||
|
||||
void ExperimentalButton::paintEvent(QPaintEvent *event) {
|
||||
// if (wheelIcon < 0) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// QPainter p(this);
|
||||
// engage_img = wheelImages[wheelIcon];
|
||||
// QPixmap img = wheelIcon != 0 ? engage_img : (experimental_mode ? experimental_img : engage_img);
|
||||
// QMovie *gif = wheelImagesGif[wheelIconGif];
|
||||
|
||||
// QColor background_color = wheelIcon != 0 && !isDown() && engageable ?
|
||||
// (scene.always_on_lateral_active ? QColor(10, 186, 181, 255) :
|
||||
// (scene.conditional_status == 1 || scene.conditional_status == 3 || scene.conditional_status == 5 ? QColor(255, 246, 0, 255) :
|
||||
// (experimental_mode ? QColor(218, 111, 37, 241) :
|
||||
// (scene.traffic_mode_active ? QColor(201, 34, 49, 255) :
|
||||
// (scene.navigate_on_openpilot ? QColor(49, 161, 238, 255) : QColor(0, 0, 0, 166)))))) :
|
||||
// QColor(0, 0, 0, 166);
|
||||
|
||||
// if (!(scene.map_open && scene.big_map)) {
|
||||
// if (wheelIconGif != 0) {
|
||||
// drawIconGif(p, QPoint(btn_size / 2, btn_size / 2 + y_offset), *gif, background_color, 1.0);
|
||||
// } else {
|
||||
// drawIcon(p, QPoint(btn_size / 2, btn_size / 2 + y_offset), img, background_color, (isDown() || !engageable) ? 0.6 : 1.0, steeringAngleDeg);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Window that shows camera view and variety of info drawn on top
|
||||
@@ -481,9 +351,6 @@ AnnotatedCameraWidget::AnnotatedCameraWidget(VisionStreamType type, QWidget* par
|
||||
recorder_btn->setVisible(false);
|
||||
// buttons_layout->addWidget(recorder_btn);
|
||||
|
||||
experimental_btn = new ExperimentalButton(this);
|
||||
// buttons_layout->addWidget(experimental_btn);
|
||||
|
||||
QVBoxLayout *top_right_layout = new QVBoxLayout();
|
||||
top_right_layout->setSpacing(0);
|
||||
top_right_layout->addLayout(buttons_layout);
|
||||
@@ -761,11 +628,19 @@ void AnnotatedCameraWidget::drawLaneLines(QPainter &painter, const UIState *s) {
|
||||
}
|
||||
|
||||
// paint center lane path
|
||||
QColor center_lane_color = bg_colors[CENTER_LANE_COLOR];
|
||||
// QColor bg_colors[CHANGE_LANE_PATH_COLOR];
|
||||
|
||||
int is_no_lat_lane_change = paramsMemory.getInt("no_lat_lane_change");
|
||||
|
||||
QColor center_lane_color = is_no_lat_lane_change ?
|
||||
bg_colors[CENTER_LANE_COLOR] :
|
||||
bg_colors[CHANGE_LANE_PATH_COLOR];
|
||||
|
||||
QLinearGradient path_gradient(0, height(), 0, 0);
|
||||
|
||||
if (edgeColor != bg_colors[STATUS_DISENGAGED]) {
|
||||
if (experimentalMode || scene.acceleration_path) {
|
||||
|
||||
if (edgeColor != bg_colors[STATUS_DISENGAGED] || is_no_lat_lane_change) {
|
||||
if (scene.acceleration_path) {
|
||||
// The first half of track_vertices are the points for the right side of the path
|
||||
// and the indices match the positions of accel from uiPlan
|
||||
const auto &acceleration_const = sm["uiPlan"].getUiPlan().getAccel();
|
||||
|
||||
@@ -113,11 +113,10 @@ void update_model(UIState *s,
|
||||
|
||||
// update path
|
||||
float path;
|
||||
if (scene.dynamic_path_width) {
|
||||
float multiplier = scene.enabled ? 1.0f : scene.always_on_lateral_active ? 0.75f : 0.50f;
|
||||
path = scene.path_width * multiplier;
|
||||
} else {
|
||||
path = scene.path_width;
|
||||
if (paramsMemory.getInt("no_lat_lane_change")) {
|
||||
path = LANE_CHANGE_NO_LAT_PATH_WIDTH;
|
||||
}
|
||||
path = CENTER_PATH_WIDTH;
|
||||
}
|
||||
|
||||
auto lead_count = model.getLeadsV3().size();
|
||||
@@ -360,8 +359,8 @@ void ui_update_frogpilot_params(UIState *s) {
|
||||
scene.lane_line_width = params.getInt("LaneLinesWidth") * (scene.is_metric ? 1.0f : INCH_TO_CM) / 200.0f;
|
||||
// CLEARPILOT - either disable these options, or set them as defaults and restore them
|
||||
scene.path_edge_width = params.getInt("PathEdgeWidth");
|
||||
// scene.path_edge_width = /* params.getInt("PathEdgeWidth"); */ OTHER_LANE_WIDTH;
|
||||
scene.path_width = /* params.getInt("PathWidth") */ CENTER_LANE_WIDTH / 10.0f * (scene.is_metric ? 1.0f : FOOT_TO_METER) / 2.0f;
|
||||
// scene.path_edge_width = /* params.getInt("PathEdgeWidth"); */ EDGE_PATH_WIDTH;
|
||||
scene.path_width = /* params.getInt("PathWidth") */ CENTER_PATH_WIDTH / 10.0f * (scene.is_metric ? 1.0f : FOOT_TO_METER) / 2.0f;
|
||||
scene.road_edge_width = params.getInt("RoadEdgesWidth") * (scene.is_metric ? 1.0f : INCH_TO_CM) / 200.0f;
|
||||
scene.unlimited_road_ui_length = scene.model_ui && params.getBool("UnlimitedLength");
|
||||
|
||||
|
||||
@@ -37,8 +37,9 @@ typedef enum UIStatus {
|
||||
const float CENTER_LANE_ALPHA = 0.75;
|
||||
const float OTHER_LANE_ALPHA = 0.75;
|
||||
|
||||
const int CENTER_LANE_WIDTH = 70;
|
||||
const int OTHER_LANE_WIDTH = 16;
|
||||
const int CENTER_PATH_WIDTH = 70;
|
||||
const int LANE_CHANGE_NO_LAT_PATH_WIDTH = 10;
|
||||
const int EDGE_PATH_WIDTH = 16;
|
||||
|
||||
const QColor ACTIVE_COLOR = QColor(189, 199, 252, 0xd1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user