Scene::Item_id Scene::erase(Scene::Item_id index) { clear(); index_map.clear(); if(index < 0 || index >= m_entries.size()) return -1; CGAL::Three::Scene_item* item = m_entries[index]; CGAL::Three::Scene_group_item* group = qobject_cast<CGAL::Three::Scene_group_item*>(item); if(group) { m_group_entries.removeAll(group); } Q_FOREACH(CGAL::Three::Scene_group_item* group, m_group_entries) { if(group->getChildren().contains(item)) group->removeChild(item); } Q_EMIT itemAboutToBeDestroyed(item); item->deleteLater(); m_entries.removeAll(item); selected_item = -1; Q_FOREACH(Scene_item* item, m_entries) { organize_items(item, invisibleRootItem(), 0); }
Scene::Item_id Scene::erase(Scene::Item_id index) { CGAL::Three::Scene_item* item = m_entries[index]; if(item->parentGroup() && item->parentGroup()->isChildLocked(item)) return -1; //clears the Scene_view clear(); index_map.clear(); if(index < 0 || index >= m_entries.size()) return -1; if(item->parentGroup()) item->parentGroup()->removeChild(item); //removes the item from all groups that contain it Q_EMIT itemAboutToBeDestroyed(item); item->deleteLater(); m_entries.removeAll(item); selected_item = -1; //re-creates the Scene_view Q_FOREACH(Scene_item* item, m_entries) { organize_items(item, invisibleRootItem(), 0); }