diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index a5059839e2037685bf623955b3425b042ba5d004..f48b9304e7ef7a1ec930317770918ac725d832de 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -547,13 +547,19 @@ bool MainWindow::addPedestrianGroup(int groupID,QString fileName){ if(fileName.isEmpty()) fileName = QFileDialog::getOpenFileName(this, - "Select the file containing data to visualize", + "Select the file containing the data to visualize", "F:\\workspace\\JPSvis\\data", - "Visualisation Files (*.dat *.trav *.xml *.pg3 *.jul);;All Files (*.*)"); + "Visualisation Files (*.dat *.trav *.xml);;All Files (*.*)"); if (fileName.isNull()) { return false; } + + //get and set the working dir + QFileInfo fileInfo(fileName); + QString wd=fileInfo.absoluteDir().absolutePath(); + SystemSettings::setWorkingDirectory(wd); + //the geometry actor //FacilityGeometry* geometry=NULL; FacilityGeometry* geometry = visualisationThread->getGeometry(); @@ -1354,7 +1360,7 @@ void MainWindow::slotPreviousFrame(){ void MainWindow::slotShowPedestrianCaption(){ - SystemSettings::setShowCaptions(ui.actionShow_Captions->isChecked()); + SystemSettings::setShowAgentsCaptions(ui.actionShow_Captions->isChecked()); extern_force_system_update=true; } @@ -1575,5 +1581,6 @@ void MainWindow::slotShowHideGeometryCaptions(){ bool value=ui.actionShow_Geometry_Captions->isChecked(); visualisationThread->setGeometryLabelsVisibility(value); + //SystemSettings::setShowCaptions(value); //SystemSettings::setOnScreenInfos(value); } diff --git a/src/SaxParser.cpp b/src/SaxParser.cpp index e74dc1ffda229e2bd152f02b7b8ee6c7eb137f7f..2d21f305dfe0503d1e959667e5c275bd1b120f84 100644 --- a/src/SaxParser.cpp +++ b/src/SaxParser.cpp @@ -37,6 +37,7 @@ #include "geometry/JPoint.h" #include "geometry/FacilityGeometry.h" #include "geometry/Building.h" +#include "SystemSettings.h" #include <QMessageBox> #include <QString> @@ -617,8 +618,12 @@ void SaxParser::parseGeometryJPS(QString fileName, FacilityGeometry *geometry){ if(!fileName.endsWith(".xml",Qt::CaseInsensitive)) return ; + QString wd; + SystemSettings::getWorkingDirectory(wd); + fileName=wd+"/"+fileName; + Building* building = new Building(); - string geometrypath = fileName.toStdString(); + string geometrypath = fileName.toStdString(); // read the geometry building->LoadBuildingFromFile(geometrypath); @@ -890,12 +895,9 @@ void SaxParser::parseGeometryXMLV04(QString filename, FacilityGeometry *geo){ QDomDocument doc(""); QFile file(filename); - //int size =file.size()/(1024*1024); - //if(size>100){ - // cout<<"The file is too large: "<<filename.toStdString()<<endl; - // return; - //} + //TODO: check if you can parse this with the building classes. + // This should be a fall back option if (!file.open(QIODevice::ReadOnly)) { qDebug()<<"could not open the file: "<<filename<<endl; diff --git a/src/SystemSettings.cpp b/src/SystemSettings.cpp index f25d4c0079a94003964d434fc2dea9f034173f70..43be1c214892dc5a74165c8e7837a883edc7e121 100644 --- a/src/SystemSettings.cpp +++ b/src/SystemSettings.cpp @@ -40,7 +40,7 @@ bool SystemSettings::showLegend=false; bool SystemSettings::pedColorProfileReadFromFile=true; -bool SystemSettings::showCaption=false; +bool SystemSettings::showAgentsCaptions=false; bool SystemSettings::is2D=false; bool SystemSettings::showAgents=true; bool SystemSettings::showGeometry=true; @@ -63,6 +63,7 @@ bool SystemSettings::onScreenInfos=true; bool SystemSettings::recordPNGsequence=false; //QString SystemSettings::outputDir =QDir::currentPath()+"/"; QString SystemSettings::outputDir = QDir::homePath() +"/Desktop/TraVisTo_Files/"; +QString SystemSettings::workingDir = QDir::currentPath(); QString SystemSettings::filesPrefix=""; @@ -90,12 +91,12 @@ unsigned short SystemSettings::getListeningPort(){ } -void SystemSettings::setShowCaptions(bool caption){ - showCaption=caption; +void SystemSettings::setShowAgentsCaptions(bool caption){ + showAgentsCaptions=caption; } -bool SystemSettings::getShowCaption(){ - return showCaption; +bool SystemSettings::getShowAgentsCaptions(){ + return showAgentsCaptions; } void SystemSettings::set2D(bool lis2D){ @@ -126,6 +127,16 @@ bool SystemSettings::getShowGeometry() return showGeometry; } +void SystemSettings::setWorkingDirectory(QString dir) +{ + workingDir=dir; +} + +void SystemSettings::getWorkingDirectory(QString& dir) +{ + dir=workingDir; +} + void SystemSettings::getBackgroundColor(double* col){ col[0]=bgColor[0]; col[1]=bgColor[1]; diff --git a/src/SystemSettings.h b/src/SystemSettings.h index 8e6455b35de158d2e734e8174e1237745c6ebd3f..58a12ae684a25fb3ebc70b1b517c5b82d75c911d 100644 --- a/src/SystemSettings.h +++ b/src/SystemSettings.h @@ -48,8 +48,8 @@ public: bool static getShowLegend(); //set/get the caption status - void static setShowCaptions(bool caption); - bool static getShowCaption(); + void static setShowAgentsCaptions(bool caption); + bool static getShowAgentsCaptions(); // set/get the listening port void static setListningPort(unsigned short port); @@ -67,6 +67,9 @@ public: void static setShowGeometry(bool status); bool static getShowGeometry(); + void static setWorkingDirectory(QString dir); + void static getWorkingDirectory(QString& dir); + // set/get the bk color // todo done directly in the travisto.cpp void static getBackgroundColor(double* col); @@ -151,13 +154,12 @@ private: static bool recordPNGsequence; static bool pedColorProfileReadFromFile; static bool showLegend; - static bool showCaption; + static bool showAgentsCaptions; static bool is2D; // Toggle 2D/3D mode static bool showAgents; static bool showGeometry; static unsigned short port; static double bgColor[3]; - //static double ellipseShape[2]; static int ellipseResolution; static int pedestriansColor[3][3]; // 3 groups, and 3 color per groups static int pedesShape; @@ -166,6 +168,7 @@ private: static int trailingType; static int trailingGeometry; static QString outputDir; + static QString workingDir; static int captionSize; static QColor captionColor; static int captionOrientaton; diff --git a/src/ThreadVisualisation.cpp b/src/ThreadVisualisation.cpp index f8c757debdb68dc464ef10424a01b182fb11e507..534cadea0ca5a5db4d24f35c461d88e4328f5635 100644 --- a/src/ThreadVisualisation.cpp +++ b/src/ThreadVisualisation.cpp @@ -73,6 +73,7 @@ #include <vtkCylinderSource.h> #include <vtkWindowToImageFilter.h> #include <vtkActor.h> +#include <vtkLightKit.h> #include "geometry/FacilityGeometry.h" @@ -279,9 +280,19 @@ void ThreadVisualisation::run(){ renderWinInteractor->Initialize(); //add a light kit + { + VTK_CREATE(vtkLightKit, lightKit); + //lightKit->SetKeyLightIntensity(1); + + //lightKit->SetKeyLightWarmth(5); + //lightKit->SetBackLightAngle(30,40); + //lightKit->SetKeyLightWarmth(2.0); + //lightKit->SetMaintainLuminance(true); + //lightKit->AddLightsToRenderer(renderer); + } - if(SystemSettings::get2D()){ + if(true || SystemSettings::get2D()){ renderer->GetActiveCamera()->OrthogonalizeViewUp(); renderer->GetActiveCamera()->ParallelProjectionOn(); renderer->ResetCamera(); @@ -1061,14 +1072,3 @@ void ThreadVisualisation::setOnscreenInformationVisibility(bool show){ runningTime->SetVisibility(show); } -//void ThreadVisualisation::WindowModifiedCallback( vtkObject* -// caller, unsigned long eventId,void* clientData ,void* callData ) -//{ -// vtkRenderWindow* window = static_cast<vtkRenderWindow*>(caller); -// int* windowSize = window->GetSize(); -// -// -// int *pos=renderWindow->GetSize(); -// runningTime->SetPosition(pos[1]/2,pos[0]); -// -//} diff --git a/src/TimerCallback.cpp b/src/TimerCallback.cpp index c79bcf157bba49a7ab72e7a35819803a71156a1c..ed8336f9ef286a55e6c512eb7c5bae89b88bfe52 100644 --- a/src/TimerCallback.cpp +++ b/src/TimerCallback.cpp @@ -183,7 +183,7 @@ void TimerCallback::Execute(vtkObject *caller, unsigned long eventId, { const std::vector<FrameElement *> &elements=frame->GetFrameElements(); - for(int i=0;i<elements.size();i++) + for(unsigned int i=0;i<elements.size();i++) { FrameElement* el = elements[i]; double pos[3]; @@ -333,6 +333,10 @@ void TimerCallback::updateSettings(vtkRenderWindow* renderWindow) { extern_glyphs_pedestrians_actor_3D->SetVisibility(SystemSettings::getShowAgents()&& !SystemSettings::get2D()); extern_trail_plotter->SetVisibility(extern_tracking_enable); + //agents captions + extern_pedestrians_labels->SetVisibility(SystemSettings::getShowAgentsCaptions()); + + //geometry captions //enable / disable full screen if(fullscreen!=extern_fullscreen_enable){ diff --git a/src/geometry/Building.cpp b/src/geometry/Building.cpp index 5fcc440f7324f8bbcb8e066fbbd0ff0805a75c85..54bf5a32c1c0f9ab31405d18d70fdb82cf3e3fae 100644 --- a/src/geometry/Building.cpp +++ b/src/geometry/Building.cpp @@ -322,7 +322,7 @@ void Building::LoadBuildingFromFile(const std::string &filename) { TiXmlDocument docGeo(geoFilename); if (!docGeo.LoadFile()){ Log->Write("ERROR: \t%s", docGeo.ErrorDesc()); - Log->Write("ERROR: \t could not parse the geometry file"); + Log->Write("ERROR: \t could not parse the geometry file [%s]",geoFilename.c_str()); exit(EXIT_FAILURE); } diff --git a/src/geometry/FacilityGeometry.cpp b/src/geometry/FacilityGeometry.cpp index 5f39a9b9cfb9caf3d8864430fdbafe2110782b72..f0001c774d0ee7d293bede903664de0e7d4ea7b0 100644 --- a/src/geometry/FacilityGeometry.cpp +++ b/src/geometry/FacilityGeometry.cpp @@ -123,12 +123,16 @@ vtkAssembly* FacilityGeometry::getActor2D(){ return assembly2D; } + vtkAssembly* FacilityGeometry::getCaptionsActor() + { + return assemblyCaptions; + } + vtkAssembly* FacilityGeometry::getActor3D() { assembly3D->AddPart(assemblyDoors3D); assembly3D->AddPart(assemblyWalls3D); -// assembly3D->AddPart(assemblyObjects); -// assembly3D->AddPart(assemblyCaptions); + assembly3D->AddPart(assemblyCaptions); return assembly3D; } @@ -667,6 +671,7 @@ void FacilityGeometry::addObjectLabel(double center[3], double orientation[3], s vtkActor2DCollection* FacilityGeometry::getCaptions(){ return captions; } + // orientation and color ignored void FacilityGeometry::addNewElementText(double center[3], double orientation[3], string text, double color) { diff --git a/src/geometry/FacilityGeometry.h b/src/geometry/FacilityGeometry.h index 1bf9d75bddef241f7e296ca1c1c8346981ec761c..49aae3ed57c879cd33668431d41da42cfc284659 100644 --- a/src/geometry/FacilityGeometry.h +++ b/src/geometry/FacilityGeometry.h @@ -70,6 +70,8 @@ public: vtkAssembly* getActor3D(); + vtkAssembly* getCaptionsActor(); + vtkActor2DCollection* getCaptions(); ///draw a wall