diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/CFLinker.cpp b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/CFLinker.cpp index 9ee8fdbbd982b308e377140753dc888063e2b70b..e928ed027c34f02ecd62ddc9b3297b62246fb184 100644 --- a/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/CFLinker.cpp +++ b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/CFLinker.cpp @@ -164,11 +164,17 @@ void CFLinker::link(int student_id, int cf_zone_index, std::string cf_name, std: links.push_back(tmp_link); // TODO: remove options linked from available ones + // Get the index of the currently selected CF int index = m_ui->comboBoxCFs->currentIndex(); - // remove items + // Remove item from the CF Combo Box m_ui->comboBoxCFs->removeItem(index); - index = m_ui->comboBoxCFZones->currentIndex(); - m_ui->comboBoxCFZones->removeItem(index); + + + // THIS WAS COMMENTED OUT TO ALLOW ASSIGNING MULTIPLE CRAYZFLIES TO ONE ZONE + // Get the index of the currently selected CF + //index = m_ui->comboBoxCFZones->currentIndex(); + // Remove item from the CF Combo Box + //m_ui->comboBoxCFZones->removeItem(index); // disable item // m_ui->comboBoxCFs->setItemData(index, 0, Qt::UserRole - 1); 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 f0c79b5bc2d296ed2428f666833301a1bd780886..32ab1cdfc35e523e06ae0bd1e00c3fc25b2d262c 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 @@ -306,13 +306,14 @@ void MainGUIWindow::updateComboBoxesCFZones() #ifdef CATKIN_MAKE for(int i = 0; i < scene->crazyfly_zones.size(); i++) { - if(!cf_linker->isCFZoneLinked(scene->crazyfly_zones[i]->getIndex())) - { + // THIS IF CHECK WAS COMMENTED OUT TO ALLOW ASSIGNING MULTIPLE CRAYZFLIES TO ONE ZONE + //if(!cf_linker->isCFZoneLinked(scene->crazyfly_zones[i]->getIndex())) + //{ int cf_zone_index = scene->crazyfly_zones[i]->getIndex(); QString qstr = "CrazyFlyZone "; qstr.append(QString::number(cf_zone_index + 1)); ui->comboBoxCFZones->addItem(qstr); - } + //} } #endif } @@ -946,27 +947,54 @@ void MainGUIWindow::on_load_from_DB_button_clicked() for(int i = 0; i < m_data_base.crazyflieEntries.size(); i++) { + // Get the CF name from the database std::string cf_name = m_data_base.crazyflieEntries[i].crazyflieContext.crazyflieName; + // Get the radio address from the database std::string radio_address = m_data_base.crazyflieEntries[i].crazyflieContext.crazyflieAddress; + // Get the CF Zone Index from the database int cf_zone_index = m_data_base.crazyflieEntries[i].crazyflieContext.localArea.crazyfly_zone_index; - // we should first create the cf zones that are in the database? - bool cf_zone_exists; - qreal width = m_data_base.crazyflieEntries[i].crazyflieContext.localArea.xmax - m_data_base.crazyflieEntries[i].crazyflieContext.localArea.xmin; - qreal height = m_data_base.crazyflieEntries[i].crazyflieContext.localArea.ymax - m_data_base.crazyflieEntries[i].crazyflieContext.localArea.ymin; - QRectF tmp_rect(m_data_base.crazyflieEntries[i].crazyflieContext.localArea.xmin * FROM_METERS_TO_UNITS, - - m_data_base.crazyflieEntries[i].crazyflieContext.localArea.ymax * FROM_METERS_TO_UNITS, // minus sign because qt has y-axis inverted - width * FROM_METERS_TO_UNITS, - height * FROM_METERS_TO_UNITS); - int student_id = m_data_base.crazyflieEntries[i].studentID; - - - scene->addCFZone(tmp_rect, cf_zone_index); + // THIS WAS ADDED TO ALLOW ASSIGNING MULTIPLE CRAYZFLIES TO ONE ZONE + // Check if a Zone with this index already exists. + bool cf_zone_exists; + scene->crazyfly_zones.size(); + for(int i = 0; i < scene->crazyfly_zones.size(); i++) + { + int existing_cf_zone_index = scene->crazyfly_zones[i]->getIndex(); + if (cf_zone_index==existing_cf_zone_index) + { + cf_zone_exists = true; + } + } + // we should first create the cf zones that are in the database? + if (!cf_zone_exists) + { + // Get the size of this Zone from the database + qreal width = m_data_base.crazyflieEntries[i].crazyflieContext.localArea.xmax - m_data_base.crazyflieEntries[i].crazyflieContext.localArea.xmin; + qreal height = m_data_base.crazyflieEntries[i].crazyflieContext.localArea.ymax - m_data_base.crazyflieEntries[i].crazyflieContext.localArea.ymin; + // Create a rectangle for disaplying the zone + QRectF tmp_rect(m_data_base.crazyflieEntries[i].crazyflieContext.localArea.xmin * FROM_METERS_TO_UNITS, + - m_data_base.crazyflieEntries[i].crazyflieContext.localArea.ymax * FROM_METERS_TO_UNITS, // minus sign because qt has y-axis inverted + width * FROM_METERS_TO_UNITS, + height * FROM_METERS_TO_UNITS); + // Add the zone to the scene + scene->addCFZone(tmp_rect, cf_zone_index); + } + + // Get the student ID for this entry in the database + int student_id = m_data_base.crazyflieEntries[i].studentID; + + // Create the link cf_linker->link(student_id, cf_zone_index, cf_name, radio_address); } + + + // THIS WAS ADDED TO ALLOW ASSIGNING MULTIPLE CRAYZFLIES TO ONE ZONE + // Update the CF Zone combo box with the zones just added + updateComboBoxesCFZones(); } else { diff --git a/pps_ws/src/d_fall_pps/param/Crazyflie.db b/pps_ws/src/d_fall_pps/param/Crazyflie.db index 5e0a39201708c4aae0f2b97c1f3510773788f738..1543fc531957685254699294e839d02f14b6376d 100644 --- a/pps_ws/src/d_fall_pps/param/Crazyflie.db +++ b/pps_ws/src/d_fall_pps/param/Crazyflie.db @@ -1 +1,3 @@ -7,PPS_CF01,0/0/2M/E7E7E7E701,0,1.56976,-0.10861,-0.2,2.79907,0.808677,1.2 +1,PPS_CF05,0/32/2M/E7E7E7E705,0,-1.97017,-1.2375,-0.2,2.11699,0.911783,1.2 +2,PPS_CF06,0/40/2M/E7E7E7E706,0,-1.97017,-1.2375,-0.2,2.11699,0.911783,1.2 +3,PPS_CF07,0/48/2M/E7E7E7E707,0,-1.97017,-1.2375,-0.2,2.11699,0.911783,1.2