diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a5a6247ad964cd51aaf498a3adf0e37ba6e4ad2..71f64da1c0f39bf93c36819afc02915b82a2fc17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,10 +18,59 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}") set(CMAKE_COLOR_MAKEFILE ON) set(JPSVIS_MAJOR_VERSION 0) set(JPSVIS_MINOR_VERSION 8) -set(JPSVIS_PATCH_VERSION 1) +set(JPSVIS_PATCH_VERSION 3) set(JPSVIS_VERSION ${JPSVIS_MAJOR_VERSION}.${JPSVIS_MINOR_VERSION}.${JPSVIS_PATCH_VERSION}) +find_package(Git REQUIRED) # no need for this msg. It comes from cmake.findgit() + +find_program(GIT_SCM git DOC "Git version control") +mark_as_advanced(GIT_SCM) +find_file(GITDIR NAMES .git PATHS ${CMAKE_SOURCE_DIR} NO_DEFAULT_PATH) +if (GIT_SCM AND GITDIR) + +# the commit's SHA1, and whether the building workspace was dirty or not +# describe --match=NeVeRmAtCh --always --tags --abbrev=40 --dirty +execute_process(COMMAND + "${GIT_EXECUTABLE}" --no-pager describe --tags --always --dirty + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + OUTPUT_VARIABLE GIT_SHA1 + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + +# branch +execute_process( + COMMAND "${GIT_EXECUTABLE}" rev-parse --abbrev-ref HEAD + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + OUTPUT_VARIABLE GIT_BRANCH + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +# the date of the commit +execute_process(COMMAND + "${GIT_EXECUTABLE}" log -1 --format=%ad --date=local + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + OUTPUT_VARIABLE GIT_DATE + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + +# the subject of the commit +execute_process(COMMAND + "${GIT_EXECUTABLE}" log -1 --format=%s + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + OUTPUT_VARIABLE GIT_COMMIT_SUBJECT + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + + + +add_definitions("-DGIT_COMMIT_HASH=\"${GIT_SHA1}\"") +add_definitions("-DGIT_COMMIT_DATE=\"${GIT_DATE}\"") +add_definitions("-DGIT_COMMIT_SUBJECT=\"${GIT_COMMIT_SUBJECT}\"") +add_definitions("-DGIT_BRANCH=\"${GIT_BRANCH}\"") +add_definitions("-DJPSVIS_VERSION=\"${JPSVIS_VERSION}\"") +else() + message(STATUS "Not in a git repo") +endif() + + # set(CMAKE_PREFIX_PATH "/usr/local/opt/qt5") # if qt is in a non-standard location, uncomment this #------------------ set important directories -------------------- set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin") @@ -35,15 +84,15 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(README_FILE "${CMAKE_SOURCE_DIR}/README.md") if(APPLE AND CMAKE_INSTALL_PREFIX MATCHES "/usr/local") - set(CMAKE_INSTALL_PREFIX ${EXECUTABLE_OUTPUT_PATH}) #"/Applications") + set(CMAKE_INSTALL_PREFIX ${EXECUTABLE_OUTPUT_PATH}) #"/Applications") endif() # these files compile need Cocoa (evtl. Mac specific) SET(MAC_FIX_SRC src/fix/osx_thread_fix.mm) #.mm SET(MAC_FIX_HDR src/fix/osx_thread_fix.h) #.h set( SRCS - src/geometry/Building.cpp - src/geometry/Crossing.cpp + src/geometry/Building.cpp + src/geometry/Crossing.cpp src/geometry/Goal.cpp src/geometry/Hline.cpp src/geometry/Line.cpp @@ -85,7 +134,7 @@ set( SRCS src/MainWindow.cpp src/TrailPlotter.cpp forms/jpsvis.rc - ) + ) # all header files that should be treated with moc set( HDR src/geometry/Building.h @@ -130,7 +179,7 @@ set( HDR src/network/TraVisToServer.h src/MainWindow.h src/TrailPlotter.h - ) + ) IF(APPLE) SET(SRCS ${SRCS} ${MAC_FIX_SRC}) SET(HDR ${HDR} ${MAC_FIX_HDR}) @@ -141,7 +190,7 @@ ENDIF(APPLE) # *.ui files set( UIS forms/settings.ui - forms/mainwindow.ui + forms/mainwindow.ui ) # and finally a resource file @@ -165,7 +214,7 @@ set(CMAKE_AUTOMOC ON) # This sets the windows build that will need the special winmain@16 call. Qt provides # this for us in the qtmain.lib file. Using this cmake code will ensure we have it -# linked into our build. Not needed on Unix/OS X/Linux which is why we have the +# linked into our build. Not needed on Unix/OS X/Linux which is why we have the # IF(WIN32) conditional. IF (WIN32) SET (QT_USE_QTMAIN TRUE) @@ -232,12 +281,12 @@ if(${QT4_INSTALLED}) ADD_EXECUTABLE( jpsvis MACOSX_BUNDLE WIN32 ${SRCS} ${MOC_HDRS} - ${UI_HDRS} + ${UI_HDRS} ${RCS} ) TARGET_LINK_LIBRARIES( jpsvis ${QT_LIBRARIES}) elseif( ${QT5_INSTALLED}) - message(MESSAGE "libs: ${Qt5Widgets_LIBRARIES} ${QT_LIBRARIES}") + message(STATUS "qt libs: ${Qt5Widgets_LIBRARIES} ${QT_LIBRARIES}") # http://www.kdab.com/using-cmake-with-qt-5/ set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}" ) qt5_wrap_ui( UI_HDRS ${UIS} ) @@ -246,7 +295,7 @@ elseif( ${QT5_INSTALLED}) ADD_EXECUTABLE( jpsvis MACOSX_BUNDLE WIN32 ${SRCS} ${MOC_HDRS} - ${UI_HDRS} + ${UI_HDRS} ${RCS} ) qt5_use_modules(jpsvis Widgets) @@ -259,7 +308,7 @@ endif() IF(APPLE) # set how it shows up in the Info.plist file - SET(MACOSX_BUNDLE_ICON_FILE JPSvis.icns) + SET(MACOSX_BUNDLE_ICON_FILE JPSvis.icns) # set where in the bundle to put the icns file SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/forms/icons/JPSvis.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources) # include the icns file in the target @@ -268,7 +317,7 @@ ENDIF(APPLE) # last thing we have to do is to tell CMake what libraries our executable needs, # luckily FIND_PACKAGE prepared QT_LIBRARIES variable for us: -set(VTK_USE_GUISUPPORT ON) +set(VTK_USE_GUISUPPORT ON) set(VTK_USE_QT ON) # QVTK is for VTK 5.x. For VTK 6, use ${VTK_LIBRARIES} instead @@ -281,13 +330,13 @@ endif() if(VTK_LIBRARIES) if(${VTK_VERSION} VERSION_LESS "6") TARGET_LINK_LIBRARIES( jpsvis ${QTLIBS} QVTK) #qt5 - else() + else() # TARGET_LINK_LIBRARIES( jpsvis ${VTK_LIBRARIES} ${QT_LIBRARIES}) - TARGET_LINK_LIBRARIES( jpsvis ${VTK_LIBRARIES} ${QTLIBS}) #qt5 + TARGET_LINK_LIBRARIES( jpsvis ${VTK_LIBRARIES} ${QTLIBS}) #qt5 endif() else() # this else is not yet tested target_link_libraries(jpsvis vtkHybrid QVTK vtkViews ${QTLIBS}) -endif() +endif() # ================================ Compiler flags # enable as many warnings as possible set(warning_flags "-Wall -Wextra") @@ -317,12 +366,12 @@ message(STATUS "Checking for C++11 compiler ................... yes") endif(NOT MSVC) #--------------------- if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - message(STATUS "Using compiler ................................ Clang (${CMAKE_CXX_COMPILER_VERSION})") + set(USED_COMPILER "Clang (${CMAKE_CXX_COMPILER_VERSION})") endif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") if(CMAKE_COMPILER_IS_GNUCXX) - message( STATUS "Using compiler ................................ g++ (${CMAKE_CXX_COMPILER_VERSION}") + set(USED_COMPILER "g++ (${CMAKE_CXX_COMPILER_VERSION})") endif(CMAKE_COMPILER_IS_GNUCXX) - + message( STATUS "Using compiler ................................ ${USED_COMPILER}") if(CMAKE_BUILD_TYPE MATCHES Debug) set(CMAKE_CXX_LDFLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage") message(STATUS "Debug flags: " ${CMAKE_CXX_FLAGS} " " ${CMAKE_CXX_FLAGS_DEBUG} ) @@ -340,14 +389,14 @@ SET(APPS "\${CMAKE_INSTALL_PREFIX}/bin/jpsvis") IF(APPLE) SET(plugin_dest_dir ${CMAKE_INSTALL_PREFIX}/jpsvis.app/Contents/MacOS) SET(qtconf_dest_dir ${CMAKE_INSTALL_PREFIX}/jpsvis.app/Contents/Resources) - SET(APPS "\${CMAKE_INSTALL_PREFIX}/jpsvis.app") + SET(APPS "\${CMAKE_INSTALL_PREFIX}/jpsvis.app") ENDIF(APPLE) IF(WIN32) SET(APPS "\${CMAKE_INSTALL_PREFIX}/bin/jpsvis.exe") ENDIF(WIN32) - +add_definitions("-DUSED_COMPILER=\"${USED_COMPILER}\"") #-------------------------------------------------------------------------------- # Install the QtTest application, on Apple, the bundle is at the root of the # install tree, and on other platforms it'll go into the bin directory. @@ -435,7 +484,7 @@ if(APPLE) set(CPACK_SYSTEM_NAME "OSX") set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${JPSVIS_VERSION}") elseif(UNIX) - # tested with success in + # tested with success in # Linux dhcppc5 3.2.0-4-686-pae #1 SMP Debian 3.2.68-1+deb7u2 i686 GNU/Linux set(CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}") SET(CPACK_GENERATOR "DEB") @@ -457,7 +506,7 @@ if(APPLE) SET(CPACK_DEBIAN_PACKAGE_SECTION "science") SET(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR}) - + endif() include(CPack) @@ -494,5 +543,3 @@ endif() # COMMAND ruby ${PROJECT_SOURCE_DIR}/ruby/fixup/fixup.rb ${CMAKE_INSTALL_PREFIX}/${EXECUTABLE} # COMMENT "Fixing up the app bundle") # ENDIF(APPLE) - - diff --git a/src/Debug.cpp b/src/Debug.cpp index 9cd6e8322b0d12581eff0b3bfcfb7ef29270ccee..97a4acdd41753a7598c72e25bfead8003fe28a09 100644 --- a/src/Debug.cpp +++ b/src/Debug.cpp @@ -68,8 +68,33 @@ void Debug::setDebugLevel(Debug::LEVEL level) debugLevel=level; } +void Debug::Info(const char *format, ...) +{ + switch (debugLevel) { + + case ALL: + case INFO: { + MSG_Count++; + char msg[256]; + va_list ap; + va_start (ap, format); + vsprintf (msg,format ,ap); + va_end (ap); + + os <<msg<<endl; + } + break; + + case ERROR: + case WARNING: + case NONE: + break; + } + +} + void Debug::Messages(const char *format, ...) -{ +{ switch (debugLevel) { case ALL: @@ -81,7 +106,7 @@ void Debug::Messages(const char *format, ...) vsprintf (msg,format ,ap); va_end (ap); - os<<"Info ["<< std::setw(2) <<MSG_Count<<"]: "<<msg<<endl; + os<<"Info ["<< std::setw(3) <<MSG_Count<<"]: "<<msg<<endl; } break; @@ -106,7 +131,7 @@ void Debug::Warning(const char *format, ...) va_start (ap, format); vsprintf (msg,format ,ap); va_end (ap); - os<<"Warning["<<WAR_Count<<"]"<<msg<<endl; + os<<"Warning["<< std::setw(3)<<WAR_Count<<"]"<<msg<<endl; } break; @@ -132,7 +157,7 @@ void Debug::Error(const char *format, ...) va_start (ap, format); vsprintf (msg,format ,ap); va_end (ap); - os<<"Error["<<ERR_Count<<"]"<<msg<<endl; + os<<"Error["<< std::setw(3)<<ERR_Count<<"]"<<msg<<endl; } break; diff --git a/src/Debug.h b/src/Debug.h index 953e3fd1d5f1d4203d1ae37c96d1b69b79d8ed67..9a88f4b5debb63bb93efbe315936926afb221c0d 100644 --- a/src/Debug.h +++ b/src/Debug.h @@ -78,6 +78,7 @@ public: */ static void setDebugLevel(Debug::LEVEL level); + static void Info(const char *string, ...); /** * send a message (information) to the output stream * diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 3cc906eafbea11d915649fbc2cb7c9670b9df4b3..3c05ab04ca9c5b0f390dbe7f7965efba28c60988 100755 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -5,7 +5,7 @@ * Copyright (C) <2009-2010> * * @section LICENSE - * This file is part of OpenPedSim. + * This file is part of JuPedSim. * * JuPedSim is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -87,7 +87,9 @@ dispatch_queue_t main_q = dispatch_get_main_queue(); void is_main_thread() { if ( main_thread_id == std::this_thread::get_id() ) - std::cout << "This is the main thread.\n"; + { + std::cout << "This is the main thread.\n"; + } else std::cout << "This is not the main thread.\n"; } @@ -211,7 +213,7 @@ MainWindow::MainWindow(QWidget *parent) : QString argument=arguments[argCount]; if(argument.compare("help")==0) { - Debug::Messages("Usage: ./TraVisTo [file1] [-2D] [-caption] [-online [port]]"); + Debug::Messages("Usage: jpsvis [file1] [-2D] [-caption] [-online [port]]"); exit(0); } else if(argument.compare("-2D")==0) { ui.action2_D->setChecked(true); @@ -240,7 +242,7 @@ MainWindow::MainWindow(QWidget *parent) : } else if(argument.startsWith("-")) { const char* std=argument.toStdString().c_str(); Debug::Error("unknown options: %s",std); - Debug::Error("Usage: ./TraVisTo [file1] [-2D] [-caption] [-online [port] ]"); + Debug::Error("Usage: jpsvis [file1] [-2D] [-caption] [-online [port] ]"); } else if(addPedestrianGroup(group,argument)) { //slotHelpAbout(); Debug::Messages("group: %d, arg: %s", group, argument.toStdString().c_str()); @@ -630,12 +632,14 @@ void MainWindow::slotClearAllDataset() 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()) fileName = QFileDialog::getOpenFileName(this, "Select the file containing the data to visualize", - "F:\\workspace\\JPSvis\\data", - "Visualisation Files (*.dat *.trav *.xml);;All Files (*.*)"); + QDir::currentPath(), + "Geometry or trajectory files (*.xml);;All Files (*.*)"); //the action was cancelled if (fileName.isNull()) { @@ -645,6 +649,7 @@ bool MainWindow::addPedestrianGroup(int groupID,QString fileName) //get and set the working dir QFileInfo fileInfo(fileName); QString wd=fileInfo.absoluteDir().absolutePath(); + Debug::Messages("MainWindow::addPedestrianGroup: wd: <%s>", wd.toStdString().c_str()); SystemSettings::setWorkingDirectory(wd); SystemSettings::setFilenamePrefix(QFileInfo ( fileName ).baseName()+"_"); @@ -653,15 +658,14 @@ bool MainWindow::addPedestrianGroup(int groupID,QString fileName) //try to get a geometry filename QString geometry_file=SaxParser::extractGeometryFilename(fileName); - //cout<<"geometry name: "<<geometry_file.toStdString()<<endl; - + Debug::Messages("MainWindow::addPedestrianGroup: geometry name: <%s>", geometry_file.toStdString().c_str()); // if xml is detected, just load and show the geometry then exit if(geometry_file.endsWith(".xml",Qt::CaseInsensitive)) { //try to parse the correct way // fall back to this if it fails SystemSettings::CreateLogfile(); - + Debug::Messages("Calling parseGeometryJPS with <%s>", geometry_file.toStdString().c_str()); if(! SaxParser::parseGeometryJPS(geometry_file,geometry)) { int res = QMessageBox::warning(this, "Errors in Geometry. Continue Parsing?", "JuPedSim has detected an error in the supplied geometry.\n" @@ -678,7 +682,8 @@ bool MainWindow::addPedestrianGroup(int groupID,QString fileName) SaxParser::parseGeometryXMLV04(wd+"/"+geometry_file,geometry); } else { //everything was fine. Delete the log file - SystemSettings::DeleteLogfile(); + std::cout << "won't delete logfile\n"; + //SystemSettings::DeleteLogfile(); } //SaxParser::parseGeometryXMLV04(fileName,geometry); @@ -696,8 +701,9 @@ bool MainWindow::addPedestrianGroup(int groupID,QString fileName) QFile file(fileName); if (!file.open(QIODevice::ReadOnly)) { - Debug::Error("could not open the File: ",fileName.toStdString().c_str()); + Debug::Error("parseGeometryJPS: could not open the File: ",fileName.toStdString().c_str()); return false; + } SyncData* dataset=NULL; @@ -1153,7 +1159,7 @@ void MainWindow::slotUpdateFrameSlider(int newValue) void MainWindow::slotUpdateContrastSlider(int newValue) { - // extern_screen_contrast=ui.contrastSettingSlider->value(); + // extern_screen_contrast=ui.contrastSettingSlider->value(); //extern_screen_contrast=newValue; QString msg; msg.setNum(newValue); diff --git a/src/SaxParser.cpp b/src/SaxParser.cpp index 01cf46d98877cbc432cd94cdddd2be6d214d3520..9ca72c5e463d9d11de03aca1af3fb1c0e4cdfae1 100644 --- a/src/SaxParser.cpp +++ b/src/SaxParser.cpp @@ -399,7 +399,7 @@ bool SaxParser::startElement(const QString & /* namespaceURI */, for(int i=0; i<at.length(); i++) { if(at.localName(i)=="ID") { _currentFrameID=at.value(i).toInt(); - //cout<<"frame id: " <<_currentFrameID<<endl; + //cout<<"frame: " <<_currentFrameID<<endl; } } @@ -461,6 +461,8 @@ bool SaxParser::startElement(const QString & /* namespaceURI */, } } +// xml2txt +// cout << _currentFrameID << " " << id << " " << xPos << " " << yPos << " " << zPos << "\n"; //coordinates of the ellipse, default to the head of the agent //if(std::isnan(el_x)) el_x=xPos; @@ -633,16 +635,20 @@ void SaxParser::clearPoints() /// provided for convenience and will be removed in the next version bool SaxParser::parseGeometryJPS(QString fileName, GeometryFactory& geoFac) -{ +{ + Debug::Messages( "Enter SaxParser::parseGeometryJPS with filename <%s>",fileName.toStdString().c_str()); + double captionsColor=0;//red if(!fileName.endsWith(".xml",Qt::CaseInsensitive)) return false; QString wd; SystemSettings::getWorkingDirectory(wd); - fileName=wd+"/"+fileName; - + fileName=wd + "/" + fileName; //TODO: is this windows compatible? + // QString = QDir::cleanPath(wd + QDir::separator() + fileName); + Debug::Messages("filename: <%s)", fileName.toStdString().c_str()); + Debug::Messages("wd: <%s>",wd.toStdString().c_str()); + Debug::Messages("filename2: <%s>",fileName.toStdString().c_str()); Building* building = new Building(); string geometrypath = fileName.toStdString(); - // read the geometry if(!building->LoadGeometry(geometrypath)) return false; @@ -653,7 +659,7 @@ bool SaxParser::parseGeometryJPS(QString fileName, GeometryFactory& geoFac) int subroom_id = -1; for(auto&& itr_room: building->GetAllRooms()) { - room_id++; + room_id++; for(auto&& itr_subroom: itr_room.second->GetAllSubRooms()) { subroom_id++; @@ -782,7 +788,7 @@ bool SaxParser::parseGeometryJPS(QString fileName, GeometryFactory& geoFac) Point p2 = tr->GetPoint2(); double z1 = 0; double z2 = 0; - + if(tr->GetSubRoom1()) // get elevation for both points { z2 = tr->GetSubRoom1()->GetElevation(p2); @@ -795,14 +801,14 @@ bool SaxParser::parseGeometryJPS(QString fileName, GeometryFactory& geoFac) } else std::cout << "ERROR: Can not calculate elevations for transition " << tr->GetID() << ", " << tr->GetCaption() << ". Both subrooms are not defined \n"; - + geometry->addDoor(p1._x*FAKTOR, p1._y*FAKTOR, z1*FAKTOR, p2._x*FAKTOR, p2._y*FAKTOR,z2*FAKTOR); const Point& p =tr->GetCentre(); double pos[3]= {p._x*FAKTOR,p._y*FAKTOR,z1*FAKTOR}; geometry->addObjectLabel(pos,pos,"door_"+QString::number(tr->GetID()).toStdString()+ +"_"+ QString::number(tr->GetUniqueID()).toStdString(),captionsColor); - } + } geoFac.AddElement(room_id,subroom_id,geometry); } @@ -1071,7 +1077,7 @@ void SaxParser::parseGeometryXMLV04(QString filename, GeometryFactory& geoFac) //cout<<"The file is too large: "<<filename.toStdString()<<endl; return; } - + auto geo= shared_ptr<FacilityGeometry>(new FacilityGeometry("no name", "no name", "no name")); //cout<<"filename: "<<filename.toStdString()<<endl; diff --git a/src/geometry/Building.cpp b/src/geometry/Building.cpp index cfab99162cb53666c830085a22233e4d8a484e89..1305cd44be0641ad36e0c4b959e3e0d56db78c2a 100644 --- a/src/geometry/Building.cpp +++ b/src/geometry/Building.cpp @@ -30,6 +30,7 @@ #include "../geometry/SubRoom.h" #include "../geometry/Room.h" #include "../tinyxml/tinyxml.h" +#include "../Debug.h" #ifdef _SIMULATOR #include "../pedestrian/Pedestrian.h" @@ -351,57 +352,63 @@ bool Building::LoadGeometry(const std::string &geometryfile) { //get the geometry filename from the project file string geoFilenameWithPath= _projectRootDir + geometryfile; - + Debug::Messages("LoadGeometry: Root Dir: <%s>", _projectRootDir.c_str()); + Debug::Messages("LoadGeometry: geometryfile: <%s>", geometryfile.c_str()); + Debug::Messages("LoadGeometry: geoFilenameWithPath: <%s>", geoFilenameWithPath.c_str()); if(geometryfile=="") { TiXmlDocument doc(_projectFilename); if (!doc.LoadFile()) { - Log->Write("ERROR: \t%s", doc.ErrorDesc()); - Log->Write("\t could not parse the project file"); + Debug::Error("%s", doc.ErrorDesc()); + Debug::Error("LoadGeometry: could not parse the project file"); return false; } - Log->Write("INFO: \tParsing the geometry file"); + Debug::Messages("Parsing the geometry file"); TiXmlElement* xMainNode = doc.RootElement(); if(xMainNode->FirstChild("geometry")) { - _geometryFilename=xMainNode->FirstChild("geometry")->FirstChild()->Value(); - geoFilenameWithPath=_projectRootDir+_geometryFilename; - Log->Write("INFO: \tgeometry <"+_geometryFilename+">"); + std::cout <<"geometry file found.\n"; + _geometryFilename=xMainNode->FirstChild("geometry")->FirstChild()->Value(); + geoFilenameWithPath=_projectRootDir+_geometryFilename; + Debug::Messages("LoadGeometry: Root Dir: <%s>", _projectRootDir.c_str()); + Debug::Messages("LoadGeometry: geometryfile: <%s>", geometryfile.c_str()); + Debug::Messages("LoadGeometry: geoFilenameWithPath: <%s>", geoFilenameWithPath.c_str()); + Debug::Messages("INFO: \tgeometry <%s>", _geometryFilename.c_str()); } } TiXmlDocument docGeo(geoFilenameWithPath); if (!docGeo.LoadFile()) { - Log->Write("ERROR: \t%s", docGeo.ErrorDesc()); - Log->Write("\t could not parse the geometry file"); + Debug::Messages("%s", docGeo.ErrorDesc()); + Debug::Error("LoadGeometry: could not parse the geometry file"); return false; } TiXmlElement* xRootNode = docGeo.RootElement(); if( ! xRootNode ) { - Log->Write("ERROR:\tRoot element does not exist"); + Debug::Error("Root element does not exist"); return false; } if( xRootNode->ValueStr () != "geometry" ) { - Log->Write("ERROR:\tRoot element value is not 'geometry'."); + Debug::Error("Root element value is not 'geometry'."); return false; } if(xRootNode->Attribute("unit")) if(string(xRootNode->Attribute("unit")) != "m") { - Log->Write("ERROR:\tOnly the unit m (meters) is supported. \n\tYou supplied [%s]",xRootNode->Attribute("unit")); + Debug::Error("Only the unit m (meters) is supported. \n\tYou supplied [%s]",xRootNode->Attribute("unit")); return false; } - double version = xmltof(xRootNode->Attribute("version"), -1); + /* double version = xmltof(xRootNode->Attribute("version"), -1); */ - if ( (version - std::stod(JPS_VERSION))*(version - std::stod(JPS_VERSION)) > 0.01*0.01){ //|| version != std::stod(JPS_OLD_VERSION)) { - Log->Write(" \tWrong geometry version %.2f!", version); - Log->Write(" \tOnly versions = %s or %s are supported",JPS_VERSION, JPS_OLD_VERSION); - Log->Write(" \tPlease update the version of your geometry file to %s",JPS_VERSION); - return false; - } + /* if ( (version - std::stod(JPS_VERSION))*(version - std::stod(JPS_VERSION)) > 0.01*0.01){ //|| version != std::stod(JPS_OLD_VERSION)) { */ + /* Log->Write(" \tWrong geometry version %.2f!", version); */ + /* Log->Write(" \tOnly versions = %s or %s are supported",JPS_VERSION, JPS_OLD_VERSION); */ + /* Log->Write(" \tPlease update the version of your geometry file to %s",JPS_VERSION); */ + /* return false; */ + /* } */ _caption = xmltoa(xRootNode->Attribute("caption"), "virtual building"); //The file has two main nodes @@ -410,7 +417,7 @@ bool Building::LoadGeometry(const std::string &geometryfile) //processing the rooms node TiXmlNode* xRoomsNode = xRootNode->FirstChild("rooms"); if (!xRoomsNode) { - Log->Write("ERROR: \tThe geometry should have at least one room and one subroom"); + Debug::Error("The geometry should have at least one room and one subroom"); return false; } @@ -456,9 +463,9 @@ bool Building::LoadGeometry(const std::string &geometryfile) if (type == "stair") { if(xSubRoom->FirstChildElement("up")==NULL) { - Log->Write("ERROR:\t the attribute <up> and <down> are missing for the stair"); - Log->Write("ERROR:\t check your geometry file"); - return false; + Debug::Error("the attribute <up> and <down> are missing for the stair"); + Debug::Error("check your geometry file"); + return false; } double up_x = xmltof( xSubRoom->FirstChildElement("up")->Attribute("px"), 0.0); double up_y = xmltof( xSubRoom->FirstChildElement("up")->Attribute("py"), 0.0); @@ -544,10 +551,10 @@ bool Building::LoadGeometry(const std::string &geometryfile) int sub1_id = xmltoi(xCrossing->Attribute("subroom1_id"), -1); int sub2_id = xmltoi(xCrossing->Attribute("subroom2_id"), -1); - double x1 = xmltof( xCrossing->FirstChildElement("vertex")->Attribute("px")); - double y1 = xmltof( xCrossing->FirstChildElement("vertex")->Attribute("py")); - double x2 = xmltof( xCrossing->LastChild("vertex")->ToElement()->Attribute("px")); - double y2 = xmltof( xCrossing->LastChild("vertex")->ToElement()->Attribute("py")); + double x1 = xmltof(xCrossing->FirstChildElement("vertex")->Attribute("px")); + double y1 = xmltof(xCrossing->FirstChildElement("vertex")->Attribute("py")); + double x2 = xmltof(xCrossing->LastChild("vertex")->ToElement()->Attribute("px")); + double y2 = xmltof(xCrossing->LastChild("vertex")->ToElement()->Attribute("py")); Crossing* c = new Crossing(); c->SetID(id); @@ -628,7 +635,7 @@ bool Building::LoadGeometry(const std::string &geometryfile) AddTransition(t); } - Log->Write("INFO: \tLoading building file successful!!!\n"); + Debug::Messages("Loading building file successful!!!\n"); //everything went fine return true; @@ -703,7 +710,7 @@ void Building::AddHline(Hline* line) // check if the lines are identical Hline* ori= _hLines[line->GetID()]; if(ori->operator ==(*line)) { - Log->Write("INFO: \tSkipping identical hlines with ID [%d]",line->GetID()); + Debug::Messages("Skipping identical hlines with ID [%d]",line->GetID()); return; } else { Log->Write( @@ -1411,5 +1418,3 @@ bool Building::SaveGeometry(const std::string &filename) } #endif // _SIMULATOR - - diff --git a/src/main.cpp b/src/main.cpp index f05f60a30b09d21eaf4e21cbaa9752f472eb6c66..05f89f327312925c3550173ddd074be074d5d97f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,7 +5,7 @@ * Copyright (C) <2009-2010> * * @section LICENSE -* This file is part of OpenPedSim. +* This file is part of JuPedSim. * * JuPedSim is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -42,11 +42,10 @@ * * Some useful links: * -* 1: <a href="http://www.openpedsim.org">www.openpedsim.org</a> <br> -* 2: <a href="http://www.vtk.org">www.vtk.org</a> <br> -* 3: <a href="http://www.trolltech.com">www.trolltech.com</a> <br> -* 4: <a href="http://www.fz-juelich.de">www.fz-juelich.de</a> <br> -* 4: <a href="http://www.jupedsim.org">www.fz-juelich.de</a> <br> +* 1: <a href="http://www.jupedsim.org">www.jupedsim.org</a> <br> +* 2: <a href="http://www.vtk.org">www.vtk.org</a> <br> +* 3: <a href="http://www.trolltech.com">www.trolltech.com</a> <br> +* 4: <a href="http://www.fz-juelich.de">www.fz-juelich.de</a> <br> * */ @@ -59,7 +58,7 @@ #include <QApplication> #include <QDir> #include <locale.h> - +#include "Debug.h" // for compiling a standalone windows exe with VS #ifdef _MSC_VER # ifdef NDEBUG @@ -73,6 +72,14 @@ int main(int argc, char *argv[]) { + Debug::Info("----\nJuPedSim - JPSvis\n"); + Debug::Info("Current date : %s %s", __DATE__, __TIME__); + Debug::Info("Version : %s", JPSVIS_VERSION); + Debug::Info("Compiler : %s", USED_COMPILER); + Debug::Info("Commit hash : %s", GIT_COMMIT_HASH); + Debug::Info("Commit date : %s", GIT_COMMIT_DATE); + Debug::Info("Branch : %s\n----\n", GIT_BRANCH); + #ifdef __APPLE__ InitMultiThreading();