diff --git a/Polyhedron/demo/Polyhedron/Scene.cpp b/Polyhedron/demo/Polyhedron/Scene.cpp index 14d68665495..d667f6196f4 100644 --- a/Polyhedron/demo/Polyhedron/Scene.cpp +++ b/Polyhedron/demo/Polyhedron/Scene.cpp @@ -90,6 +90,8 @@ Scene::addItem(CGAL::Three::Scene_item* item) item->drawEdges(CGAL::Three::Three::mainViewer()); item->drawPoints(CGAL::Three::Three::mainViewer()); CGAL::Three::Three::mainViewer()->setDepthPeelingFbo(fbo); + if(group) + m_groups.append(id); return id; } @@ -110,6 +112,7 @@ Scene::replaceItem(Scene::Item_id index, CGAL::Three::Scene_item* item, bool emi QList group_children; if(group) { + m_groups.removeAll(index); Q_FOREACH(Item_id id, group->getChildren()) { CGAL::Three::Scene_item* child = group->getChild(id); @@ -152,6 +155,7 @@ Scene::replaceItem(Scene::Item_id index, CGAL::Three::Scene_item* item, bool emi if(group) { addGroup(group); + m_groups.append(index); } itemChanged(index); Q_EMIT restoreCollapsedState(); @@ -173,6 +177,7 @@ Scene::erase(Scene::Item_id index) setSelectedItemsList(QList()<parentGroup() && item->parentGroup()->isChildLocked(item)) return -1; @@ -248,6 +253,7 @@ Scene::erase(QList indices) item->parentGroup()->removeChild(item); children.removeAll(removed_item); indexErased(removed_item); + m_groups.removeAll(removed_item); m_entries.removeAll(item); Q_EMIT itemAboutToBeDestroyed(item); @@ -1344,9 +1350,15 @@ QItemSelection Scene::createSelectionAll() //it is not possible to directly create a selection with items that have different parents, so //we do it iteratively. QItemSelection sel; - for(int i=0; i< m_entries.size(); ++i) - sel.select(index_map.keys(i).at(0), - index_map.keys(i).at(4)); + sel.select(this->createIndex(0, 0), + this->createIndex(m_entries.size(), LastColumn)); + for(const auto& gid : m_groups) + { + CGAL::Three::Scene_group_item* group = + qobject_cast(item(gid)); + sel.select(index_map.keys(group->getChildren().first()).at(0), + index_map.keys(group->getChildren().last()).at(4)); + } return sel; } diff --git a/Polyhedron/demo/Polyhedron/Scene.h b/Polyhedron/demo/Polyhedron/Scene.h index 6240a255abf..61010a23513 100644 --- a/Polyhedron/demo/Polyhedron/Scene.h +++ b/Polyhedron/demo/Polyhedron/Scene.h @@ -64,6 +64,7 @@ public: int numberOfEntries() const Q_DECL_OVERRIDE; // returns the list of items. const QList& entries() const { return m_entries; } + Q_INVOKABLE CGAL::Three::Scene_item* item(int) const Q_DECL_OVERRIDE; int item_id(CGAL::Three::Scene_item*) const Q_DECL_OVERRIDE; @@ -280,6 +281,7 @@ private: typedef QList Entries; //List containing all the scene_items. Entries m_entries; + QList m_groups; //used to optimize createSelectionAll() QList children; // Index of the currently selected item. int selected_item;