diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui index 21186d13457f8dc8680e207fdd78cdd97dbced63..ed21be23c70b5dc51a4d957f2e121dd0dbe2114b 100644 --- a/forms/mainwindow.ui +++ b/forms/mainwindow.ui @@ -539,7 +539,7 @@ border-color: rgb(255, 255, 255);</string> <x>0</x> <y>0</y> <width>450</width> - <height>25</height> + <height>22</height> </rect> </property> <widget class="QMenu" name="menuFile"> @@ -591,6 +591,7 @@ border-color: rgb(255, 255, 255);</string> <addaction name="actionFloor_Color"/> <addaction name="actionWalls_Color"/> <addaction name="actionExits_Color"/> + <addaction name="actionObstacles_Color"/> <addaction name="actionNavigation_Lines_Color"/> <addaction name="separator"/> <addaction name="actionPedestrian_Shape"/> @@ -628,6 +629,7 @@ border-color: rgb(255, 255, 255);</string> <addaction name="actionShow_Wall_Caption"/> <addaction name="actionShow_Room_Caption"/> <addaction name="actionShow_Door_Caption"/> + <addaction name="actionShow_Obstacles"/> <addaction name="actionShow_Navigation_Lines"/> <addaction name="actionShow_Geometry_Captions"/> <addaction name="actionFirst_Group"/> @@ -1319,6 +1321,22 @@ border-color: rgb(255, 255, 255);</string> <string>Ctrl+G</string> </property> </action> + <action name="actionShow_Obstacles"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="text"> + <string>Show Obstacles</string> + </property> + </action> + <action name="actionObstacles_Color"> + <property name="text"> + <string>Obstacles Color</string> + </property> + </action> </widget> <resources> <include location="icons.qrc"/> @@ -2172,6 +2190,38 @@ border-color: rgb(255, 255, 255);</string> </hint> </hints> </connection> + <connection> + <sender>actionShow_Obstacles</sender> + <signal>triggered()</signal> + <receiver>mainwindow</receiver> + <slot>slotShowHideObstacles()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>224</x> + <y>199</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionObstacles_Color</sender> + <signal>triggered()</signal> + <receiver>mainwindow</receiver> + <slot>slotChangeObstacleColor()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>224</x> + <y>199</y> + </hint> + </hints> + </connection> </connections> <slots> <slot>slotHelpAbout()</slot> @@ -2236,5 +2286,7 @@ border-color: rgb(255, 255, 255);</string> <slot>slotShowHideFloor()</slot> <slot>slotChangeFloorColor()</slot> <slot>slotShowGeometryStructure()</slot> + <slot>slotChangeObstacleColor()</slot> + <slot>slotShowHideObstacles()</slot> </slots> </ui> diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 56ebdc44301575030327c893e45a79a077c2b084..da951ed51472068158e8ac095008ee9dca95c83b 100755 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -1515,6 +1515,23 @@ void MainWindow::slotChangeFloorColor() delete colorDialog; } +void MainWindow::slotChangeObstacleColor() +{ + QColorDialog* colorDialog = new QColorDialog(this); + colorDialog->setToolTip("Choose a new color for the obstacles"); + QColor col=colorDialog->getColor(Qt::white,this,"Select new obstalce color"); + + //the user may have cancelled the process + if(col.isValid()==false) return; + + _visualisationThread->setObstacleColor(col); + + QSettings settings; + settings.setValue("options/obstacle", col); + + delete colorDialog; +} + void MainWindow::slotSetCameraPerspectiveToTop() { int p= 1; //TOP @@ -1680,6 +1697,13 @@ void MainWindow::loadAllSettings() slotShowHideNavLines(); qDebug()<<"show Navlines: "<<checked; } + if (settings.contains("view/showObstacles")) + { + bool checked = settings.value("view/showObstacles").toBool(); + ui.actionShow_Obstacles->setChecked(checked); + slotShowHideObstacles(); + qDebug()<<"show showObstacles: "<<checked; + } if (settings.contains("view/showOnScreensInfos")) { bool checked = settings.value("view/showOnScreensInfos").toBool(); @@ -1730,6 +1754,12 @@ void MainWindow::loadAllSettings() SystemSettings::setNavLinesColor(color); qDebug()<<"Navlines color: "<<color; } + if (settings.contains("options/obstaclesColor")) + { + QColor color = settings.value("options/obstaclesColor").value<QColor>(); + SystemSettings::setObstacleColor(color); + qDebug()<<"Obstacles color: "<<color; + } extern_force_system_update=true; } @@ -1752,6 +1782,7 @@ void MainWindow::saveAllSettings() 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()); + settings.setValue("view/showObstacles", ui.actionShow_Obstacles->isChecked()); //options: the color settings are saved in the methods where they are used. settings.setValue("options/listeningPort", SystemSettings::getListeningPort()); @@ -1845,7 +1876,12 @@ void MainWindow::slotShowHideGeometryCaptions() //SystemSettings::setShowCaptions(value); //SystemSettings::setOnScreenInfos(value); } - +void MainWindow::slotShowHideObstacles() +{ + bool value=ui.actionShow_Obstacles->isChecked(); + _visualisationThread->showObstacle(value); + SystemSettings::setShowObstacles(value); +} void MainWindow::slotShowGeometryStructure() { //QListView list; diff --git a/src/MainWindow.h b/src/MainWindow.h index a487756caec97583f9697e2eccab956ca1848101..af30864fc58e491c0f5b32a7583e694508d57e54 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -172,6 +172,8 @@ public Q_SLOTS: void slotShowHideFloor(); /// shows/hide geometry captions void slotShowHideGeometryCaptions(); + /// show hide the obstacles + void slotShowHideObstacles(); /// show pedestrians only without trail void slotShowPedestrianOnly(); @@ -192,7 +194,6 @@ public Q_SLOTS: /// enable/disable the pedestrian captions void slotShowPedestrianCaption(); - /// update the contrast void slotUpdateContrastSlider(int newValue); @@ -237,8 +238,11 @@ public Q_SLOTS: /// change the floor color void slotChangeFloorColor(); + /// change the obstacle color + void slotChangeObstacleColor(); + /// show/hide onscreen information - /// information include Time and pedestrians left in the facility + /// information include Time and number pedestrians left in the facility void slotShowOnScreenInfos(); ///show the detailed structure of the geometry diff --git a/src/SystemSettings.cpp b/src/SystemSettings.cpp index 65de97526602fb1ebc4cc591425cee9068607c13..c5c508cbe228460274ed08793c0b5024b9c1cb27 100644 --- a/src/SystemSettings.cpp +++ b/src/SystemSettings.cpp @@ -53,12 +53,14 @@ bool SystemSettings::showWalls=true; bool SystemSettings::showExits=true; bool SystemSettings::showNavLines=true; bool SystemSettings::showTrajectories=false; +bool SystemSettings::showObstacle=true; unsigned short SystemSettings::port=8989; //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::obstacleColor = 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); @@ -193,6 +195,16 @@ bool SystemSettings::getShowWalls() return showWalls; } +void SystemSettings::setShowObstacles(bool status) +{ + showObstacle=status; +} + +bool SystemSettings::getShowObstacles() +{ + return showObstacle; +} + void SystemSettings::setShowNavLines(bool status) { showNavLines=status; @@ -268,6 +280,16 @@ const QColor& SystemSettings::getNavLinesColor() return navLinesColor; } +const QColor& SystemSettings::getObstacleColor() +{ + return obstacleColor; +} + +void SystemSettings::setObstacleColor(const QColor &col) +{ + obstacleColor=col; +} + void SystemSettings::setNavLinesColor(const QColor &col) { navLinesColor=col; diff --git a/src/SystemSettings.h b/src/SystemSettings.h index d5da07d1028b40c7254da1b8870a8ede26b625eb..d295c19fd81898bdad020221c72a0754023919b2 100644 --- a/src/SystemSettings.h +++ b/src/SystemSettings.h @@ -83,6 +83,10 @@ public: void static setShowWalls(bool status); bool static getShowWalls(); + //set/get the obstacles visibility + void static setShowObstacles(bool status); + bool static getShowObstacles(); + // set/get the navigation lines visibility void static setShowNavLines(bool status); bool static getShowNavLines(); @@ -111,11 +115,13 @@ public: static const QColor& getNavLinesColor(); void static setNavLinesColor(const QColor &col); + static const QColor& getObstacleColor(); + void static setObstacleColor(const QColor &col); + /// set/get pedestrian private sphere ellipse resolution int static getEllipseResolution(); void static setEllipseResolution(int resolution); - /// set/get the pedestrian shape /// 0 for default, 1 for Ellipse, 2 for pinguins void static setPedestrianShape(int shape); @@ -200,6 +206,7 @@ private: static bool showGeometry; static bool showGeometryCaptions; static bool showFloor; + static bool showObstacle; static bool showWalls; static bool showExits; static bool showNavLines; @@ -209,6 +216,7 @@ private: static QColor floorColor; static QColor wallsColor; static QColor exitsColor; + static QColor obstacleColor; static QColor navLinesColor; static int ellipseResolution; static int pedestriansColor[3][3]; // 3 groups, and 3 color per groups diff --git a/src/ThreadVisualisation.cpp b/src/ThreadVisualisation.cpp index dfb7c007919da57d8b9f9fcbc0edcaf243d8e4c3..651bcb105da3f15b666cb26b503d8592892eb4b0 100644 --- a/src/ThreadVisualisation.cpp +++ b/src/ThreadVisualisation.cpp @@ -343,17 +343,18 @@ void ThreadVisualisation::run() setGeometryVisibility(SystemSettings::getShowGeometry()); setOnscreenInformationVisibility(SystemSettings::getOnScreenInfos()); showFloor(SystemSettings::getShowFloor()); - showWalls((SystemSettings::getShowWalls())); - showDoors((SystemSettings::getShowExits())); - showNavLines((SystemSettings::getShowNavLines())); + showWalls(SystemSettings::getShowWalls()); + showObstacle(SystemSettings::getShowObstacles()); + showDoors(SystemSettings::getShowExits()); + showNavLines(SystemSettings::getShowNavLines()); setGeometryLabelsVisibility(SystemSettings::getShowGeometryCaptions()); setBackgroundColor(SystemSettings::getBackgroundColor()); setWallsColor(SystemSettings::getWallsColor()); + setObstacleColor(SystemSettings::getObstacleColor()); setFloorColor(SystemSettings::getFloorColor()); setExitsColor(SystemSettings::getExitsColor()); setNavLinesColor(SystemSettings::getNavLinesColor()); - _renderWinInteractor->Start(); @@ -431,6 +432,10 @@ void ThreadVisualisation::showFloor(bool status) { _geometry.ShowFloor(status); } +void ThreadVisualisation::showObstacle(bool status) +{ + _geometry.ShowObstacles(status); +} void ThreadVisualisation::initGlyphs2D() { @@ -793,6 +798,13 @@ void ThreadVisualisation::setFloorColor(const QColor &color) _geometry.ChangeFloorColor(rbgColor); } +void ThreadVisualisation::setObstacleColor(const QColor &color) +{ + double rbgColor[3]; + QcolorToDouble(color,rbgColor); + _geometry.ChangeObstaclesColor(rbgColor); +} + void ThreadVisualisation::setGeometryLabelsVisibility(int v) { _geometry.ShowGeometryLabels(v); diff --git a/src/ThreadVisualisation.h b/src/ThreadVisualisation.h index 12eab0aef5107b9709e958fa02c565f4a77f7ccc..f47c146fa8e6aa13d14fc577c0ed18c6780b1214 100644 --- a/src/ThreadVisualisation.h +++ b/src/ThreadVisualisation.h @@ -122,6 +122,9 @@ public: /// change the floor color void setFloorColor(const QColor &color); + /// change the obstacle color + void setObstacleColor(const QColor &color); + /// change the exits color. void setExitsColor(const QColor &color); @@ -140,6 +143,10 @@ public: /// show/ hide the floor void showFloor(bool status); + /// show/ hide the obstacles + void showObstacle(bool status); + + /// show / hide stairs ///not implemented void showStairs(bool status); diff --git a/src/geometry/GeometryFactory.h b/src/geometry/GeometryFactory.h index f6fc74a3632c5e9308674f701e2b5a9b0a5b91bc..112cf4f562d65d57f6cda5e77e0d7bda33b49ad4 100644 --- a/src/geometry/GeometryFactory.h +++ b/src/geometry/GeometryFactory.h @@ -30,6 +30,7 @@ public: void ShowWalls(bool status); void ShowNavLines(bool status); void ShowFloor(bool status); + void ShowObstacles(bool status); void ShowGeometryLabels(int status); bool RefreshView(); void Clear();