diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index fff3cd5297ca5092b45d1a1de881a2a86339df36..90a43fb001a9438fa064513eee648576685630af 100755 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -635,7 +635,7 @@ bool MainWindow::addPedestrianGroup(int groupID,QString fileName) Debug::Messages("Enter MainWindow::addPedestrianGroup with filename <%s>", fileName.toStdString().c_str()); statusBar()->showMessage(tr("Select a file")); - if(fileName.isEmpty()) + if(fileName.isEmpty()) fileName = QFileDialog::getOpenFileName(this, "Select the file containing the data to visualize", QDir::currentPath(), @@ -670,6 +670,38 @@ bool MainWindow::addPedestrianGroup(int groupID,QString fileName) Debug::Messages("MainWindow::addPedestrianGroup: geometry name: <%s>", geometry_file.toStdString().c_str()); + if(geometry_file.isEmpty()) + { + auto fileDir = fileInfo.path(); + if(fileName.endsWith(".txt",Qt::CaseInsensitive)) + { + int res = QMessageBox::warning(this, "Did not find geometry name in TXT file", + "Warning: Did not find geometry name in TXT file\nOpen geometry file?" + , QMessageBox::Yes + | QMessageBox::No, QMessageBox::Yes); + if (res == QMessageBox::No) { + exit(EXIT_FAILURE); + //return false; + } + geometry_file = QFileDialog::getOpenFileName(this, + "Select a geometry file", + fileDir, + "Geometry (*.xml)"); + Debug::Messages("Got geometry file: <%s>", geometry_file.toStdString().c_str()); + QFileInfo check_file(geometry_file); + if( !(check_file.exists() && check_file.isFile()) ) + { + Debug::Error("Geomery file does not exist."); + exit(EXIT_FAILURE); + } + geometry_file = check_file.fileName(); + } + // @todo: check xml file too, although probably xml files + // always have a geometry tag + + } + std::cout << "---> geometry " << geometry_file.toStdString().c_str() << "\n" ; + // if xml is detected, just load and show the geometry then exit if(geometry_file.endsWith(".xml",Qt::CaseInsensitive)) { @@ -690,7 +722,9 @@ bool MainWindow::addPedestrianGroup(int groupID,QString fileName) if (res == QMessageBox::No) { return false; } - SaxParser::parseGeometryXMLV04(wd+"/"+geometry_file,geometry); + SaxParser::parseGeometryXMLV04(wd+"/"+geometry_file,geometry);//@todo: + //use + //qt sep } else { //everything was fine. Delete the log file //std::cout << "won't delete logfile\n"; diff --git a/src/SaxParser.cpp b/src/SaxParser.cpp index cd0f3acda1053380f90a3a39a10b45812ddd02ee..1cd0f61c17cfb0b2aad4a309c0d5de4f766489c7 100644 --- a/src/SaxParser.cpp +++ b/src/SaxParser.cpp @@ -1125,7 +1125,11 @@ QString SaxParser::extractGeometryFilenameTXT(QString &filename) }// while } // if open if(extracted_geo_name=="") - Debug::Warning("Could not extracted geometry file!"); + { + Debug::Warning("Could not extract geometry file!"); +// extracted_geo_name = "geo.xml"; + } + else Debug::Messages("Extracted geometry from TXT file <%s>", extracted_geo_name.toStdString().c_str()); return extracted_geo_name; diff --git a/src/geometry/Building.cpp b/src/geometry/Building.cpp index 2abf8e7059f71cb5ef9832d7c97164f524474113..a5a00f2db0d83cfb4d9ca362a5364a2aa7e035f8 100644 --- a/src/geometry/Building.cpp +++ b/src/geometry/Building.cpp @@ -380,7 +380,7 @@ bool Building::LoadGeometry(const std::string &geometryfile) TiXmlDocument docGeo(geoFilenameWithPath); if (!docGeo.LoadFile()) { Debug::Messages("%s", docGeo.ErrorDesc()); - Debug::Error("LoadGeometry: could not parse the geometry file"); + Debug::Error("LoadGeometry: could not parse the geometry file %s", geoFilenameWithPath.c_str()); return false; }