CloudViewer: fixed save/load background color

This commit is contained in:
Mathieu Labbe
2015-03-17 15:11:05 -04:00
parent 63f438876c
commit 6979c0d4b8
5 changed files with 33 additions and 12 deletions

View File

@@ -91,7 +91,7 @@ private slots:
}
else
{
cloudViewer_->setBackgroundColor(Qt::black);
cloudViewer_->setBackgroundColor(cloudViewer_->getDefaultBackgroundColor());
}
if(!pose.isNull())
{

View File

@@ -156,6 +156,7 @@ public:
bool getCloudVisibility(const std::string & id);
const QMap<std::string, Transform> & getAddedClouds() const {return _addedClouds;} //including meshes
const QColor & getDefaultBackgroundColor() const;
const QColor & getBackgroundColor() const;
Transform getTargetPose() const;
void getCameraPosition(
@@ -184,6 +185,7 @@ public:
void setWorkingDirectory(const QString & path) {_workingDirectory = path;}
public slots:
void setDefaultBackgroundColor(const QColor & color);
void setBackgroundColor(const QColor & color);
void setCloudVisibility(const std::string & id, bool isVisible);
void setCloudOpacity(const std::string & id, double opacity = 1.0);
@@ -232,7 +234,8 @@ private:
std::list<std::string> _gridLines;
QSet<Qt::Key> _keysPressed;
QString _workingDirectory;
QColor _backgroundColor;
QColor _defaultBgColor;
QColor _currentBgColor;
};
} /* namespace rtabmap */

View File

@@ -76,7 +76,8 @@ CloudViewer::CloudViewer(QWidget *parent) :
_gridCellCount(50),
_gridCellSize(1),
_workingDirectory("."),
_backgroundColor(Qt::black)
_defaultBgColor(Qt::black),
_currentBgColor(Qt::black)
{
this->setMinimumSize(200, 200);
@@ -202,7 +203,7 @@ void CloudViewer::saveSettings(QSettings & settings, const QString & group) cons
settings.setValue("camera_free", this->isCameraFree());
settings.setValue("camera_lockZ", this->isCameraLockZ());
settings.setValue("bg_color", this->getBackgroundColor());
settings.setValue("bg_color", this->getDefaultBackgroundColor());
if(!group.isEmpty())
{
settings.endGroup();
@@ -239,7 +240,7 @@ void CloudViewer::loadSettings(QSettings & settings, const QString & group)
}
this->setCameraLockZ(settings.value("camera_lockZ", this->isCameraLockZ()).toBool());
this->setBackgroundColor(settings.value("bg_color", this->getBackgroundColor()).value<QColor>());
this->setDefaultBackgroundColor(settings.value("bg_color", this->getDefaultBackgroundColor()).value<QColor>());
if(!group.isEmpty())
{
settings.endGroup();
@@ -776,14 +777,28 @@ void CloudViewer::updateCameraTargetPosition(const Transform & pose)
_lastPose = pose;
}
const QColor & CloudViewer::getDefaultBackgroundColor() const
{
return _defaultBgColor;
}
void CloudViewer::setDefaultBackgroundColor(const QColor & color)
{
if(_currentBgColor == _defaultBgColor)
{
setBackgroundColor(color);
}
_defaultBgColor = color;
}
const QColor & CloudViewer::getBackgroundColor() const
{
return _backgroundColor;
return _currentBgColor;
}
void CloudViewer::setBackgroundColor(const QColor & color)
{
_backgroundColor = color;
_currentBgColor = color;
_visualizer->setBackgroundColor(color.redF(), color.greenF(), color.blueF());
}
@@ -1237,9 +1252,12 @@ void CloudViewer::handleAction(QAction * a)
}
else if(a == _aSetBackgroundColor)
{
QColor color = this->getBackgroundColor();
QColor color = this->getDefaultBackgroundColor();
color = QColorDialog::getColor(color, this);
this->setBackgroundColor(color);
if(color.isValid())
{
this->setDefaultBackgroundColor(color);
}
}
else if(a == _aLockViewZ)
{

View File

@@ -687,7 +687,7 @@ void MainWindow::processOdometry(const rtabmap::SensorData & data, const rtabmap
{
UDEBUG("odom ok");
lostStateChanged = _ui->widget_cloudViewer->getBackgroundColor() == Qt::darkRed;
_ui->widget_cloudViewer->setBackgroundColor(Qt::black);
_ui->widget_cloudViewer->setBackgroundColor(_ui->widget_cloudViewer->getDefaultBackgroundColor());
_ui->imageView_odometry->setBackgroundBrush(QBrush(Qt::black));
}
if(info.inliers >= 0)
@@ -3713,7 +3713,7 @@ void MainWindow::clearTheCache()
_projectionLocalMaps.clear();
_ui->widget_cloudViewer->removeAllClouds();
_ui->widget_cloudViewer->removeAllGraphs();
_ui->widget_cloudViewer->setBackgroundColor(Qt::black);
_ui->widget_cloudViewer->setBackgroundColor(_ui->widget_cloudViewer->getDefaultBackgroundColor());
_ui->widget_cloudViewer->clearTrajectory();
_ui->widget_mapVisibility->clear();
_currentPosesMap.clear();

View File

@@ -155,7 +155,7 @@ void OdometryViewer::processData()
}
else
{
this->setBackgroundColor(Qt::black);
this->setBackgroundColor(this->getDefaultBackgroundColor());
}
}
else