Commit 26118972 authored by roangel's avatar roangel
Browse files

fixed some weird crash?

parent 470352ce
......@@ -818,8 +818,18 @@ void MainGUIWindow::on_load_from_DB_button_clicked()
{
ROS_INFO_STREAM("database:\n" << tmp_db);
m_data_base = tmp_db;
// TODO: update links table
cf_linker->clear_all_links();
// remove all cf_zones existing
for(int j = scene->crazyfly_zones.size() - 1; j >= 0; j--)
{
scene->removeCrazyFlyZone(scene->crazyfly_zones[j]->getIndex());
}
int size = scene->crazyfly_zones.size();
ROS_INFO("vector_cf_zones_size %d", size);
for(int i = 0; i < m_data_base.crazyflieEntries.size(); i++)
{
std::string cf_name = m_data_base.crazyflieEntries[i].crazyflieContext.crazyflieName;
......@@ -832,28 +842,14 @@ void MainGUIWindow::on_load_from_DB_button_clicked()
- 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 found_j;
for(int j = 0; j < scene->crazyfly_zones.size(); j++)
{
if(cf_zone_index == scene->crazyfly_zones[j]->getIndex())
{
cf_zone_exists = true;
found_j = j;
break;
}
}
if(!cf_zone_exists)
{
scene->addCFZone(tmp_rect, cf_zone_index);
}
else
{
scene->crazyfly_zones[found_j]->setPos(tmp_rect.topLeft());
// scene->crazyfly_zones[found_j]->setRect(tmp_rect);
scene->crazyfly_zones[found_j]->rectSizeChanged();
}
int student_id = m_data_base.crazyflieEntries[i].studentID;
scene->addCFZone(tmp_rect, cf_zone_index);
cf_linker->link(student_id, cf_zone_index, cf_name);
}
}
else
......
......@@ -103,7 +103,7 @@ void myGraphicsScene::addCFZone(QRectF rect, int index)
addCrazyFlyZoneToVector(tmp_crazyfly_zone_item);
std::string str = std::to_string(tmp_crazyfly_zone_item->getIndex() + 1);
tmp_crazyfly_zone_item->setLabel(str.c_str());
setSelectedCrazyFlyZone(crazyfly_zones.size() - 1); //select just created rectangle
// setSelectedCrazyFlyZone(crazyfly_zones.size() - 1); //select just created rectangle
}
void myGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
......@@ -207,6 +207,8 @@ void myGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
void myGraphicsScene::addCrazyFlyZoneToVector(crazyFlyZone* rect)
{
crazyfly_zones.push_back(rect);
int size = crazyfly_zones.size();
qDebug("size crazyflyzones %d", size);
emit numCrazyFlyZonesChanged(rect->getIndex());
}
......
2,CF1,,0,-1.18203,0.803384,0,-0.372033,1.94338,0
1,CF2,,1,-1.70283,2.03901,0,-1.15283,2.96901,0
1,CF1,,0,-0.58,1.22,0,0.97,1.89,0
2,CF2,,1,-0.19,0.15,0,0.85,0.96,0
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment