From 8a155b4f5d9ae8e52db139ae674221cedca4aa7c Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 8 Feb 2016 15:29:30 +0100 Subject: [PATCH] The scene performs a check on the item to insure it is able to display its primitive IDs. --- Polyhedron/demo/Polyhedron/Scene.cpp | 15 +++++++++++++-- Three/include/CGAL/Three/Scene_item.h | 2 +- .../CGAL/Three/Scene_item_print_interface.h | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Scene.cpp b/Polyhedron/demo/Polyhedron/Scene.cpp index e56bec4bb38..965b852ff56 100644 --- a/Polyhedron/demo/Polyhedron/Scene.cpp +++ b/Polyhedron/demo/Polyhedron/Scene.cpp @@ -5,6 +5,7 @@ #include "config.h" #include "Scene.h" #include +#include #include #include @@ -1141,13 +1142,23 @@ void Scene::printPrimitiveId(QPoint point, CGAL::Three::Viewer_interface* viewer { Scene_item *it = item(mainSelectionIndex()); if(it) - it->printPrimitiveId(point, viewer); + { + //Only call printPrimitiveId if the item is a Scene_item_print_interface + Scene_item_print_interface* item= dynamic_cast(it); + if(item) + item->printPrimitiveId(point, viewer); + } } void Scene::printPrimitiveIds(CGAL::Three::Viewer_interface* viewer) { Scene_item *it = item(mainSelectionIndex()); if(it) - it->printPrimitiveIds(viewer); + { + //Only call printPrimitiveIds if the item is a Scene_item_print_interface + Scene_item_print_interface* item= dynamic_cast(it); + if(item) + item->printPrimitiveIds(viewer); + } } bool Scene::testDisplayId(double x, double y, double z, CGAL::Three::Viewer_interface* viewer) { diff --git a/Three/include/CGAL/Three/Scene_item.h b/Three/include/CGAL/Three/Scene_item.h index aceea6b8479..c5a1a9bcc78 100644 --- a/Three/include/CGAL/Three/Scene_item.h +++ b/Three/include/CGAL/Three/Scene_item.h @@ -47,7 +47,7 @@ namespace Three { class Scene_group_item; class Viewer_interface; //! This class represents an object in the OpenGL scene -class SCENE_ITEM_EXPORT Scene_item : public QObject, CGAL::Three::Scene_item_print_interface { +class SCENE_ITEM_EXPORT Scene_item : public QObject, public CGAL::Three::Scene_item_print_interface { Q_OBJECT Q_PROPERTY(QColor color READ color WRITE setColor) Q_PROPERTY(QString name READ name WRITE setName) diff --git a/Three/include/CGAL/Three/Scene_item_print_interface.h b/Three/include/CGAL/Three/Scene_item_print_interface.h index c2020421fc6..9d283d76be9 100644 --- a/Three/include/CGAL/Three/Scene_item_print_interface.h +++ b/Three/include/CGAL/Three/Scene_item_print_interface.h @@ -26,7 +26,7 @@ namespace Three { class Viewer_interface; -//! Base class to allow an item to print ts primitive. +//! Base class to allow an item to print its primitive IDs. class Scene_item_print_interface { public: virtual ~Scene_item_print_interface(){}