diff --git a/JPSvis.pro b/JPSvis.pro index f9a4f320ee98d9162818a5c105c2b88e74990fa6..c90dd42a91d60698191ed5aa6c99db4813e58b1a 100644 --- a/JPSvis.pro +++ b/JPSvis.pro @@ -186,7 +186,7 @@ win32_6.1 { #Dynamic linking #Windows VTK 5.10 -win32_dyn { +win32 { INCLUDEPATH += C:/VTK/VTK5.1/include LIBS += -LC:/VTK/VTK5.1/bin_shared \ -lvtksys \ @@ -217,9 +217,9 @@ win32_dyn { -lwsock32\ } -#Static compilation +#Static linking #VTK 5.10 Windows -win32 { +win32_static { INCLUDEPATH += C:/VTK/VTK5.1/static_2/include/vtk-5.10 LIBS += -LC:\VTK\VTK5.1\static_2\lib\vtk-5.10 \ C:\VTK\VTK5.1\static_2\lib\vtk-5.10/libvtkCharts.a C:\VTK\VTK5.1\static_2\lib\vtk-5.10/libvtkViews.a \ @@ -245,28 +245,6 @@ win32 { -luuid -lcomdlg32 -ladvapi32\ } -#Static compilation -#VTK 5.10 Windows -win32_old { - INCLUDEPATH += C:/VTK/VTK5.1/include - #LIBS += -LC:/VTK/VTK5.1/bin_static \ - LIBS += -LC:\VTK\VTK5.1\static_2\lib\vtk-5.10 \ - -lvtkCharts -lvtkViews -lvtkInfovis\ - -lvtkWidgets -lvtkHybrid\ - -lvtkVolumeRendering -lvtkParallel\ - -lvtkRendering -lvtkGraphics\ - -lvtkverdict -lvtkImaging -lvtkIO\ - -lvtkFiltering -lvtkDICOMParser\ - -lvtkNetCDF_cxx -lvtkmetaio -lvtksqlite\ - -lvtkpng -lvtktiff -lvtkjpeg\ - -lvtkexpat -lVPIC -lCosmo -lvtkCommon\ - -lLSDyna -lvtksys -lvtkexoIIc\ - -lvtkNetCDF -lvtkhdf5_hl -lvtkhdf5\ - -lvtklibxml2 -lvtkzlib -lvtkalglib\ - -lvtkftgl -lvtkfreetype \ - -lvfw32 -lwsock32\ - } - unix_6 { INCLUDEPATH += /usr/local/include/vtk-6.0 LIBS += -L/usr/local/lib/ \ @@ -390,26 +368,6 @@ unix_6 { unix_dyn { INCLUDEPATH += /usr/include/vtk-5.8 LIBS += -L/usr/lib \ -#INCLUDEPATH +=/usr/local/include/vtk-5.10 -#LIBS += -L/usr/local/lib/vtk-5.10 \ -# -lvtkCommon \ -# -lvtkDICOMParser \ -# -lvtkFiltering \ -# -lvtkGenericFiltering \ -# -lvtkGraphics \ -# -lvtkHybrid \ -# -lvtkIO \ -# -lvtkImaging \ -# -lvtkRendering \ -# -lvtkVolumeRendering \ -# -lvtkWidgets \ -# -lvtkexoIIc \ -# -lvtkftgl \ -# -lvtksys \ -# -lvtkverdict \ -# -lvtkParallel \ -# -lvtkmetaio \ -# -lvtkRendering \ -lvtkCommon \ -lvtkHybrid \ diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui index 94d340b9b53a22b6ef06d1c794d8575fe210b137..edd034029a16d8f3fa37d0f84eb10ed04462756b 100644 --- a/forms/mainwindow.ui +++ b/forms/mainwindow.ui @@ -587,18 +587,7 @@ border-color: rgb(255, 255, 255);</string> <property name="title"> <string>Options</string> </property> - <widget class="QMenu" name="menuCaption_Color"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="title"> - <string>Caption Color</string> - </property> - <addaction name="actionCaptionAuto"/> - <addaction name="actionCaptionCustom"/> - </widget> <addaction name="actionBackground_Color"/> - <addaction name="menuCaption_Color"/> <addaction name="actionFloor_Color"/> <addaction name="actionWalls_Color"/> <addaction name="actionExits_Color"/> @@ -606,6 +595,8 @@ border-color: rgb(255, 255, 255);</string> <addaction name="separator"/> <addaction name="actionPedestrian_Shape"/> <addaction name="actionNetwork_settings"/> + <addaction name="separator"/> + <addaction name="actionRemember_Settings"/> </widget> <widget class="QMenu" name="menuView"> <property name="title"> @@ -640,8 +631,6 @@ border-color: rgb(255, 255, 255);</string> <addaction name="actionShow_Navigation_Lines"/> <addaction name="actionShow_Geometry_Captions"/> <addaction name="actionFirst_Group"/> - <addaction name="actionSecond_Group"/> - <addaction name="actionThird_Group"/> <addaction name="separator"/> <addaction name="actionShow_Onscreen_Infos"/> <addaction name="separator"/> @@ -921,7 +910,7 @@ border-color: rgb(255, 255, 255);</string> <string>Second Group</string> </property> <property name="visible"> - <bool>false</bool> + <bool>true</bool> </property> </action> <action name="actionThird_Group"> @@ -935,7 +924,7 @@ border-color: rgb(255, 255, 255);</string> <string>Third Group</string> </property> <property name="visible"> - <bool>false</bool> + <bool>true</bool> </property> </action> <action name="actionShow_Legend"> @@ -1304,6 +1293,17 @@ border-color: rgb(255, 255, 255);</string> <string>Show Floor</string> </property> </action> + <action name="actionRemember_Settings"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="text"> + <string>Remember Settings</string> + </property> + </action> </widget> <resources> <include location="icons.qrc"/> @@ -1501,38 +1501,6 @@ border-color: rgb(255, 255, 255);</string> </hint> </hints> </connection> - <connection> - <sender>actionSecond_Group</sender> - <signal>toggled(bool)</signal> - <receiver>mainwindow</receiver> - <slot>slotToggleSecondPedestrianGroup()</slot> - <hints> - <hint type="sourcelabel"> - <x>-1</x> - <y>-1</y> - </hint> - <hint type="destinationlabel"> - <x>318</x> - <y>264</y> - </hint> - </hints> - </connection> - <connection> - <sender>actionThird_Group</sender> - <signal>toggled(bool)</signal> - <receiver>mainwindow</receiver> - <slot>slotToggleThirdPedestrianGroup()</slot> - <hints> - <hint type="sourcelabel"> - <x>-1</x> - <y>-1</y> - </hint> - <hint type="destinationlabel"> - <x>318</x> - <y>264</y> - </hint> - </hints> - </connection> <connection> <sender>actionAdd_Trajectories_File</sender> <signal>triggered()</signal> diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 8c2e5d9e11367ed83bd25e155538d99854bfb4ca..9bcfcebdee48dfab7f02a078498a5a40d1fe8ea1 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -64,6 +64,7 @@ #include <QTemporaryFile> + #include <iostream> #include <limits> #include <string> @@ -78,7 +79,12 @@ MainWindow::MainWindow(QWidget *parent) : this->setWindowTitle("JPSvis"); //disable the maximize Button - setWindowFlags( Qt::Window | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint ); + setWindowFlags( Qt::Window | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint); + + //used for saving the settings in a persistant way + QCoreApplication::setOrganizationName("Forschungszentrum Juelich GmbH"); + QCoreApplication::setOrganizationDomain("jupedsim.org"); + QCoreApplication::setApplicationName("jupedsim"); //create the 2 threads and connect them dataTransferThread = new ThreadDataTransfer(this); @@ -138,18 +144,11 @@ MainWindow::MainWindow(QWidget *parent) : labelCurrentAction = new QLabel(); labelCurrentAction->setFrameStyle(QFrame::Panel | QFrame::Sunken); - // currentAction->setLineWidth(5); - // currentAction->setMargin(2); - // currentAction->setMidLineWidth(2); labelCurrentAction->setText(" Idle "); statusBar()->addPermanentWidget(labelCurrentAction); labelFrameNumber = new QLabel(); labelFrameNumber->setFrameStyle(QFrame::Panel | QFrame::Sunken); - // frameNumber->setLineWidth(5); - // frameNumber->setFixedWidth(80); - // frameNumber->setMargin(2); - // frameNumber->setMidLineWidth(2); labelFrameNumber->setText("fps:"); statusBar()->addPermanentWidget(labelFrameNumber); @@ -174,8 +173,8 @@ MainWindow::MainWindow(QWidget *parent) : int group=1; // there are max 3 groups of pedestrians bool mayPlay=false; - // arguments.append("-online"); - // arguments.append("-caption"); + //arguments.append("-online"); + //arguments.append("-caption"); arguments.append("-2D"); // parse arguments list if(arguments.size()>1) @@ -184,7 +183,7 @@ MainWindow::MainWindow(QWidget *parent) : QString argument=arguments[argCount]; if(argument.compare("help")==0) { - Debug::Error("Usage: ./TraVisTo [file1] [file2] [file3] [-2D] [-caption] [-online [port]]"); + Debug::Error("Usage: ./TraVisTo [file1] [-2D] [-caption] [-online [port]]"); } else if(argument.compare("-2D")==0) { ui.action2_D->setChecked(true); slotToogle2D(); @@ -203,7 +202,7 @@ MainWindow::MainWindow(QWidget *parent) : Debug::Messages(" listening port: %d",port); if (ok) { - SystemSettings::setListningPort(port); + SystemSettings::setListeningPort(port); } else { // maybe that wasnt the port argCount--; // to ensure that the "option" will be checked } @@ -213,7 +212,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] [file2] [file3] [-2D] [-caption] [-online [port] ]"); + Debug::Error("Usage: ./TraVisTo [file1] [-2D] [-caption] [-online [port] ]"); } else if(addPedestrianGroup(group,argument)) { //slotHelpAbout(); @@ -223,15 +222,33 @@ MainWindow::MainWindow(QWidget *parent) : } + //restore the settings + loadAllSettings(); + if(mayPlay)slotStartPlaying(); } MainWindow::~MainWindow() { - extern_shutdown_visual_thread=true; extern_recording_enable=false; + //save all settings for the next session + if(ui.actionRemember_Settings->isChecked()) + { + saveAllSettings(); + qDebug()<<"saving all settings"; + } + else + { + //first clear everyting + QSettings settings; + settings.clear(); + //then remember that we do not want any settings saved + settings.setValue("options/rememberSettings", false); + qDebug()<<"clearing all settings"; + } + if (visualisationThread->isRunning()) { //std::Debug::Messages("Thread visualisation is still running" << std::endl; @@ -251,12 +268,10 @@ MainWindow::~MainWindow() delete labelFrameNumber; delete labelRecording; delete labelMode; - } void MainWindow::slotHelpAbout() { - QMessageBox::about( this, "About JPSVis", @@ -268,29 +283,23 @@ void MainWindow::slotHelpAbout() "Authors: Ulrich Kemloh\n\n" "For questions, contact +49-40-246161-4193 \nor mail at \n" "u.kemloh@fz-juelich.de\n"); - } - /** *setup the network port to bind * */ - void MainWindow::slotNetworkSettings() { bool ok; - int port = QInputDialog::getInt(this, tr("input a port "), tr( "port(default to 8989):"), 8989, 5000, 65355, 1, &ok); - if (ok) { - SystemSettings::setListningPort(port); + SystemSettings::setListeningPort(port); } } - void MainWindow::slotStartPlaying() { @@ -402,16 +411,12 @@ void MainWindow::slotStopPlaying() */ bool MainWindow::slotLoadFile() { - return slotAddDataSet(); - } - // This function is only used in online Mode FacilityGeometry* MainWindow::parseGeometry(QDomNode geoNode) { - cout<<"parsing the geo"<<endl; if(geoNode.isNull()) return NULL; @@ -552,31 +557,13 @@ bool MainWindow::parsePedestrianShapes(QDomNode shapeNode, int groupID) extern_trajectories_firstSet.setInitialColors(colors); break; } - return true; - } - /// add a new dataset bool MainWindow::slotAddDataSet() { -// if (numberOfDatasetLoaded>=3){ -// QMessageBox::information(this,"notice","You can load at most 3 datasets.\n In" -// " Order to load other data, please first clear previously loaded data."); -// return false; -// } - -// // if at least one data set was loaded -// if (numberOfDatasetLoaded>=1){ -// int res = QMessageBox::question(this, "action", -// "adding a new dataset will reset the visualisation process. Continue?", QMessageBox::Discard -// | QMessageBox::Yes, QMessageBox::Yes); - -// if (res == QMessageBox::Discard) return false; -// } - // just continue numberOfDatasetLoaded=1; if(addPedestrianGroup(numberOfDatasetLoaded)==false) { @@ -597,14 +584,12 @@ bool MainWindow::slotAddDataSet() ///clear all datasets previously entered. void MainWindow::slotClearAllDataset() { - clearDataSet(1); clearDataSet(2); clearDataSet(3); numberOfDatasetLoaded=0; } - bool MainWindow::addPedestrianGroup(int groupID,QString fileName) { statusBar()->showMessage(tr("Select a file")); @@ -685,7 +670,7 @@ bool MainWindow::addPedestrianGroup(int groupID,QString fileName) break; default: - Debug::Error("invalid pedestrian group: %d " ,groupID); + Debug::Error("Only one dataset can be loaded at a time"); //return false; break; } @@ -725,7 +710,6 @@ bool MainWindow::addPedestrianGroup(int groupID,QString fileName) return true; } - void MainWindow::slotRecord() { @@ -748,7 +732,6 @@ void MainWindow::slotRecord() } - QString MainWindow::getTagValueFromElement(QDomNode node, const char * tagName) { @@ -880,7 +863,6 @@ void MainWindow::slotRenderingTime(int fps) labelFrameNumber->setText(msg); } - void MainWindow::slotExit() { cleanUp(); @@ -894,11 +876,6 @@ void MainWindow::closeEvent(QCloseEvent* event) event->accept(); } -/** - * performs the necessary cleaning such as: - * closing data - * stopping recording - */ void MainWindow::cleanUp() { //stop the recording process @@ -913,11 +890,8 @@ void MainWindow::cleanUp() } - - void MainWindow::slotControlSequence(const char * sex) { - QString str(sex); //todo: check wich stack is empty and disable @@ -983,7 +957,6 @@ void MainWindow::slotControlSequence(const char * sex) } } - void MainWindow::resetGraphicalElements() { @@ -1031,7 +1004,6 @@ void MainWindow::resetGraphicalElements() } - void MainWindow::slotToggleFirstPedestrianGroup() { if(ui.actionFirst_Group->isChecked()) { @@ -1043,45 +1015,17 @@ void MainWindow::slotToggleFirstPedestrianGroup() } -/// enable/disable the second pedestrian group -void MainWindow::slotToggleSecondPedestrianGroup() -{ -// if(ui.actionSecond_Group->isChecked()){ -// extern_second_dataset_visible=true; -// }else{ -// extern_second_dataset_visible=false; -// } -// extern_force_system_update=true; -} - -/// enable/disable the third pedestrian group -void MainWindow::slotToggleThirdPedestrianGroup() -{ -// if(ui.actionThird_Group->isChecked()){ -// extern_third_dataset_visible=true; -// }else{ -// extern_third_dataset_visible=false; -// } -// extern_force_system_update=true; -} - bool MainWindow::anyDatasetLoaded() { - return - extern_first_dataset_loaded; + return extern_first_dataset_loaded; } void MainWindow::slotShowTrajectoryOnly() { - if(ui.actionShow_Trajectories->isChecked()) { - extern_tracking_enable=true; - } else { - extern_tracking_enable=false; - } + SystemSettings::setShowTrajectories(ui.actionShow_Trajectories->isChecked()); extern_force_system_update=true; } - void MainWindow::slotShowPedestrianOnly() { @@ -1095,7 +1039,6 @@ void MainWindow::slotShowPedestrianOnly() void MainWindow::slotShowGeometry() { - if (ui.actionShow_Geometry->isChecked()) { visualisationThread->setGeometryVisibility(true); ui.actionShow_Exits->setEnabled(true); @@ -1119,30 +1062,24 @@ void MainWindow::slotShowGeometry() /// shows/hide geometry void MainWindow::slotShowHideExits() { - if (ui.actionShow_Exits->isChecked()) { - visualisationThread->showDoors(true); - } else { - visualisationThread->showDoors(false); - } + bool status = ui.actionShow_Exits->isChecked(); + visualisationThread->showDoors(status); + SystemSettings::setShowExits(status); } /// shows/hide geometry void MainWindow::slotShowHideWalls() { - if (ui.actionShow_Walls->isChecked()) { - visualisationThread->showWalls(true); - } else { - visualisationThread->showWalls(false); - } + bool status = ui.actionShow_Walls->isChecked(); + visualisationThread->showWalls(status); + SystemSettings::setShowWalls(status); } void MainWindow::slotShowHideNavLines() { - if (ui.actionShow_Navigation_Lines->isChecked()) { - visualisationThread->showNavLines(true); - } else { - visualisationThread->showNavLines(false); - } + bool status = ui.actionShow_Navigation_Lines->isChecked(); + visualisationThread->showNavLines(status); + SystemSettings::setShowNavLines(status); } //todo: add to the system settings @@ -1157,14 +1094,11 @@ void MainWindow::slotShowHideFloor() /// update the playing speed void MainWindow::slotUpdateSpeedSlider(int newValue) { - QString msg; msg.setNum(newValue); - extern_update_step=newValue; //Debug::Error( " speed updated to: %d", extern_update_step); ui.speedSliderLabel->setText("Speed: " + msg + " "); - } /// update the position slider @@ -1202,7 +1136,6 @@ void MainWindow::slotUpdateContrastSlider(int newValue) } - ///clear the corresponding dataset; void MainWindow::clearDataSet(int ID) { @@ -1266,7 +1199,6 @@ void MainWindow::waitForDataThread() Debug::Messages("Network Engine shutdown successfully."); } - /// set visualisation mode to 2D void MainWindow::slotToogle2D() { @@ -1321,8 +1253,8 @@ void MainWindow::slotToogleShowLegend() SystemSettings::setShowLegend(false); } } + /*** - * * @param geodata the geometry data received from the data transfer thread */ void MainWindow::slotStartVisualisationThread(QString data,int numberOfAgents,float frameRate) @@ -1411,14 +1343,12 @@ void MainWindow::slotShowPedestrianCaption() extern_force_system_update=true; } - void MainWindow::slotToogleShowAxis() { visualisationThread->setAxisVisible(ui.actionShow_Axis->isChecked()); } - //todo: rename this to slotChangeSettting void MainWindow::slotChangePedestrianShape() { @@ -1454,16 +1384,19 @@ void MainWindow::slotChangeBackgroundColor() //the user may have cancelled the process if(col.isValid()==false) return; - double bkcolor[3]= {(double)col.red()/255.0 ,(double)col.green()/255.0 ,(double)col.blue()/255.0}; - visualisationThread->setBackgroundColor(bkcolor); + //double bkcolor[3]= {(double)col.red()/255.0 ,(double)col.green()/255.0 ,(double)col.blue()/255.0}; + visualisationThread->setBackgroundColor(col); + + QSettings settings; + settings.setValue("options/bgColor", col); delete colorDialog; } + /// change the wall color void MainWindow::slotChangeWallsColor() { - QColorDialog* colorDialog = new QColorDialog(this); colorDialog->setToolTip("Choose a new color for walls"); QColor col=colorDialog->getColor(Qt::white,this,"Select new wall color"); @@ -1471,9 +1404,10 @@ void MainWindow::slotChangeWallsColor() //the user may have cancelled the process if(col.isValid()==false) return; - double bkcolor[3]= {(double)col.red()/255.0 ,(double)col.green()/255.0 ,(double)col.blue()/255.0}; + visualisationThread->setWallsColor(col); - visualisationThread->setWallsColor(bkcolor); + QSettings settings; + settings.setValue("options/wallsColor", col); delete colorDialog; @@ -1489,9 +1423,10 @@ void MainWindow::slotChangeExitsColor() //the user may have cancelled the process if(col.isValid()==false) return; - double color[3]= {(double)col.red()/255.0 ,(double)col.green()/255.0 ,(double)col.blue()/255.0}; + visualisationThread->setExitsColor(col); - visualisationThread->setExitsColor(color); + QSettings settings; + settings.setValue("options/exitsColor", col); delete colorDialog; } @@ -1506,9 +1441,10 @@ void MainWindow::slotChangeNavLinesColor() //the user may have cancelled the process if(col.isValid()==false) return; - double color[3]= {(double)col.red()/255.0 ,(double)col.green()/255.0 ,(double)col.blue()/255.0}; + visualisationThread->setNavLinesColor(col); - visualisationThread->setNavLinesColor(color); + QSettings settings; + settings.setValue("options/navLinesColor", col); delete colorDialog; } @@ -1516,15 +1452,16 @@ void MainWindow::slotChangeNavLinesColor() void MainWindow::slotChangeFloorColor() { QColorDialog* colorDialog = new QColorDialog(this); - colorDialog->setToolTip("Choose a new color for teh floor"); + colorDialog->setToolTip("Choose a new color for the floor"); QColor col=colorDialog->getColor(Qt::white,this,"Select new floor color"); //the user may have cancelled the process if(col.isValid()==false) return; - double color[3]= {(double)col.red()/255.0 ,(double)col.green()/255.0 ,(double)col.blue()/255.0}; + visualisationThread->setFloorColor(col); - visualisationThread->setFloorColor(color); + QSettings settings; + settings.setValue("options/floorColor", col); delete colorDialog; } @@ -1596,11 +1533,186 @@ void MainWindow::slotTakeScreenShot() } /// load settings, parsed from the project file -void MainWindow::loadSettings() +void MainWindow::loadAllSettings() +{ + qDebug()<<"restoring previous settings"; + QSettings settings; + + //visualisation + if (settings.contains("vis/offline")) + { + bool offline = settings.value("vis/offline").toBool(); + slotSetOnlineMode(!offline); + slotSetOfflineMode(offline); + if(!offline){ + int port = SystemSettings::getListeningPort(); + if (settings.contains("options/listeningPort")) + { + port = settings.value("options/listeningPort").toInt(); + SystemSettings::setListeningPort(port); + } + qDebug()<<"online listening on port: "<<port; + } + else + { + qDebug()<<"offline: "<<offline; + } + } + + //view + if (settings.contains("view/2d")) + { + bool checked = settings.value("view/2d").toBool(); + ui.action2_D->setChecked(checked); + ui.action3_D->setChecked(!checked); + SystemSettings::set2D(checked); + qDebug()<<"2D: "<<checked; + } + if (settings.contains("view/showAgents")) + { + bool checked = settings.value("view/showAgents").toBool(); + ui.actionShow_Agents->setChecked(checked); + SystemSettings::setShowAgents(checked); + qDebug()<<"show Agents: "<<checked; + } + if (settings.contains("view/showCaptions")) + { + bool checked = settings.value("view/showCaptions").toBool(); + ui.actionShow_Captions->setChecked(checked); + SystemSettings::setShowAgentsCaptions(checked); + qDebug()<<"show Captions: "<<checked; + } + if (settings.contains("view/showTrajectories")) + { + bool checked = settings.value("view/showTrajectories").toBool(); + ui.actionShow_Trajectories->setChecked(checked); + SystemSettings::setShowTrajectories(checked); + qDebug()<<"show Trajectories: "<<checked; + } + if (settings.contains("view/showGeometry")) + { + bool checked = settings.value("view/showGeometry").toBool(); + ui.actionShow_Geometry->setChecked(checked); + slotShowGeometry();//will take care of the others things like enabling options + qDebug()<<"show Geometry: "<<checked; + } + if (settings.contains("view/showFloor")) + { + bool checked = settings.value("view/showFloor").toBool(); + ui.actionShow_Floor->setChecked(checked); + slotShowHideFloor(); + qDebug()<<"show Floor: "<<checked; + } + if (settings.contains("view/showExits")) + { + bool checked = settings.value("view/showExits").toBool(); + ui.actionShow_Exits->setChecked(checked); + slotShowHideExits(); + qDebug()<<"show Exits: "<<checked; + } + if (settings.contains("view/showWalls")) + { + bool checked = settings.value("view/showWalls").toBool(); + ui.actionShow_Walls->setChecked(checked); + slotShowHideWalls(); + qDebug()<<"show Walls: "<<checked; + } + if (settings.contains("view/showGeoCaptions")) + { + bool checked = settings.value("view/showGeoCaptions").toBool(); + ui.actionShow_Geometry_Captions->setChecked(checked); + slotShowHideGeometryCaptions(); + qDebug()<<"show geometry Captions: "<<checked; + } + if (settings.contains("view/showNavLines")) + { + bool checked = settings.value("view/showNavLines").toBool(); + ui.actionShow_Navigation_Lines->setChecked(checked); + slotShowHideNavLines(); + qDebug()<<"show Navlines: "<<checked; + } + if (settings.contains("view/showOnScreensInfos")) + { + bool checked = settings.value("view/showOnScreensInfos").toBool(); + ui.actionShow_Onscreen_Infos->setChecked(checked); + slotShowOnScreenInfos(); + qDebug()<<"show OnScreensInfos: "<<checked; + } + + //options + if (settings.contains("options/rememberSettings")) + { + bool checked = settings.value("options/rememberSettings").toBool(); + ui.actionRemember_Settings->setChecked(checked); + qDebug()<<"remember settings: "<<checked; + } + + if (settings.contains("options/bgColor")) + { + QColor color = settings.value("options/bgColor").value<QColor>(); + SystemSettings::setBackgroundColor(color); + qDebug()<<"background color: "<<color; + } + + if (settings.contains("options/exitsColor")) + { + QColor color = settings.value("options/bgColor").value<QColor>(); + SystemSettings::setExitsColor(color); + qDebug()<<"Exits color: "<<color; + } + + if (settings.contains("options/floorColor")) + { + QColor color = settings.value("options/floorColor").value<QColor>(); + SystemSettings::setFloorColor(color); + qDebug()<<"Floor color: "<<color; + } + + if (settings.contains("options/wallsColor")) + { + QColor color = settings.value("options/wallsColor").value<QColor>(); + SystemSettings::setWallsColor(color); + qDebug()<<"Walls color: "<<color; + } + + if (settings.contains("options/navLinesColor")) + { + QColor color = settings.value("options/navLinesColor").value<QColor>(); + SystemSettings::setWallsColor(color); + qDebug()<<"Navlines color: "<<color; + } + + extern_force_system_update=true; +} + +void MainWindow::saveAllSettings() { + //visualiation + QSettings settings; + settings.setValue("vis/offline", ui.actionOffline->isChecked()); + + //view + settings.setValue("view/2d", ui.action2_D->isChecked()); + settings.setValue("view/showAgents", ui.actionShow_Agents->isChecked()); + settings.setValue("view/showCaptions", ui.actionShow_Captions->isChecked()); + settings.setValue("view/showTrajectories", ui.actionShow_Trajectories->isChecked()); + settings.setValue("view/showGeometry", ui.actionShow_Geometry->isChecked()); + settings.setValue("view/showFloor", ui.actionShow_Floor->isChecked()); + settings.setValue("view/showWalls", ui.actionShow_Walls->isChecked()); + settings.setValue("view/showExits", ui.actionShow_Exits->isChecked()); + settings.setValue("view/showGeoCaptions", ui.actionShow_Geometry_Captions->isChecked()); + settings.setValue("view/showNavLines", ui.actionShow_Navigation_Lines->isChecked()); + settings.setValue("view/showOnScreensInfos", ui.actionShow_Onscreen_Infos->isChecked()); - Debug::Error("Not implemented"); + //options: the color settings are saved in the methods where they are used. + settings.setValue("options/listeningPort", SystemSettings::getListeningPort()); + settings.setValue("options/rememberSettings", ui.actionRemember_Settings->isChecked()); + //settings.setValue("options/bgColor", ui.actionBackground_Color->isChecked()); + // NOT USED: settings.setValue("options/captionColor", ui.action3_D->isChecked()); + //settings.setValue("options/floorColor", ui.action3_D->isChecked()); + //settings.setValue("options/wallsColor", ui.action3_D->isChecked()); + //settings.setValue("options/navLinesColor", ui.action3_D->isChecked()); } /// start/stop the recording process als png images sequences @@ -1678,9 +1790,9 @@ void MainWindow::slotShowOnScreenInfos() /// show/hide the geometry captions void MainWindow::slotShowHideGeometryCaptions() { - bool value=ui.actionShow_Geometry_Captions->isChecked(); visualisationThread->setGeometryLabelsVisibility(value); + SystemSettings::setShowGeometryCaptions(value); //SystemSettings::setShowCaptions(value); //SystemSettings::setOnScreenInfos(value); } diff --git a/src/MainWindow.h b/src/MainWindow.h index 41de09d6a5de563e6452bf0920d0fbba2faba628..7cffd303d463dfb56e7a7f1fadf56e3b334a162f 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -36,6 +36,7 @@ #include "ui_mainwindow.h" #include <QMainWindow> +#include <QSettings> #include <vector> @@ -61,22 +62,14 @@ extern bool extern_shutdown_visual_thread; extern bool extern_fullscreen_enable; extern bool extern_pedestrians_firstSet_visible; -extern bool extern_pedestrians_secondSet_visible; -extern bool extern_pedestrians_thirdSet_visible; extern SyncData extern_trajectories_firstSet; -extern SyncData extern_trajectories_secondSet; -extern SyncData extern_trajectories_thirdSet; //states if the datasets are loaded. extern bool extern_first_dataset_loaded; -extern bool extern_second_dataset_loaded; -extern bool extern_third_dataset_loaded; //states whether the loaded datasets are visible extern bool extern_first_dataset_visible; -extern bool extern_second_dataset_visible; -extern bool extern_third_dataset_visible; class MainWindow : public QMainWindow { @@ -97,7 +90,6 @@ public Q_SLOTS: /// load a file bool slotLoadFile(); - //void slotLoadProject(); /// output an Error void slotErrorOutput(QString err); @@ -158,10 +150,7 @@ public Q_SLOTS: /// enable/disable the first pedestrian group void slotToggleFirstPedestrianGroup(); - /// enable/disable the second pedestrian group - void slotToggleSecondPedestrianGroup(); - /// enable/disable the third pedestrian group - void slotToggleThirdPedestrianGroup(); + /// show/hides trajectories (leaving a trail) only void slotShowTrajectoryOnly(); @@ -189,7 +178,6 @@ public Q_SLOTS: void slotUpdateFrameSlider(int newValue); void slotFrameSliderPressed(); void slotFrameSliderReleased(); - //void slotFrameSliderChanged(); /// handle the frame by frame navigation void slotFramesByFramesNavigation(); @@ -199,8 +187,6 @@ public Q_SLOTS: /// enable/disable the pedestrian captions void slotShowPedestrianCaption(); - /// set the bg color - //void slotPickBackgroundColor(); /// update the contrast void slotUpdateContrastSlider(int newValue); @@ -261,9 +247,11 @@ protected: private: - /// load settings, parsed from the project file - /// @todo not implemented - void loadSettings(); + /// load settings in the case the remember settings is checked. + void loadAllSettings(); + + /// save all system settings + void saveAllSettings(); /// performs the necessary cleaning before shutting down the program. void cleanUp(); @@ -295,7 +283,6 @@ private: /// groupID may be 2 or 3 /// @return false if something went wrong. - bool addPedestrianGroup_old(int groupID, QString fileName=""); bool addPedestrianGroup(int groupID, QString fileName=""); ///return true if at least one dataset was loaded diff --git a/src/SimpleVisualisationWindow.cpp b/src/SimpleVisualisationWindow.cpp index 7dcfe5db285c3c8f76844a32caf3676eae86ba0f..09f39af89268f1849e18b2b40d03caf4b3f701f9 100644 --- a/src/SimpleVisualisationWindow.cpp +++ b/src/SimpleVisualisationWindow.cpp @@ -69,29 +69,30 @@ void SimpleVisualisationWindow::start() vtkRenderer* renderer = vtkRenderer::New(); renderer->SetBackground(0,0,0); -// //add the line actor -// LinePlotter * ln = new LinePlotter(); -// ln->PlotPoint(324,34,34); -// ln->AddPoint(1,1,1); -// ln->AddPoint(11,11,171); -// ln->AddPoint(34,334,334); -// ln->AddPoint(81,821,81); -// ln->AddPoint(134,14,134); - -// ln->PlotLine(1,1,1,324,34,34,1); -// ln->PlotLine(11,11,171,34,334,334,1); -// ln->PlotLine(81,821,81,14,134,134,1); -// renderer->AddActor(ln->getActor()); + // //add the line actor + // LinePlotter * ln = new LinePlotter(); + // ln->PlotPoint(324,34,34); + // ln->AddPoint(1,1,1); + // ln->AddPoint(11,11,171); + // ln->AddPoint(34,334,334); + // ln->AddPoint(81,821,81); + // ln->AddPoint(134,14,134); + + // ln->PlotLine(1,1,1,324,34,34,1); + // ln->PlotLine(11,11,171,34,334,334,1); + // ln->PlotLine(81,821,81,14,134,134,1); + // renderer->AddActor(ln->getActor()); // -// PointPlotter * pt = new PointPlotter(); -// pt->PlotPoint(324,34,34); -// pt->PlotPoint(1,1,1); -// pt->PlotPoint(11,11,171); -// pt->PlotPoint(34,334,334); -// pt->PlotPoint(81,821,81); -// pt->PlotPoint(134,14,134); -// renderer->AddActor(pt->getActor()); + // PointPlotter * pt = new PointPlotter(); + // pt->PlotPoint(324,34,34); + // pt->PlotPoint(1,1,1); + // pt->PlotPoint(11,11,171); + // pt->PlotPoint(34,334,334); + // pt->PlotPoint(81,821,81); + // pt->PlotPoint(134,14,134); + // renderer->AddActor(pt->getActor()); + //add the different actors renderer->AddActor(assembly); @@ -105,7 +106,7 @@ void SimpleVisualisationWindow::start() light->SetIntensity(1); light->SetLightTypeToCameraLight(); // renderer->AddLight(light); -// light->Delete(); + // light->Delete(); // Create a render window vtkRenderWindow *renderWindow = vtkRenderWindow::New(); @@ -141,7 +142,7 @@ void SimpleVisualisationWindow::start() renderWinInteractor->Delete(); if(assembly) assembly->Delete(); -// if(actor) -// actor->Delete(); + // if(actor) + // actor->Delete(); } diff --git a/src/SystemSettings.cpp b/src/SystemSettings.cpp index 709f29399bfb457bacc29957f96fa1a9efd13dc3..7c5b9454136fb1b1278fc9ec40094dfe009a3fba 100644 --- a/src/SystemSettings.cpp +++ b/src/SystemSettings.cpp @@ -47,9 +47,21 @@ bool SystemSettings::showAgentsCaptions=false; bool SystemSettings::is2D=false; bool SystemSettings::showAgents=true; bool SystemSettings::showGeometry=true; +bool SystemSettings::showGeometryCaptions=true; bool SystemSettings::showFloor=true; +bool SystemSettings::showWalls=true; +bool SystemSettings::showExits=true; +bool SystemSettings::showNavLines=true; +bool SystemSettings::showTrajectories=false; + unsigned short SystemSettings::port=8989; -double SystemSettings::bgColor[]= {1.0,1.0,1.0}; +//double SystemSettings::bgColor[]= {1.0,1.0,1.0}; +QColor SystemSettings::bgColor = QColor(Qt::white); +QColor SystemSettings::floorColor = QColor(0,0,255); +QColor SystemSettings::wallsColor = QColor(180,180,180);//180.0/255,180.0/255.0,180.0/255.0 +QColor SystemSettings::exitsColor = QColor(175,175,255); //175.0/255,175.0/255.0,255.0/255.0 +QColor SystemSettings::navLinesColor = QColor(Qt::white); + int SystemSettings::pedestriansColor[3][3]= {{255 , 17, 224},{122, 255, 122},{130, 130, 130}}; int SystemSettings::pedesShape=Settings::PINGUINS; int SystemSettings::ellipseResolution=10; @@ -82,7 +94,6 @@ SystemSettings::~SystemSettings() {} void SystemSettings::setShowLegend(bool legend) { showLegend=legend; - } bool SystemSettings::getShowLegend() @@ -91,23 +102,23 @@ bool SystemSettings::getShowLegend() } -void SystemSettings::setListningPort(unsigned short porta) +void SystemSettings::setListeningPort(unsigned short porta) { port=porta; } -unsigned short SystemSettings::getListeningPort() +unsigned short SystemSettings::getListeningPort() { return port; } -void SystemSettings::setShowAgentsCaptions(bool caption) +void SystemSettings::setShowAgentsCaptions(bool caption) { showAgentsCaptions=caption; } -bool SystemSettings::getShowAgentsCaptions() +bool SystemSettings::getShowAgentsCaptions() { return showAgentsCaptions; } @@ -142,6 +153,16 @@ bool SystemSettings::getShowGeometry() return showGeometry; } +void SystemSettings::setShowGeometryCaptions(bool status) +{ + showGeometryCaptions=status; +} + +bool SystemSettings::getShowGeometryCaptions() +{ + return showGeometryCaptions; +} + void SystemSettings::setShowFloor(bool status) { showFloor=status; @@ -152,31 +173,105 @@ bool SystemSettings::getShowFloor() return showFloor; } -void SystemSettings::setWorkingDirectory(QString dir) +void SystemSettings::setShowExits(bool status) +{ + showExits=status; +} + +bool SystemSettings::getShowExits() +{ + return showExits; +} + +void SystemSettings::setShowWalls(bool status) +{ + showWalls=status; +} + +bool SystemSettings::getShowWalls() +{ + return showWalls; +} + +void SystemSettings::setShowNavLines(bool status) +{ + showNavLines=status; +} + +bool SystemSettings::getShowNavLines() +{ + return showNavLines; +} + +void SystemSettings::setShowTrajectories(bool status) +{ + showTrajectories=status; +} + +bool SystemSettings::getShowTrajectories() +{ + return showTrajectories; +} + +void SystemSettings::setWorkingDirectory(const QString& dir) { workingDir=dir; } -void SystemSettings::getWorkingDirectory(QString& dir) +void SystemSettings::getWorkingDirectory(QString& dir) { dir=workingDir; } -void SystemSettings::getBackgroundColor(double* col) +const QColor& SystemSettings::getBackgroundColor() +{ + return bgColor; +} + +void SystemSettings::setBackgroundColor(const QColor& col) +{ + bgColor=col; +} + +const QColor& SystemSettings::getFloorColor() +{ + return floorColor; +} + +void SystemSettings::setFloorColor(const QColor &col) { - col[0]=bgColor[0]; - col[1]=bgColor[1]; - col[2]=bgColor[2]; + floorColor=col; } -void SystemSettings::setBackgroundColor(double* col) +const QColor& SystemSettings::getWallsColor() { - bgColor[0]=col[0]; - bgColor[1]=col[1]; - bgColor[2]=col[2]; + return wallsColor; } +void SystemSettings::setWallsColor(const QColor &col) +{ + wallsColor=col; +} +const QColor& SystemSettings::getExitsColor() +{ + return exitsColor; +} + +void SystemSettings::setExitsColor(const QColor &col) +{ + exitsColor=col; +} + +const QColor& SystemSettings::getNavLinesColor() +{ + return navLinesColor; +} + +void SystemSettings::setNavLinesColor(const QColor &col) +{ + navLinesColor=col; +} /// set/get pedestrian private sphere ellipse resolution int SystemSettings::getEllipseResolution() @@ -189,18 +284,18 @@ void SystemSettings::setEllipseResolution(int resolution) ellipseResolution=resolution; } - - /// set/get the pedestrian shape /// 0 for default, 1 for Ellipse, 2 for pinguins void SystemSettings::setPedestrianShape(int shape) { pedesShape=shape; } + int SystemSettings::getPedestrianShape() { return pedesShape; } + void SystemSettings::setTrailsInfo(int count, int type, int geo) { trailCount=count; @@ -214,6 +309,7 @@ void SystemSettings::getTrailsInfo(int* count, int *type, int* geo) *type=trailingType; *geo=trailingGeometry; } + void SystemSettings::setPedestrianColor(int groupID, int color[3]) { if((groupID<0) || (groupID>3)) { @@ -249,7 +345,6 @@ void SystemSettings::getOutputDirectory(QString& dir) dir=QString(outputDir); } - int SystemSettings::getPedestrianCaptionSize() { return captionSize; @@ -259,6 +354,7 @@ void SystemSettings::setRecordPNGsequence(bool status) { recordPNGsequence=status; } + bool SystemSettings::getRecordPNGsequence() { return recordPNGsequence; @@ -322,7 +418,7 @@ int SystemSettings::getVirtualAgent() } void SystemSettings::setCaptionsParameters(int size, const QColor& col, int orientation, - bool automaticRotation) + bool automaticRotation) { captionSize=size; captionColor=col; @@ -332,7 +428,7 @@ void SystemSettings::setCaptionsParameters(int size, const QColor& col, int orie } void SystemSettings::getCaptionsParameters(int &size, QColor& col, int &orientation, - bool &automaticRotation) + bool &automaticRotation) { size=captionSize; col=captionColor; @@ -349,4 +445,3 @@ bool SystemSettings::getOnScreenInfos() { return onScreenInfos; } - diff --git a/src/SystemSettings.h b/src/SystemSettings.h index 27dfeb7ca9cf6f5b6fef833dd7c0026a39573570..d5da07d1028b40c7254da1b8870a8ede26b625eb 100644 --- a/src/SystemSettings.h +++ b/src/SystemSettings.h @@ -52,7 +52,7 @@ public: bool static getShowAgentsCaptions(); // set/get the listening port - void static setListningPort(unsigned short port); + void static setListeningPort(unsigned short port); unsigned short static getListeningPort(); // set/get the 2D visio @@ -67,17 +67,49 @@ public: void static setShowGeometry(bool status); bool static getShowGeometry(); - // set/get the geometry visibility + // set/get the geometry captions visibility + void static setShowGeometryCaptions(bool status); + bool static getShowGeometryCaptions(); + + // set/get the floor visibility void static setShowFloor(bool status); bool static getShowFloor(); - void static setWorkingDirectory(QString dir); + // set/get the doors visibility + void static setShowExits(bool status); + bool static getShowExits(); + + // set/get the walls visibility + void static setShowWalls(bool status); + bool static getShowWalls(); + + // set/get the navigation lines visibility + void static setShowNavLines(bool status); + bool static getShowNavLines(); + + // set/get the trajectories visibility + void static setShowTrajectories(bool status); + bool static getShowTrajectories(); + + void static setWorkingDirectory(const QString &dir); void static getWorkingDirectory(QString& dir); - // set/get the bk color + // set/get the gk color // todo done directly in the travisto.cpp - void static getBackgroundColor(double* col); - void static setBackgroundColor(double* col); + static const QColor& getBackgroundColor(); + void static setBackgroundColor(const QColor &col); + + static const QColor& getFloorColor(); + void static setFloorColor(const QColor &col); + + static const QColor& getWallsColor(); + void static setWallsColor(const QColor &col); + + static const QColor& getExitsColor(); + void static setExitsColor(const QColor &col); + + static const QColor& getNavLinesColor(); + void static setNavLinesColor(const QColor &col); /// set/get pedestrian private sphere ellipse resolution int static getEllipseResolution(); @@ -166,9 +198,18 @@ private: static bool is2D; // Toggle 2D/3D mode static bool showAgents; static bool showGeometry; + static bool showGeometryCaptions; static bool showFloor; + static bool showWalls; + static bool showExits; + static bool showNavLines; + static bool showTrajectories; static unsigned short port; - static double bgColor[3]; + static QColor bgColor; + static QColor floorColor; + static QColor wallsColor; + static QColor exitsColor; + static QColor navLinesColor; static int ellipseResolution; static int pedestriansColor[3][3]; // 3 groups, and 3 color per groups static int pedesShape; diff --git a/src/ThreadVisualisation.cpp b/src/ThreadVisualisation.cpp index 6a995229bacc0eb6ba4847cb3737869230356cdb..78cb73d9f9ff2df6e95909f4c5b1f6c3c8382589 100644 --- a/src/ThreadVisualisation.cpp +++ b/src/ThreadVisualisation.cpp @@ -103,6 +103,7 @@ ThreadVisualisation::ThreadVisualisation(QObject *parent): renderer=NULL; renderWindow=NULL; renderWinInteractor=NULL; + runningTime=NULL; framePerSecond=25; axis=NULL; winTitle="header without room caption"; @@ -153,10 +154,6 @@ void ThreadVisualisation::run() renderer->AddActor(geometry->getActor2D()); renderer->AddActor(geometry->getActor3D()); - //initialize the datasets - //mem leak - - initGlyphs2D(); initGlyphs3D(); @@ -231,17 +228,11 @@ void ThreadVisualisation::run() //renderer->AddActor(actor); } - //compute the relatives delays - // necessary in the case several dataset were loaded - computeDelays(); - // Create the render window renderWindow = vtkRenderWindow::New(); renderWindow->AddRenderer( renderer ); renderWindow->SetSize(960, 800); //renderWindow->SetSize(640, 480); - //renderWindow->SetSize(800, 586); - //renderWindow->SetSize(1280, 960); // add the legend //if(SystemSettings::getShowLegend()) @@ -282,7 +273,7 @@ void ThreadVisualisation::run() //add a light kit { - VTK_CREATE(vtkLightKit, lightKit); + //VTK_CREATE(vtkLightKit, lightKit); //lightKit->SetKeyLightIntensity(1); //lightKit->SetKeyLightWarmth(5); @@ -306,7 +297,6 @@ void ThreadVisualisation::run() renderingTimer->setTextActor(runningTime); renderWinInteractor->AddObserver(vtkCommand::TimerEvent,renderingTimer); - //create the necessary connections QObject::connect(renderingTimer, SIGNAL(signalRunningTime(unsigned long )), this->parent(), SLOT(slotRunningTime(unsigned long ))); @@ -330,20 +320,6 @@ void ThreadVisualisation::run() //Pedestrian::setCamera(renderer->GetActiveCamera()); //renderer->ResetCamera(); - // just a workaround - - //if(LinePlotter2D::doorColorsToDefault) - { - //LinePlotter2D::doorColorsToDefault=false; - double col[3]= {82.0/255,218.0 /255.0,255.0/255.0}; - double wallcol[3]= {180.0/255,180.0/255.0,180.0/255.0}; - double exitcol[3]= {175.0/255,175.0/255.0,255.0/255.0}; - double navlinecol[3]= {165.0/255,175.0/255.0,225.0/255.0}; - setExitsColor(exitcol); - setWallsColor(wallcol); - //setNavLinesColor(navlinecol); - //showDoors(false); - } //renderWinInteractor->Initialize(); // Initialize and enter interactive mode // should be called after the observer has been added @@ -358,9 +334,22 @@ void ThreadVisualisation::run() //renderer->GetActiveCamera()->Modified(); _topViewCamera->DeepCopy(renderer->GetActiveCamera()); - //TODO: update all system settings + //update all (restored) system settings setGeometryVisibility2D(SystemSettings::get2D()); setGeometryVisibility3D(!SystemSettings::get2D()); + setGeometryVisibility(SystemSettings::getShowGeometry()); + setOnscreenInformationVisibility(SystemSettings::getOnScreenInfos()); + showFloor(SystemSettings::getShowFloor()); + showWalls((SystemSettings::getShowWalls())); + showDoors((SystemSettings::getShowExits())); + showNavLines((SystemSettings::getShowNavLines())); + setGeometryLabelsVisibility(SystemSettings::getShowGeometryCaptions()); + setBackgroundColor(SystemSettings::getBackgroundColor()); + setWallsColor(SystemSettings::getWallsColor()); + setFloorColor(SystemSettings::getFloorColor()); + setExitsColor(SystemSettings::getExitsColor()); + setNavLinesColor(SystemSettings::getNavLinesColor()); + renderWinInteractor->Start(); @@ -448,6 +437,35 @@ void ThreadVisualisation::initGlyphs2D() agentShape->SetInnerRadius(0); agentShape->SetOuterRadius(30); +// { +// //personal space +// VTK_CREATE (vtkDiskSource, perSpace); +// perSpace->SetCircumferentialResolution(20); +// perSpace->SetInnerRadius(0); +// perSpace->SetOuterRadius(30); +// //forehead +// perSpace->SetCircumferentialResolution(20); +// perSpace->SetInnerRadius(0); +// perSpace->SetOuterRadius(30); +// //backhead + +// //Append the two meshes +// VTK_CREATE (vtkAppendPolyData, appendFilter); +//#if VTK_MAJOR_VERSION <= 5 +// appendFilter->AddInputConnection(perSpace->GetProducerPort()); +// appendFilter->AddInputConnection(input2->GetProducerPort()); +//#else +// appendFilter->AddInputData(perSpace); +// appendFilter->AddInputData(input2); +//#endif +// appendFilter->Update(); + +// // Remove any duplicate points. +// VTK_CREATE (vtkCleanPolyData, cleanFilter); +// cleanFilter->SetInputConnection(appendFilter->GetOutputPort()); +// cleanFilter->Update(); +// } + //speed the rendering using triangles stripers vtkTriangleFilter *tris = vtkTriangleFilter::New(); tris->SetInputConnection(agentShape->GetOutputPort()); @@ -595,9 +613,14 @@ void ThreadVisualisation::finalize() { } -/// compute the relative delays to the datasets -void ThreadVisualisation::computeDelays() {} + +void ThreadVisualisation::QcolorToDouble(const QColor &col, double *rgb) +{ + rgb[0]=(double)col.red()/255.0; + rgb[1]=(double)col.green()/255.0; + rgb[2]=(double)col.blue()/255.0; +} void ThreadVisualisation::initLegend(/*std::vector scalars*/) { @@ -690,10 +713,12 @@ void ThreadVisualisation::setCameraPerspective(int mode) } } -void ThreadVisualisation::setBackgroundColor(double* color) +void ThreadVisualisation::setBackgroundColor(const QColor& col) { + double bgcolor[3]; + QcolorToDouble(col,bgcolor); if (renderer!=NULL) - renderer->SetBackground(color); + renderer->SetBackground(bgcolor); } void ThreadVisualisation::setWindowTitle(QString title) @@ -716,14 +741,18 @@ FacilityGeometry* ThreadVisualisation::getGeometry() return geometry; } -void ThreadVisualisation::setWallsColor(double* color) +void ThreadVisualisation::setWallsColor(const QColor &color) { - geometry->changeWallsColor(color); + double rbgColor[3]; + QcolorToDouble(color,rbgColor); + geometry->changeWallsColor(rbgColor); } -void ThreadVisualisation::setFloorColor(double *color) +void ThreadVisualisation::setFloorColor(const QColor &color) { - geometry->changeFloorColor(color); + double rbgColor[3]; + QcolorToDouble(color,rbgColor); + geometry->changeFloorColor(rbgColor); } void ThreadVisualisation::setGeometryLabelsVisibility(int v) @@ -731,14 +760,18 @@ void ThreadVisualisation::setGeometryLabelsVisibility(int v) geometry->showGeometryLabels(v); } -void ThreadVisualisation::setExitsColor(double* color) +void ThreadVisualisation::setExitsColor(const QColor &color) { - geometry->changeExitsColor(color); + double rbgColor[3]; + QcolorToDouble(color,rbgColor); + geometry->changeExitsColor(rbgColor); } -void ThreadVisualisation::setNavLinesColor(double *color) +void ThreadVisualisation::setNavLinesColor(const QColor &color) { - geometry->changeNavLinesColor(color); + double rbgColor[3]; + QcolorToDouble(color,rbgColor); + geometry->changeNavLinesColor(rbgColor); } /// enable/disable 2D @@ -759,6 +792,11 @@ void ThreadVisualisation::setGeometryVisibility3D(bool status) void ThreadVisualisation::setOnscreenInformationVisibility(bool show) { + if(runningTime) runningTime->SetVisibility(show); } +void ThreadVisualisation::Create2dAgent() +{ + +} diff --git a/src/ThreadVisualisation.h b/src/ThreadVisualisation.h index 6fe79b5ae5777342500b37ef36471ec0b7ec48ea..d36f42f446f08ad7bf4969c77f000299a699d177 100644 --- a/src/ThreadVisualisation.h +++ b/src/ThreadVisualisation.h @@ -63,8 +63,6 @@ class TrailPlotter; class PointPlotter; extern Pedestrian** extern_pedestrians_firstSet; -extern Pedestrian** extern_pedestrians_secondSet; -extern Pedestrian** extern_pedestrians_thirdSet; extern PointPlotter* extern_trail_plotter; @@ -74,8 +72,6 @@ extern vtkActor* extern_glyphs_pedestrians_actor_2D; extern vtkActor* extern_glyphs_pedestrians_actor_3D; extern SyncData extern_trajectories_firstSet; -extern SyncData extern_trajectories_secondSet; -extern SyncData extern_trajectories_thirdSet; class ThreadVisualisation :public QThread { Q_OBJECT @@ -116,19 +112,19 @@ public: void setGeometryVisibility3D(bool status); /// change the background color of the rendering windows - void setBackgroundColor(double* color); + void setBackgroundColor(const QColor &col); /// change the walls color - void setWallsColor(double* color); + void setWallsColor(const QColor &color); /// change the floor color - void setFloorColor(double* color); + void setFloorColor(const QColor &color); /// change the exits color. - void setExitsColor(double* color); + void setExitsColor(const QColor &color); /// change the exits color. - void setNavLinesColor(double* color); + void setNavLinesColor(const QColor &color); /// show / hide the walls void showWalls(bool status); @@ -176,12 +172,9 @@ private: //finalize the datasets void finalize(); - /// compute the relative delays to the datasets - void computeDelays(); - - /// window change events - //static void WindowModifiedCallback(vtkObject* caller, long unsigned int eventId, void* clientData, void* callData ); + void QcolorToDouble(const QColor& col, double* rgb); + void Create2dAgent(); private: FacilityGeometry* geometry; diff --git a/src/TimerCallback.cpp b/src/TimerCallback.cpp index 1b9631bf67294debbe4c72dc78bc64e8d505a404..776c88af821f791d5a1fc3bb3f8026ed9467623c 100644 --- a/src/TimerCallback.cpp +++ b/src/TimerCallback.cpp @@ -171,7 +171,7 @@ void TimerCallback::Execute(vtkObject *caller, unsigned long eventId, extern_glyphs_pedestrians_3D->Update(); } - if(extern_tracking_enable) { + if(SystemSettings::getShowTrajectories()) { const std::vector<FrameElement *> &elements=frame->GetFrameElements(); for(unsigned int i=0; i<elements.size(); i++) { @@ -322,12 +322,11 @@ void TimerCallback::Execute(vtkObject *caller, unsigned long eventId, void TimerCallback::updateSettings(vtkRenderWindow* renderWindow) { - static bool fullscreen=false; extern_glyphs_pedestrians_actor_2D->SetVisibility(SystemSettings::getShowAgents()&& SystemSettings::get2D()); extern_glyphs_pedestrians_actor_3D->SetVisibility(SystemSettings::getShowAgents()&& !SystemSettings::get2D()); - extern_trail_plotter->SetVisibility(extern_tracking_enable); + extern_trail_plotter->SetVisibility(SystemSettings::getShowTrajectories()); //agents captions extern_pedestrians_labels->SetVisibility(SystemSettings::getShowAgentsCaptions()); diff --git a/src/TimerCallback.h b/src/TimerCallback.h index 3871ce11b4f290d5808636b7c3aa7c7de5db3a1b..8699f590b03f50733051508bf5eab632df761470 100644 --- a/src/TimerCallback.h +++ b/src/TimerCallback.h @@ -77,11 +77,8 @@ extern bool extern_recording_enable; extern bool extern_launch_recording; extern bool extern_fullscreen_enable; extern bool extern_take_screenshot; -extern bool extern_tracking_enable; extern Pedestrian** extern_pedestrians_firstSet; -extern Pedestrian** extern_pedestrians_secondSet; -extern Pedestrian** extern_pedestrians_thirdSet; extern vtkActor2D* extern_pedestrians_labels; extern vtkTensorGlyph* extern_glyphs_pedestrians; @@ -91,18 +88,12 @@ extern vtkActor* extern_glyphs_pedestrians_actor_3D; extern PointPlotter* extern_trail_plotter; extern SyncData extern_trajectories_firstSet; -extern SyncData extern_trajectories_secondSet; -extern SyncData extern_trajectories_thirdSet; //states if the datasets are loaded. extern bool extern_first_dataset_loaded; -extern bool extern_second_dataset_loaded; -extern bool extern_third_dataset_loaded; //states whether the loaded datasets are visible extern bool extern_first_dataset_visible; -extern bool extern_second_dataset_visible; -extern bool extern_third_dataset_visible; diff --git a/src/extern_var.h b/src/extern_var.h index 843e2e6509c1e3d190a7dab5b819d2c41c9335af..39aa913cca048d6656431d50c2f3d554b42df4ef 100644 --- a/src/extern_var.h +++ b/src/extern_var.h @@ -72,7 +72,6 @@ bool extern_force_system_update=false; /// enables of disables tracking. /// With this enable, moving pedestrians will leave a /// trail behind them -bool extern_tracking_enable=false; PointPlotter* extern_trail_plotter=NULL; ///relative scale from pedestrian to the geometry (environment) diff --git a/src/geometry/LinePlotter2D.cpp b/src/geometry/LinePlotter2D.cpp index b14c522aa42783f70120d55dd61a895ef3e0fdd8..c7cc41924180fa704c4850bb05b44d2b91a6d137 100644 --- a/src/geometry/LinePlotter2D.cpp +++ b/src/geometry/LinePlotter2D.cpp @@ -45,6 +45,7 @@ #include <vtkAssembly.h> #include <vtkSmartPointer.h> +#include <QColor> #define VTK_CREATE(type, name) \ vtkSmartPointer<type> name = vtkSmartPointer<type>::New() @@ -248,8 +249,8 @@ vtkAssembly* LinePlotter2D::createAssembly() //if default, then hide all doors // fixme: not working if(doorColorsToDefault) { - double col[3]= {1.0,1.0,1.0}; - SystemSettings::getBackgroundColor(col); + const QColor& bgcolor = SystemSettings::getBackgroundColor(); + double col[3]= {(double)bgcolor.red()/255.0 ,(double)bgcolor.green()/255.0 ,(double)bgcolor.blue()/255.0}; door_actor->GetProperty()->SetColor(col); door_actor->Modified(); } diff --git a/src/main.cpp b/src/main.cpp index 1bb6b7b5d661675cfa2cd8bb1631032dbed8038f..d6790d580c1f05fdbd1dee1c519a1a693f7286c7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,18 +1,18 @@ /** * @file main.h * @author Ulrich Kemloh <kemlohulrich@gmail.com> -* @version 0.1 +* @version 0.5 * Copyright (C) <2009-2010> * * @section LICENSE * This file is part of OpenPedSim. * -* OpenPedSim is free software: you can redistribute it and/or modify +* JuPedSim is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * -* OpenPedSim is distributed in the hope that it will be useful, +* JuPedSim is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. @@ -35,7 +35,8 @@ * * \date 7.6.2010 * -* JuPedSim stands for Jülich Pedestrians Simulator and is currently developed at the Forschungszentrum Jülich in Germany. +* JuPedSim stands for Jülich Pedestrians Simulator and is currently +* developed at the Forschungszentrum Jülich in Germany. * * @image html travisto.png " " *