mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-06-28 01:52:06 +08:00
Pending Speed Limit Cleanup
Fixed the speed limit display so it no longer flashes an empty speeds, and now flashes over the current speed for a cleaner look.
This commit is contained in:
@@ -220,6 +220,7 @@ void StarPilotAnnotatedCameraWidget::updateState(const UIState &s, const StarPil
|
||||
slcOverriddenSpeed = starpilotPlan.getSlcOverriddenSpeed();
|
||||
speedLimit = slcOverriddenSpeed != 0 ? slcOverriddenSpeed : starpilotPlan.getSlcSpeedLimit();
|
||||
speedLimitChanged = starpilotPlan.getSpeedLimitChanged();
|
||||
unconfirmedSpeedLimitValid = starpilotPlan.getUnconfirmedSlcSpeedLimit() > 1;
|
||||
speedLimitSource = starpilotPlan.getSlcSpeedLimitSource();
|
||||
stoppingDistance = modelV2.getPosition().getX().size() > 33 - 1 ? modelV2.getPosition().getX()[33 - 1] : 0.0;
|
||||
unconfirmedSpeedLimit = starpilotPlan.getUnconfirmedSlcSpeedLimit();
|
||||
@@ -261,7 +262,7 @@ void StarPilotAnnotatedCameraWidget::updateState(const UIState &s, const StarPil
|
||||
glowTimer.invalidate();
|
||||
}
|
||||
|
||||
if (speedLimitChanged) {
|
||||
if (speedLimitChanged && unconfirmedSpeedLimitValid) {
|
||||
if (!pendingLimitTimer.isValid()) {
|
||||
pendingLimitTimer.start();
|
||||
}
|
||||
@@ -287,7 +288,7 @@ void StarPilotAnnotatedCameraWidget::mousePressEvent(QMouseEvent *mouseEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (speedLimitChanged && newSpeedLimitRect.contains(mouseEvent->pos())) {
|
||||
if (speedLimitChanged && speedLimitRect.contains(mouseEvent->pos())) {
|
||||
params_memory.putBool("SpeedLimitAccepted", true);
|
||||
mouseEvent->accept();
|
||||
return;
|
||||
@@ -301,7 +302,6 @@ void StarPilotAnnotatedCameraWidget::paintStarPilotWidgets(QPainter &p, UIState
|
||||
cemStatusPosition = QPoint(0, 0);
|
||||
compassPosition = QPoint(0, 0);
|
||||
lateralPausedPosition = QPoint(0, 0);
|
||||
newSpeedLimitRect = QRect();
|
||||
speedLimitHeight = 0;
|
||||
return;
|
||||
}
|
||||
@@ -345,10 +345,6 @@ void StarPilotAnnotatedCameraWidget::paintStarPilotWidgets(QPainter &p, UIState
|
||||
paintPedalIcons(p);
|
||||
}
|
||||
|
||||
if (speedLimitChanged) {
|
||||
paintPendingSpeedLimit(p);
|
||||
}
|
||||
|
||||
if (cachedRadarTracks) {
|
||||
paintRadarTracks(p);
|
||||
}
|
||||
@@ -357,7 +353,7 @@ void StarPilotAnnotatedCameraWidget::paintStarPilotWidgets(QPainter &p, UIState
|
||||
paintRoadName(p);
|
||||
}
|
||||
|
||||
bool hideSpeedLimit = !speedLimitChanged && cachedHideSpeedLimit;
|
||||
bool hideSpeedLimit = !(speedLimitChanged && unconfirmedSpeedLimitValid) && cachedHideSpeedLimit;
|
||||
if (!hideSpeedLimit && (cachedShowSpeedLimits || cachedSpeedLimitController)) {
|
||||
paintSpeedLimit(p);
|
||||
} else {
|
||||
@@ -845,40 +841,6 @@ void StarPilotAnnotatedCameraWidget::paintPedalIcons(QPainter &p) {
|
||||
p.restore();
|
||||
}
|
||||
|
||||
void StarPilotAnnotatedCameraWidget::paintPendingSpeedLimit(QPainter &p) {
|
||||
p.save();
|
||||
|
||||
QString newSpeedLimitStr = (unconfirmedSpeedLimit > 1) ? QString::number(std::nearbyint(unconfirmedSpeedLimit * speedConversion)) : "–";
|
||||
newSpeedLimitRect = speedLimitRect.translated(speedLimitRect.width() + UI_BORDER_SIZE, 0);
|
||||
|
||||
if (!cachedSpeedLimitVienna) {
|
||||
newSpeedLimitRect.setWidth(newSpeedLimitStr.size() >= 3 ? 200 : 175);
|
||||
|
||||
p.setBrush(whiteColor());
|
||||
p.setPen(Qt::NoPen);
|
||||
p.drawRoundedRect(newSpeedLimitRect, 24, 24);
|
||||
p.setPen(pendingLimitTimer.elapsed() % 1000 < 500 ? QPen(blackColor(), 6) : QPen(redColor(), 6));
|
||||
p.drawRoundedRect(newSpeedLimitRect.adjusted(9, 9, -9, -9), 16, 16);
|
||||
|
||||
p.setFont(InterFont(28, QFont::DemiBold));
|
||||
p.drawText(newSpeedLimitRect.adjusted(0, 22, 0, 0), Qt::AlignTop | Qt::AlignHCenter, tr("PENDING"));
|
||||
p.drawText(newSpeedLimitRect.adjusted(0, 51, 0, 0), Qt::AlignTop | Qt::AlignHCenter, tr("LIMIT"));
|
||||
p.setFont(InterFont(70, QFont::Bold));
|
||||
p.drawText(newSpeedLimitRect.adjusted(0, 85, 0, 0), Qt::AlignTop | Qt::AlignHCenter, newSpeedLimitStr);
|
||||
} else {
|
||||
p.setBrush(whiteColor());
|
||||
p.setPen(Qt::NoPen);
|
||||
p.drawEllipse(newSpeedLimitRect);
|
||||
p.setPen(QPen(Qt::red, 20));
|
||||
p.drawEllipse(newSpeedLimitRect.adjusted(16, 16, -16, -16));
|
||||
|
||||
p.setPen(pendingLimitTimer.elapsed() % 1000 < 500 ? QPen(blackColor(), 6) : QPen(redColor(), 6));
|
||||
p.setFont(InterFont((newSpeedLimitStr.size() >= 3) ? 60 : 70, QFont::Bold));
|
||||
p.drawText(newSpeedLimitRect, Qt::AlignCenter, newSpeedLimitStr);
|
||||
}
|
||||
|
||||
p.restore();
|
||||
}
|
||||
|
||||
void StarPilotAnnotatedCameraWidget::paintRainbowPath(QPainter &p, QLinearGradient &bg, float lin_grad_point) {
|
||||
p.save();
|
||||
@@ -959,7 +921,12 @@ void StarPilotAnnotatedCameraWidget::paintSpeedLimit(QPainter &p) {
|
||||
|
||||
p.save();
|
||||
|
||||
QString speedLimitStr = (speedLimit > 1) ? QString::number(std::nearbyint(speedLimit)) : "–";
|
||||
bool isFlashingPending = speedLimitChanged && unconfirmedSpeedLimitValid;
|
||||
bool flashOn = isFlashingPending && (pendingLimitTimer.elapsed() % 1000 < 500);
|
||||
QString displaySpeedLimitStr = isFlashingPending
|
||||
? QString::number(std::nearbyint(unconfirmedSpeedLimit * speedConversion))
|
||||
: ((speedLimit > 1) ? QString::number(std::nearbyint(speedLimit)) : "–");
|
||||
QString speedLimitStr = displaySpeedLimitStr;
|
||||
|
||||
bool hasUsSpeedLimit = !cachedSpeedLimitVienna;
|
||||
bool hasEuSpeedLimit = !hasUsSpeedLimit;
|
||||
@@ -983,14 +950,23 @@ void StarPilotAnnotatedCameraWidget::paintSpeedLimit(QPainter &p) {
|
||||
speedLimitRect = signRect;
|
||||
|
||||
if (hasUsSpeedLimit) {
|
||||
QColor borderColor = flashOn ? redColor() : blackColor();
|
||||
QColor textColor = flashOn ? redColor() : blackColor();
|
||||
|
||||
p.setPen(Qt::NoPen);
|
||||
p.setBrush(whiteColor());
|
||||
p.drawRoundedRect(signRect, 24, 24);
|
||||
p.setPen(QPen(blackColor(), 6));
|
||||
p.setPen(QPen(borderColor, 6));
|
||||
p.drawRoundedRect(signRect.adjusted(9, 9, -9, -9), 16, 16);
|
||||
|
||||
p.setOpacity(slcOverriddenSpeed == 0 ? 1.0 : 0.25);
|
||||
if (slcOverriddenSpeed == 0 && cachedShowSpeedLimitOffset) {
|
||||
p.setPen(textColor);
|
||||
if (isFlashingPending) {
|
||||
p.setFont(InterFont(28, QFont::DemiBold));
|
||||
p.drawText(signRect.adjusted(0, 22, 0, 0), Qt::AlignTop | Qt::AlignHCenter, tr("PENDING"));
|
||||
p.setFont(InterFont(70, QFont::Bold));
|
||||
p.drawText(signRect.adjusted(0, 51, 0, 0), Qt::AlignTop | Qt::AlignHCenter, speedLimitStr);
|
||||
} else if (slcOverriddenSpeed == 0 && cachedShowSpeedLimitOffset) {
|
||||
p.setFont(InterFont(28, QFont::DemiBold));
|
||||
p.drawText(signRect.adjusted(0, 22, 0, 0), Qt::AlignTop | Qt::AlignHCenter, tr("LIMIT"));
|
||||
p.setFont(InterFont(70, QFont::Bold));
|
||||
@@ -1007,6 +983,8 @@ void StarPilotAnnotatedCameraWidget::paintSpeedLimit(QPainter &p) {
|
||||
}
|
||||
|
||||
if (hasEuSpeedLimit) {
|
||||
QColor textColor = flashOn ? redColor() : blackColor();
|
||||
|
||||
p.setPen(Qt::NoPen);
|
||||
p.setBrush(whiteColor());
|
||||
p.drawEllipse(signRect);
|
||||
@@ -1014,8 +992,11 @@ void StarPilotAnnotatedCameraWidget::paintSpeedLimit(QPainter &p) {
|
||||
p.drawEllipse(signRect.adjusted(16, 16, -16, -16));
|
||||
|
||||
p.setOpacity(slcOverriddenSpeed == 0 ? 1.0 : 0.25);
|
||||
p.setPen(blackColor());
|
||||
if (cachedShowSpeedLimitOffset) {
|
||||
p.setPen(textColor);
|
||||
if (isFlashingPending) {
|
||||
p.setFont(InterFont((speedLimitStr.size() >= 3) ? 60 : 70, QFont::Bold));
|
||||
p.drawText(signRect, Qt::AlignCenter, speedLimitStr);
|
||||
} else if (cachedShowSpeedLimitOffset) {
|
||||
p.setFont(InterFont((speedLimitStr.size() >= 3) ? 60 : 70, QFont::Bold));
|
||||
p.drawText(signRect.adjusted(0, -25, 0, 0), Qt::AlignCenter, speedLimitStr);
|
||||
p.setFont(InterFont(40, QFont::DemiBold));
|
||||
|
||||
@@ -66,7 +66,6 @@ private:
|
||||
void paintLateralPaused(QPainter &p);
|
||||
void paintLongitudinalPaused(QPainter &p);
|
||||
void paintPedalIcons(QPainter &p);
|
||||
void paintPendingSpeedLimit(QPainter &p);
|
||||
void paintRadarTracks(QPainter &p);
|
||||
void paintRoadName(QPainter &p);
|
||||
void paintSpeedLimit(QPainter &p);
|
||||
@@ -93,6 +92,7 @@ private:
|
||||
bool longitudinalPaused;
|
||||
bool redLight;
|
||||
bool speedLimitChanged;
|
||||
bool unconfirmedSpeedLimitValid = false;
|
||||
bool weatherDaytime;
|
||||
|
||||
// Cached toggle values — refreshed once per updateState(), used in paint code
|
||||
@@ -186,7 +186,6 @@ private:
|
||||
QPoint compassPosition;
|
||||
QPoint lateralPausedPosition;
|
||||
|
||||
QRect newSpeedLimitRect;
|
||||
QRect speedLimitRect;
|
||||
|
||||
QSharedPointer<QMovie> cemCurveIcon;
|
||||
|
||||
Reference in New Issue
Block a user