Skip to content

Commit 0cf40d9

Browse files
author
KhalilSelyan
committed
refactor: Update Autoware state panel layout and appearance
Signed-off-by: KhalilSelyan <khalil@leodrive.ai>
1 parent 4e01a78 commit 0cf40d9

File tree

1 file changed

+46
-28
lines changed

1 file changed

+46
-28
lines changed

common/tier4_state_rviz_plugin/src/autoware_state_panel.cpp

+46-28
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,16 @@ AutowareStatePanel::AutowareStatePanel(QWidget * parent) : rviz_common::Panel(pa
3636
this->setMaximumWidth(400);
3737

3838
// Layout
39-
auto * main_v_layout = new QVBoxLayout;
40-
main_v_layout->setAlignment(Qt::AlignTop);
39+
40+
// Create a new container widget
41+
QWidget * containerWidget = new QWidget(this);
42+
containerWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
43+
44+
containerWidget->setStyleSheet("QWidget { background-color: #0F1417; color: #d0e6f2; }");
45+
46+
auto * containerLayout = new QVBoxLayout(containerWidget);
47+
// Set the alignment of the layout
48+
containerLayout->setAlignment(Qt::AlignTop);
4149

4250
auto * operation_mode_group = makeOperationModeGroup();
4351
auto * diagnostic_v_layout = new QVBoxLayout;
@@ -56,16 +64,18 @@ AutowareStatePanel::AutowareStatePanel(QWidget * parent) : rviz_common::Panel(pa
5664
// diagnostic_v_layout->addSpacing(5);
5765
diagnostic_v_layout->addLayout(fail_safe_group);
5866

59-
// main_v_layout->addLayout(diagnostic_group);
67+
// containerLayout->addLayout(diagnostic_group);
6068

61-
main_v_layout->addLayout(operation_mode_group);
62-
// main_v_layout->addSpacing(5);
63-
main_v_layout->addLayout(diagnostic_v_layout);
69+
containerLayout->addLayout(operation_mode_group);
70+
// containerLayout->addSpacing(5);
71+
containerLayout->addLayout(diagnostic_v_layout);
6472
// main_v_layout->addSpacing(5);
65-
main_v_layout->addLayout(velocity_limit_group);
73+
containerLayout->addLayout(velocity_limit_group);
6674

67-
// Setting the layout
68-
setLayout(main_v_layout);
75+
// Main layout for AutowareStatePanel
76+
QVBoxLayout * mainLayout = new QVBoxLayout(this);
77+
mainLayout->addWidget(containerWidget);
78+
setLayout(mainLayout);
6979
}
7080

7181
void AutowareStatePanel::onInitialize()
@@ -394,28 +404,31 @@ QVBoxLayout * AutowareStatePanel::makeVelocityLimitGroup()
394404
void AutowareStatePanel::onOperationMode(const OperationModeState::ConstSharedPtr msg)
395405
{
396406
auto changeButtonState = [this](
397-
QPushButton * button, const bool is_desired_mode_available,
407+
CustomSegmentedButtonItem * button,
408+
const bool is_desired_mode_available,
398409
const uint8_t current_mode = OperationModeState::UNKNOWN,
399410
const uint8_t desired_mode = OperationModeState::STOP) {
400-
if (is_desired_mode_available && current_mode != desired_mode) {
401-
activateButton(button);
402-
button->setStyleSheet(
403-
"QPushButton {"
404-
"background-color: #8BD0F0;color: #003546;"
405-
"font-weight: bold;"
406-
"}"
407-
"QPushButton:hover {"
408-
"background-color: #84c2e6;"
409-
"color: #003546;"
410-
"}");
411+
button->setHovered(false); // Reset hover state
412+
if (is_desired_mode_available) {
413+
if (current_mode == desired_mode) {
414+
// Enabled and Checked
415+
button->setChecked(true);
416+
button->setActivated(true);
417+
button->setCheckableButton(false);
418+
button->setDisabledButton(false);
419+
} else {
420+
// Enabled and Checkable
421+
button->setChecked(false);
422+
button->setActivated(false);
423+
button->setCheckableButton(true);
424+
button->setDisabledButton(false);
425+
}
411426
} else {
412-
button->setStyleSheet(
413-
"QPushButton {"
414-
"background-color: #292d30;color: #6e7276;"
415-
"border: 2px solid #292d30;"
416-
"font-weight: bold;"
417-
"}");
418-
deactivateButton(button);
427+
// Disabled and Unchecked
428+
button->setChecked(false);
429+
button->setActivated(false);
430+
button->setCheckableButton(false);
431+
button->setDisabledButton(true);
419432
}
420433
};
421434

@@ -437,6 +450,11 @@ void AutowareStatePanel::onOperationMode(const OperationModeState::ConstSharedPt
437450

438451
// toggle switch for control mode
439452
changeToggleSwitchState(control_mode_switch_ptr_, !msg->is_autoware_control_enabled);
453+
454+
// routing
455+
if (msg->is_in_transition) {
456+
routing_icon->updateStyle(Pending, QColor("#eef08b"));
457+
}
440458
}
441459

442460
void AutowareStatePanel::onRoute(const RouteState::ConstSharedPtr msg)

0 commit comments

Comments
 (0)