From fb0b23ae06f92c973e300c4a05b687e12801e2fe Mon Sep 17 00:00:00 2001 From: Mathieu Labbe Date: Tue, 13 Jan 2015 18:11:34 -0500 Subject: [PATCH] saving CloudViewer settings (Camera,Trajectory,Grid) in the config file --- examples/RGBDMapping/MapBuilder.h | 2 +- guilib/include/rtabmap/gui/CloudViewer.h | 30 ++- guilib/include/rtabmap/gui/ImageView.h | 8 +- .../include/rtabmap/gui/PreferencesDialog.h | 6 + guilib/src/CloudViewer.cpp | 217 +++++++++++++++++- guilib/src/DatabaseViewer.cpp | 4 +- guilib/src/ImageView.cpp | 8 +- guilib/src/MainWindow.cpp | 12 +- guilib/src/OdometryViewer.cpp | 2 +- guilib/src/PreferencesDialog.cpp | 117 ++++++++++ 10 files changed, 379 insertions(+), 27 deletions(-) diff --git a/examples/RGBDMapping/MapBuilder.h b/examples/RGBDMapping/MapBuilder.h index 39839d2b..38f9c9da 100644 --- a/examples/RGBDMapping/MapBuilder.h +++ b/examples/RGBDMapping/MapBuilder.h @@ -126,7 +126,7 @@ private slots: if(!data.pose().isNull()) { // update camera position - cloudViewer_->updateCameraPosition(data.pose()); + cloudViewer_->updateCameraTargetPosition(data.pose()); } } cloudViewer_->render(); diff --git a/guilib/include/rtabmap/gui/CloudViewer.h b/guilib/include/rtabmap/gui/CloudViewer.h index 51432f8a..e30425c7 100644 --- a/guilib/include/rtabmap/gui/CloudViewer.h +++ b/guilib/include/rtabmap/gui/CloudViewer.h @@ -127,7 +127,7 @@ public: float opacity); void removeOccupancyGridMap(); - void updateCameraPosition( + void updateCameraTargetPosition( const Transform & pose); void addOrUpdateGraph( @@ -137,8 +137,10 @@ public: void removeGraph(const std::string & id); void removeAllGraphs(); + bool isTrajectoryShown() const; + int getTrajectorySize() const; void setTrajectoryShown(bool shown); - void setTrajectorySize(int value); + void setTrajectorySize(unsigned int value); void clearTrajectory(); void removeAllClouds(); //including meshes @@ -149,12 +151,30 @@ public: const QMap & getAddedClouds() const {return _addedClouds;} //including meshes const QColor & getBackgroundColor() const; + Transform getTargetPose() const; + void getCameraPosition( + float & x, float & y, float & z, + float & focalX, float & focalY, float & focalZ, + float & upX, float & upY, float & upZ) const; + bool isCameraTargetLocked() const; + bool isCameraTargetFollow() const; + bool isCameraFree() const; + bool isCameraLockZ() const; + bool isGridShown() const; + unsigned int getGridCellCount() const; + float getGridCellSize() const; + void setCameraPosition( + float x, float y, float z, + float focalX, float focalY, float focalZ, + float upX, float upY, float upZ); void setCameraTargetLocked(bool enabled = true); void setCameraTargetFollow(bool enabled = true); void setCameraFree(); void setCameraLockZ(bool enabled = true); void setGridShown(bool shown); + void setGridCellCount(unsigned int count); + void setGridCellSize(float size); void setWorkingDirectory(const QString & path) {_workingDirectory = path;} public slots: @@ -168,6 +188,8 @@ public slots: protected: virtual void keyReleaseEvent(QKeyEvent * event); virtual void keyPressEvent(QKeyEvent * event); + virtual void mousePressEvent(QMouseEvent * event); + virtual void mouseMoveEvent(QMouseEvent * event); virtual void contextMenuEvent(QContextMenuEvent * event); virtual void handleAction(QAction * event); QMenu * menu() {return _menu;} @@ -188,11 +210,15 @@ private: QAction * _aSetTrajectorySize; QAction * _aClearTrajectory; QAction * _aShowGrid; + QAction * _aSetGridCellCount; + QAction * _aSetGridCellSize; QAction * _aSetBackgroundColor; QMenu * _menu; std::map::Ptr > _graphes; pcl::PointCloud::Ptr _trajectory; unsigned int _maxTrajectorySize; + unsigned int _gridCellCount; + float _gridCellSize; QMap _addedClouds; // include cloud, scan, meshes Transform _lastPose; std::list _gridLines; diff --git a/guilib/include/rtabmap/gui/ImageView.h b/guilib/include/rtabmap/gui/ImageView.h index 51af66c1..5bc8d27b 100644 --- a/guilib/include/rtabmap/gui/ImageView.h +++ b/guilib/include/rtabmap/gui/ImageView.h @@ -53,10 +53,10 @@ public: void resetZoom(); - bool isImageShown(); - bool isImageDepthShown(); - bool isFeaturesShown(); - bool isLinesShown(); + bool isImageShown() const; + bool isImageDepthShown() const; + bool isFeaturesShown() const; + bool isLinesShown() const; void setFeaturesShown(bool shown); void setImageShown(bool shown); diff --git a/guilib/include/rtabmap/gui/PreferencesDialog.h b/guilib/include/rtabmap/gui/PreferencesDialog.h index 421ca16b..e1f7df38 100644 --- a/guilib/include/rtabmap/gui/PreferencesDialog.h +++ b/guilib/include/rtabmap/gui/PreferencesDialog.h @@ -61,6 +61,8 @@ class OdometryThread; class CameraThread; class Signature; class LoopClosureViewer; +class CloudViewer; +class ImageView; class RTABMAPGUI_EXP PreferencesDialog : public QDialog { @@ -101,6 +103,10 @@ public: void loadWindowGeometry(const QString & windowName, QWidget * window); void saveMainWindowState(const QMainWindow * mainWindow); void loadMainWindowState(QMainWindow * mainWindow); + void saveCloudViewerState(const QString & name, const CloudViewer * viewer); + void loadCloudViewerState(const QString & name, CloudViewer * viewer); + void saveImageViewState(const QString & name, const ImageView * view); + void loadImageViewState(const QString & name, ImageView * view); void saveCustomConfig(const QString & section, const QString & key, const QString & value); QString loadCustomConfig(const QString & section, const QString & key); diff --git a/guilib/src/CloudViewer.cpp b/guilib/src/CloudViewer.cpp index fa53e9bd..593792c0 100644 --- a/guilib/src/CloudViewer.cpp +++ b/guilib/src/CloudViewer.cpp @@ -70,10 +70,14 @@ CloudViewer::CloudViewer(QWidget *parent) : _aSetTrajectorySize(0), _aClearTrajectory(0), _aShowGrid(0), + _aSetGridCellCount(0), + _aSetGridCellSize(0), _aSetBackgroundColor(0), _menu(0), _trajectory(new pcl::PointCloud), _maxTrajectorySize(100), + _gridCellCount(50), + _gridCellSize(1), _workingDirectory("."), _backgroundColor(Qt::black) { @@ -125,6 +129,8 @@ void CloudViewer::createMenu() _aClearTrajectory = new QAction("Clear trajectory", this); _aShowGrid = new QAction("Show grid", this); _aShowGrid->setCheckable(true); + _aSetGridCellCount = new QAction("Set cell count...", this); + _aSetGridCellSize = new QAction("Set cell size...", this); _aSetBackgroundColor = new QAction("Set background color...", this); QMenu * cameraMenu = new QMenu("Camera", this); @@ -144,11 +150,16 @@ void CloudViewer::createMenu() trajectoryMenu->addAction(_aSetTrajectorySize); trajectoryMenu->addAction(_aClearTrajectory); + QMenu * gridMenu = new QMenu("Grid", this); + gridMenu->addAction(_aShowGrid); + gridMenu->addAction(_aSetGridCellCount); + gridMenu->addAction(_aSetGridCellSize); + //menus _menu = new QMenu(this); _menu->addMenu(cameraMenu); _menu->addMenu(trajectoryMenu); - _menu->addAction(_aShowGrid); + _menu->addMenu(gridMenu); _menu->addAction(_aSetBackgroundColor); } @@ -480,12 +491,22 @@ void CloudViewer::removeAllGraphs() _graphes.clear(); } +bool CloudViewer::isTrajectoryShown() const +{ + return _aShowTrajectory->isChecked(); +} + +int CloudViewer::getTrajectorySize() const +{ + return _maxTrajectorySize; +} + void CloudViewer::setTrajectoryShown(bool shown) { _aShowTrajectory->setChecked(shown); } -void CloudViewer::setTrajectorySize(int value) +void CloudViewer::setTrajectorySize(unsigned int value) { _maxTrajectorySize = value; } @@ -494,7 +515,6 @@ void CloudViewer::clearTrajectory() { _trajectory->clear(); _visualizer->removeShape("trajectory"); - _lastPose.setNull(); this->render(); } @@ -521,7 +541,42 @@ bool CloudViewer::getPose(const std::string & id, Transform & pose) return false; } -void CloudViewer::updateCameraPosition(const Transform & pose) +Transform CloudViewer::getTargetPose() const +{ + if(_lastPose.isNull()) + { + return Transform::getIdentity(); + } + return _lastPose; +} + +void CloudViewer::getCameraPosition( + float & x, float & y, float & z, + float & focalX, float & focalY, float & focalZ, + float & upX, float & upY, float & upZ) const +{ + std::vector cameras; + _visualizer->getCameras(cameras); + x = cameras.front().pos[0]; + y = cameras.front().pos[1]; + z = cameras.front().pos[2]; + focalX = cameras.front().focal[0]; + focalY = cameras.front().focal[1]; + focalZ = cameras.front().focal[2]; + upX = cameras.front().view[0]; + upY = cameras.front().view[1]; + upZ = cameras.front().view[2]; +} + +void CloudViewer::setCameraPosition( + float x, float y, float z, + float focalX, float focalY, float focalZ, + float upX, float upY, float upZ) +{ + _visualizer->setCameraPosition(x,y,z, focalX,focalY,focalX, upX,upY,upZ); +} + +void CloudViewer::updateCameraTargetPosition(const Transform & pose) { if(!pose.isNull()) { @@ -752,12 +807,73 @@ void CloudViewer::setGridShown(bool shown) } } +bool CloudViewer::isCameraTargetLocked() const +{ + return _aLockCamera->isChecked(); +} +bool CloudViewer::isCameraTargetFollow() const +{ + return _aFollowCamera->isChecked(); +} +bool CloudViewer::isCameraFree() const +{ + return !_aFollowCamera->isChecked() && !_aLockCamera->isChecked(); +} +bool CloudViewer::isCameraLockZ() const +{ + return _aLockViewZ->isChecked(); +} +bool CloudViewer::isGridShown() const +{ + return _aShowGrid->isChecked(); +} +unsigned int CloudViewer::getGridCellCount() const +{ + return _gridCellCount; +} +float CloudViewer::getGridCellSize() const +{ + return _gridCellSize; +} + +void CloudViewer::setGridCellCount(unsigned int count) +{ + if(count > 0) + { + _gridCellCount = count; + if(_aShowGrid->isChecked()) + { + this->removeGrid(); + this->addGrid(); + } + } + else + { + UERROR("Cannot set grid cell count < 1, count=%d", count); + } +} +void CloudViewer::setGridCellSize(float size) +{ + if(size > 0) + { + _gridCellSize = size; + if(_aShowGrid->isChecked()) + { + this->removeGrid(); + this->addGrid(); + } + } + else + { + UERROR("Cannot set grid cell size <= 0, value=%f", size); + } +} void CloudViewer::addGrid() { if(_gridLines.empty()) { - float cellSize = 1.0f; - int cellCount = 50; + float cellSize = _gridCellSize; + int cellCount = _gridCellCount; double r=0.5; double g=0.5; double b=0.5; @@ -935,6 +1051,39 @@ void CloudViewer::keyPressEvent(QKeyEvent * event) } } +void CloudViewer::mousePressEvent(QMouseEvent * event) +{ + if(event->button() == Qt::RightButton) + { + event->accept(); + } + else + { + QVTKWidget::mousePressEvent(event); + } +} + +void CloudViewer::mouseMoveEvent(QMouseEvent * event) +{ + QVTKWidget::mouseMoveEvent(event); + // camera view up z locked? + if(_aLockViewZ->isChecked()) + { + std::vector cameras; + _visualizer->getCameras(cameras); + + cameras.front().view[0] = 0; + cameras.front().view[1] = 0; + cameras.front().view[2] = 1; + + _visualizer->setCameraPosition( + cameras.front().pos[0], cameras.front().pos[1], cameras.front().pos[2], + cameras.front().focal[0], cameras.front().focal[1], cameras.front().focal[2], + cameras.front().view[0], cameras.front().view[1], cameras.front().view[2]); + + } +} + void CloudViewer::contextMenuEvent(QContextMenuEvent * event) { QAction * a = _menu->exec(event->globalPos()); @@ -961,10 +1110,31 @@ void CloudViewer::handleAction(QAction * a) } else if(a == _aResetCamera) { - _visualizer->setCameraPosition( - -1, 0, 0, - 0, 0, 0, - 0, 0, 1); + if((_aFollowCamera->isChecked() || _aLockCamera->isChecked()) && !_lastPose.isNull()) + { + // reset relative to last current pose + if(_aLockViewZ->isChecked()) + { + _visualizer->setCameraPosition( + _lastPose.x()-1, _lastPose.y(), _lastPose.z(), + _lastPose.x(), _lastPose.y(), _lastPose.z(), + 0, 0, 1); + } + else + { + _visualizer->setCameraPosition( + _lastPose.x()-1, _lastPose.y(), _lastPose.z(), + _lastPose.x(), _lastPose.y(), _lastPose.z(), + _lastPose.r31(), _lastPose.r32(), _lastPose.r33()); + } + } + else + { + _visualizer->setCameraPosition( + -1, 0, 0, + 0, 0, 0, + 0, 0, 1); + } this->render(); } else if(a == _aShowGrid) @@ -980,12 +1150,37 @@ void CloudViewer::handleAction(QAction * a) this->render(); } + else if(a == _aSetGridCellCount) + { + bool ok; + int value = QInputDialog::getInt(this, tr("Set grid cell count"), tr("Count"), _gridCellCount, 1, 10000, 10, &ok); + if(ok) + { + this->setGridCellCount(value); + } + } + else if(a == _aSetGridCellSize) + { + bool ok; + double value = QInputDialog::getDouble(this, tr("Set grid cell size"), tr("Size (m)"), _gridCellSize, 0.01, 10, 2, &ok); + if(ok) + { + this->setGridCellSize(value); + } + } else if(a == _aSetBackgroundColor) { - QColor color = Qt::black; + QColor color = this->getBackgroundColor(); color = QColorDialog::getColor(color, this); this->setBackgroundColor(color); } + else if(a == _aLockViewZ) + { + if(_aLockViewZ->isChecked()) + { + this->render(); + } + } } } /* namespace rtabmap */ diff --git a/guilib/src/DatabaseViewer.cpp b/guilib/src/DatabaseViewer.cpp index d31b4734..b09dd98f 100644 --- a/guilib/src/DatabaseViewer.cpp +++ b/guilib/src/DatabaseViewer.cpp @@ -1240,7 +1240,7 @@ void DatabaseViewer::updateStereo(const Signature * data) UINFO("correspondences = %d/%d (%f) (time kpt=%fs flow=%fs)", (int)cloud->size(), (int)leftCorners.size(), float(cloud->size())/float(leftCorners.size()), timeKpt, timeFlow); - ui_->stereoViewer->updateCameraPosition(Transform::getIdentity()); + ui_->stereoViewer->updateCameraTargetPosition(Transform::getIdentity()); ui_->stereoViewer->addOrUpdateCloud("stereo", cloud); ui_->stereoViewer->render(); @@ -1655,7 +1655,7 @@ void DatabaseViewer::updateConstraintView(const rtabmap::Link & linkIn, } //update cordinate - ui_->constraintsViewer->updateCameraPosition(t); + ui_->constraintsViewer->updateCameraTargetPosition(t); ui_->constraintsViewer->clearTrajectory(); ui_->constraintsViewer->render(); diff --git a/guilib/src/ImageView.cpp b/guilib/src/ImageView.cpp index e4aebb37..159e8821 100644 --- a/guilib/src/ImageView.cpp +++ b/guilib/src/ImageView.cpp @@ -77,17 +77,17 @@ void ImageView::resetZoom() this->setDragMode(QGraphicsView::NoDrag); } -bool ImageView::isImageShown() +bool ImageView::isImageShown() const { return _showImage->isChecked(); } -bool ImageView::isImageDepthShown() +bool ImageView::isImageDepthShown() const { return _showImageDepth->isChecked(); } -bool ImageView::isFeaturesShown() +bool ImageView::isFeaturesShown() const { return _showFeatures->isChecked(); } @@ -121,7 +121,7 @@ void ImageView::setImageDepthShown(bool shown) } } -bool ImageView::isLinesShown() +bool ImageView::isLinesShown() const { return _showLines->isChecked(); } diff --git a/guilib/src/MainWindow.cpp b/guilib/src/MainWindow.cpp index d23e2ca3..678743d6 100644 --- a/guilib/src/MainWindow.cpp +++ b/guilib/src/MainWindow.cpp @@ -196,6 +196,9 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent) : _ui->imageView_source->setBackgroundBrush(QBrush(Qt::black)); _ui->imageView_loopClosure->setBackgroundBrush(QBrush(Qt::black)); _ui->imageView_odometry->setBackgroundBrush(QBrush(Qt::black)); + _preferencesDialog->loadImageViewState(_ui->imageView_source->objectName(), _ui->imageView_source); + _preferencesDialog->loadImageViewState(_ui->imageView_loopClosure->objectName(), _ui->imageView_loopClosure); + _preferencesDialog->loadImageViewState(_ui->imageView_odometry->objectName(), _ui->imageView_odometry); _posteriorCurve = new PdfPlotCurve("Posterior", &_cachedSignatures, this); _ui->posteriorPlot->addCurve(_posteriorCurve, false); @@ -370,6 +373,7 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent) : _ui->statsToolBox->setWorkingDirectory(_preferencesDialog->getWorkingDirectory()); _ui->graphicsView_graphView->setWorkingDirectory(_preferencesDialog->getWorkingDirectory()); _ui->widget_cloudViewer->setWorkingDirectory(_preferencesDialog->getWorkingDirectory()); + _preferencesDialog->loadCloudViewerState(_ui->widget_cloudViewer->objectName(), _ui->widget_cloudViewer); if(_ui->statsToolBox->findChildren().size() == 0) { @@ -448,6 +452,10 @@ void MainWindow::closeEvent(QCloseEvent* event) //write settings before quit? _preferencesDialog->saveMainWindowState(this); + _preferencesDialog->saveCloudViewerState(_ui->widget_cloudViewer->objectName(), _ui->widget_cloudViewer); + _preferencesDialog->saveImageViewState(_ui->imageView_source->objectName(), _ui->imageView_source); + _preferencesDialog->saveImageViewState(_ui->imageView_loopClosure->objectName(), _ui->imageView_loopClosure); + _preferencesDialog->saveImageViewState(_ui->imageView_odometry->objectName(), _ui->imageView_odometry); _ui->dockWidget_imageView->close(); _ui->dockWidget_likelihood->close(); @@ -695,7 +703,7 @@ void MainWindow::processOdometry(const rtabmap::SensorData & data, const rtabmap if(!data.pose().isNull()) { // update camera position - _ui->widget_cloudViewer->updateCameraPosition(_odometryCorrection*data.pose()); + _ui->widget_cloudViewer->updateCameraTargetPosition(_odometryCorrection*data.pose()); } } _ui->widget_cloudViewer->render(); @@ -1359,7 +1367,7 @@ void MainWindow::updateMapCloud( if(!currentPose.isNull()) { - _ui->widget_cloudViewer->updateCameraPosition(currentPose); + _ui->widget_cloudViewer->updateCameraTargetPosition(currentPose); } _ui->widget_cloudViewer->render(); diff --git a/guilib/src/OdometryViewer.cpp b/guilib/src/OdometryViewer.cpp index afffebf4..cea3266c 100644 --- a/guilib/src/OdometryViewer.cpp +++ b/guilib/src/OdometryViewer.cpp @@ -147,7 +147,7 @@ void OdometryViewer::processData() this->addCloud(uFormat("cloud%d", clouds_.rbegin()->first), clouds_.rbegin()->second, data.pose()); } - this->updateCameraPosition(data.pose()); + this->updateCameraTargetPosition(data.pose()); if(qualityWarningThr_ && quality>=0 && quality < qualityWarningThr_) { diff --git a/guilib/src/PreferencesDialog.cpp b/guilib/src/PreferencesDialog.cpp index 1e6da58f..4a1d2492 100644 --- a/guilib/src/PreferencesDialog.cpp +++ b/guilib/src/PreferencesDialog.cpp @@ -34,6 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include #include #include #include @@ -56,6 +57,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "rtabmap/gui/LoopClosureViewer.h" #include "rtabmap/gui/DataRecorder.h" +#include "rtabmap/gui/CloudViewer.h" +#include "rtabmap/gui/ImageView.h" #include #include @@ -1687,6 +1690,120 @@ void PreferencesDialog::loadMainWindowState(QMainWindow * mainWindow) loadWindowGeometry("MainWindow", mainWindow); } +void PreferencesDialog::saveCloudViewerState(const QString & name, const CloudViewer * viewer) +{ + QSettings settings(getIniFilePath(), QSettings::IniFormat); + settings.beginGroup("Gui"); + settings.beginGroup(name); + + float poseX, poseY, poseZ, focalX, focalY, focalZ, upX, upY, upZ; + viewer->getCameraPosition(poseX, poseY, poseZ, focalX, focalY, focalZ, upX, upY, upZ); + QVector3D pose(poseX, poseY, poseZ); + QVector3D focal(focalX, focalY, focalZ); + if(!viewer->isCameraFree()) + { + // make camera position relative to target + Transform T = viewer->getTargetPose(); + if(viewer->isCameraTargetLocked()) + { + T = Transform(T.x(), T.y(), T.z(), 0,0,0); + } + Transform F(focalX, focalY, focalZ, 0,0,0); + Transform P(poseX, poseY, poseZ, 0,0,0); + Transform newFocal = T.inverse() * F; + Transform newPose = newFocal * F.inverse() * P; + pose = QVector3D(newPose.x(), newPose.y(), newPose.z()); + focal = QVector3D(newFocal.x(), newFocal.y(), newFocal.z()); + } + settings.setValue("camera_pose", pose); + settings.setValue("camera_focal", focal); + settings.setValue("camera_up", QVector3D(upX, upY, upZ)); + + settings.setValue("grid", viewer->isGridShown()); + settings.setValue("grid_cell_count", viewer->getGridCellCount()); + settings.setValue("grid_cell_size", viewer->getGridCellSize()); + + settings.setValue("trajectory_shown", viewer->isTrajectoryShown()); + settings.setValue("trajectory_size", viewer->getTrajectorySize()); + + settings.setValue("camera_target_locked", viewer->isCameraTargetLocked()); + settings.setValue("camera_target_follow", viewer->isCameraTargetFollow()); + settings.setValue("camera_free", viewer->isCameraFree()); + settings.setValue("camera_lockZ", viewer->isCameraLockZ()); + + settings.setValue("bg_color", viewer->getBackgroundColor()); + + settings.endGroup(); // "name" + settings.endGroup(); // Gui +} + +void PreferencesDialog::loadCloudViewerState(const QString & name, CloudViewer * viewer) +{ + QByteArray bytes; + QSettings settings(getIniFilePath(), QSettings::IniFormat); + settings.beginGroup("Gui"); + settings.beginGroup(name); + + float poseX, poseY, poseZ, focalX, focalY, focalZ, upX, upY, upZ; + viewer->getCameraPosition(poseX, poseY, poseZ, focalX, focalY, focalZ, upX, upY, upZ); + QVector3D pose(poseX, poseY, poseZ), focal(focalX, focalY, focalZ), up(upX, upY, upZ); + pose = settings.value("camera_pose", pose).value(); + focal = settings.value("camera_focal", focal).value(); + up = settings.value("camera_up", up).value(); + viewer->setCameraPosition(pose.x(),pose.y(),pose.z(), focal.x(),focal.y(),focal.z(), up.x(),up.y(),up.z()); + + viewer->setGridShown(settings.value("grid", viewer->isGridShown()).toBool()); + viewer->setGridCellCount(settings.value("grid_cell_count", viewer->getGridCellCount()).toInt()); + viewer->setGridCellSize(settings.value("grid_cell_size", viewer->getGridCellSize()).toFloat()); + + viewer->setTrajectoryShown(settings.value("trajectory_shown", viewer->isTrajectoryShown()).toBool()); + viewer->setTrajectorySize(settings.value("trajectory_size", viewer->getTrajectorySize()).toInt()); + + viewer->setCameraTargetLocked(settings.value("camera_target_locked", viewer->isCameraTargetLocked()).toBool()); + viewer->setCameraTargetFollow(settings.value("camera_target_follow", viewer->isCameraTargetFollow()).toBool()); + if(settings.value("camera_free", viewer->isCameraFree()).toBool()) + { + viewer->setCameraFree(); + } + viewer->setCameraLockZ(settings.value("camera_lockZ", viewer->isCameraLockZ()).toBool()); + + viewer->setBackgroundColor(settings.value("bg_color", viewer->getBackgroundColor()).value()); + + settings.endGroup(); //"name" + settings.endGroup(); // Gui +} + +void PreferencesDialog::saveImageViewState(const QString & name, const ImageView * view) +{ + QSettings settings(getIniFilePath(), QSettings::IniFormat); + settings.beginGroup("Gui"); + settings.beginGroup(name); + + settings.setValue("image_shown", view->isImageShown()); + settings.setValue("depth_shown", view->isImageDepthShown()); + settings.setValue("features_shown", view->isFeaturesShown()); + settings.setValue("lines_shown", view->isLinesShown()); + + settings.endGroup(); // "name" + settings.endGroup(); // Gui +} + +void PreferencesDialog::loadImageViewState(const QString & name, ImageView * view) +{ + QByteArray bytes; + QSettings settings(getIniFilePath(), QSettings::IniFormat); + settings.beginGroup("Gui"); + settings.beginGroup(name); + + view->setImageShown(settings.value("image_shown", view->isImageShown()).toBool()); + view->setImageDepthShown(settings.value("depth_shown", view->isImageDepthShown()).toBool()); + view->setFeaturesShown(settings.value("features_shown", view->isFeaturesShown()).toBool()); + view->setLinesShown(settings.value("lines_shown", view->isLinesShown()).toBool()); + + settings.endGroup(); //"name" + settings.endGroup(); // Gui +} + void PreferencesDialog::saveCustomConfig(const QString & section, const QString & key, const QString & value) { QSettings settings(getIniFilePath(), QSettings::IniFormat);