From 70fa002ca6439dea2e4dd4baf22aca2b9d0c0c2e Mon Sep 17 00:00:00 2001 From: roangel <roangel@student.ethz.ch> Date: Fri, 26 May 2017 11:51:09 +0200 Subject: [PATCH] fixed problem removing cf zones? --- .../CrazyFlyGUI/include/myGraphicsScene.h | 2 +- .../GUI_Qt/CrazyFlyGUI/src/mainguiwindow.cpp | 4 ++-- .../GUI_Qt/CrazyFlyGUI/src/myGraphicsScene.cpp | 18 ++++++++++++------ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/include/myGraphicsScene.h b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/include/myGraphicsScene.h index 2418484d..c9691a58 100755 --- a/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/include/myGraphicsScene.h +++ b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/include/myGraphicsScene.h @@ -45,7 +45,7 @@ public: void removeTable(); public slots: - void removeCrazyFlyZone(int index); + void removeCrazyFlyZone(int cf_zone_index); void setSelectedCrazyFlyZone(int index); void changeModeTo(int next_mode); diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/mainguiwindow.cpp b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/mainguiwindow.cpp index 601d24db..138331a3 100755 --- a/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/mainguiwindow.cpp +++ b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/mainguiwindow.cpp @@ -186,8 +186,8 @@ void MainGUIWindow::_init() void MainGUIWindow::doTabClosed(int tab_index) { QString name = ui->tabWidget->tabText(tab_index); - int cf_index = cf_linker->getCFZoneIndexFromName(name); - scene->removeCrazyFlyZone(cf_index); + int cf_zone_index = cf_linker->getCFZoneIndexFromName(name); + scene->removeCrazyFlyZone(cf_zone_index); } void MainGUIWindow::setTabIndex(int index) diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/myGraphicsScene.cpp b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/myGraphicsScene.cpp index 4cf079ff..f38f8722 100755 --- a/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/myGraphicsScene.cpp +++ b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/myGraphicsScene.cpp @@ -321,13 +321,19 @@ QRectF myGraphicsScene::getRectFCrazyFlyZone(int index) return rect; } -void myGraphicsScene::removeCrazyFlyZone(int index) +void myGraphicsScene::removeCrazyFlyZone(int cf_zone_index) { - int n = crazyfly_zones[index]->getIndex(); - this->removeItem(crazyfly_zones[index]); - crazyfly_zones.erase(crazyfly_zones.begin() + index); - qDebug("removed CFzone %d", index); - emit numCrazyFlyZonesChanged(n); // for tab managing + for(int i = 0; i < crazyfly_zones.size(); i++) + { + if(crazyfly_zones[i]->getIndex() == cf_zone_index) + { + this->removeItem(crazyfly_zones[i]); + crazyfly_zones.erase(crazyfly_zones.begin() + i); + qDebug("removed CFzone %d", cf_zone_index); + emit numCrazyFlyZonesChanged(cf_zone_index); // for tab managing + break; + } + } } void myGraphicsScene::removeTable() -- GitLab