From 3b735907c810923e7ec33cd5746d9239886bab48 Mon Sep 17 00:00:00 2001 From: matlabbe Date: Fri, 29 Mar 2024 13:30:12 -0700 Subject: [PATCH] DbViewer tool: added database's parameter overriding from arguments --- guilib/include/rtabmap/gui/DatabaseViewer.h | 2 +- guilib/src/DatabaseViewer.cpp | 5 ++++- tools/DatabaseViewer/main.cpp | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/guilib/include/rtabmap/gui/DatabaseViewer.h b/guilib/include/rtabmap/gui/DatabaseViewer.h index ede9f1d187..fb80247d9d 100644 --- a/guilib/include/rtabmap/gui/DatabaseViewer.h +++ b/guilib/include/rtabmap/gui/DatabaseViewer.h @@ -71,7 +71,7 @@ class RTABMAP_GUI_EXPORT DatabaseViewer : public QMainWindow public: DatabaseViewer(const QString & ini = QString(), QWidget * parent = 0); virtual ~DatabaseViewer(); - bool openDatabase(const QString & path); + bool openDatabase(const QString & path, const ParametersMap & overridenParameters = ParametersMap()); bool isSavedMaximized() const {return savedMaximized_;} void showCloseButton(bool visible = true); diff --git a/guilib/src/DatabaseViewer.cpp b/guilib/src/DatabaseViewer.cpp index 90f4aec213..9426db840c 100644 --- a/guilib/src/DatabaseViewer.cpp +++ b/guilib/src/DatabaseViewer.cpp @@ -809,7 +809,7 @@ void DatabaseViewer::openDatabase() } } -bool DatabaseViewer::openDatabase(const QString & path) +bool DatabaseViewer::openDatabase(const QString & path, const ParametersMap & overriddenParameters) { UDEBUG("Open database \"%s\"", path.toStdString().c_str()); if(QFile::exists(path)) @@ -844,6 +844,9 @@ bool DatabaseViewer::openDatabase(const QString & path) // look if there are saved parameters ParametersMap parameters = dbDriver_->getLastParameters(); + // add overridden parameters + uInsert(parameters, overriddenParameters); + if(parameters.size()) { const ParametersMap & currentParameters = ui_->parameters_toolbox->getParameters(); diff --git a/tools/DatabaseViewer/main.cpp b/tools/DatabaseViewer/main.cpp index 3872cc4d91..0b96e41382 100644 --- a/tools/DatabaseViewer/main.cpp +++ b/tools/DatabaseViewer/main.cpp @@ -55,9 +55,9 @@ int main(int argc, char * argv[]) mainWindow->showNormal(); - if(argc == 2) + if(argc >= 2) { - mainWindow->openDatabase(argv[1]); + mainWindow->openDatabase(argv[argc-1], rtabmap::Parameters::parseArguments(argc, argv, true)); } // Now wait for application to finish