From d3d99396f58a6558b073c9c5295ee7b7b34d0ed2 Mon Sep 17 00:00:00 2001
From: roangel <roangel@student.ethz.ch>
Date: Tue, 15 Aug 2017 14:03:06 +0200
Subject: [PATCH] Now its working perfectly apparently. Problem was only that
 current changed function

---
 .../GUI_Qt/CrazyFlyGUI/src/mainguiwindow.cpp  | 92 +++++++++----------
 pps_ws/src/d_fall_pps/param/Crazyflie.db      |  5 +-
 2 files changed, 48 insertions(+), 49 deletions(-)

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 e92508fb..c2ba86f1 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
@@ -73,39 +73,39 @@ void MainGUIWindow::doNumCrazyFlyZonesChanged(int n)
     // first check if size of tabs is greater than size of vector or viceversa. Have we removed or added a zone?
 
     qDebug("tabWidgetCount : %d", ui->tabWidget->count());
-    // if(ui->tabWidget->count() > scene->crazyfly_zones.size())
-    // {
-    //     // we removed one crazyfly_zone, n means index of the one we removed. Look for that index tab and remove it
-    //     QString qstr = "CrazyFly ";
-    //     qstr.append(QString::number(n+1));
-    //     if(scene->crazyfly_zones.size() == 0)
-    //     {
-    //         ui->tabWidget->clear();
-    //     }
-    //     int found_index = getTabIndexFromName(qstr);
-    //     if(found_index != -1)
-    //     {
-    //         ui->tabWidget->widget(found_index)->deleteLater();
-    //         // ui->tabWidget->removeTab(found_index);
-    //     }
-
-    //     //  now unlink it from table also:
-    //     #ifdef CATKIN_MAKE
-    //     if(cf_linker->isCFZoneLinked(n))
-    //     {
-    //         cf_linker->unlink_cf_zone(n);
-    //     }
-    //     #endif
-    // }
-    // else if(ui->tabWidget->count() < scene->crazyfly_zones.size())
-    // {
-    //     // we added one crazyfly_zone, n means index of the new one. New tab will be labeld index + 1
-    //     QString qstr = "CrazyFly ";
-    //     qstr.append(QString::number(n+1));
-    //     crazyFlyZoneTab* widget = new crazyFlyZoneTab(n);
-    //     ui->tabWidget->insertTab(n, widget, qstr);
-    //     connect(widget, SIGNAL(centerButtonClickedSignal(int)), this, SLOT(centerViewIndex(int)));
-    // }
+    if(ui->tabWidget->count() > scene->crazyfly_zones.size())
+    {
+        // we removed one crazyfly_zone, n means index of the one we removed. Look for that index tab and remove it
+        QString qstr = "CrazyFly ";
+        qstr.append(QString::number(n+1));
+        if(scene->crazyfly_zones.size() == 0)
+        {
+            ui->tabWidget->clear();
+        }
+        int found_index = getTabIndexFromName(qstr);
+        if(found_index != -1)
+        {
+            ui->tabWidget->widget(found_index)->deleteLater();
+            // ui->tabWidget->removeTab(found_index);
+        }
+
+        //  now unlink it from table also:
+        #ifdef CATKIN_MAKE
+        if(cf_linker->isCFZoneLinked(n))
+        {
+            cf_linker->unlink_cf_zone(n);
+        }
+        #endif
+    }
+    else if(ui->tabWidget->count() < scene->crazyfly_zones.size())
+    {
+        // we added one crazyfly_zone, n means index of the new one. New tab will be labeld index + 1
+        QString qstr = "CrazyFly ";
+        qstr.append(QString::number(n+1));
+        crazyFlyZoneTab* widget = new crazyFlyZoneTab(n);
+        ui->tabWidget->insertTab(n, widget, qstr);
+        connect(widget, SIGNAL(centerButtonClickedSignal(int)), this, SLOT(centerViewIndex(int)));
+    }
 
     // for(int index = 0; index < ui->tabWidget->count(); index++)
     // {
@@ -116,20 +116,20 @@ void MainGUIWindow::doNumCrazyFlyZonesChanged(int n)
     // // unlink all?
     // // cf_linker->clear_all_links();
 
-    ui->tabWidget->clear();
+    // ui->tabWidget->clear();
 
-    for(int i = 0; i < scene->crazyfly_zones.size(); i++)
-    {
-        ROS_INFO("inside for loop");
-        QString qstr = "CrazyFly ";
-        int CF_index = scene->crazyfly_zones[i]->getIndex();
-        qstr.append(QString::number(CF_index + 1));
-        crazyFlyZoneTab* widget = new crazyFlyZoneTab(i);
-        // ui->tabWidget->insertTab(i, widget, qstr);
-        ui->tabWidget->addTab(widget, qstr);
-        ROS_INFO("Added tab");
-        connect(widget, SIGNAL(centerButtonClickedSignal(int)), this, SLOT(centerViewIndex(int)));
-    }
+    // for(int i = 0; i < scene->crazyfly_zones.size(); i++)
+    // {
+    //     ROS_INFO("inside for loop");
+    //     QString qstr = "CrazyFly ";
+    //     int CF_index = scene->crazyfly_zones[i]->getIndex();
+    //     qstr.append(QString::number(CF_index + 1));
+    //     crazyFlyZoneTab* widget = new crazyFlyZoneTab(i);
+    //     // ui->tabWidget->insertTab(i, widget, qstr);
+    //     ui->tabWidget->addTab(widget, qstr);
+    //     ROS_INFO("Added tab");
+    //     connect(widget, SIGNAL(centerButtonClickedSignal(int)), this, SLOT(centerViewIndex(int)));
+    // }
 
 
     // for(int i = 0; i < n; i++)
diff --git a/pps_ws/src/d_fall_pps/param/Crazyflie.db b/pps_ws/src/d_fall_pps/param/Crazyflie.db
index ae58bf59..8b5dace7 100644
--- a/pps_ws/src/d_fall_pps/param/Crazyflie.db
+++ b/pps_ws/src/d_fall_pps/param/Crazyflie.db
@@ -1,3 +1,2 @@
-2,CF1,123,0,0.66,0.11,-0.2,3.46,1.76,2
-1,CF2,1234,1,0.78,-2.09,-0.2,3.38,-0.45,2
-5,CF3,12346,2,3.94,-1.07,-0.2,5.33,0.81,2
+2,CF1,1,0,0.52,0.41,-0.2,1.56,1.55,2
+1,CF2,3,1,-1.15,-0.69,-0.2,0.94,0.46,2
-- 
GitLab