mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-06-28 01:52:06 +08:00
ui: show map with nav (#28867)
* accept touch events in map settings * draft * draft 2.0 * revert this stuff * need this * fix * clean up debug prints * fraft * only show map on closeSettings if nav * works! * can't do it here * I was going to connect signals from UIState to HomeWindow, then to OnroadWidget, but that seems like too much * just need to keep track of it in onroad, seems like the cleanest option * ideally we show the map where we set the scene variable, and that's in map.cc * old variable * comments * less confusing * app comment * add back * fix * move to top * remove this comment old-commit-hash: 34a5e626d6f55cd33bc292e4f9d4a21e1fd2972b
This commit is contained in:
@@ -55,6 +55,10 @@ void HomeWindow::showSidebar(bool show) {
|
||||
sidebar->setVisible(show);
|
||||
}
|
||||
|
||||
void HomeWindow::showMapPanel(bool show) {
|
||||
onroad->showMapPanel(show);
|
||||
}
|
||||
|
||||
void HomeWindow::updateState(const UIState &s) {
|
||||
const SubMaster &sm = *(s.sm);
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ public slots:
|
||||
void offroadTransition(bool offroad);
|
||||
void showDriverView(bool show);
|
||||
void showSidebar(bool show);
|
||||
void showMapPanel(bool show);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent* e) override;
|
||||
|
||||
@@ -130,6 +130,15 @@ void MapWindow::updateState(const UIState &s) {
|
||||
const SubMaster &sm = *(s.sm);
|
||||
update();
|
||||
|
||||
// update navigate on openpilot status
|
||||
if (sm.updated("modelV2")) {
|
||||
bool nav_enabled = sm["modelV2"].getModelV2().getNavEnabled();
|
||||
if (nav_enabled && !uiState()->scene.navigate_on_openpilot) {
|
||||
emit requestVisible(true); // Show map on rising edge of navigate on openpilot
|
||||
}
|
||||
uiState()->scene.navigate_on_openpilot = nav_enabled;
|
||||
}
|
||||
|
||||
if (sm.updated("liveLocationKalman")) {
|
||||
auto locationd_location = sm["liveLocationKalman"].getLiveLocationKalman();
|
||||
auto locationd_pos = locationd_location.getPositionGeodetic();
|
||||
|
||||
@@ -74,8 +74,10 @@ void OnroadWindow::updateState(const UIState &s) {
|
||||
void OnroadWindow::mousePressEvent(QMouseEvent* e) {
|
||||
#ifdef ENABLE_MAPS
|
||||
if (map != nullptr) {
|
||||
// Switch between map and sidebar when using navigate on openpilot
|
||||
bool sidebarVisible = geometry().x() > 0;
|
||||
map->setVisible(!sidebarVisible && !map->isVisible());
|
||||
bool show_map = uiState()->scene.navigate_on_openpilot ? sidebarVisible : !sidebarVisible;
|
||||
map->setVisible(show_map && !map->isVisible());
|
||||
}
|
||||
#endif
|
||||
// propagation event to parent(HomeWindow)
|
||||
|
||||
@@ -117,6 +117,7 @@ class OnroadWindow : public QWidget {
|
||||
public:
|
||||
OnroadWindow(QWidget* parent = 0);
|
||||
bool isMapVisible() const { return map && map->isVisible(); }
|
||||
void showMapPanel(bool show) { if (map) map->setVisible(show); }
|
||||
|
||||
signals:
|
||||
void mapPanelRequested();
|
||||
|
||||
@@ -75,6 +75,10 @@ void MainWindow::closeSettings() {
|
||||
|
||||
if (uiState()->scene.started) {
|
||||
homeWindow->showSidebar(false);
|
||||
// Map is always shown when using navigate on openpilot
|
||||
if (uiState()->scene.navigate_on_openpilot) {
|
||||
homeWindow->showMapPanel(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -131,6 +131,8 @@ typedef struct UIScene {
|
||||
float driver_pose_coss[3];
|
||||
vec3 face_kpts_draw[std::size(default_face_kpts_3d)];
|
||||
|
||||
bool navigate_on_openpilot = false;
|
||||
|
||||
float light_sensor;
|
||||
bool started, ignition, is_metric, map_on_left, longitudinal_control;
|
||||
uint64_t started_frame;
|
||||
|
||||
Reference in New Issue
Block a user