Fixed crash on startup with vtk6+qt5. All cloud viewers in QDockWidget are now created manually instead of being defined in the *.ui files. The generated ui didn't pass the top level parent window to constructor of CloudViewer, which caused a problem when initializing the QVTKWidget.

This commit is contained in:
matlabbe
2016-05-05 18:25:26 -04:00
parent 74d0bfa1bb
commit ad0afc58c0
11 changed files with 455 additions and 250 deletions
+4
View File
@@ -206,6 +206,8 @@ public:
Transform getTargetPose() const; Transform getTargetPose() const;
void setBackfaceCulling(bool enabled, bool frontfaceCulling); void setBackfaceCulling(bool enabled, bool frontfaceCulling);
void setRenderingRate(double rate);
double getRenderingRate() const;
void getCameraPosition( void getCameraPosition(
float & x, float & y, float & z, float & x, float & y, float & z,
@@ -275,6 +277,7 @@ private:
QAction * _aSetGridCellCount; QAction * _aSetGridCellCount;
QAction * _aSetGridCellSize; QAction * _aSetGridCellSize;
QAction * _aSetBackgroundColor; QAction * _aSetBackgroundColor;
QAction * _aSetRenderingRate;
QMenu * _menu; QMenu * _menu;
std::set<std::string> _graphes; std::set<std::string> _graphes;
std::set<std::string> _coordinates; std::set<std::string> _coordinates;
@@ -297,6 +300,7 @@ private:
QColor _currentBgColor; QColor _currentBgColor;
bool _backfaceCulling; bool _backfaceCulling;
bool _frontfaceCulling; bool _frontfaceCulling;
double _renderingRate;
}; };
} /* namespace rtabmap */ } /* namespace rtabmap */
@@ -157,6 +157,10 @@ private:
private: private:
Ui_DatabaseViewer * ui_; Ui_DatabaseViewer * ui_;
CloudViewer * constraintsViewer_;
CloudViewer * cloudViewerA_;
CloudViewer * cloudViewerB_;
CloudViewer * stereoViewer_;
QList<int> ids_; QList<int> ids_;
std::map<int, int> mapIds_; std::map<int, int> mapIds_;
QMap<int, int> idToIndex_; QMap<int, int> idToIndex_;
@@ -45,7 +45,7 @@ class RTABMAPGUI_EXP LoopClosureViewer : public QWidget {
Q_OBJECT Q_OBJECT
public: public:
LoopClosureViewer(QWidget * parent); LoopClosureViewer(QWidget * parent = 0);
virtual ~LoopClosureViewer(); virtual ~LoopClosureViewer();
void setData(const Signature & sA, const Signature & sB); // sB contains loop transform as pose() from sA void setData(const Signature & sA, const Signature & sB); // sB contains loop transform as pose() from sA
+4
View File
@@ -52,6 +52,7 @@ class CameraOpenni;
class CameraFreenect; class CameraFreenect;
class OdometryThread; class OdometryThread;
class CloudViewer; class CloudViewer;
class LoopClosureViewer;
} }
class QGraphicsScene; class QGraphicsScene;
@@ -307,6 +308,9 @@ private:
ProgressDialog * _initProgressDialog; ProgressDialog * _initProgressDialog;
CloudViewer * _cloudViewer;
LoopClosureViewer * _loopClosureViewer;
QString _graphSavingFileName; QString _graphSavingFileName;
QMap<int, QString> _exportPosesFileName; QMap<int, QString> _exportPosesFileName;
bool _autoScreenCaptureOdomSync; bool _autoScreenCaptureOdomSync;
+40 -8
View File
@@ -31,7 +31,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <rtabmap/utilite/UTimer.h> #include <rtabmap/utilite/UTimer.h>
#include <rtabmap/utilite/UMath.h> #include <rtabmap/utilite/UMath.h>
#include <rtabmap/utilite/UConversion.h> #include <rtabmap/utilite/UConversion.h>
#include <rtabmap/core/util3d.h>
#include <pcl/visualization/pcl_visualizer.h> #include <pcl/visualization/pcl_visualizer.h>
#include <pcl/common/transforms.h> #include <pcl/common/transforms.h>
#include <QMenu> #include <QMenu>
@@ -42,6 +41,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QtGui/QKeyEvent> #include <QtGui/QKeyEvent>
#include <QColorDialog> #include <QColorDialog>
#include <QtGui/QVector3D> #include <QtGui/QVector3D>
#include <QMainWindow>
#include <set> #include <set>
#include <vtkCamera.h> #include <vtkCamera.h>
@@ -121,22 +121,29 @@ CloudViewer::CloudViewer(QWidget *parent) :
_defaultBgColor(Qt::black), _defaultBgColor(Qt::black),
_currentBgColor(Qt::black), _currentBgColor(Qt::black),
_backfaceCulling(false), _backfaceCulling(false),
_frontfaceCulling(false) _frontfaceCulling(false),
_renderingRate(5.0)
{ {
UDEBUG("");
this->setMinimumSize(200, 200); this->setMinimumSize(200, 200);
int argc = 0; int argc = 0;
_visualizer = new pcl::visualization::PCLVisualizer(argc, 0, "PCLVisualizer", vtkSmartPointer<MyInteractorStyle>(new MyInteractorStyle()), false); _visualizer = new pcl::visualization::PCLVisualizer(
argc,
0,
"PCLVisualizer",
vtkSmartPointer<MyInteractorStyle>(new MyInteractorStyle()),
false);
_visualizer->setShowFPS(false); _visualizer->setShowFPS(false);
this->SetRenderWindow(_visualizer->getRenderWindow()); this->SetRenderWindow(_visualizer->getRenderWindow());
// Replaced by the second line, to avoid a crash in Mac OS X on close, as well as // Replaced by the second line, to avoid a crash in Mac OS X on close, as well as
// the "Invalid drawable" warning when the view is not visible. // the "Invalid drawable" warning when the view is not visible.
//_visualizer->setupInteractor(this->GetInteractor(), this->GetRenderWindow()); //_visualizer->setupInteractor(this->GetInteractor(), this->GetRenderWindow());
this->GetInteractor()->SetInteractorStyle (_visualizer->getInteractorStyle()); this->GetInteractor()->SetInteractorStyle (_visualizer->getInteractorStyle());
_visualizer->getInteractorStyle()->GetInteractor()->SetDesiredUpdateRate(5.0); setRenderingRate(_renderingRate);
_visualizer->setCameraPosition( _visualizer->setCameraPosition(
-1, 0, 0, -1, 0, 0,
@@ -205,7 +212,8 @@ void CloudViewer::createMenu()
_aShowGrid->setCheckable(true); _aShowGrid->setCheckable(true);
_aSetGridCellCount = new QAction("Set cell count...", this); _aSetGridCellCount = new QAction("Set cell count...", this);
_aSetGridCellSize = new QAction("Set cell size...", this); _aSetGridCellSize = new QAction("Set cell size...", this);
_aSetBackgroundColor = new QAction("Set background color...", this); _aSetBackgroundColor = new QAction("Set background color...", this);
_aSetRenderingRate = new QAction("Set rendering rate...", this);
QMenu * cameraMenu = new QMenu("Camera", this); QMenu * cameraMenu = new QMenu("Camera", this);
cameraMenu->addAction(_aLockCamera); cameraMenu->addAction(_aLockCamera);
@@ -241,6 +249,7 @@ void CloudViewer::createMenu()
_menu->addMenu(frustumMenu); _menu->addMenu(frustumMenu);
_menu->addMenu(gridMenu); _menu->addMenu(gridMenu);
_menu->addAction(_aSetBackgroundColor); _menu->addAction(_aSetBackgroundColor);
_menu->addAction(_aSetRenderingRate);
} }
void CloudViewer::saveSettings(QSettings & settings, const QString & group) const void CloudViewer::saveSettings(QSettings & settings, const QString & group) const
@@ -290,6 +299,7 @@ void CloudViewer::saveSettings(QSettings & settings, const QString & group) cons
settings.setValue("camera_lockZ", this->isCameraLockZ()); settings.setValue("camera_lockZ", this->isCameraLockZ());
settings.setValue("bg_color", this->getDefaultBackgroundColor()); settings.setValue("bg_color", this->getDefaultBackgroundColor());
settings.setValue("rendering_rate", this->getRenderingRate());
if(!group.isEmpty()) if(!group.isEmpty())
{ {
settings.endGroup(); settings.endGroup();
@@ -331,6 +341,9 @@ void CloudViewer::loadSettings(QSettings & settings, const QString & group)
this->setCameraLockZ(settings.value("camera_lockZ", this->isCameraLockZ()).toBool()); this->setCameraLockZ(settings.value("camera_lockZ", this->isCameraLockZ()).toBool());
this->setDefaultBackgroundColor(settings.value("bg_color", this->getDefaultBackgroundColor()).value<QColor>()); this->setDefaultBackgroundColor(settings.value("bg_color", this->getDefaultBackgroundColor()).value<QColor>());
this->setRenderingRate(settings.value("rendering_rate", this->getRenderingRate()).toDouble());
if(!group.isEmpty()) if(!group.isEmpty())
{ {
settings.endGroup(); settings.endGroup();
@@ -1136,6 +1149,12 @@ void CloudViewer::setBackfaceCulling(bool enabled, bool frontfaceCulling)
_frontfaceCulling = frontfaceCulling; _frontfaceCulling = frontfaceCulling;
} }
void CloudViewer::setRenderingRate(double rate)
{
_renderingRate = rate;
_visualizer->getInteractorStyle()->GetInteractor()->SetDesiredUpdateRate(_renderingRate);
}
void CloudViewer::getCameraPosition( void CloudViewer::getCameraPosition(
float & x, float & y, float & z, float & x, float & y, float & z,
float & focalX, float & focalY, float & focalZ, float & focalX, float & focalY, float & focalZ,
@@ -1438,6 +1457,10 @@ float CloudViewer::getGridCellSize() const
{ {
return _gridCellSize; return _gridCellSize;
} }
double CloudViewer::getRenderingRate() const
{
return _renderingRate;
}
void CloudViewer::setGridCellCount(unsigned int count) void CloudViewer::setGridCellCount(unsigned int count)
{ {
@@ -1555,7 +1578,7 @@ void CloudViewer::keyReleaseEvent(QKeyEvent * event) {
} }
else else
{ {
QVTKWidget::keyPressEvent(event); QWidget::keyPressEvent(event);
} }
} }
@@ -1655,7 +1678,7 @@ void CloudViewer::keyPressEvent(QKeyEvent * event)
} }
else else
{ {
QVTKWidget::keyPressEvent(event); QWidget::keyPressEvent(event);
} }
} }
@@ -1815,6 +1838,15 @@ void CloudViewer::handleAction(QAction * a)
this->update(); this->update();
} }
} }
else if(a == _aSetRenderingRate)
{
bool ok;
double value = QInputDialog::getDouble(this, tr("Rendering rate"), tr("Rate (hz)"), _renderingRate, 0, 60, 0, &ok);
if(ok)
{
this->setRenderingRate(value);
}
}
else if(a == _aLockViewZ) else if(a == _aLockViewZ)
{ {
if(_aLockViewZ->isChecked()) if(_aLockViewZ->isChecked())
+72 -57
View File
@@ -47,6 +47,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <rtabmap/utilite/UFile.h> #include <rtabmap/utilite/UFile.h>
#include "rtabmap/core/DBDriver.h" #include "rtabmap/core/DBDriver.h"
#include "rtabmap/gui/KeypointItem.h" #include "rtabmap/gui/KeypointItem.h"
#include "rtabmap/gui/CloudViewer.h"
#include "rtabmap/utilite/UCv2Qt.h" #include "rtabmap/utilite/UCv2Qt.h"
#include "rtabmap/core/util3d.h" #include "rtabmap/core/util3d.h"
#include "rtabmap/core/util3d_transforms.h" #include "rtabmap/core/util3d_transforms.h"
@@ -113,8 +114,22 @@ DatabaseViewer::DatabaseViewer(const QString & ini, QWidget * parent) :
ui_->dockWidget_stereoView->setVisible(false); ui_->dockWidget_stereoView->setVisible(false);
ui_->dockWidget_view3d->setVisible(false); ui_->dockWidget_view3d->setVisible(false);
ui_->constraintsViewer->setCameraLockZ(false); // Create cloud viewers
ui_->constraintsViewer->setCameraFree(); constraintsViewer_ = new CloudViewer(ui_->dockWidgetContents);
cloudViewerA_ = new CloudViewer(ui_->dockWidgetContents_3dviews);
cloudViewerB_ = new CloudViewer(ui_->dockWidgetContents_3dviews);
stereoViewer_ = new CloudViewer(ui_->dockWidgetContents_stereo);
constraintsViewer_->setObjectName("constraintsViewer");
cloudViewerA_->setObjectName("cloudViewerA");
cloudViewerB_->setObjectName("cloudViewerB");
stereoViewer_->setObjectName("stereoViewer");
ui_->layout_constraintsViewer->addWidget(constraintsViewer_);
ui_->horizontalLayout_3dviews->addWidget(cloudViewerA_, 1);
ui_->horizontalLayout_3dviews->addWidget(cloudViewerB_, 1);
ui_->horizontalLayout_stereo->addWidget(stereoViewer_, 1);
constraintsViewer_->setCameraLockZ(false);
constraintsViewer_->setCameraFree();
ui_->graphicsView_stereo->setAlpha(255); ui_->graphicsView_stereo->setAlpha(255);
@@ -1449,8 +1464,8 @@ void DatabaseViewer::view3DMap()
QString item = QInputDialog::getItem(this, tr("Decimation?"), tr("Image decimation"), items, 2, false, &ok); QString item = QInputDialog::getItem(this, tr("Decimation?"), tr("Image decimation"), items, 2, false, &ok);
if(ok) if(ok)
{ {
int decimation = item.toInt(); int decimation = item.toInt();
double maxDepth = QInputDialog::getDouble(this, tr("Camera depth?"), tr("Maximum depth (m, 0=no max):"), 4.0, 0, 100, 2, &ok); double maxDepth = QInputDialog::getDouble(this, tr("Camera depth?"), tr("Maximum depth (m, 0=no max):"), 4.0, 0, 100, 2, &ok);
if(ok) if(ok)
{ {
std::map<int, Transform> optimizedPoses = uValueAt(graphes_, ui_->horizontalSlider_iterations->value()); std::map<int, Transform> optimizedPoses = uValueAt(graphes_, ui_->horizontalSlider_iterations->value());
@@ -1667,7 +1682,7 @@ void DatabaseViewer::generate3DMap()
QString item = QInputDialog::getItem(this, tr("Decimation?"), tr("Image decimation"), items, 2, false, &ok); QString item = QInputDialog::getItem(this, tr("Decimation?"), tr("Image decimation"), items, 2, false, &ok);
if(ok) if(ok)
{ {
int decimation = item.toInt(); int decimation = item.toInt();
double maxDepth = QInputDialog::getDouble(this, tr("Camera depth?"), tr("Maximum depth (m, 0=no max):"), 4.0, 0, 100, 2, &ok); double maxDepth = QInputDialog::getDouble(this, tr("Camera depth?"), tr("Maximum depth (m, 0=no max):"), 4.0, 0, 100, 2, &ok);
if(ok) if(ok)
{ {
@@ -2068,7 +2083,7 @@ void DatabaseViewer::sliderAValueChanged(int value)
ui_->label_labelA, ui_->label_labelA,
ui_->label_stampA, ui_->label_stampA,
ui_->graphicsView_A, ui_->graphicsView_A,
ui_->widget_cloudA, cloudViewerA_,
ui_->label_idA, ui_->label_idA,
ui_->label_mapA, ui_->label_mapA,
ui_->label_poseA, ui_->label_poseA,
@@ -2086,7 +2101,7 @@ void DatabaseViewer::sliderBValueChanged(int value)
ui_->label_labelB, ui_->label_labelB,
ui_->label_stampB, ui_->label_stampB,
ui_->graphicsView_B, ui_->graphicsView_B,
ui_->widget_cloudB, cloudViewerB_,
ui_->label_idB, ui_->label_idB,
ui_->label_mapB, ui_->label_mapB,
ui_->label_poseB, ui_->label_poseB,
@@ -2235,7 +2250,7 @@ void DatabaseViewer::update(int value,
} }
else else
{ {
ui_->stereoViewer->clear(); stereoViewer_->clear();
ui_->graphicsView_stereo->clear(); ui_->graphicsView_stereo->clear();
} }
@@ -2430,7 +2445,7 @@ void DatabaseViewer::update(int value,
ui_->horizontalSlider_loops->blockSignals(false); ui_->horizontalSlider_loops->blockSignals(false);
ui_->horizontalSlider_neighbors->blockSignals(false); ui_->horizontalSlider_neighbors->blockSignals(false);
ui_->constraintsViewer->removeAllClouds(); constraintsViewer_->removeAllClouds();
// make a fake link using globally optimized poses // make a fake link using globally optimized poses
if(graphes_.size()) if(graphes_.size())
@@ -2449,7 +2464,7 @@ void DatabaseViewer::update(int value,
} }
} }
ui_->constraintsViewer->update(); constraintsViewer_->update();
} }
} }
@@ -2467,7 +2482,7 @@ void DatabaseViewer::updateLoggerLevel()
ULogger::setLevel((ULogger::Level)ui_->comboBox_logger_level->currentIndex()); ULogger::setLevel((ULogger::Level)ui_->comboBox_logger_level->currentIndex());
} }
} }
void DatabaseViewer::updateStereo() void DatabaseViewer::updateStereo()
{ {
if(ui_->horizontalSlider_A->maximum()) if(ui_->horizontalSlider_A->maximum())
@@ -2480,7 +2495,7 @@ void DatabaseViewer::updateStereo()
} }
} }
void DatabaseViewer::updateStereo(const SensorData * data) void DatabaseViewer::updateStereo(const SensorData * data)
{ {
if(data && if(data &&
ui_->dockWidget_stereoView->isVisible() && ui_->dockWidget_stereoView->isVisible() &&
@@ -2567,10 +2582,10 @@ void DatabaseViewer::updateStereo(const SensorData * data)
data->stereoCameraModel()); data->stereoCameraModel());
if(util3d::isFinite(tmpPt)) if(util3d::isFinite(tmpPt))
{ {
pt = util3d::transformPoint(tmpPt, data->stereoCameraModel().left().localTransform()); pt = util3d::transformPoint(tmpPt, data->stereoCameraModel().left().localTransform());
status[i] = 100; //blue status[i] = 100; //blue
++inliers; ++inliers;
cloud->at(oi++) = pcl::PointXYZ(pt.x, pt.y, pt.z); cloud->at(oi++) = pcl::PointXYZ(pt.x, pt.y, pt.z);
} }
} }
@@ -2590,9 +2605,9 @@ void DatabaseViewer::updateStereo(const SensorData * data)
UINFO("correspondences = %d/%d (%f) (time kpt=%fs stereo=%fs)", UINFO("correspondences = %d/%d (%f) (time kpt=%fs stereo=%fs)",
(int)cloud->size(), (int)leftCorners.size(), float(cloud->size())/float(leftCorners.size()), timeKpt, timeStereo); (int)cloud->size(), (int)leftCorners.size(), float(cloud->size())/float(leftCorners.size()), timeKpt, timeStereo);
ui_->stereoViewer->updateCameraTargetPosition(Transform::getIdentity()); stereoViewer_->updateCameraTargetPosition(Transform::getIdentity());
ui_->stereoViewer->addCloud("stereo", cloud); stereoViewer_->addCloud("stereo", cloud);
ui_->stereoViewer->update(); stereoViewer_->update();
ui_->label_stereo_inliers->setNum(inliers); ui_->label_stereo_inliers->setNum(inliers);
ui_->label_stereo_flowOutliers->setNum(flowOutliers); ui_->label_stereo_flowOutliers->setNum(flowOutliers);
@@ -2885,7 +2900,7 @@ void DatabaseViewer::updateConstraintView(
ui_->label_labelA, ui_->label_labelA,
ui_->label_stampA, ui_->label_stampA,
ui_->graphicsView_A, ui_->graphicsView_A,
ui_->widget_cloudA, cloudViewerA_,
ui_->label_idA, ui_->label_idA,
ui_->label_mapA, ui_->label_mapA,
ui_->label_poseA, ui_->label_poseA,
@@ -2899,7 +2914,7 @@ void DatabaseViewer::updateConstraintView(
ui_->label_labelB, ui_->label_labelB,
ui_->label_stampB, ui_->label_stampB,
ui_->graphicsView_B, ui_->graphicsView_B,
ui_->widget_cloudB, cloudViewerB_,
ui_->label_idB, ui_->label_idB,
ui_->label_mapB, ui_->label_mapB,
ui_->label_poseB, ui_->label_poseB,
@@ -2907,7 +2922,7 @@ void DatabaseViewer::updateConstraintView(
false); // don't update constraints view! false); // don't update constraints view!
} }
if(ui_->constraintsViewer->isVisible()) if(constraintsViewer_->isVisible())
{ {
SensorData dataFrom, dataTo; SensorData dataFrom, dataTo;
@@ -2939,18 +2954,18 @@ void DatabaseViewer::updateConstraintView(
if(cloudFrom.get() && cloudFrom->size()) if(cloudFrom.get() && cloudFrom->size())
{ {
ui_->constraintsViewer->addCloud("cloud0", cloudFrom, Transform::getIdentity(), Qt::red); constraintsViewer_->addCloud("cloud0", cloudFrom, Transform::getIdentity(), Qt::red);
} }
if(cloudTo.get() && cloudTo->size()) if(cloudTo.get() && cloudTo->size())
{ {
cloudTo = rtabmap::util3d::transformPointCloud(cloudTo, t); cloudTo = rtabmap::util3d::transformPointCloud(cloudTo, t);
ui_->constraintsViewer->addCloud("cloud1", cloudTo, Transform::getIdentity(), Qt::cyan); constraintsViewer_->addCloud("cloud1", cloudTo, Transform::getIdentity(), Qt::cyan);
} }
} }
else else
{ {
ui_->constraintsViewer->removeCloud("cloud0"); constraintsViewer_->removeCloud("cloud0");
ui_->constraintsViewer->removeCloud("cloud1"); constraintsViewer_->removeCloud("cloud1");
} }
if(ui_->checkBox_show3DWords->isChecked()) if(ui_->checkBox_show3DWords->isChecked())
{ {
@@ -2998,28 +3013,28 @@ void DatabaseViewer::updateConstraintView(
if(cloudFrom->size()) if(cloudFrom->size())
{ {
ui_->constraintsViewer->addCloud("words0", cloudFrom, Transform::getIdentity(), Qt::red); constraintsViewer_->addCloud("words0", cloudFrom, Transform::getIdentity(), Qt::red);
} }
else else
{ {
UWARN("Empty 3D words for node %d", link.from()); UWARN("Empty 3D words for node %d", link.from());
ui_->constraintsViewer->removeCloud("words0"); constraintsViewer_->removeCloud("words0");
} }
if(cloudTo->size()) if(cloudTo->size())
{ {
ui_->constraintsViewer->addCloud("words1", cloudTo, Transform::getIdentity(), Qt::cyan); constraintsViewer_->addCloud("words1", cloudTo, Transform::getIdentity(), Qt::cyan);
} }
else else
{ {
UWARN("Empty 3D words for node %d", link.to()); UWARN("Empty 3D words for node %d", link.to());
ui_->constraintsViewer->removeCloud("words1"); constraintsViewer_->removeCloud("words1");
} }
} }
else else
{ {
UERROR("Not found signature %d or %d in RAM", link.from(), link.to()); UERROR("Not found signature %d or %d in RAM", link.from(), link.to());
ui_->constraintsViewer->removeCloud("words0"); constraintsViewer_->removeCloud("words0");
ui_->constraintsViewer->removeCloud("words1"); constraintsViewer_->removeCloud("words1");
} }
//cleanup //cleanup
for(std::list<Signature*>::iterator iter=signatures.begin(); iter!=signatures.end(); ++iter) for(std::list<Signature*>::iterator iter=signatures.begin(); iter!=signatures.end(); ++iter)
@@ -3029,19 +3044,19 @@ void DatabaseViewer::updateConstraintView(
} }
else else
{ {
ui_->constraintsViewer->removeCloud("words0"); constraintsViewer_->removeCloud("words0");
ui_->constraintsViewer->removeCloud("words1"); constraintsViewer_->removeCloud("words1");
} }
} }
else else
{ {
if(cloudFrom->size()) if(cloudFrom->size())
{ {
ui_->constraintsViewer->addCloud("cloud0", cloudFrom, Transform::getIdentity(), Qt::red); constraintsViewer_->addCloud("cloud0", cloudFrom, Transform::getIdentity(), Qt::red);
} }
if(cloudTo->size()) if(cloudTo->size())
{ {
ui_->constraintsViewer->addCloud("cloud1", cloudTo, Transform::getIdentity(), Qt::cyan); constraintsViewer_->addCloud("cloud1", cloudTo, Transform::getIdentity(), Qt::cyan);
} }
} }
@@ -3051,8 +3066,8 @@ void DatabaseViewer::updateConstraintView(
{ {
//cloud 2d //cloud 2d
ui_->constraintsViewer->removeCloud("scan2"); constraintsViewer_->removeCloud("scan2");
ui_->constraintsViewer->removeGraph("scan2graph"); constraintsViewer_->removeGraph("scan2graph");
if(link.type() == Link::kLocalSpaceClosure && if(link.type() == Link::kLocalSpaceClosure &&
!link.userDataCompressed().empty()) !link.userDataCompressed().empty())
{ {
@@ -3150,11 +3165,11 @@ void DatabaseViewer::updateConstraintView(
if(assembledScans->size()) if(assembledScans->size())
{ {
ui_->constraintsViewer->addCloud("scan2", assembledScans, Transform::getIdentity(), Qt::cyan); constraintsViewer_->addCloud("scan2", assembledScans, Transform::getIdentity(), Qt::cyan);
} }
if(graph->size()) if(graph->size())
{ {
ui_->constraintsViewer->addOrUpdateGraph("scan2graph", graph, Qt::cyan); constraintsViewer_->addOrUpdateGraph("scan2graph", graph, Qt::cyan);
} }
} }
} }
@@ -3167,62 +3182,62 @@ void DatabaseViewer::updateConstraintView(
scanB = rtabmap::util3d::transformPointCloud(scanB, t); scanB = rtabmap::util3d::transformPointCloud(scanB, t);
if(scanA->size()) if(scanA->size())
{ {
ui_->constraintsViewer->addCloud("scan0", scanA, Transform::getIdentity(), Qt::yellow); constraintsViewer_->addCloud("scan0", scanA, Transform::getIdentity(), Qt::yellow);
} }
else else
{ {
ui_->constraintsViewer->removeCloud("scan0"); constraintsViewer_->removeCloud("scan0");
} }
if(scanB->size()) if(scanB->size())
{ {
ui_->constraintsViewer->addCloud("scan1", scanB, Transform::getIdentity(), Qt::magenta); constraintsViewer_->addCloud("scan1", scanB, Transform::getIdentity(), Qt::magenta);
} }
else else
{ {
ui_->constraintsViewer->removeCloud("scan1"); constraintsViewer_->removeCloud("scan1");
} }
} }
else else
{ {
ui_->constraintsViewer->removeCloud("scan0"); constraintsViewer_->removeCloud("scan0");
ui_->constraintsViewer->removeCloud("scan1"); constraintsViewer_->removeCloud("scan1");
ui_->constraintsViewer->removeCloud("scan2"); constraintsViewer_->removeCloud("scan2");
} }
} }
else else
{ {
if(scanFrom->size()) if(scanFrom->size())
{ {
ui_->constraintsViewer->addCloud("scan0", scanFrom, Transform::getIdentity(), Qt::yellow); constraintsViewer_->addCloud("scan0", scanFrom, Transform::getIdentity(), Qt::yellow);
} }
else else
{ {
ui_->constraintsViewer->removeCloud("scan0"); constraintsViewer_->removeCloud("scan0");
} }
if(scanTo->size()) if(scanTo->size())
{ {
ui_->constraintsViewer->addCloud("scan1", scanTo, Transform::getIdentity(), Qt::magenta); constraintsViewer_->addCloud("scan1", scanTo, Transform::getIdentity(), Qt::magenta);
} }
else else
{ {
ui_->constraintsViewer->removeCloud("scan1"); constraintsViewer_->removeCloud("scan1");
} }
ui_->constraintsViewer->removeCloud("scan2"); constraintsViewer_->removeCloud("scan2");
} }
//update coordinate //update coordinate
ui_->constraintsViewer->addOrUpdateCoordinate("from_coordinate", Transform::getIdentity(), 0.2); constraintsViewer_->addOrUpdateCoordinate("from_coordinate", Transform::getIdentity(), 0.2);
ui_->constraintsViewer->addOrUpdateCoordinate("to_coordinate", t, 0.2); constraintsViewer_->addOrUpdateCoordinate("to_coordinate", t, 0.2);
if(uContains(groundTruthPoses_, link.from()) && uContains(groundTruthPoses_, link.to())) if(uContains(groundTruthPoses_, link.from()) && uContains(groundTruthPoses_, link.to()))
{ {
ui_->constraintsViewer->addOrUpdateCoordinate("to_coordinate_gt", constraintsViewer_->addOrUpdateCoordinate("to_coordinate_gt",
groundTruthPoses_.at(link.from()).inverse()*groundTruthPoses_.at(link.to()), 0.1); groundTruthPoses_.at(link.from()).inverse()*groundTruthPoses_.at(link.to()), 0.1);
} }
ui_->constraintsViewer->clearTrajectory(); constraintsViewer_->clearTrajectory();
ui_->constraintsViewer->update(); constraintsViewer_->update();
} }
// update buttons // update buttons
@@ -4209,8 +4224,8 @@ void DatabaseViewer::updateLoopClosuresSlider(int from, int to)
else else
{ {
ui_->horizontalSlider_loops->setEnabled(false); ui_->horizontalSlider_loops->setEnabled(false);
ui_->constraintsViewer->removeAllClouds(); constraintsViewer_->removeAllClouds();
ui_->constraintsViewer->update(); constraintsViewer_->update();
updateConstraintButtons(); updateConstraintButtons();
} }
} }
+135 -114
View File
@@ -48,6 +48,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "rtabmap/gui/PdfPlot.h" #include "rtabmap/gui/PdfPlot.h"
#include "rtabmap/gui/StatsToolBox.h" #include "rtabmap/gui/StatsToolBox.h"
#include "rtabmap/gui/ProgressDialog.h" #include "rtabmap/gui/ProgressDialog.h"
#include "rtabmap/gui/CloudViewer.h"
#include "rtabmap/gui/LoopClosureViewer.h"
#include <rtabmap/utilite/UStl.h> #include <rtabmap/utilite/UStl.h>
#include <rtabmap/utilite/ULogger.h> #include <rtabmap/utilite/ULogger.h>
@@ -175,8 +177,23 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent) :
_postProcessingDialog->setObjectName("PostProcessingDialog"); _postProcessingDialog->setObjectName("PostProcessingDialog");
_ui = new Ui_mainWindow(); _ui = new Ui_mainWindow();
UDEBUG("Setup ui...");
_ui->setupUi(this); _ui->setupUi(this);
// Add cloud viewers
// Note that we add them here manually because there is a crash issue
// when adding them in a DockWidget of the *.ui file. The cloud viewer is
// created in a widget which is not yet linked to main window when the CloudViewer constructor
// is called (see order in generated ui file). VTK needs to get the top
// level window at the time CloudViewer is created, otherwise it may crash on some systems.
_cloudViewer = new CloudViewer(_ui->layout_cloudViewer);
_cloudViewer->setObjectName("widget_cloudViewer");
_ui->layout_cloudViewer->layout()->addWidget(_cloudViewer);
_loopClosureViewer = new LoopClosureViewer(_ui->layout_loopClosureViewer);
_loopClosureViewer->setObjectName("widget_loopClosureViewer");
_ui->layout_loopClosureViewer->layout()->addWidget(_loopClosureViewer);
UDEBUG("Setup ui... end");
QString title("RTAB-Map[*]"); QString title("RTAB-Map[*]");
this->setWindowTitle(title); this->setWindowTitle(title);
this->setWindowIconText(tr("RTAB-Map")); this->setWindowIconText(tr("RTAB-Map"));
@@ -196,6 +213,7 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent) :
{ {
_preferencesDialog = new PreferencesDialog(this); _preferencesDialog = new PreferencesDialog(this);
} }
_preferencesDialog->setObjectName("PreferencesDialog"); _preferencesDialog->setObjectName("PreferencesDialog");
_preferencesDialog->init(); _preferencesDialog->init();
@@ -347,6 +365,9 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent) :
_ui->actionPause->setShortcut(Qt::Key_Space); _ui->actionPause->setShortcut(Qt::Key_Space);
_ui->actionSave_GUI_config->setShortcut(QKeySequence::Save); _ui->actionSave_GUI_config->setShortcut(QKeySequence::Save);
// Qt5 issue, we should explicitly add actions not in
// menu bar to have shortcut working
this->addAction(_ui->actionSave_GUI_config);
_ui->actionReset_Odometry->setEnabled(false); _ui->actionReset_Odometry->setEnabled(false);
_ui->actionPost_processing->setEnabled(false); _ui->actionPost_processing->setEnabled(false);
_ui->actionAnchor_clouds_to_ground_truth->setEnabled(false); _ui->actionAnchor_clouds_to_ground_truth->setEnabled(false);
@@ -415,7 +436,7 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent) :
connect(_ui->imageView_loopClosure, SIGNAL(configChanged()), this, SLOT(configGUIModified())); connect(_ui->imageView_loopClosure, SIGNAL(configChanged()), this, SLOT(configGUIModified()));
connect(_ui->imageView_odometry, SIGNAL(configChanged()), this, SLOT(configGUIModified())); connect(_ui->imageView_odometry, SIGNAL(configChanged()), this, SLOT(configGUIModified()));
connect(_ui->graphicsView_graphView, SIGNAL(configChanged()), this, SLOT(configGUIModified())); connect(_ui->graphicsView_graphView, SIGNAL(configChanged()), this, SLOT(configGUIModified()));
connect(_ui->widget_cloudViewer, SIGNAL(configChanged()), this, SLOT(configGUIModified())); connect(_cloudViewer, SIGNAL(configChanged()), this, SLOT(configGUIModified()));
connect(_exportCloudsDialog, SIGNAL(configChanged()), this, SLOT(configGUIModified())); connect(_exportCloudsDialog, SIGNAL(configChanged()), this, SLOT(configGUIModified()));
connect(_exportScansDialog, SIGNAL(configChanged()), this, SLOT(configGUIModified())); connect(_exportScansDialog, SIGNAL(configChanged()), this, SLOT(configGUIModified()));
connect(_postProcessingDialog, SIGNAL(configChanged()), this, SLOT(configGUIModified())); connect(_postProcessingDialog, SIGNAL(configChanged()), this, SLOT(configGUIModified()));
@@ -467,9 +488,9 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent) :
_ui->statsToolBox->setWorkingDirectory(_preferencesDialog->getWorkingDirectory()); _ui->statsToolBox->setWorkingDirectory(_preferencesDialog->getWorkingDirectory());
_ui->graphicsView_graphView->setWorkingDirectory(_preferencesDialog->getWorkingDirectory()); _ui->graphicsView_graphView->setWorkingDirectory(_preferencesDialog->getWorkingDirectory());
_ui->widget_cloudViewer->setWorkingDirectory(_preferencesDialog->getWorkingDirectory()); _cloudViewer->setWorkingDirectory(_preferencesDialog->getWorkingDirectory());
_ui->widget_cloudViewer->setBackfaceCulling(true, false); _cloudViewer->setBackfaceCulling(true, false);
_preferencesDialog->loadWidgetState(_ui->widget_cloudViewer); _preferencesDialog->loadWidgetState(_cloudViewer);
//dialog states //dialog states
_preferencesDialog->loadWidgetState(_exportCloudsDialog); _preferencesDialog->loadWidgetState(_exportCloudsDialog);
@@ -533,8 +554,8 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent) :
connect(_ui->statsToolBox, SIGNAL(figuresSetupChanged()), this, SLOT(configGUIModified())); connect(_ui->statsToolBox, SIGNAL(figuresSetupChanged()), this, SLOT(configGUIModified()));
// update loop closure viewer parameters // update loop closure viewer parameters
_ui->widget_loopClosureViewer->setDecimation(_preferencesDialog->getCloudDecimation(0)); _loopClosureViewer->setDecimation(_preferencesDialog->getCloudDecimation(0));
_ui->widget_loopClosureViewer->setMaxDepth(_preferencesDialog->getCloudMaxDepth(0)); _loopClosureViewer->setMaxDepth(_preferencesDialog->getCloudMaxDepth(0));
//update ui //update ui
_ui->doubleSpinBox_stats_detectionRate->setValue(_preferencesDialog->getDetectionRate()); _ui->doubleSpinBox_stats_detectionRate->setValue(_preferencesDialog->getDetectionRate());
@@ -811,8 +832,8 @@ void MainWindow::processOdometry(const rtabmap::OdometryEvent & odom)
if(pose.isNull()) if(pose.isNull())
{ {
UDEBUG("odom lost"); // use last pose UDEBUG("odom lost"); // use last pose
lostStateChanged = _ui->widget_cloudViewer->getBackgroundColor() != Qt::darkRed; lostStateChanged = _cloudViewer->getBackgroundColor() != Qt::darkRed;
_ui->widget_cloudViewer->setBackgroundColor(Qt::darkRed); _cloudViewer->setBackgroundColor(Qt::darkRed);
_ui->imageView_odometry->setBackgroundColor(Qt::darkRed); _ui->imageView_odometry->setBackgroundColor(Qt::darkRed);
pose = _lastOdomPose; pose = _lastOdomPose;
@@ -823,15 +844,15 @@ void MainWindow::processOdometry(const rtabmap::OdometryEvent & odom)
odom.info().inliers < _preferencesDialog->getOdomQualityWarnThr()) odom.info().inliers < _preferencesDialog->getOdomQualityWarnThr())
{ {
UDEBUG("odom warn, quality(inliers)=%d thr=%d", odom.info().inliers, _preferencesDialog->getOdomQualityWarnThr()); UDEBUG("odom warn, quality(inliers)=%d thr=%d", odom.info().inliers, _preferencesDialog->getOdomQualityWarnThr());
lostStateChanged = _ui->widget_cloudViewer->getBackgroundColor() == Qt::darkRed; lostStateChanged = _cloudViewer->getBackgroundColor() == Qt::darkRed;
_ui->widget_cloudViewer->setBackgroundColor(Qt::darkYellow); _cloudViewer->setBackgroundColor(Qt::darkYellow);
_ui->imageView_odometry->setBackgroundColor(Qt::darkYellow); _ui->imageView_odometry->setBackgroundColor(Qt::darkYellow);
} }
else else
{ {
UDEBUG("odom ok"); UDEBUG("odom ok");
lostStateChanged = _ui->widget_cloudViewer->getBackgroundColor() == Qt::darkRed; lostStateChanged = _cloudViewer->getBackgroundColor() == Qt::darkRed;
_ui->widget_cloudViewer->setBackgroundColor(_ui->widget_cloudViewer->getDefaultBackgroundColor()); _cloudViewer->setBackgroundColor(_cloudViewer->getDefaultBackgroundColor());
_ui->imageView_odometry->setBackgroundColor(Qt::black); _ui->imageView_odometry->setBackgroundColor(Qt::black);
} }
@@ -894,7 +915,7 @@ void MainWindow::processOdometry(const rtabmap::OdometryEvent & odom)
Eigen::Vector3f(pose.x(), pose.y(), pose.z()) + viewpoint); Eigen::Vector3f(pose.x(), pose.y(), pose.z()) + viewpoint);
if(polygons.size()) if(polygons.size())
{ {
if(!_ui->widget_cloudViewer->addCloudMesh("cloudOdom", output, polygons, _odometryCorrection)) if(!_cloudViewer->addCloudMesh("cloudOdom", output, polygons, _odometryCorrection))
{ {
UERROR("Adding cloudOdom to viewer failed!"); UERROR("Adding cloudOdom to viewer failed!");
} }
@@ -902,14 +923,14 @@ void MainWindow::processOdometry(const rtabmap::OdometryEvent & odom)
} }
else else
{ {
if(!_ui->widget_cloudViewer->addCloud("cloudOdom", cloud, _odometryCorrection)) if(!_cloudViewer->addCloud("cloudOdom", cloud, _odometryCorrection))
{ {
UERROR("Adding cloudOdom to viewer failed!"); UERROR("Adding cloudOdom to viewer failed!");
} }
} }
_ui->widget_cloudViewer->setCloudVisibility("cloudOdom", true); _cloudViewer->setCloudVisibility("cloudOdom", true);
_ui->widget_cloudViewer->setCloudOpacity("cloudOdom", _preferencesDialog->getCloudOpacity(1)); _cloudViewer->setCloudOpacity("cloudOdom", _preferencesDialog->getCloudOpacity(1));
_ui->widget_cloudViewer->setCloudPointSize("cloudOdom", _preferencesDialog->getCloudPointSize(1)); _cloudViewer->setCloudPointSize("cloudOdom", _preferencesDialog->getCloudPointSize(1));
cloudUpdated = true; cloudUpdated = true;
} }
@@ -922,15 +943,15 @@ void MainWindow::processOdometry(const rtabmap::OdometryEvent & odom)
{ {
pcl::PointCloud<pcl::PointNormal>::Ptr cloud; pcl::PointCloud<pcl::PointNormal>::Ptr cloud;
cloud = util3d::laserScanToPointCloudNormal(odom.info().localScanMap); cloud = util3d::laserScanToPointCloudNormal(odom.info().localScanMap);
if(!_ui->widget_cloudViewer->addCloud("scanMapOdom", cloud, _odometryCorrection, Qt::blue)) if(!_cloudViewer->addCloud("scanMapOdom", cloud, _odometryCorrection, Qt::blue))
{ {
UERROR("Adding scanMapOdom to viewer failed!"); UERROR("Adding scanMapOdom to viewer failed!");
} }
else else
{ {
_ui->widget_cloudViewer->setCloudVisibility("scanMapOdom", true); _cloudViewer->setCloudVisibility("scanMapOdom", true);
_ui->widget_cloudViewer->setCloudOpacity("scanMapOdom", _preferencesDialog->getScanOpacity(1)); _cloudViewer->setCloudOpacity("scanMapOdom", _preferencesDialog->getScanOpacity(1));
_ui->widget_cloudViewer->setCloudPointSize("scanMapOdom", _preferencesDialog->getScanPointSize(1)); _cloudViewer->setCloudPointSize("scanMapOdom", _preferencesDialog->getScanPointSize(1));
scanUpdated = true; scanUpdated = true;
} }
} }
@@ -951,15 +972,15 @@ void MainWindow::processOdometry(const rtabmap::OdometryEvent & odom)
cloud = util3d::voxelize(cloud, _preferencesDialog->getCloudVoxelSizeScan(1)); cloud = util3d::voxelize(cloud, _preferencesDialog->getCloudVoxelSizeScan(1));
} }
if(!_ui->widget_cloudViewer->addCloud("scanOdom", cloud, _odometryCorrection, Qt::magenta)) if(!_cloudViewer->addCloud("scanOdom", cloud, _odometryCorrection, Qt::magenta))
{ {
UERROR("Adding scanOdom to viewer failed!"); UERROR("Adding scanOdom to viewer failed!");
} }
else else
{ {
_ui->widget_cloudViewer->setCloudVisibility("scanOdom", true); _cloudViewer->setCloudVisibility("scanOdom", true);
_ui->widget_cloudViewer->setCloudOpacity("scanOdom", _preferencesDialog->getScanOpacity(1)); _cloudViewer->setCloudOpacity("scanOdom", _preferencesDialog->getScanOpacity(1));
_ui->widget_cloudViewer->setCloudPointSize("scanOdom", _preferencesDialog->getScanPointSize(1)); _cloudViewer->setCloudPointSize("scanOdom", _preferencesDialog->getScanPointSize(1));
scanUpdated = true; scanUpdated = true;
} }
} }
@@ -986,38 +1007,38 @@ void MainWindow::processOdometry(const rtabmap::OdometryEvent & odom)
(*cloud)[i++].b = 0; (*cloud)[i++].b = 0;
} }
_ui->widget_cloudViewer->addCloud("featuresOdom", cloud, _odometryCorrection); _cloudViewer->addCloud("featuresOdom", cloud, _odometryCorrection);
_ui->widget_cloudViewer->setCloudVisibility("featuresOdom", true); _cloudViewer->setCloudVisibility("featuresOdom", true);
_ui->widget_cloudViewer->setCloudPointSize("featuresOdom", _preferencesDialog->getFeaturesPointSize(1)); _cloudViewer->setCloudPointSize("featuresOdom", _preferencesDialog->getFeaturesPointSize(1));
featuresUpdated = true; featuresUpdated = true;
} }
} }
} }
if(!cloudUpdated && _ui->widget_cloudViewer->getAddedClouds().contains("cloudOdom")) if(!cloudUpdated && _cloudViewer->getAddedClouds().contains("cloudOdom"))
{ {
_ui->widget_cloudViewer->setCloudVisibility("cloudOdom", false); _cloudViewer->setCloudVisibility("cloudOdom", false);
} }
if(!scanUpdated && _ui->widget_cloudViewer->getAddedClouds().contains("scanOdom")) if(!scanUpdated && _cloudViewer->getAddedClouds().contains("scanOdom"))
{ {
_ui->widget_cloudViewer->setCloudVisibility("scanOdom", false); _cloudViewer->setCloudVisibility("scanOdom", false);
} }
if(!scanUpdated && _ui->widget_cloudViewer->getAddedClouds().contains("scanMapOdom")) if(!scanUpdated && _cloudViewer->getAddedClouds().contains("scanMapOdom"))
{ {
_ui->widget_cloudViewer->setCloudVisibility("scanMapOdom", false); _cloudViewer->setCloudVisibility("scanMapOdom", false);
} }
if(!featuresUpdated && _ui->widget_cloudViewer->getAddedClouds().contains("featuresOdom")) if(!featuresUpdated && _cloudViewer->getAddedClouds().contains("featuresOdom"))
{ {
_ui->widget_cloudViewer->setCloudVisibility("featuresOdom", false); _cloudViewer->setCloudVisibility("featuresOdom", false);
} }
} }
if(!odom.pose().isNull()) if(!odom.pose().isNull())
{ {
// update camera position // update camera position
_ui->widget_cloudViewer->updateCameraTargetPosition(_odometryCorrection*odom.pose()); _cloudViewer->updateCameraTargetPosition(_odometryCorrection*odom.pose());
} }
_ui->widget_cloudViewer->update(); _cloudViewer->update();
if(_ui->graphicsView_graphView->isVisible()) if(_ui->graphicsView_graphView->isVisible())
{ {
@@ -1529,11 +1550,11 @@ void MainWindow::processStats(const rtabmap::Statistics & stat)
// the last loop closure data // the last loop closure data
Transform loopClosureTransform = stat.loopClosureTransform(); Transform loopClosureTransform = stat.loopClosureTransform();
signature.setPose(loopClosureTransform); signature.setPose(loopClosureTransform);
_ui->widget_loopClosureViewer->setData(loopSignature, signature); _loopClosureViewer->setData(loopSignature, signature);
if(_ui->dockWidget_loopClosureViewer->isVisible()) if(_ui->dockWidget_loopClosureViewer->isVisible())
{ {
UTimer loopTimer; UTimer loopTimer;
_ui->widget_loopClosureViewer->updateView(); _loopClosureViewer->updateView();
UINFO("Updating loop closure cloud view time=%fs", loopTimer.elapsed()); UINFO("Updating loop closure cloud view time=%fs", loopTimer.elapsed());
_ui->statsToolBox->updateStat("GUI/RGB-D closure view/ms", stat.refImageId(), int(loopTimer.elapsed()*1000.0f)); _ui->statsToolBox->updateStat("GUI/RGB-D closure view/ms", stat.refImageId(), int(loopTimer.elapsed()*1000.0f));
} }
@@ -1790,7 +1811,7 @@ void MainWindow::updateMapCloud(
// Map updated! regenerate the assembled cloud, last pose is the new one // Map updated! regenerate the assembled cloud, last pose is the new one
UDEBUG("Update map with %d locations (currentPose=%s)", poses.size(), currentPose.prettyPrint().c_str()); UDEBUG("Update map with %d locations (currentPose=%s)", poses.size(), currentPose.prettyPrint().c_str());
QMap<std::string, Transform> viewerClouds = _ui->widget_cloudViewer->getAddedClouds(); QMap<std::string, Transform> viewerClouds = _cloudViewer->getAddedClouds();
int i=1; int i=1;
for(std::map<int, Transform>::const_iterator iter = poses.begin(); iter!=poses.end(); ++iter) for(std::map<int, Transform>::const_iterator iter = poses.begin(); iter!=poses.end(); ++iter)
{ {
@@ -1799,24 +1820,24 @@ void MainWindow::updateMapCloud(
std::string cloudName = uFormat("cloud%d", iter->first); std::string cloudName = uFormat("cloud%d", iter->first);
// 3d point cloud // 3d point cloud
if((_ui->widget_cloudViewer->isVisible() && _preferencesDialog->isCloudsShown(0)) || if((_cloudViewer->isVisible() && _preferencesDialog->isCloudsShown(0)) ||
(_ui->graphicsView_graphView->isVisible() && _ui->graphicsView_graphView->isGridMapVisible() && _preferencesDialog->isGridMapFrom3DCloud())) (_ui->graphicsView_graphView->isVisible() && _ui->graphicsView_graphView->isGridMapVisible() && _preferencesDialog->isGridMapFrom3DCloud()))
{ {
if(viewerClouds.contains(cloudName)) if(viewerClouds.contains(cloudName))
{ {
// Update only if the pose has changed // Update only if the pose has changed
Transform tCloud; Transform tCloud;
_ui->widget_cloudViewer->getPose(cloudName, tCloud); _cloudViewer->getPose(cloudName, tCloud);
if(tCloud.isNull() || iter->second != tCloud) if(tCloud.isNull() || iter->second != tCloud)
{ {
if(!_ui->widget_cloudViewer->updateCloudPose(cloudName, iter->second)) if(!_cloudViewer->updateCloudPose(cloudName, iter->second))
{ {
UERROR("Updating pose cloud %d failed!", iter->first); UERROR("Updating pose cloud %d failed!", iter->first);
} }
} }
_ui->widget_cloudViewer->setCloudVisibility(cloudName, true); _cloudViewer->setCloudVisibility(cloudName, true);
_ui->widget_cloudViewer->setCloudOpacity(cloudName, _preferencesDialog->getCloudOpacity(0)); _cloudViewer->setCloudOpacity(cloudName, _preferencesDialog->getCloudOpacity(0));
_ui->widget_cloudViewer->setCloudPointSize(cloudName, _preferencesDialog->getCloudPointSize(0)); _cloudViewer->setCloudPointSize(cloudName, _preferencesDialog->getCloudPointSize(0));
} }
else if(_cachedSignatures.contains(iter->first)) else if(_cachedSignatures.contains(iter->first))
{ {
@@ -1825,29 +1846,29 @@ void MainWindow::updateMapCloud(
} }
else if(viewerClouds.contains(cloudName)) else if(viewerClouds.contains(cloudName))
{ {
_ui->widget_cloudViewer->setCloudVisibility(cloudName.c_str(), false); _cloudViewer->setCloudVisibility(cloudName.c_str(), false);
} }
// 2d point cloud // 2d point cloud
std::string scanName = uFormat("scan%d", iter->first); std::string scanName = uFormat("scan%d", iter->first);
if((_ui->widget_cloudViewer->isVisible() && (_preferencesDialog->isScansShown(0) || _preferencesDialog->getGridMapShown())) || if((_cloudViewer->isVisible() && (_preferencesDialog->isScansShown(0) || _preferencesDialog->getGridMapShown())) ||
(_ui->graphicsView_graphView->isVisible() && _ui->graphicsView_graphView->isGridMapVisible())) (_ui->graphicsView_graphView->isVisible() && _ui->graphicsView_graphView->isGridMapVisible()))
{ {
if(viewerClouds.contains(scanName)) if(viewerClouds.contains(scanName))
{ {
// Update only if the pose has changed // Update only if the pose has changed
Transform tScan; Transform tScan;
_ui->widget_cloudViewer->getPose(scanName, tScan); _cloudViewer->getPose(scanName, tScan);
if(tScan.isNull() || iter->second != tScan) if(tScan.isNull() || iter->second != tScan)
{ {
if(!_ui->widget_cloudViewer->updateCloudPose(scanName, iter->second)) if(!_cloudViewer->updateCloudPose(scanName, iter->second))
{ {
UERROR("Updating pose scan %d failed!", iter->first); UERROR("Updating pose scan %d failed!", iter->first);
} }
} }
_ui->widget_cloudViewer->setCloudVisibility(scanName, _preferencesDialog->isScansShown(0)); _cloudViewer->setCloudVisibility(scanName, _preferencesDialog->isScansShown(0));
_ui->widget_cloudViewer->setCloudOpacity(scanName, _preferencesDialog->getScanOpacity(0)); _cloudViewer->setCloudOpacity(scanName, _preferencesDialog->getScanOpacity(0));
_ui->widget_cloudViewer->setCloudPointSize(scanName, _preferencesDialog->getScanPointSize(0)); _cloudViewer->setCloudPointSize(scanName, _preferencesDialog->getScanPointSize(0));
} }
else if(_cachedSignatures.contains(iter->first)) else if(_cachedSignatures.contains(iter->first))
{ {
@@ -1860,27 +1881,27 @@ void MainWindow::updateMapCloud(
} }
else if(viewerClouds.contains(scanName)) else if(viewerClouds.contains(scanName))
{ {
_ui->widget_cloudViewer->setCloudVisibility(scanName.c_str(), false); _cloudViewer->setCloudVisibility(scanName.c_str(), false);
} }
// 3d features // 3d features
std::string featuresName = uFormat("features%d", iter->first); std::string featuresName = uFormat("features%d", iter->first);
if(_ui->widget_cloudViewer->isVisible() && _preferencesDialog->isFeaturesShown(0)) if(_cloudViewer->isVisible() && _preferencesDialog->isFeaturesShown(0))
{ {
if(viewerClouds.contains(featuresName)) if(viewerClouds.contains(featuresName))
{ {
// Update only if the pose has changed // Update only if the pose has changed
Transform tFeatures; Transform tFeatures;
_ui->widget_cloudViewer->getPose(featuresName, tFeatures); _cloudViewer->getPose(featuresName, tFeatures);
if(tFeatures.isNull() || iter->second != tFeatures) if(tFeatures.isNull() || iter->second != tFeatures)
{ {
if(!_ui->widget_cloudViewer->updateCloudPose(featuresName, iter->second)) if(!_cloudViewer->updateCloudPose(featuresName, iter->second))
{ {
UERROR("Updating pose features %d failed!", iter->first); UERROR("Updating pose features %d failed!", iter->first);
} }
} }
_ui->widget_cloudViewer->setCloudVisibility(featuresName, _preferencesDialog->isFeaturesShown(0)); _cloudViewer->setCloudVisibility(featuresName, _preferencesDialog->isFeaturesShown(0));
_ui->widget_cloudViewer->setCloudPointSize(featuresName, _preferencesDialog->getFeaturesPointSize(0)); _cloudViewer->setCloudPointSize(featuresName, _preferencesDialog->getFeaturesPointSize(0));
} }
else if(_cachedSignatures.contains(iter->first)) else if(_cachedSignatures.contains(iter->first))
{ {
@@ -1893,7 +1914,7 @@ void MainWindow::updateMapCloud(
} }
else if(viewerClouds.contains(featuresName)) else if(viewerClouds.contains(featuresName))
{ {
_ui->widget_cloudViewer->setCloudVisibility(featuresName.c_str(), false); _cloudViewer->setCloudVisibility(featuresName.c_str(), false);
} }
if(verboseProgress) if(verboseProgress)
@@ -1929,10 +1950,10 @@ void MainWindow::updateMapCloud(
int id = std::atoi(splitted.back().c_str()); int id = std::atoi(splitted.back().c_str());
if(poses.find(id) == poses.end()) if(poses.find(id) == poses.end())
{ {
if(_ui->widget_cloudViewer->getCloudVisibility(iter.key())) if(_cloudViewer->getCloudVisibility(iter.key()))
{ {
UDEBUG("Hide %s", iter.key().c_str()); UDEBUG("Hide %s", iter.key().c_str());
_ui->widget_cloudViewer->setCloudVisibility(iter.key(), false); _cloudViewer->setCloudVisibility(iter.key(), false);
} }
} }
} }
@@ -1941,8 +1962,8 @@ void MainWindow::updateMapCloud(
UDEBUG(""); UDEBUG("");
// update 3D graphes (show all poses) // update 3D graphes (show all poses)
_ui->widget_cloudViewer->removeAllGraphs(); _cloudViewer->removeAllGraphs();
_ui->widget_cloudViewer->removeCloud("graph_nodes"); _cloudViewer->removeCloud("graph_nodes");
if(_preferencesDialog->isGraphsShown() && _currentPosesMap.size()) if(_preferencesDialog->isGraphsShown() && _currentPosesMap.size())
{ {
// Find all graphs // Find all graphs
@@ -1983,14 +2004,14 @@ void MainWindow::updateMapCloud(
{ {
color = (Qt::GlobalColor)((iter->first+3) % 12 + 7 ); color = (Qt::GlobalColor)((iter->first+3) % 12 + 7 );
} }
_ui->widget_cloudViewer->addOrUpdateGraph(uFormat("graph_%d", iter->first), iter->second, color); _cloudViewer->addOrUpdateGraph(uFormat("graph_%d", iter->first), iter->second, color);
} }
} }
UDEBUG("labels.size()=%d", (int)labels.size()); UDEBUG("labels.size()=%d", (int)labels.size());
// Update labels // Update labels
_ui->widget_cloudViewer->removeAllTexts(); _cloudViewer->removeAllTexts();
if(_preferencesDialog->isLabelsShown() && labels.size()) if(_preferencesDialog->isLabelsShown() && labels.size())
{ {
for(std::map<int, std::string>::const_iterator iter=labels.begin(); iter!=labels.end(); ++iter) for(std::map<int, std::string>::const_iterator iter=labels.begin(); iter!=labels.end(); ++iter)
@@ -2003,7 +2024,7 @@ void MainWindow::updateMapCloud(
{ {
color = (Qt::GlobalColor)((mapId+3) % 12 + 7 ); color = (Qt::GlobalColor)((mapId+3) % 12 + 7 );
} }
_ui->widget_cloudViewer->addOrUpdateText( _cloudViewer->addOrUpdateText(
std::string("label_") + uNumber2Str(iter->first), std::string("label_") + uNumber2Str(iter->first),
iter->second, iter->second,
_currentPosesMap.at(iter->first), _currentPosesMap.at(iter->first),
@@ -2048,7 +2069,7 @@ void MainWindow::updateMapCloud(
if(_preferencesDialog->getGridMapShown()) if(_preferencesDialog->getGridMapShown())
{ {
float opacity = _preferencesDialog->getGridMapOpacity(); float opacity = _preferencesDialog->getGridMapOpacity();
_ui->widget_cloudViewer->addOccupancyGridMap(map8U, resolution, xMin, yMin, opacity); _cloudViewer->addOccupancyGridMap(map8U, resolution, xMin, yMin, opacity);
} }
if(_ui->graphicsView_graphView->isVisible()) if(_ui->graphicsView_graphView->isVisible())
{ {
@@ -2063,7 +2084,7 @@ void MainWindow::updateMapCloud(
if(!_preferencesDialog->getGridMapShown()) if(!_preferencesDialog->getGridMapShown())
{ {
UDEBUG(""); UDEBUG("");
_ui->widget_cloudViewer->removeOccupancyGridMap(); _cloudViewer->removeOccupancyGridMap();
} }
if(viewerClouds.contains("cloudOdom")) if(viewerClouds.contains("cloudOdom"))
@@ -2071,14 +2092,14 @@ void MainWindow::updateMapCloud(
if(!_preferencesDialog->isCloudsShown(1)) if(!_preferencesDialog->isCloudsShown(1))
{ {
UDEBUG(""); UDEBUG("");
_ui->widget_cloudViewer->setCloudVisibility("cloudOdom", false); _cloudViewer->setCloudVisibility("cloudOdom", false);
} }
else else
{ {
UDEBUG(""); UDEBUG("");
_ui->widget_cloudViewer->updateCloudPose("cloudOdom", _odometryCorrection); _cloudViewer->updateCloudPose("cloudOdom", _odometryCorrection);
_ui->widget_cloudViewer->setCloudOpacity("cloudOdom", _preferencesDialog->getCloudOpacity(1)); _cloudViewer->setCloudOpacity("cloudOdom", _preferencesDialog->getCloudOpacity(1));
_ui->widget_cloudViewer->setCloudPointSize("cloudOdom", _preferencesDialog->getCloudPointSize(1)); _cloudViewer->setCloudPointSize("cloudOdom", _preferencesDialog->getCloudPointSize(1));
} }
} }
if(viewerClouds.contains("scanOdom")) if(viewerClouds.contains("scanOdom"))
@@ -2086,14 +2107,14 @@ void MainWindow::updateMapCloud(
if(!_preferencesDialog->isScansShown(1)) if(!_preferencesDialog->isScansShown(1))
{ {
UDEBUG(""); UDEBUG("");
_ui->widget_cloudViewer->setCloudVisibility("scanOdom", false); _cloudViewer->setCloudVisibility("scanOdom", false);
} }
else else
{ {
UDEBUG(""); UDEBUG("");
_ui->widget_cloudViewer->updateCloudPose("scanOdom", _odometryCorrection); _cloudViewer->updateCloudPose("scanOdom", _odometryCorrection);
_ui->widget_cloudViewer->setCloudOpacity("scanOdom", _preferencesDialog->getScanOpacity(1)); _cloudViewer->setCloudOpacity("scanOdom", _preferencesDialog->getScanOpacity(1));
_ui->widget_cloudViewer->setCloudPointSize("scanOdom", _preferencesDialog->getScanPointSize(1)); _cloudViewer->setCloudPointSize("scanOdom", _preferencesDialog->getScanPointSize(1));
} }
} }
if(viewerClouds.contains("scanMapOdom")) if(viewerClouds.contains("scanMapOdom"))
@@ -2101,14 +2122,14 @@ void MainWindow::updateMapCloud(
if(!_preferencesDialog->isScansShown(1)) if(!_preferencesDialog->isScansShown(1))
{ {
UDEBUG(""); UDEBUG("");
_ui->widget_cloudViewer->setCloudVisibility("scanMapOdom", false); _cloudViewer->setCloudVisibility("scanMapOdom", false);
} }
else else
{ {
UDEBUG(""); UDEBUG("");
_ui->widget_cloudViewer->updateCloudPose("scanMapOdom", _odometryCorrection); _cloudViewer->updateCloudPose("scanMapOdom", _odometryCorrection);
_ui->widget_cloudViewer->setCloudOpacity("scanMapOdom", _preferencesDialog->getScanOpacity(1)); _cloudViewer->setCloudOpacity("scanMapOdom", _preferencesDialog->getScanOpacity(1));
_ui->widget_cloudViewer->setCloudPointSize("scanMapOdom", _preferencesDialog->getScanPointSize(1)); _cloudViewer->setCloudPointSize("scanMapOdom", _preferencesDialog->getScanPointSize(1));
} }
} }
if(viewerClouds.contains("featuresOdom")) if(viewerClouds.contains("featuresOdom"))
@@ -2116,24 +2137,24 @@ void MainWindow::updateMapCloud(
if(!_preferencesDialog->isFeaturesShown(1)) if(!_preferencesDialog->isFeaturesShown(1))
{ {
UDEBUG(""); UDEBUG("");
_ui->widget_cloudViewer->setCloudVisibility("featuresOdom", false); _cloudViewer->setCloudVisibility("featuresOdom", false);
} }
else else
{ {
UDEBUG(""); UDEBUG("");
_ui->widget_cloudViewer->updateCloudPose("featuresOdom", _odometryCorrection); _cloudViewer->updateCloudPose("featuresOdom", _odometryCorrection);
_ui->widget_cloudViewer->setCloudPointSize("featuresOdom", _preferencesDialog->getFeaturesPointSize(1)); _cloudViewer->setCloudPointSize("featuresOdom", _preferencesDialog->getFeaturesPointSize(1));
} }
} }
if(!currentPose.isNull()) if(!currentPose.isNull())
{ {
UDEBUG(""); UDEBUG("");
_ui->widget_cloudViewer->updateCameraTargetPosition(currentPose); _cloudViewer->updateCameraTargetPosition(currentPose);
} }
UDEBUG(""); UDEBUG("");
_ui->widget_cloudViewer->update(); _cloudViewer->update();
UDEBUG(""); UDEBUG("");
} }
@@ -2142,7 +2163,7 @@ void MainWindow::createAndAddCloudToMap(int nodeId, const Transform & pose, int
UDEBUG(""); UDEBUG("");
UASSERT(!pose.isNull()); UASSERT(!pose.isNull());
std::string cloudName = uFormat("cloud%d", nodeId); std::string cloudName = uFormat("cloud%d", nodeId);
if(_ui->widget_cloudViewer->getAddedClouds().contains(cloudName)) if(_cloudViewer->getAddedClouds().contains(cloudName))
{ {
UERROR("Cloud %d already added to map.", nodeId); UERROR("Cloud %d already added to map.", nodeId);
return; return;
@@ -2285,7 +2306,7 @@ void MainWindow::createAndAddCloudToMap(int nodeId, const Transform & pose, int
pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr outputFiltered(new pcl::PointCloud<pcl::PointXYZRGBNormal>); pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr outputFiltered(new pcl::PointCloud<pcl::PointXYZRGBNormal>);
std::vector<pcl::Vertices> outputPolygons; std::vector<pcl::Vertices> outputPolygons;
util3d::filterNotUsedVerticesFromMesh(*output, polygons, *outputFiltered, outputPolygons); util3d::filterNotUsedVerticesFromMesh(*output, polygons, *outputFiltered, outputPolygons);
if(!_ui->widget_cloudViewer->addCloudMesh(cloudName, outputFiltered, outputPolygons, pose)) if(!_cloudViewer->addCloudMesh(cloudName, outputFiltered, outputPolygons, pose))
{ {
UERROR("Adding mesh cloud %d to viewer failed!", nodeId); UERROR("Adding mesh cloud %d to viewer failed!", nodeId);
} }
@@ -2302,7 +2323,7 @@ void MainWindow::createAndAddCloudToMap(int nodeId, const Transform & pose, int
color = (Qt::GlobalColor)(mapId+3 % 12 + 7 ); color = (Qt::GlobalColor)(mapId+3 % 12 + 7 );
} }
if(!_ui->widget_cloudViewer->addCloud(cloudName, output, pose, color)) if(!_cloudViewer->addCloud(cloudName, output, pose, color))
{ {
UERROR("Adding cloud %d to viewer failed!", nodeId); UERROR("Adding cloud %d to viewer failed!", nodeId);
} }
@@ -2314,15 +2335,15 @@ void MainWindow::createAndAddCloudToMap(int nodeId, const Transform & pose, int
return; return;
} }
_ui->widget_cloudViewer->setCloudOpacity(cloudName, _preferencesDialog->getCloudOpacity(0)); _cloudViewer->setCloudOpacity(cloudName, _preferencesDialog->getCloudOpacity(0));
_ui->widget_cloudViewer->setCloudPointSize(cloudName, _preferencesDialog->getCloudPointSize(0)); _cloudViewer->setCloudPointSize(cloudName, _preferencesDialog->getCloudPointSize(0));
UDEBUG(""); UDEBUG("");
} }
void MainWindow::createAndAddScanToMap(int nodeId, const Transform & pose, int mapId) void MainWindow::createAndAddScanToMap(int nodeId, const Transform & pose, int mapId)
{ {
std::string scanName = uFormat("scan%d", nodeId); std::string scanName = uFormat("scan%d", nodeId);
if(_ui->widget_cloudViewer->getAddedClouds().contains(scanName)) if(_cloudViewer->getAddedClouds().contains(scanName))
{ {
UERROR("Scan %d already added to map.", nodeId); UERROR("Scan %d already added to map.", nodeId);
return; return;
@@ -2358,7 +2379,7 @@ void MainWindow::createAndAddScanToMap(int nodeId, const Transform & pose, int m
{ {
color = (Qt::GlobalColor)(mapId+3 % 12 + 7 ); color = (Qt::GlobalColor)(mapId+3 % 12 + 7 );
} }
if(!_ui->widget_cloudViewer->addCloud(scanName, cloud, pose, color)) if(!_cloudViewer->addCloud(scanName, cloud, pose, color))
{ {
UERROR("Adding cloud %d to viewer failed!", nodeId); UERROR("Adding cloud %d to viewer failed!", nodeId);
} }
@@ -2385,7 +2406,7 @@ void MainWindow::createAndAddScanToMap(int nodeId, const Transform & pose, int m
{ {
color = (Qt::GlobalColor)(mapId+3 % 12 + 7 ); color = (Qt::GlobalColor)(mapId+3 % 12 + 7 );
} }
if(!_ui->widget_cloudViewer->addCloud(scanName, cloud, pose, color)) if(!_cloudViewer->addCloud(scanName, cloud, pose, color))
{ {
UERROR("Adding cloud %d to viewer failed!", nodeId); UERROR("Adding cloud %d to viewer failed!", nodeId);
} }
@@ -2413,8 +2434,8 @@ void MainWindow::createAndAddScanToMap(int nodeId, const Transform & pose, int m
} }
} }
} }
_ui->widget_cloudViewer->setCloudOpacity(scanName, _preferencesDialog->getScanOpacity(0)); _cloudViewer->setCloudOpacity(scanName, _preferencesDialog->getScanOpacity(0));
_ui->widget_cloudViewer->setCloudPointSize(scanName, _preferencesDialog->getScanPointSize(0)); _cloudViewer->setCloudPointSize(scanName, _preferencesDialog->getScanPointSize(0));
} }
} }
@@ -2423,7 +2444,7 @@ void MainWindow::createAndAddFeaturesToMap(int nodeId, const Transform & pose, i
UDEBUG(""); UDEBUG("");
UASSERT(!pose.isNull()); UASSERT(!pose.isNull());
std::string cloudName = uFormat("features%d", nodeId); std::string cloudName = uFormat("features%d", nodeId);
if(_ui->widget_cloudViewer->getAddedClouds().contains(cloudName)) if(_cloudViewer->getAddedClouds().contains(cloudName))
{ {
UERROR("Features cloud %d already added to map.", nodeId); UERROR("Features cloud %d already added to map.", nodeId);
return; return;
@@ -2492,7 +2513,7 @@ void MainWindow::createAndAddFeaturesToMap(int nodeId, const Transform & pose, i
(*cloud)[oi].r = (*cloud)[oi].g = (*cloud)[oi].b = 255; (*cloud)[oi].r = (*cloud)[oi].g = (*cloud)[oi].b = 255;
} }
} }
if(!_ui->widget_cloudViewer->addCloud(cloudName, cloud, pose, color)) if(!_cloudViewer->addCloud(cloudName, cloud, pose, color))
{ {
UERROR("Adding features cloud %d to viewer failed!", nodeId); UERROR("Adding features cloud %d to viewer failed!", nodeId);
} }
@@ -2506,7 +2527,7 @@ void MainWindow::createAndAddFeaturesToMap(int nodeId, const Transform & pose, i
return; return;
} }
_ui->widget_cloudViewer->setCloudPointSize(cloudName, _preferencesDialog->getFeaturesPointSize(0)); _cloudViewer->setCloudPointSize(cloudName, _preferencesDialog->getFeaturesPointSize(0));
UDEBUG(""); UDEBUG("");
} }
@@ -2564,7 +2585,7 @@ void MainWindow::updateNodeVisibility(int nodeId, bool visible)
{ {
if(_currentPosesMap.find(nodeId) != _currentPosesMap.end()) if(_currentPosesMap.find(nodeId) != _currentPosesMap.end())
{ {
QMap<std::string, Transform> viewerClouds = _ui->widget_cloudViewer->getAddedClouds(); QMap<std::string, Transform> viewerClouds = _cloudViewer->getAddedClouds();
if(_preferencesDialog->isCloudsShown(0)) if(_preferencesDialog->isCloudsShown(0))
{ {
std::string cloudName = uFormat("cloud%d", nodeId); std::string cloudName = uFormat("cloud%d", nodeId);
@@ -2577,9 +2598,9 @@ void MainWindow::updateNodeVisibility(int nodeId, bool visible)
if(visible) if(visible)
{ {
//make sure the transformation was done //make sure the transformation was done
_ui->widget_cloudViewer->updateCloudPose(cloudName, _currentPosesMap.find(nodeId)->second); _cloudViewer->updateCloudPose(cloudName, _currentPosesMap.find(nodeId)->second);
} }
_ui->widget_cloudViewer->setCloudVisibility(cloudName, visible); _cloudViewer->setCloudVisibility(cloudName, visible);
} }
} }
@@ -2595,13 +2616,13 @@ void MainWindow::updateNodeVisibility(int nodeId, bool visible)
if(visible) if(visible)
{ {
//make sure the transformation was done //make sure the transformation was done
_ui->widget_cloudViewer->updateCloudPose(scanName, _currentPosesMap.find(nodeId)->second); _cloudViewer->updateCloudPose(scanName, _currentPosesMap.find(nodeId)->second);
} }
_ui->widget_cloudViewer->setCloudVisibility(scanName, visible); _cloudViewer->setCloudVisibility(scanName, visible);
} }
} }
} }
_ui->widget_cloudViewer->update(); _cloudViewer->update();
} }
void MainWindow::processRtabmapEventInit(int status, const QString & info) void MainWindow::processRtabmapEventInit(int status, const QString & info)
@@ -2977,7 +2998,7 @@ void MainWindow::applyPrefSettings(const rtabmap::ParametersMap & parameters, bo
{ {
_ui->statsToolBox->setWorkingDirectory(_preferencesDialog->getWorkingDirectory()); _ui->statsToolBox->setWorkingDirectory(_preferencesDialog->getWorkingDirectory());
_ui->graphicsView_graphView->setWorkingDirectory(_preferencesDialog->getWorkingDirectory()); _ui->graphicsView_graphView->setWorkingDirectory(_preferencesDialog->getWorkingDirectory());
_ui->widget_cloudViewer->setWorkingDirectory(_preferencesDialog->getWorkingDirectory()); _cloudViewer->setWorkingDirectory(_preferencesDialog->getWorkingDirectory());
} }
if(_state != kIdle && parametersModified.size()) if(_state != kIdle && parametersModified.size())
@@ -2998,8 +3019,8 @@ void MainWindow::applyPrefSettings(const rtabmap::ParametersMap & parameters, bo
} }
// update loop closure viewer parameters (Use Map parameters) // update loop closure viewer parameters (Use Map parameters)
_ui->widget_loopClosureViewer->setDecimation(_preferencesDialog->getCloudDecimation(0)); _loopClosureViewer->setDecimation(_preferencesDialog->getCloudDecimation(0));
_ui->widget_loopClosureViewer->setMaxDepth(_preferencesDialog->getCloudMaxDepth(0)); _loopClosureViewer->setMaxDepth(_preferencesDialog->getCloudMaxDepth(0));
// update graph view parameters // update graph view parameters
if(uContains(parameters, Parameters::kRGBDLocalRadius())) if(uContains(parameters, Parameters::kRGBDLocalRadius()))
@@ -3291,7 +3312,7 @@ void MainWindow::saveConfigGUI()
_preferencesDialog->saveMainWindowState(this); _preferencesDialog->saveMainWindowState(this);
_preferencesDialog->saveWindowGeometry(_preferencesDialog); _preferencesDialog->saveWindowGeometry(_preferencesDialog);
_preferencesDialog->saveWindowGeometry(_aboutDialog); _preferencesDialog->saveWindowGeometry(_aboutDialog);
_preferencesDialog->saveWidgetState(_ui->widget_cloudViewer); _preferencesDialog->saveWidgetState(_cloudViewer);
_preferencesDialog->saveWidgetState(_ui->imageView_source); _preferencesDialog->saveWidgetState(_ui->imageView_source);
_preferencesDialog->saveWidgetState(_ui->imageView_loopClosure); _preferencesDialog->saveWidgetState(_ui->imageView_loopClosure);
_preferencesDialog->saveWidgetState(_ui->imageView_odometry); _preferencesDialog->saveWidgetState(_ui->imageView_odometry);
@@ -4649,9 +4670,9 @@ void MainWindow::clearTheCache()
_gridLocalMaps.clear(); _gridLocalMaps.clear();
_projectionLocalMaps.clear(); _projectionLocalMaps.clear();
_createdFeatures.clear(); _createdFeatures.clear();
_ui->widget_cloudViewer->clear(); _cloudViewer->clear();
_ui->widget_cloudViewer->setBackgroundColor(_ui->widget_cloudViewer->getDefaultBackgroundColor()); _cloudViewer->setBackgroundColor(_cloudViewer->getDefaultBackgroundColor());
_ui->widget_cloudViewer->clearTrajectory(); _cloudViewer->clearTrajectory();
_ui->widget_mapVisibility->clear(); _ui->widget_mapVisibility->clear();
_currentPosesMap.clear(); _currentPosesMap.clear();
_currentGTPosesMap.clear(); _currentGTPosesMap.clear();
@@ -4781,7 +4802,7 @@ void MainWindow::setDefaultViews()
_ui->toolBar_2->setVisible(true); _ui->toolBar_2->setVisible(true);
_ui->statusbar->setVisible(false); _ui->statusbar->setVisible(false);
this->setAspectRatio720p(); this->setAspectRatio720p();
_ui->widget_cloudViewer->resetCamera(); _cloudViewer->resetCamera();
} }
void MainWindow::selectScreenCaptureFormat(bool checked) void MainWindow::selectScreenCaptureFormat(bool checked)
+5 -5
View File
@@ -98,6 +98,7 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
_ui(0), _ui(0),
_indexModel(0), _indexModel(0),
_initialized(false), _initialized(false),
_progressDialog(new QProgressDialog(this)),
_calibrationDialog(new CalibrationDialog(false, ".", this)), _calibrationDialog(new CalibrationDialog(false, ".", this)),
_createCalibrationDialog(new CreateSimpleCalibrationDialog(".", "", this)) _createCalibrationDialog(new CreateSimpleCalibrationDialog(".", "", this))
{ {
@@ -105,6 +106,10 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
_calibrationDialog->setWindowFlags(Qt::Window); _calibrationDialog->setWindowFlags(Qt::Window);
_calibrationDialog->setWindowTitle(tr("Calibration")); _calibrationDialog->setWindowTitle(tr("Calibration"));
_progressDialog->setWindowTitle(tr("Read parameters..."));
_progressDialog->setMaximum(2);
_progressDialog->setValue(2);
_ui = new Ui_preferencesDialog(); _ui = new Ui_preferencesDialog();
_ui->setupUi(this); _ui->setupUi(this);
@@ -817,11 +822,6 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
this->setupTreeView(); this->setupTreeView();
_obsoletePanels = kPanelAll; _obsoletePanels = kPanelAll;
_progressDialog = new QProgressDialog(this);
_progressDialog->setWindowTitle(tr("Read parameters..."));
_progressDialog->setMaximum(2);
_progressDialog->setValue(2);
} }
PreferencesDialog::~PreferencesDialog() { PreferencesDialog::~PreferencesDialog() {
+77 -34
View File
@@ -21,7 +21,16 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@@ -52,7 +61,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>202</width> <width>205</width>
<height>196</height> <height>196</height>
</rect> </rect>
</property> </property>
@@ -210,7 +219,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>201</width> <width>204</width>
<height>196</height> <height>196</height>
</rect> </rect>
</property> </property>
@@ -357,7 +366,16 @@
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="margin"> <property name="leftMargin">
<number>12</number>
</property>
<property name="topMargin">
<number>12</number>
</property>
<property name="rightMargin">
<number>12</number>
</property>
<property name="bottomMargin">
<number>12</number> <number>12</number>
</property> </property>
<item> <item>
@@ -413,7 +431,16 @@
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="margin"> <property name="leftMargin">
<number>12</number>
</property>
<property name="topMargin">
<number>12</number>
</property>
<property name="rightMargin">
<number>12</number>
</property>
<property name="bottomMargin">
<number>12</number> <number>12</number>
</property> </property>
<item> <item>
@@ -541,7 +568,11 @@
<widget class="QWidget" name="dockWidgetContents"> <widget class="QWidget" name="dockWidgetContents">
<layout class="QVBoxLayout" name="verticalLayout_8" stretch="1,0,0,0"> <layout class="QVBoxLayout" name="verticalLayout_8" stretch="1,0,0,0">
<item> <item>
<widget class="rtabmap::CloudViewer" name="constraintsViewer" native="true"/> <layout class="QVBoxLayout" name="layout_constraintsViewer">
<property name="spacing">
<number>0</number>
</property>
</layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_10"> <layout class="QHBoxLayout" name="horizontalLayout_10">
@@ -983,7 +1014,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>333</width> <width>340</width>
<height>186</height> <height>186</height>
</rect> </rect>
</property> </property>
@@ -1118,8 +1149,8 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>-51</y> <y>0</y>
<width>278</width> <width>282</width>
<height>611</height> <height>611</height>
</rect> </rect>
</property> </property>
@@ -1530,7 +1561,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>201</width> <width>205</width>
<height>117</height> <height>117</height>
</rect> </rect>
</property> </property>
@@ -1630,8 +1661,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>289</width> <width>267</width>
<height>182</height> <height>157</height>
</rect> </rect>
</property> </property>
<attribute name="label"> <attribute name="label">
@@ -1725,22 +1756,28 @@
<attribute name="dockWidgetArea"> <attribute name="dockWidgetArea">
<number>4</number> <number>4</number>
</attribute> </attribute>
<widget class="QWidget" name="dockWidgetContents_5"> <widget class="QWidget" name="dockWidgetContents_stereo">
<layout class="QVBoxLayout" name="verticalLayout_11" stretch="1,0"> <layout class="QVBoxLayout" name="verticalLayout_11" stretch="1,0">
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_9" stretch="1,1"> <layout class="QHBoxLayout" name="horizontalLayout_stereo" stretch="1">
<item> <item>
<widget class="rtabmap::ImageView" name="graphicsView_stereo" native="true"/> <widget class="rtabmap::ImageView" name="graphicsView_stereo" native="true"/>
</item> </item>
<item>
<widget class="rtabmap::CloudViewer" name="stereoViewer" native="true"/>
</item>
</layout> </layout>
</item> </item>
<item> <item>
@@ -1841,25 +1878,28 @@
<attribute name="dockWidgetArea"> <attribute name="dockWidgetArea">
<number>4</number> <number>4</number>
</attribute> </attribute>
<widget class="QWidget" name="dockWidgetContents_6"> <widget class="QWidget" name="dockWidgetContents_3dviews">
<layout class="QVBoxLayout" name="verticalLayout_5" stretch="1,0"> <layout class="QVBoxLayout" name="verticalLayout_5" stretch="1,0">
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_3dviews" stretch="1,1"> <layout class="QHBoxLayout" name="horizontalLayout_3dviews">
<property name="spacing"> <property name="spacing">
<number>1</number> <number>1</number>
</property> </property>
<item>
<widget class="rtabmap::CloudViewer" name="widget_cloudA" native="true"/>
</item>
<item>
<widget class="rtabmap::CloudViewer" name="widget_cloudB" native="true"/>
</item>
</layout> </layout>
</item> </item>
<item> <item>
@@ -1906,7 +1946,16 @@
</attribute> </attribute>
<widget class="QWidget" name="dockWidgetContents_7"> <widget class="QWidget" name="dockWidgetContents_7">
<layout class="QVBoxLayout" name="verticalLayout_13"> <layout class="QVBoxLayout" name="verticalLayout_13">
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@@ -2032,12 +2081,6 @@
</action> </action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget>
<class>rtabmap::CloudViewer</class>
<extends>QWidget</extends>
<header>rtabmap/gui/CloudViewer.h</header>
<container>1</container>
</customwidget>
<customwidget> <customwidget>
<class>rtabmap::ImageView</class> <class>rtabmap::ImageView</class>
<extends>QWidget</extends> <extends>QWidget</extends>
+112 -31
View File
@@ -285,7 +285,16 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@@ -323,7 +332,16 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@@ -566,7 +584,16 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@@ -587,7 +614,16 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@@ -608,7 +644,16 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@@ -624,17 +669,23 @@
<attribute name="dockWidgetArea"> <attribute name="dockWidgetArea">
<number>2</number> <number>2</number>
</attribute> </attribute>
<widget class="QWidget" name="dockWidgetContents_5"> <widget class="QWidget" name="layout_cloudViewer">
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item>
<widget class="rtabmap::CloudViewer" name="widget_cloudViewer" native="true"/>
</item>
</layout> </layout>
</widget> </widget>
</widget> </widget>
@@ -645,17 +696,23 @@
<attribute name="dockWidgetArea"> <attribute name="dockWidgetArea">
<number>2</number> <number>2</number>
</attribute> </attribute>
<widget class="QWidget" name="dockWidgetContents_7"> <widget class="QWidget" name="layout_loopClosureViewer">
<layout class="QVBoxLayout" name="verticalLayout_7"> <layout class="QVBoxLayout" name="verticalLayout_7">
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item>
<widget class="rtabmap::LoopClosureViewer" name="widget_loopClosureViewer" native="true"/>
</item>
</layout> </layout>
</widget> </widget>
</widget> </widget>
@@ -674,7 +731,16 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@@ -695,7 +761,16 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@@ -719,7 +794,16 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@@ -789,7 +873,16 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@@ -1323,18 +1416,6 @@
<header>../include/rtabmap/gui/ConsoleWidget.h</header> <header>../include/rtabmap/gui/ConsoleWidget.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>rtabmap::CloudViewer</class>
<extends>QWidget</extends>
<header>../include/rtabmap/gui/CloudViewer.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>rtabmap::LoopClosureViewer</class>
<extends>QWidget</extends>
<header>../include/rtabmap/gui/LoopClosureViewer.h</header>
<container>1</container>
</customwidget>
<customwidget> <customwidget>
<class>rtabmap::MapVisibilityWidget</class> <class>rtabmap::MapVisibilityWidget</class>
<extends>QWidget</extends> <extends>QWidget</extends>
+1
View File
@@ -51,6 +51,7 @@ int main(int argc, char * argv[])
delete mainWindow; delete mainWindow;
delete app; delete app;
UINFO("All done! closing...");
return 0; return 0;
} }