GraphViewer: added Ensure Frame Visible menu option. MainWindow: fixed loop signature failed to load image warning when camera is not used.

This commit is contained in:
matlabbe
2022-02-19 16:16:29 -05:00
parent c2c68c0caf
commit 4d895785a6
3 changed files with 36 additions and 7 deletions

View File

@@ -307,7 +307,8 @@ GraphViewer::GraphViewer(QWidget * parent) :
_loopClosureOutlierThr(0),
_maxLinkLength(0.02f),
_orientationENU(false),
_viewPlane(XY)
_viewPlane(XY),
_ensureFrameVisible(true)
{
this->setScene(new QGraphicsScene(this));
this->setDragMode(QGraphicsView::ScrollHandDrag);
@@ -1008,10 +1009,13 @@ void GraphViewer::updateReferentialPosition(const Transform & t)
_referential->setTransform(qt);
_localRadius->setTransform(qt);
this->ensureVisible(_referential);
if(_localRadius->isVisible())
if(_ensureFrameVisible)
{
this->ensureVisible(_localRadius, 0, 0);
this->ensureVisible(_referential);
if(_localRadius->isVisible())
{
this->ensureVisible(_localRadius, 0, 0);
}
}
}
@@ -1276,6 +1280,7 @@ void GraphViewer::saveSettings(QSettings & settings, const QString & group) cons
settings.setValue("odom_cache_overlay", this->isOdomCacheOverlayVisible());
settings.setValue("orientation_ENU", this->isOrientationENU());
settings.setValue("view_plane", (int)this->getViewPlane());
settings.setValue("ensure_frame_visible", (int)this->isEnsureFrameVisible());
if(!group.isEmpty())
{
settings.endGroup();
@@ -1321,6 +1326,7 @@ void GraphViewer::loadSettings(QSettings & settings, const QString & group)
this->setOdomCacheOverlayVisible(settings.value("odom_cache_overlay", this->isOdomCacheOverlayVisible()).toBool());
this->setOrientationENU(settings.value("orientation_ENU", this->isOrientationENU()).toBool());
this->setViewPlane((ViewPlane)settings.value("view_plane", (int)this->getViewPlane()).toInt());
this->setEnsureFrameVisible(settings.value("ensure_frame_visible", this->isEnsureFrameVisible()).toBool());
if(!group.isEmpty())
{
settings.endGroup();
@@ -1375,6 +1381,10 @@ GraphViewer::ViewPlane GraphViewer::getViewPlane() const
{
return _viewPlane;
}
bool GraphViewer::isEnsureFrameVisible() const
{
return _ensureFrameVisible;
}
void GraphViewer::setWorkingDirectory(const QString & path)
{
@@ -1734,6 +1744,11 @@ void GraphViewer::setViewPlane(ViewPlane plane)
this->scene()->setSceneRect(this->scene()->itemsBoundingRect()); // Re-shrink the scene to it's bounding contents
}
}
void GraphViewer::setEnsureFrameVisible(bool visible)
{
_ensureFrameVisible = visible;
}
void GraphViewer::restoreDefaults()
{
@@ -1840,6 +1855,7 @@ void GraphViewer::contextMenuEvent(QContextMenuEvent * event)
QAction * aSetLinkSize = menu.addAction(tr("Set link width..."));
QAction * aChangeMaxLinkLength = menu.addAction(tr("Set maximum link length..."));
menu.addSeparator();
QAction * aEnsureFrameVisible;
QAction * aShowHideGridMap;
QAction * aShowHideGraph;
QAction * aShowHideGraphNodes;
@@ -1855,6 +1871,9 @@ void GraphViewer::contextMenuEvent(QContextMenuEvent * event)
QAction * aViewPlaneXY;
QAction * aViewPlaneXZ;
QAction * aViewPlaneYZ;
aEnsureFrameVisible = menu.addAction(tr("Ensure Frame Visible"));
aEnsureFrameVisible->setCheckable(true);
aEnsureFrameVisible->setChecked(_ensureFrameVisible);
if(_gridMap->isVisible())
{
aShowHideGridMap = menu.addAction(tr("Hide grid map"));
@@ -2274,6 +2293,10 @@ void GraphViewer::contextMenuEvent(QContextMenuEvent * event)
setLinkWidth(value);
}
}
else if(r == aEnsureFrameVisible)
{
this->setEnsureFrameVisible(!this->isEnsureFrameVisible());
}
else if(r == aShowHideGridMap)
{
this->setGridMapVisible(!this->isGridMapVisible());

View File

@@ -2121,9 +2121,12 @@ void MainWindow::processStats(const rtabmap::Statistics & stat)
{
// uncompress after copy to avoid keeping uncompressed data in memory
loopSignature = iter.value();
bool uncompressImages = _ui->imageView_source->isVisible() ||
(_loopClosureViewer->isVisible() && !signature.sensorData().depthOrRightCompressed().empty());
bool uncompressScan = _loopClosureViewer->isVisible() && !signature.sensorData().laserScanCompressed().isEmpty();
bool uncompressImages = !loopSignature.sensorData().imageCompressed().empty() && (
_ui->imageView_source->isVisible() ||
(_loopClosureViewer->isVisible() &&
!loopSignature.sensorData().depthOrRightCompressed().empty()));
bool uncompressScan = _loopClosureViewer->isVisible() &&
!loopSignature.sensorData().laserScanCompressed().isEmpty();
if(uncompressImages || uncompressScan)
{
cv::Mat tmpRGB, tmpDepth;