From 21c91e252e3e1fa6f69ea511f6113b2eb6666ace Mon Sep 17 00:00:00 2001 From: Victor Reijgwart Date: Thu, 12 Dec 2024 18:11:17 +0100 Subject: [PATCH] Preselect last loaded map in file dialog to enable easy reloads in Rviz --- .../ros1/wavemap_rviz_plugin/src/wavemap_map_display.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/interfaces/ros1/wavemap_rviz_plugin/src/wavemap_map_display.cc b/interfaces/ros1/wavemap_rviz_plugin/src/wavemap_map_display.cc index a9452c92e..872c28253 100644 --- a/interfaces/ros1/wavemap_rviz_plugin/src/wavemap_map_display.cc +++ b/interfaces/ros1/wavemap_rviz_plugin/src/wavemap_map_display.cc @@ -275,7 +275,12 @@ void WavemapMapDisplay::requestWholeMapCallback() { void WavemapMapDisplay::loadMapFromDiskCallback() { ProfilerZoneScoped; // Open file selection dialog - const auto filepath_qt = QFileDialog::getOpenFileName(); + const bool has_last_path = + std::filesystem::exists(load_map_from_disk_property_.getAtRestValue()); + const std::string last_path = + has_last_path ? load_map_from_disk_property_.getAtRestValue() : ""; + const auto filepath_qt = QFileDialog::getOpenFileName( + nullptr, "Choose a wavemap map file", last_path.c_str()); // Check if the chosen filepath is not empty if (filepath_qt.isEmpty()) {