From 1ea94c0356c780f2a086c153d6f9177f1287cce4 Mon Sep 17 00:00:00 2001 From: matlabbe Date: Thu, 27 Apr 2017 16:13:27 -0400 Subject: [PATCH] DbViewer: refining cancelable, statistics labels selectable and x-axis can be time or IDs --- guilib/src/DatabaseViewer.cpp | 59 +++++++++++++++----- guilib/src/StatsToolBox.cpp | 2 + guilib/src/ui/DatabaseViewer.ui | 97 +++++++++++++++++++++------------ 3 files changed, 108 insertions(+), 50 deletions(-) diff --git a/guilib/src/DatabaseViewer.cpp b/guilib/src/DatabaseViewer.cpp index 63e0c350..ecfb9ae9 100644 --- a/guilib/src/DatabaseViewer.cpp +++ b/guilib/src/DatabaseViewer.cpp @@ -331,6 +331,8 @@ DatabaseViewer::DatabaseViewer(const QString & ini, QWidget * parent) : connect(ui_->actionVertical_Layout, SIGNAL(toggled(bool)), this, SLOT(configModified())); connect(ui_->checkBox_alignPosesWithGroundTruth, SIGNAL(stateChanged(int)), this, SLOT(configModified())); connect(ui_->checkBox_alignPosesWithGroundTruth, SIGNAL(stateChanged(int)), this, SLOT(updateGraphView())); + connect(ui_->checkBox_timeStats, SIGNAL(stateChanged(int)), this, SLOT(configModified())); + connect(ui_->checkBox_timeStats, SIGNAL(stateChanged(int)), this, SLOT(updateStatistics())); // Graph view connect(ui_->checkBox_spanAllMaps, SIGNAL(stateChanged(int)), this, SLOT(configModified())); connect(ui_->checkBox_ignorePoseCorrection, SIGNAL(stateChanged(int)), this, SLOT(configModified())); @@ -455,6 +457,7 @@ void DatabaseViewer::readSettings() ui_->comboBox_logger_level->setCurrentIndex(settings.value("loggerLevel", ui_->comboBox_logger_level->currentIndex()).toInt()); ui_->actionVertical_Layout->setChecked(settings.value("verticalLayout", ui_->actionVertical_Layout->isChecked()).toBool()); ui_->checkBox_alignPosesWithGroundTruth->setChecked(settings.value("alignGroundTruth", ui_->checkBox_alignPosesWithGroundTruth->isChecked()).toBool()); + ui_->checkBox_timeStats->setChecked(settings.value("timeStats", ui_->checkBox_timeStats->isChecked()).toBool()); // GraphViewer settings ui_->graphViewer->loadSettings(settings, "GraphView"); @@ -544,6 +547,7 @@ void DatabaseViewer::writeSettings() settings.setValue("loggerLevel", ui_->comboBox_logger_level->currentIndex()); settings.setValue("verticalLayout", ui_->actionVertical_Layout->isChecked()); settings.setValue("alignGroundTruth", ui_->checkBox_alignPosesWithGroundTruth->isChecked()); + settings.setValue("timeStats", ui_->checkBox_timeStats->isChecked()); // save GraphViewer settings ui_->graphViewer->saveSettings(settings, "GraphView"); @@ -630,6 +634,7 @@ void DatabaseViewer::restoreDefaultSettings() // reset GUI parameters ui_->comboBox_logger_level->setCurrentIndex(1); ui_->checkBox_alignPosesWithGroundTruth->setChecked(true); + ui_->checkBox_timeStats->setChecked(true); ui_->checkBox_spanAllMaps->setChecked(true); ui_->checkBox_ignorePoseCorrection->setChecked(false); @@ -707,6 +712,8 @@ bool DatabaseViewer::openDatabase(const QString & path) ui_->checkBox_showOptimized->setEnabled(false); ui_->toolBox_statistics->clear(); databaseFileName_.clear(); + ui_->checkBox_alignPosesWithGroundTruth->setVisible(false); + ui_->label_alignPosesWithGroundTruth->setVisible(false); } std::string driverType = "sqlite3"; @@ -1283,6 +1290,8 @@ void DatabaseViewer::updateIds() mapIds_.clear(); poses_.clear(); groundTruthPoses_.clear(); + ui_->checkBox_alignPosesWithGroundTruth->setVisible(false); + ui_->label_alignPosesWithGroundTruth->setVisible(false); links_.clear(); linksAdded_.clear(); linksRefined_.clear(); @@ -1382,6 +1391,12 @@ void DatabaseViewer::updateIds() } } } + if(!groundTruthPoses_.empty()) + { + ui_->checkBox_alignPosesWithGroundTruth->setVisible(true); + ui_->label_alignPosesWithGroundTruth->setVisible(true); + } + UINFO("Loaded %d ids, %d poses and %d links", (int)ids_.size(), (int)poses_.size(), (int)links_.size()); if(ids_.size() && ui_->toolBox_statistics->isVisible()) @@ -1547,7 +1562,7 @@ void DatabaseViewer::updateStatistics() } for(std::map::iterator iter=statistics.begin(); iter!=statistics.end(); ++iter) { - ui_->toolBox_statistics->updateStat(iter->first.c_str(), float(stamp-firstStamp), iter->second, true); + ui_->toolBox_statistics->updateStat(iter->first.c_str(), ui_->checkBox_timeStats->isChecked()?float(stamp-firstStamp):ids_[i], iter->second, true); } } } @@ -2315,9 +2330,12 @@ void DatabaseViewer::refineAllNeighborLinks() { if(neighborLinks_.size()) { - rtabmap::ProgressDialog progressDialog(this); - progressDialog.setMaximumSteps(neighborLinks_.size()); - progressDialog.show(); + rtabmap::ProgressDialog * progressDialog = new rtabmap::ProgressDialog(this); + progressDialog->setAttribute(Qt::WA_DeleteOnClose); + progressDialog->setMaximumSteps(neighborLinks_.size()); + progressDialog->setCancelButtonVisible(true); + progressDialog->setMinimumWidth(800); + progressDialog->show(); for(int i=0; irefineConstraint(neighborLinks_[i].from(), neighborLinks_[i].to(), true); - progressDialog.appendText(tr("Refined link %1->%2 (%3/%4)").arg(from).arg(to).arg(i+1).arg(neighborLinks_.size())); - progressDialog.incrementStep(); + progressDialog->appendText(tr("Refined link %1->%2 (%3/%4)").arg(from).arg(to).arg(i+1).arg(neighborLinks_.size())); + progressDialog->incrementStep(); QApplication::processEvents(); + if(progressDialog->isCanceled()) + { + break; + } } this->updateGraphView(); - progressDialog.setValue(progressDialog.maximumSteps()); - progressDialog.appendText("Refining links finished!"); + progressDialog->setValue(progressDialog->maximumSteps()); + progressDialog->appendText("Refining links finished!"); } } @@ -2340,9 +2362,12 @@ void DatabaseViewer::refineAllLoopClosureLinks() { if(loopLinks_.size()) { - rtabmap::ProgressDialog progressDialog(this); - progressDialog.setMaximumSteps(loopLinks_.size()); - progressDialog.show(); + rtabmap::ProgressDialog * progressDialog = new rtabmap::ProgressDialog(this); + progressDialog->setAttribute(Qt::WA_DeleteOnClose); + progressDialog->setMaximumSteps(neighborLinks_.size()); + progressDialog->setCancelButtonVisible(true); + progressDialog->setMinimumWidth(800); + progressDialog->show(); for(int i=0; irefineConstraint(loopLinks_[i].from(), loopLinks_[i].to(), true); - progressDialog.appendText(tr("Refined link %1->%2 (%3/%4)").arg(from).arg(to).arg(i+1).arg(loopLinks_.size())); - progressDialog.incrementStep(); + progressDialog->appendText(tr("Refined link %1->%2 (%3/%4)").arg(from).arg(to).arg(i+1).arg(loopLinks_.size())); + progressDialog->incrementStep(); QApplication::processEvents(); + if(progressDialog->isCanceled()) + { + break; + } } this->updateGraphView(); - progressDialog.setValue(progressDialog.maximumSteps()); - progressDialog.appendText("Refining links finished!"); + progressDialog->setValue(progressDialog->maximumSteps()); + progressDialog->appendText("Refining links finished!"); } } diff --git a/guilib/src/StatsToolBox.cpp b/guilib/src/StatsToolBox.cpp index 72c948a7..59b9a0c7 100644 --- a/guilib/src/StatsToolBox.cpp +++ b/guilib/src/StatsToolBox.cpp @@ -154,8 +154,10 @@ void StatItem::setupUi(QGridLayout * grid) _button->setPopupMode(QToolButton::InstantPopup); _button->setMenu(_menu); _name = new QLabel(this); + _name->setTextInteractionFlags(Qt::TextSelectableByMouse); _name->setWordWrap(true); _value = new QLabel(this); + _value->setTextInteractionFlags(Qt::TextSelectableByMouse); _unit = new QLabel(this); if(grid) diff --git a/guilib/src/ui/DatabaseViewer.ui b/guilib/src/ui/DatabaseViewer.ui index 801437cc..d4b98044 100644 --- a/guilib/src/ui/DatabaseViewer.ui +++ b/guilib/src/ui/DatabaseViewer.ui @@ -52,7 +52,7 @@ 0 0 - 394 + 381 196 @@ -210,7 +210,7 @@ 0 0 - 394 + 381 196 @@ -916,6 +916,26 @@ + + + + Align poses with ground truth + + + true + + + + + + + + + + true + + + @@ -936,19 +956,12 @@ + + 0 + - - - - - Logger level - - - true - - - - + + 1 @@ -975,32 +988,22 @@ - - + + - Align poses with ground truth + Logger level true - - - - - - - true - - - - 1 + 0 @@ -1008,7 +1011,7 @@ 0 0 339 - 210 + 186 @@ -1143,8 +1146,8 @@ 0 0 - 282 - 626 + 326 + 609 @@ -1506,8 +1509,8 @@ 0 0 - 295 - 223 + 339 + 173 @@ -1606,8 +1609,8 @@ 0 0 - 282 - 266 + 326 + 249 @@ -1974,6 +1977,30 @@ 0 + + + + + + + + + true + + + + + + + Time (s) used in figures for x-axis instead of node IDs. + + + true + + + + +