Removed trailing separator from working directory. Replaced all slashes by QDir::separator().

git-svn-id: http://rtabmap.googlecode.com/svn/trunk/rtabmap@1935 f169173b-cf89-36c8-b27e-44dbe73f0c83
This commit is contained in:
matlabbe
2014-10-28 05:00:10 +00:00
parent 850c277dac
commit 9ffd103e69
5 changed files with 27 additions and 35 deletions
-2
View File
@@ -60,8 +60,6 @@ std::string Parameters::getDefaultWorkingDirectory()
{ {
UFATAL("Can't get the HOME variable environment!"); UFATAL("Can't get the HOME variable environment!");
} }
path += UDirectory::separator(); // add trailing separator
return path; return path;
} }
+10 -15
View File
@@ -115,7 +115,7 @@ Rtabmap::Rtabmap() :
_memory(0), _memory(0),
_foutFloat(0), _foutFloat(0),
_foutInt(0), _foutInt(0),
_wDir(std::string(".")+UDirectory::separator()), _wDir("."),
_mapCorrection(Transform::getIdentity()), _mapCorrection(Transform::getIdentity()),
_mapTransform(Transform::getIdentity()) _mapTransform(Transform::getIdentity())
{ {
@@ -158,15 +158,15 @@ void Rtabmap::setupLogFiles(bool overwrite)
attributes = "w"; attributes = "w";
} }
bool addLogFHeader = overwrite || !UFile::exists(_wDir+LOG_F); bool addLogFHeader = overwrite || !UFile::exists(_wDir+"/"+LOG_F);
bool addLogIHeader = overwrite || !UFile::exists(_wDir+LOG_I); bool addLogIHeader = overwrite || !UFile::exists(_wDir+"/"+LOG_I);
#ifdef _MSC_VER #ifdef _MSC_VER
fopen_s(&_foutFloat, (_wDir+LOG_F).c_str(), attributes.c_str()); fopen_s(&_foutFloat, (_wDir+"/"+LOG_F).c_str(), attributes.c_str());
fopen_s(&_foutInt, (_wDir+LOG_I).c_str(), attributes.c_str()); fopen_s(&_foutInt, (_wDir+"/"+LOG_I).c_str(), attributes.c_str());
#else #else
_foutFloat = fopen((_wDir+LOG_F).c_str(), attributes.c_str()); _foutFloat = fopen((_wDir+"/"+LOG_F).c_str(), attributes.c_str());
_foutInt = fopen((_wDir+LOG_I).c_str(), attributes.c_str()); _foutInt = fopen((_wDir+"/"+LOG_I).c_str(), attributes.c_str());
#endif #endif
// add header (column identification) // add header (column identification)
if(_statisticLoggedHeaders && addLogFHeader && _foutFloat) if(_statisticLoggedHeaders && addLogFHeader && _foutFloat)
@@ -215,8 +215,8 @@ void Rtabmap::setupLogFiles(bool overwrite)
fprintf(_foutInt, " 17-Is last location merged through Weight Update?\n"); fprintf(_foutInt, " 17-Is last location merged through Weight Update?\n");
} }
ULOGGER_DEBUG("Log file (int)=%s", (_wDir+LOG_I).c_str()); ULOGGER_DEBUG("Log file (int)=%s", (_wDir+"/"+LOG_I).c_str());
ULOGGER_DEBUG("Log file (float)=%s", (_wDir+LOG_F).c_str()); ULOGGER_DEBUG("Log file (float)=%s", (_wDir+"/"+LOG_F).c_str());
} }
else else
{ {
@@ -257,7 +257,7 @@ void Rtabmap::init(const ParametersMap & parameters, const std::string & databas
_databasePath = databasePath; _databasePath = databasePath;
if(_databasePath.empty()) if(_databasePath.empty())
{ {
_databasePath = _wDir + Parameters::getDefaultDatabaseName(); _databasePath = _wDir + "/" + Parameters::getDefaultDatabaseName();
} }
UINFO("Using database \"%s\".", _databasePath.c_str()); UINFO("Using database \"%s\".", _databasePath.c_str());
this->parseParameters(parameters); this->parseParameters(parameters);
@@ -1775,11 +1775,6 @@ void Rtabmap::setTimeThreshold(float maxTimeAllowed)
void Rtabmap::setWorkingDirectory(std::string path) void Rtabmap::setWorkingDirectory(std::string path)
{ {
if(path.size() && (path.at(path.size()-1) != '\\' || path.at(path.size()-1) != '/' ))
{
path += UDirectory::separator();
}
if(!path.empty() && UDirectory::exists(path)) if(!path.empty() && UDirectory::exists(path))
{ {
ULOGGER_DEBUG("Comparing new working directory path \"%s\" with \"%s\"", path.c_str(), _wDir.c_str()); ULOGGER_DEBUG("Comparing new working directory path \"%s\" with \"%s\"", path.c_str(), _wDir.c_str());
+1 -1
View File
@@ -97,7 +97,7 @@ int main(int argc, char * argv[])
// Appearance-based only, disable RGB-D mode // Appearance-based only, disable RGB-D mode
parameters.insert(rtabmap::ParametersPair(rtabmap::Parameters::kRGBDEnabled(), "false")); parameters.insert(rtabmap::ParametersPair(rtabmap::Parameters::kRGBDEnabled(), "false"));
std::string databasePath = rtabmap::Parameters::defaultRtabmapWorkingDirectory()+rtabmap::Parameters::getDefaultDatabaseName(); std::string databasePath = rtabmap::Parameters::defaultRtabmapWorkingDirectory()+"/"+rtabmap::Parameters::getDefaultDatabaseName();
if(localizationMode) if(localizationMode)
{ {
parameters.insert(rtabmap::ParametersPair(rtabmap::Parameters::kMemIncrementalMemory(), "false")); parameters.insert(rtabmap::ParametersPair(rtabmap::Parameters::kMemIncrementalMemory(), "false"));
+15 -16
View File
@@ -1441,10 +1441,10 @@ void MainWindow::processRtabmapEventInit(int status, const QString & info)
else if((RtabmapEventInit::Status)status == RtabmapEventInit::kClosed) else if((RtabmapEventInit::Status)status == RtabmapEventInit::kClosed)
{ {
_initProgressDialog->setValue(_initProgressDialog->maximumSteps()); _initProgressDialog->setValue(_initProgressDialog->maximumSteps());
if(_openedDatabasePath.compare(_preferencesDialog->getWorkingDirectory()+"/"+Parameters::getDefaultDatabaseName().c_str()) == 0) if(_openedDatabasePath.compare(_preferencesDialog->getWorkingDirectory()+QDir::separator()+Parameters::getDefaultDatabaseName().c_str()) == 0)
{ {
// Temp database used, automatically backup with unique name (timestamp) // Temp database used, automatically backup with unique name (timestamp)
QString newName = _preferencesDialog->getWorkingDirectory()+(QString("/rtabmap_%1.db").arg(QDateTime::currentDateTime().toString("yyMMddhhmmss"))); QString newName = _preferencesDialog->getWorkingDirectory()+QDir::separator()+(QString("rtabmap_%1.db").arg(QDateTime::currentDateTime().toString("yyMMdd-hhmmsszzz")));
if(QFile::rename(_openedDatabasePath, newName)) if(QFile::rename(_openedDatabasePath, newName))
{ {
std::string msg = uFormat("Database saved to \"%s\".", newName.toStdString().c_str()); std::string msg = uFormat("Database saved to \"%s\".", newName.toStdString().c_str());
@@ -1609,7 +1609,7 @@ void MainWindow::applyPrefSettings(PreferencesDialog::PANEL_FLAGS flags)
ULogger::setLevel((ULogger::Level)_preferencesDialog->getGeneralLoggerLevel()); ULogger::setLevel((ULogger::Level)_preferencesDialog->getGeneralLoggerLevel());
ULogger::setEventLevel((ULogger::Level)_preferencesDialog->getGeneralLoggerEventLevel()); ULogger::setEventLevel((ULogger::Level)_preferencesDialog->getGeneralLoggerEventLevel());
ULogger::setType((ULogger::Type)_preferencesDialog->getGeneralLoggerType(), ULogger::setType((ULogger::Type)_preferencesDialog->getGeneralLoggerType(),
((_preferencesDialog->getWorkingDirectory()+"/")+LOG_FILE_NAME).toStdString(), true); (_preferencesDialog->getWorkingDirectory()+QDir::separator()+LOG_FILE_NAME).toStdString(), true);
ULogger::setPrintTime(_preferencesDialog->getGeneralLoggerPrintTime()); ULogger::setPrintTime(_preferencesDialog->getGeneralLoggerPrintTime());
} }
} }
@@ -1895,19 +1895,19 @@ void MainWindow::changeMappingMode()
void MainWindow::captureScreen() void MainWindow::captureScreen()
{ {
QString targetDir = _preferencesDialog->getWorkingDirectory() + "/ScreensCaptured"; QString targetDir = _preferencesDialog->getWorkingDirectory() + QDir::separator() + "ScreensCaptured";
QDir dir; QDir dir;
if(!dir.exists(targetDir)) if(!dir.exists(targetDir))
{ {
dir.mkdir(targetDir); dir.mkdir(targetDir);
} }
targetDir += "/"; targetDir += QDir::separator();
targetDir += "Main_window"; targetDir += "Main_window";
if(!dir.exists(targetDir)) if(!dir.exists(targetDir))
{ {
dir.mkdir(targetDir); dir.mkdir(targetDir);
} }
targetDir += "/"; targetDir += QDir::separator();
QString name = (QDateTime::currentDateTime().toString("yyMMddhhmmsszzz") + ".png"); QString name = (QDateTime::currentDateTime().toString("yyMMddhhmmsszzz") + ".png");
_ui->statusbar->clearMessage(); _ui->statusbar->clearMessage();
QPixmap figure = QPixmap::grabWidget(this); QPixmap figure = QPixmap::grabWidget(this);
@@ -1933,7 +1933,7 @@ void MainWindow::newDatabase()
_openedDatabasePath.clear(); _openedDatabasePath.clear();
ULOGGER_DEBUG(""); ULOGGER_DEBUG("");
this->clearTheCache(); this->clearTheCache();
std::string databasePath = _preferencesDialog->getWorkingDirectory().toStdString()+"/"+Parameters::getDefaultDatabaseName(); std::string databasePath = (_preferencesDialog->getWorkingDirectory()+QDir::separator()+Parameters::getDefaultDatabaseName().c_str()).toStdString();
if(QFile::exists(databasePath.c_str())) if(QFile::exists(databasePath.c_str()))
{ {
if(QFile::remove(databasePath.c_str())) if(QFile::remove(databasePath.c_str()))
@@ -2421,7 +2421,7 @@ void MainWindow::generateMap()
{ {
if(_graphSavingFileName.isEmpty()) if(_graphSavingFileName.isEmpty())
{ {
_graphSavingFileName = _preferencesDialog->getWorkingDirectory() + "/Graph.dot"; _graphSavingFileName = _preferencesDialog->getWorkingDirectory() + QDir::separator() + "Graph.dot";
} }
QString path = QFileDialog::getSaveFileName(this, tr("Save File"), _graphSavingFileName, tr("Graphiz file (*.dot)")); QString path = QFileDialog::getSaveFileName(this, tr("Save File"), _graphSavingFileName, tr("Graphiz file (*.dot)"));
if(!path.isEmpty()) if(!path.isEmpty())
@@ -2438,7 +2438,7 @@ void MainWindow::generateLocalMap()
{ {
if(_graphSavingFileName.isEmpty()) if(_graphSavingFileName.isEmpty())
{ {
_graphSavingFileName = _preferencesDialog->getWorkingDirectory() + "/Graph.dot"; _graphSavingFileName = _preferencesDialog->getWorkingDirectory() + QDir::separator() + "Graph.dot";
} }
bool ok = false; bool ok = false;
@@ -2480,7 +2480,7 @@ void MainWindow::generateTOROMap()
{ {
if(_toroSavingFileName.isEmpty()) if(_toroSavingFileName.isEmpty())
{ {
_toroSavingFileName = _preferencesDialog->getWorkingDirectory() + "/toro.graph"; _toroSavingFileName = _preferencesDialog->getWorkingDirectory() + QDir::separator() + "toro.graph";
} }
QStringList items; QStringList items;
@@ -2596,10 +2596,9 @@ void MainWindow::openWorkingDirectory()
void MainWindow::updateEditMenu() void MainWindow::updateEditMenu()
{ {
// Update Memory delete database size // Update Memory delete database size
if(_state != kMonitoring && _state != kMonitoringPaused) if(_state != kMonitoring && _state != kMonitoringPaused && !_openedDatabasePath.isEmpty())
{ {
QString dbPath = _preferencesDialog->getWorkingDirectory() + "/rtabmap.db"; _ui->actionDelete_memory->setText(tr("Delete memory (%1 MB)").arg(UFile::length(_openedDatabasePath.toStdString())/1000000));
_ui->actionDelete_memory->setText(tr("Delete memory (%1 MB)").arg(UFile::length(dbPath.toStdString())/1000000));
} }
} }
@@ -3442,7 +3441,7 @@ void MainWindow::saveClouds(const std::map<int, pcl::PointCloud<pcl::PointXYZRGB
{ {
if(clouds.size() == 1) if(clouds.size() == 1)
{ {
QString path = QFileDialog::getSaveFileName(this, tr("Save to ..."), _preferencesDialog->getWorkingDirectory()+"/cloud.ply", tr("Point cloud data (*.ply *.pcd)")); QString path = QFileDialog::getSaveFileName(this, tr("Save to ..."), _preferencesDialog->getWorkingDirectory()+QDir::separator()+"cloud.ply", tr("Point cloud data (*.ply *.pcd)"));
if(!path.isEmpty()) if(!path.isEmpty())
{ {
if(clouds.begin()->second->size()) if(clouds.begin()->second->size())
@@ -3550,7 +3549,7 @@ void MainWindow::saveMeshes(const std::map<int, pcl::PolygonMesh::Ptr> & meshes)
{ {
if(meshes.size() == 1) if(meshes.size() == 1)
{ {
QString path = QFileDialog::getSaveFileName(this, tr("Save to ..."), _preferencesDialog->getWorkingDirectory()+"/mesh.ply", tr("Mesh (*.ply)")); QString path = QFileDialog::getSaveFileName(this, tr("Save to ..."), _preferencesDialog->getWorkingDirectory()+QDir::separator()+"mesh.ply", tr("Mesh (*.ply)"));
if(!path.isEmpty()) if(!path.isEmpty())
{ {
if(meshes.begin()->second->polygons.size()) if(meshes.begin()->second->polygons.size())
@@ -3649,7 +3648,7 @@ void MainWindow::saveScans(const std::map<int, pcl::PointCloud<pcl::PointXYZ>::P
{ {
if(scans.size() == 1) if(scans.size() == 1)
{ {
QString path = QFileDialog::getSaveFileName(this, tr("Save to ..."), _preferencesDialog->getWorkingDirectory()+"/scan.ply", tr("Point cloud data (*.ply *.pcd)")); QString path = QFileDialog::getSaveFileName(this, tr("Save to ..."), _preferencesDialog->getWorkingDirectory()+QDir::separator()+"scan.ply", tr("Point cloud data (*.ply *.pcd)"));
if(!path.isEmpty()) if(!path.isEmpty())
{ {
if(scans.begin()->second->size()) if(scans.begin()->second->size())
+1 -1
View File
@@ -1191,7 +1191,7 @@ bool PreferencesDialog::readCoreSettings(const QString & filePath)
bool PreferencesDialog::saveConfigTo() bool PreferencesDialog::saveConfigTo()
{ {
QString path = QFileDialog::getSaveFileName(this, tr("Save settings..."), this->getWorkingDirectory()+"/config.ini", "*.ini"); QString path = QFileDialog::getSaveFileName(this, tr("Save settings..."), this->getWorkingDirectory()+QDir::separator()+"config.ini", "*.ini");
if(!path.isEmpty()) if(!path.isEmpty())
{ {
this->writeSettings(path); this->writeSettings(path);