diff --git a/Polyhedron/demo/Polyhedron/Scene.cpp b/Polyhedron/demo/Polyhedron/Scene.cpp index 570cf69c23b..48b37b5bc2c 100644 --- a/Polyhedron/demo/Polyhedron/Scene.cpp +++ b/Polyhedron/demo/Polyhedron/Scene.cpp @@ -1203,6 +1203,18 @@ void Scene::printFaceIds(CGAL::Three::Viewer_interface* viewer) item->printFaceIds(viewer); } } + +void Scene::printAllIds(CGAL::Three::Viewer_interface* viewer) +{ + Scene_item *it = item(mainSelectionIndex()); + if(it) + { + //Only call printFaceIds if the item is a Scene_print_item_interface + Scene_print_item_interface* item= dynamic_cast(it); + if(item) + item->printAllIds(viewer); + } +} void Scene::updatePrimitiveIds(CGAL::Three::Viewer_interface* viewer, CGAL::Three::Scene_item* it) { if(it) diff --git a/Polyhedron/demo/Polyhedron/Scene.h b/Polyhedron/demo/Polyhedron/Scene.h index 7b544aa13f4..dc22b013fd4 100644 --- a/Polyhedron/demo/Polyhedron/Scene.h +++ b/Polyhedron/demo/Polyhedron/Scene.h @@ -88,6 +88,7 @@ public: void printVertexIds(CGAL::Three::Viewer_interface*) Q_DECL_OVERRIDE; void printEdgeIds(CGAL::Three::Viewer_interface*) Q_DECL_OVERRIDE; void printFaceIds(CGAL::Three::Viewer_interface*) Q_DECL_OVERRIDE; + void printAllIds(CGAL::Three::Viewer_interface*) Q_DECL_OVERRIDE; //!Re-computes the primitiveIds for `item` void updatePrimitiveIds(Viewer_interface *, Scene_item *item) Q_DECL_OVERRIDE; bool testDisplayId(double x, double y, double z, CGAL::Three::Viewer_interface* viewer) Q_DECL_OVERRIDE; diff --git a/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.cpp b/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.cpp index c6e600c331d..8f23a16c317 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.cpp @@ -119,6 +119,7 @@ struct Scene_polyhedron_item_priv{ vertices_displayed = false; edges_displayed = false; faces_displayed = false; + all_primitives_displayed = false; invalidate_stats(); } @@ -173,6 +174,7 @@ struct Scene_polyhedron_item_priv{ mutable bool vertices_displayed; mutable bool edges_displayed; mutable bool faces_displayed; + mutable bool all_primitives_displayed; mutable QList text_ids; mutable TextItem* targeted_id; void initialize_buffers(CGAL::Three::Viewer_interface *viewer = 0) const; @@ -922,7 +924,7 @@ init() max = (std::max)(max, fit->patch_id()); min = (std::min)(min, fit->patch_id()); } - + colors_.clear(); compute_color_map(item->color(), (std::max)(0, max + 1 - min), std::back_inserter(colors_)); @@ -1073,23 +1075,30 @@ QMenu* Scene_polyhedron_item::contextMenu() menu->addAction(tr("Display Vertices Ids")); actionPrintVertices->setCheckable(true); actionPrintVertices->setObjectName("actionPrintVertices"); - connect(actionPrintVertices, SIGNAL(toggled(bool)), + connect(actionPrintVertices, SIGNAL(triggered(bool)), this, SLOT(showVertices(bool))); QAction* actionPrintEdges= menu->addAction(tr("Display Edges Ids")); actionPrintEdges->setCheckable(true); actionPrintEdges->setObjectName("actionPrintEdges"); - connect(actionPrintEdges, SIGNAL(toggled(bool)), + connect(actionPrintEdges, SIGNAL(triggered(bool)), this, SLOT(showEdges(bool))); QAction* actionPrintFaces= menu->addAction(tr("Display Faces Ids")); actionPrintFaces->setCheckable(true); actionPrintFaces->setObjectName("actionPrintFaces"); - connect(actionPrintFaces, SIGNAL(toggled(bool)), + connect(actionPrintFaces, SIGNAL(triggered(bool)), this, SLOT(showFaces(bool))); + QAction* actionPrintAll= + menu->addAction(tr("Display All Ids")); + actionPrintAll->setCheckable(true); + actionPrintAll->setObjectName("actionPrintAll"); + connect(actionPrintAll, SIGNAL(triggered(bool)), + this, SLOT(showPrimitives(bool))); + QAction* actionZoomToId= menu->addAction(tr("Zoom to Index")); actionZoomToId->setObjectName("actionZoomToId"); @@ -1146,6 +1155,15 @@ QMenu* Scene_polyhedron_item::contextMenu() if(action) action->setChecked(d->facet_picking_m); action = menu->findChild("actionEraseNextFacet"); if(action) action->setChecked(d->erase_next_picked_facet_m); + action = menu->findChild("actionPrintVertices"); + if(action) action->setChecked(d->vertices_displayed); + action = menu->findChild("actionPrintEdges"); + if(action) action->setChecked(d->edges_displayed); + action = menu->findChild("actionPrintFaces"); + if(action) action->setChecked(d->faces_displayed); + action = menu->findChild("actionPrintAll"); + if(action) action->setChecked(d->all_primitives_displayed); + return menu; } void Scene_polyhedron_item::show_only_feature_edges(bool b) @@ -1579,7 +1597,7 @@ QString Scene_polyhedron_item::computeStats(int type) case NB_FACETS: return QString::number(d->poly->size_of_facets()); - + case NB_CONNECTED_COMPOS: { typedef boost::graph_traits::face_descriptor face_descriptor; @@ -1881,7 +1899,7 @@ void Scene_polyhedron_item::printPrimitiveId(QPoint point, CGAL::Three::Viewer_i } } } -void Scene_polyhedron_item::printVertexIds(CGAL::Three::Viewer_interface *viewer) const +bool Scene_polyhedron_item::printVertexIds(CGAL::Three::Viewer_interface *viewer) const { TextRenderer *renderer = viewer->textRenderer(); if(!d->vertices_displayed) @@ -1903,7 +1921,10 @@ void Scene_polyhedron_item::printVertexIds(CGAL::Three::Viewer_interface *viewer //add the QList to the render's pool renderer->addTextList(textVItems); if(textVItems->size() > static_cast(renderer->getMax_textItems())) - d->vertices_displayed = !d->vertices_displayed; + { + textVItems->clear(); + return false; + } } else { @@ -1918,8 +1939,9 @@ void Scene_polyhedron_item::printVertexIds(CGAL::Three::Viewer_interface *viewer } d->vertices_displayed = !d->vertices_displayed; viewer->update(); + return true; } -void Scene_polyhedron_item::printEdgeIds(CGAL::Three::Viewer_interface *viewer) const +bool Scene_polyhedron_item::printEdgeIds(CGAL::Three::Viewer_interface *viewer) const { TextRenderer *renderer = viewer->textRenderer(); if(!d->edges_displayed) @@ -1940,7 +1962,10 @@ void Scene_polyhedron_item::printEdgeIds(CGAL::Three::Viewer_interface *viewer) //add the QList to the render's pool renderer->addTextList(textEItems); if(textEItems->size() > static_cast(renderer->getMax_textItems())) - d->edges_displayed = !d->edges_displayed; + { + textEItems->clear(); + return false; + } } else { @@ -1950,8 +1975,9 @@ void Scene_polyhedron_item::printEdgeIds(CGAL::Three::Viewer_interface *viewer) } d->edges_displayed = !d->edges_displayed; viewer->update(); + return true; } -void Scene_polyhedron_item::printFaceIds(CGAL::Three::Viewer_interface *viewer) const +bool Scene_polyhedron_item::printFaceIds(CGAL::Three::Viewer_interface *viewer) const { TextRenderer *renderer = viewer->textRenderer(); if(!d->faces_displayed) @@ -1979,7 +2005,10 @@ void Scene_polyhedron_item::printFaceIds(CGAL::Three::Viewer_interface *viewer) //add the QList to the render's pool renderer->addTextList(textFItems); if(textFItems->size() > static_cast(renderer->getMax_textItems())) - d->faces_displayed = !d->faces_displayed; + { + textFItems->clear(); + return false; + } } else { @@ -1989,8 +2018,26 @@ void Scene_polyhedron_item::printFaceIds(CGAL::Three::Viewer_interface *viewer) } d->faces_displayed = !d->faces_displayed; viewer->update(); + return true; } +void Scene_polyhedron_item::printAllIds(CGAL::Three::Viewer_interface *viewer) +{ + static bool all_ids_displayed = false; + d->vertices_displayed = all_ids_displayed; + d->edges_displayed = all_ids_displayed; + d->faces_displayed = all_ids_displayed; + + all_ids_displayed = !all_ids_displayed; + bool s1(printVertexIds(viewer)), + s2(printEdgeIds(viewer)), + s3(printFaceIds(viewer)); + + if((s1 && s2 && s3)) + d->all_primitives_displayed = all_ids_displayed; + + +} bool Scene_polyhedron_item::testDisplayId(double x, double y, double z, CGAL::Three::Viewer_interface* viewer)const { const qglviewer::Vec offset = static_cast(QGLViewer::QGLViewerPool().first())->offset(); @@ -2239,6 +2286,12 @@ void Scene_polyhedron_item::showFaces(bool) printFaceIds(viewer); } +void Scene_polyhedron_item::showPrimitives(bool) +{ + CGAL::Three::Viewer_interface* viewer = + qobject_cast(QGLViewer::QGLViewerPool().first()); + printAllIds(viewer); +} void Scene_polyhedron_item::zoomToId() { bool ok; diff --git a/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.h b/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.h index 2cf4d497d2b..5e5eb272dc5 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.h @@ -133,9 +133,10 @@ public: bool isItemMulticolor(); void printPrimitiveId(QPoint point, CGAL::Three::Viewer_interface*viewer)Q_DECL_OVERRIDE; - void printVertexIds(CGAL::Three::Viewer_interface*)const Q_DECL_OVERRIDE; - void printEdgeIds(CGAL::Three::Viewer_interface*)const Q_DECL_OVERRIDE; - void printFaceIds(CGAL::Three::Viewer_interface*)const Q_DECL_OVERRIDE; + bool printVertexIds(CGAL::Three::Viewer_interface*)const Q_DECL_OVERRIDE; + bool printEdgeIds(CGAL::Three::Viewer_interface*)const Q_DECL_OVERRIDE; + bool printFaceIds(CGAL::Three::Viewer_interface*)const Q_DECL_OVERRIDE; + void printAllIds(CGAL::Three::Viewer_interface*) Q_DECL_OVERRIDE; bool testDisplayId(double x, double y, double z, CGAL::Three::Viewer_interface*)const Q_DECL_OVERRIDE; @@ -173,6 +174,7 @@ public Q_SLOTS: void showVertices(bool); void showEdges(bool); void showFaces(bool); + void showPrimitives(bool); void zoomToId(); Q_SIGNALS: diff --git a/Polyhedron/demo/Polyhedron/Viewer.cpp b/Polyhedron/demo/Polyhedron/Viewer.cpp index bf8f1303e05..7d1ae8e6a5e 100644 --- a/Polyhedron/demo/Polyhedron/Viewer.cpp +++ b/Polyhedron/demo/Polyhedron/Viewer.cpp @@ -519,9 +519,7 @@ void Viewer::keyPressEvent(QKeyEvent* e) } } else if(e->key() == Qt::Key_I && e->modifiers() & Qt::ControlModifier){ - d->scene->printVertexIds(this); - d->scene->printEdgeIds(this); - d->scene->printFaceIds(this); + d->scene->printAllIds(this); update(); return; } diff --git a/Three/include/CGAL/Three/Scene_draw_interface.h b/Three/include/CGAL/Three/Scene_draw_interface.h index 3b32c82da8f..a90a6c57caf 100644 --- a/Three/include/CGAL/Three/Scene_draw_interface.h +++ b/Three/include/CGAL/Three/Scene_draw_interface.h @@ -76,6 +76,8 @@ public: virtual void printEdgeIds(CGAL::Three::Viewer_interface*) = 0; ///\brief displays all the faces ids if there are less than max_textItems. virtual void printFaceIds(CGAL::Three::Viewer_interface*) = 0; + ///\brief displays all the primitive ids if there are less than max_textItems. + virtual void printAllIds(CGAL::Three::Viewer_interface*) = 0; //!\brief moves the camera orthogonally to the picked sface. //! diff --git a/Three/include/CGAL/Three/Scene_print_item_interface.h b/Three/include/CGAL/Three/Scene_print_item_interface.h index ea699a6e526..0c5c866529a 100644 --- a/Three/include/CGAL/Three/Scene_print_item_interface.h +++ b/Three/include/CGAL/Three/Scene_print_item_interface.h @@ -38,13 +38,19 @@ public: //! Prints all the vertices ids if their number is not too high. The limit is //! editable in the View menu of the application. - virtual void printVertexIds(CGAL::Three::Viewer_interface*) const= 0; + //! \returns `false` if the number of ids is too high to be displayed. + virtual bool printVertexIds(CGAL::Three::Viewer_interface*) const= 0; //! Prints all the edges ids if their number is not too high. The limit is //! editable in the View menu of the application. - virtual void printEdgeIds(CGAL::Three::Viewer_interface*) const= 0; + //! \returns `false` if the number of ids is too high to be displayed. + virtual bool printEdgeIds(CGAL::Three::Viewer_interface*) const= 0; //! Prints all the faces ids if their number is not too high. The limit is //! editable in the View menu of the application. - virtual void printFaceIds(CGAL::Three::Viewer_interface*) const= 0; + //! \returns `false` if the number of ids is too high to be displayed. + virtual bool printFaceIds(CGAL::Three::Viewer_interface*) const= 0; + //! Prints all the primitive ids if their number is not too high. The limit is + //! editable in the View menu of the application. + virtual void printAllIds(CGAL::Three::Viewer_interface*) = 0; //! \brief Tests if an id should be displayed or not. //! //! \returns true if the Id should be displayed