From 56486dbadd5e330626e084f845b7ad46026b2e6a Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 4 Apr 2016 10:13:21 +0200 Subject: [PATCH 1/3] Fix for the ctrl+space shortcut --- Polyhedron/demo/Polyhedron/MainWindow.cpp | 2 +- Three/include/CGAL/Three/Scene_item.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index a51f7301475..566f75d230e 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -1516,7 +1516,7 @@ void MainWindow::on_actionShowHide_triggered() { Q_FOREACH(QModelIndex index, sceneView->selectionModel()->selectedRows()) { - int i = proxyModel->mapToSource(index).row(); + int i = scene->getIdFromModelIndex(proxyModel->mapToSource(index)); CGAL::Three::Scene_item* item = scene->item(i); item->setVisible(!item->visible()); scene->itemChanged(i); diff --git a/Three/include/CGAL/Three/Scene_item.h b/Three/include/CGAL/Three/Scene_item.h index 37eafaae201..e0ddc3254b6 100644 --- a/Three/include/CGAL/Three/Scene_item.h +++ b/Three/include/CGAL/Three/Scene_item.h @@ -305,7 +305,7 @@ public Q_SLOTS: //!Setter for the name of the item. virtual void setName(QString n) { name_ = n; } //!Setter for the visibility of the item. - virtual void setVisible(bool b) { visible_ = b; } + virtual void setVisible(bool b) { visible_ = b; Q_EMIT itemChanged();} //!Setter for the rendering mode of the item. //!@see RenderingMode virtual void setRenderingMode(RenderingMode m) { From dfc2143b283a37c5d9a8f3f6c0dbf9c1c00af0db Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 4 Apr 2016 11:18:29 +0200 Subject: [PATCH 2/3] Fix for emit itemChanged() --- Polyhedron/demo/Polyhedron/Scene_group_item.cpp | 6 ++++-- Polyhedron/demo/Polyhedron/Scene_item.cpp | 8 ++++++++ Three/include/CGAL/Three/Scene_group_item.h | 2 +- Three/include/CGAL/Three/Scene_item.h | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Scene_group_item.cpp b/Polyhedron/demo/Polyhedron/Scene_group_item.cpp index 86d2b2269e5..61324f6a66e 100644 --- a/Polyhedron/demo/Polyhedron/Scene_group_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_group_item.cpp @@ -86,13 +86,15 @@ void Scene_group_item::setRenderingMode(RenderingMode m) } } -void Scene_group_item::setVisible(bool b) +void Scene_group_item::setVisible(bool b, bool does_emit) { Scene_item::setVisible(b); Q_FOREACH(Scene_item* child, children) { - child->setVisible(b); + child->setVisible(b, true); } + if(does_emit) + Q_EMIT itemChanged(); } bool Scene_group_item::isExpanded() const diff --git a/Polyhedron/demo/Polyhedron/Scene_item.cpp b/Polyhedron/demo/Polyhedron/Scene_item.cpp index c4ba9a84db7..dea57a01ae6 100644 --- a/Polyhedron/demo/Polyhedron/Scene_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_item.cpp @@ -104,6 +104,14 @@ QMenu* CGAL::Three::Scene_item::contextMenu() void CGAL::Three::Scene_item::invalidateOpenGLBuffers() {} void CGAL::Three::Scene_item::selection_changed(bool) {} +void CGAL::Three::Scene_item::setVisible(bool b, bool does_emit) +{ + visible_ = b; + if(does_emit) + { + Q_EMIT itemChanged(); + } +} void CGAL::Three::Scene_item::select(double /*orig_x*/, diff --git a/Three/include/CGAL/Three/Scene_group_item.h b/Three/include/CGAL/Three/Scene_group_item.h index bc4db1cc511..5a79e9e2f2c 100644 --- a/Three/include/CGAL/Three/Scene_group_item.h +++ b/Three/include/CGAL/Three/Scene_group_item.h @@ -70,7 +70,7 @@ public : //!Sets all the children in the specified rendering mode. void setRenderingMode(RenderingMode m); //!Sets all the children to the specified visibility. - void setVisible(bool b); + void setVisible(bool b, bool does_emit = false); //!Sets all the children in points mode. void setPointsMode() { setRenderingMode(Points); diff --git a/Three/include/CGAL/Three/Scene_item.h b/Three/include/CGAL/Three/Scene_item.h index e0ddc3254b6..84416f774c8 100644 --- a/Three/include/CGAL/Three/Scene_item.h +++ b/Three/include/CGAL/Three/Scene_item.h @@ -305,7 +305,7 @@ public Q_SLOTS: //!Setter for the name of the item. virtual void setName(QString n) { name_ = n; } //!Setter for the visibility of the item. - virtual void setVisible(bool b) { visible_ = b; Q_EMIT itemChanged();} + virtual void setVisible(bool b, bool does_emit = false); //!Setter for the rendering mode of the item. //!@see RenderingMode virtual void setRenderingMode(RenderingMode m) { From 386995bbdc235cee3a2efe9aed61d021874e4e6a Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 4 Apr 2016 16:53:17 +0200 Subject: [PATCH 3/3] Final fix for itemChanged calls --- Polyhedron/demo/Polyhedron/Scene_group_item.cpp | 6 +++--- Polyhedron/demo/Polyhedron/Scene_item.cpp | 6 +----- Three/include/CGAL/Three/Scene_group_item.h | 2 +- Three/include/CGAL/Three/Scene_item.h | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Scene_group_item.cpp b/Polyhedron/demo/Polyhedron/Scene_group_item.cpp index 61324f6a66e..faa5757f0bb 100644 --- a/Polyhedron/demo/Polyhedron/Scene_group_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_group_item.cpp @@ -86,14 +86,14 @@ void Scene_group_item::setRenderingMode(RenderingMode m) } } -void Scene_group_item::setVisible(bool b, bool does_emit) +void Scene_group_item::setVisible(bool b) { Scene_item::setVisible(b); Q_FOREACH(Scene_item* child, children) { - child->setVisible(b, true); + child->setVisible(b); + child->itemChanged(); } - if(does_emit) Q_EMIT itemChanged(); } diff --git a/Polyhedron/demo/Polyhedron/Scene_item.cpp b/Polyhedron/demo/Polyhedron/Scene_item.cpp index dea57a01ae6..4ac8bca89de 100644 --- a/Polyhedron/demo/Polyhedron/Scene_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_item.cpp @@ -104,13 +104,9 @@ QMenu* CGAL::Three::Scene_item::contextMenu() void CGAL::Three::Scene_item::invalidateOpenGLBuffers() {} void CGAL::Three::Scene_item::selection_changed(bool) {} -void CGAL::Three::Scene_item::setVisible(bool b, bool does_emit) +void CGAL::Three::Scene_item::setVisible(bool b) { visible_ = b; - if(does_emit) - { - Q_EMIT itemChanged(); - } } diff --git a/Three/include/CGAL/Three/Scene_group_item.h b/Three/include/CGAL/Three/Scene_group_item.h index 5a79e9e2f2c..bc4db1cc511 100644 --- a/Three/include/CGAL/Three/Scene_group_item.h +++ b/Three/include/CGAL/Three/Scene_group_item.h @@ -70,7 +70,7 @@ public : //!Sets all the children in the specified rendering mode. void setRenderingMode(RenderingMode m); //!Sets all the children to the specified visibility. - void setVisible(bool b, bool does_emit = false); + void setVisible(bool b); //!Sets all the children in points mode. void setPointsMode() { setRenderingMode(Points); diff --git a/Three/include/CGAL/Three/Scene_item.h b/Three/include/CGAL/Three/Scene_item.h index 84416f774c8..9e2cd98cf32 100644 --- a/Three/include/CGAL/Three/Scene_item.h +++ b/Three/include/CGAL/Three/Scene_item.h @@ -305,7 +305,7 @@ public Q_SLOTS: //!Setter for the name of the item. virtual void setName(QString n) { name_ = n; } //!Setter for the visibility of the item. - virtual void setVisible(bool b, bool does_emit = false); + virtual void setVisible(bool b); //!Setter for the rendering mode of the item. //!@see RenderingMode virtual void setRenderingMode(RenderingMode m) {