Skip to content

Commit 0eb1376

Browse files
author
KhalilSelyan
committed
chore: update steering wheel display to center the steering angle text
Signed-off-by: KhalilSelyan <khalil@leodrive.ai>
1 parent 612ba58 commit 0eb1376

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

Diff for: common/autoware_overlay_rviz_plugin/autoware_overlay_rviz_plugin/src/steering_wheel_display.cpp

+14-3
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,20 @@ void SteeringWheelDisplay::drawSteeringWheel(
111111
QFont steeringFont("Quicksand", 8, QFont::Bold);
112112
painter.setFont(steeringFont);
113113
painter.setPen(QColor(0, 0, 0, 255));
114-
QRect steeringRect(
115-
wheelCenterX - wheelImage.width() / 2 + 1, wheelCenterY - wheelImage.height() / 2,
116-
wheelImage.width(), wheelImage.height());
114+
// QRect steeringRect(
115+
// wheelCenterX - wheelImage.width() / 2 + 1, wheelCenterY - wheelImage.height() / 2,
116+
// wheelImage.width(), wheelImage.height());
117+
// painter.drawText(steeringRect, Qt::AlignCenter, steeringAngleString);
118+
119+
// Measure the text
120+
QFontMetrics fontMetrics(steeringFont);
121+
QRect textRect = fontMetrics.boundingRect(steeringAngleString);
122+
123+
// Center the text
124+
int textX = wheelCenterX - textRect.width() / 2;
125+
int textY = wheelCenterY - textRect.height() / 2;
126+
127+
QRect steeringRect(textX, textY, textRect.width(), textRect.height());
117128
painter.drawText(steeringRect, Qt::AlignCenter, steeringAngleString);
118129
}
119130

0 commit comments

Comments
 (0)