From e99655ab87e1cc0b03a92f7ec465dd186de2b7fa Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 2 Aug 2016 11:48:44 +0200 Subject: [PATCH 1/3] Add a renderingMode to distinguish between ShadedPoints and regular Points. --- Polyhedron/demo/Polyhedron/Scene.cpp | 3 ++- Polyhedron/demo/Polyhedron/Scene_item.cpp | 4 ++++ .../demo/Polyhedron/Scene_points_with_normal_item.cpp | 9 ++++++--- Three/include/CGAL/Three/Scene_interface.h | 4 ++-- Three/include/CGAL/Three/Scene_item.h | 4 ++++ 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Scene.cpp b/Polyhedron/demo/Polyhedron/Scene.cpp index 332f5dbf2cc..aa1ce0fce4e 100644 --- a/Polyhedron/demo/Polyhedron/Scene.cpp +++ b/Polyhedron/demo/Polyhedron/Scene.cpp @@ -482,7 +482,8 @@ Scene::draw_aux(bool with_names, CGAL::Three::Viewer_interface* viewer) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } if(item.renderingMode() == Points || - (!with_names && item.renderingMode() == PointsPlusNormals)) + (!with_names && item.renderingMode() == PointsPlusNormals) || + (!with_names && item.renderingMode() == ShadedPoints)) { viewer->glDisable(GL_LIGHTING); viewer->glPointSize(2.0f); diff --git a/Polyhedron/demo/Polyhedron/Scene_item.cpp b/Polyhedron/demo/Polyhedron/Scene_item.cpp index eb451622e4f..c065c3b13bd 100644 --- a/Polyhedron/demo/Polyhedron/Scene_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_item.cpp @@ -64,6 +64,8 @@ QString modeName(RenderingMode mode) { { case Points: return QObject::tr("points"); + case ShadedPoints: + return QObject::tr("shaded points"); case Wireframe: return QObject::tr("wire"); case Flat: @@ -87,6 +89,8 @@ const char* slotName(RenderingMode mode) { { case Points: return SLOT(setPointsMode()); + case ShadedPoints: + return SLOT(setShadedPointsMode()); case Wireframe: return SLOT(setWireframeMode()); case Flat: diff --git a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp index 50b43153b00..fafbc8ff7ea 100644 --- a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp @@ -538,7 +538,7 @@ bool Scene_points_with_normal_item::supportsRenderingMode(RenderingMode m) const { return m==Points || ( has_normals() && - ( m==PointsPlusNormals || m==Splatting ) ); + ( m==PointsPlusNormals || m==ShadedPoints || m==Splatting ) ); } void Scene_points_with_normal_item::drawSplats(CGAL::Three::Viewer_interface* viewer) const @@ -592,7 +592,7 @@ void Scene_points_with_normal_item::drawPoints(CGAL::Three::Viewer_interface* vi ratio_displayed = 3 * 300000. / (double)(d->nb_points + d->nb_selected_points); vaos[Scene_points_with_normal_item_priv::ThePoints]->bind(); - if(has_normals()) + if(has_normals() && renderingMode() == ShadedPoints) { d->program=getShaderProgram(PROGRAM_WITH_LIGHT); attribBuffers(viewer,PROGRAM_WITH_LIGHT); @@ -604,13 +604,16 @@ void Scene_points_with_normal_item::drawPoints(CGAL::Three::Viewer_interface* vi } d->program->bind(); d->program->setAttributeValue("colors", this->color()); + if(renderingMode() != ShadedPoints) + d->program->setAttributeValue("normals", QVector3D(0,0,0)); + viewer->glDrawArrays(GL_POINTS, 0, static_cast(((std::size_t)(ratio_displayed * d->nb_points)/3))); vaos[Scene_points_with_normal_item_priv::ThePoints]->release(); d->program->release(); vaos[Scene_points_with_normal_item_priv::Selected_points]->bind(); - if(has_normals()) + if(has_normals() && renderingMode() == ShadedPoints) { d->program=getShaderProgram(PROGRAM_WITH_LIGHT); attribBuffers(viewer,PROGRAM_WITH_LIGHT); diff --git a/Three/include/CGAL/Three/Scene_interface.h b/Three/include/CGAL/Three/Scene_interface.h index b4231f22398..914ff21f64b 100644 --- a/Three/include/CGAL/Three/Scene_interface.h +++ b/Three/include/CGAL/Three/Scene_interface.h @@ -45,13 +45,13 @@ class Scene_group_item; */ enum RenderingMode { Points = 0, PointsPlusNormals, + ShadedPoints, Splatting, Wireframe, Flat, FlatPlusEdges, Gouraud, - LastRenderingMode = Gouraud, - NumberOfRenderingMode = LastRenderingMode+1 }; + NumberOfRenderingMode}; namespace CGAL { diff --git a/Three/include/CGAL/Three/Scene_item.h b/Three/include/CGAL/Three/Scene_item.h index fe47b51773e..52d4c7dc8f8 100644 --- a/Three/include/CGAL/Three/Scene_item.h +++ b/Three/include/CGAL/Three/Scene_item.h @@ -285,6 +285,10 @@ public Q_SLOTS: void setPointsMode() { setRenderingMode(Points); } + //!Sets the RenderingMode to Points. + void setShadedPointsMode() { + setRenderingMode(ShadedPoints); + } //!Sets the RenderingMode to Wireframe. void setWireframeMode() { setRenderingMode(Wireframe); From ff25c2bac6a14c08125e182c8518279156f852c1 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 9 Aug 2016 15:05:23 +0200 Subject: [PATCH 2/3] Move ShadedPoints in the enum to preserve some of the binary compatibility. --- Three/include/CGAL/Three/Scene_interface.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Three/include/CGAL/Three/Scene_interface.h b/Three/include/CGAL/Three/Scene_interface.h index 914ff21f64b..d51e90fadb1 100644 --- a/Three/include/CGAL/Three/Scene_interface.h +++ b/Three/include/CGAL/Three/Scene_interface.h @@ -45,12 +45,12 @@ class Scene_group_item; */ enum RenderingMode { Points = 0, PointsPlusNormals, - ShadedPoints, Splatting, Wireframe, Flat, FlatPlusEdges, Gouraud, + ShadedPoints, NumberOfRenderingMode}; From 0f36186509792108677e013fc82208736f004e97 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 5 Oct 2016 09:48:19 +0200 Subject: [PATCH 3/3] Update supportsRenderingMode for affected items. --- .../Scene_combinatorial_map_item.h | 2 +- Polyhedron/demo/Polyhedron/Scene_c2t3_item.h | 2 +- Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp | 2 +- Polyhedron/demo/Polyhedron/Scene_c3t3_item.h | 2 +- .../demo/Polyhedron/Scene_nef_polyhedron_item.h | 2 +- .../Polyhedron/Scene_points_with_normal_item.cpp | 14 +++++++++++--- .../demo/Polyhedron/Scene_polygon_soup_item.h | 2 +- Polyhedron/demo/Polyhedron/Scene_polyhedron_item.h | 2 +- .../Polyhedron/Scene_textured_polyhedron_item.h | 2 +- 9 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Operations_on_polyhedra/Scene_combinatorial_map_item.h b/Polyhedron/demo/Polyhedron/Plugins/Operations_on_polyhedra/Scene_combinatorial_map_item.h index 60a96455b6a..b90c6fe7805 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Operations_on_polyhedra/Scene_combinatorial_map_item.h +++ b/Polyhedron/demo/Polyhedron/Plugins/Operations_on_polyhedra/Scene_combinatorial_map_item.h @@ -41,7 +41,7 @@ public: QString toolTip() const; // Indicate if rendering mode is supported - virtual bool supportsRenderingMode(RenderingMode m) const { return (m != Gouraud && m!=PointsPlusNormals && m!=Splatting); } // CHECK THIS! + virtual bool supportsRenderingMode(RenderingMode m) const { return (m != Gouraud && m!=PointsPlusNormals && m!=Splatting && m!=ShadedPoints); } // CHECK THIS! //Event handling virtual bool keyPressEvent(QKeyEvent*); //drawing of the scene diff --git a/Polyhedron/demo/Polyhedron/Scene_c2t3_item.h b/Polyhedron/demo/Polyhedron/Scene_c2t3_item.h index 125fcedb5c1..673baa94630 100644 --- a/Polyhedron/demo/Polyhedron/Scene_c2t3_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_c2t3_item.h @@ -72,7 +72,7 @@ public: // Indicate if rendering mode is supported bool supportsRenderingMode(RenderingMode m) const { - return (m != Gouraud && m!=PointsPlusNormals && m!=Splatting); // CHECK THIS! + return (m != Gouraud && m!=PointsPlusNormals && m!=Splatting && m!=ShadedPoints); // CHECK THIS! } void draw() const { diff --git a/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp b/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp index 6795edcac9d..03e97e92b1b 100644 --- a/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp @@ -63,7 +63,7 @@ public : } // Indicates if rendering mode is supported bool supportsRenderingMode(RenderingMode m) const { - return (m != Gouraud && m != PointsPlusNormals && m != Splatting && m != Points); + return (m != Gouraud && m != PointsPlusNormals && m != Splatting && m != Points && m != ShadedPoints); } void initialize_buffers(CGAL::Three::Viewer_interface *viewer) { diff --git a/Polyhedron/demo/Polyhedron/Scene_c3t3_item.h b/Polyhedron/demo/Polyhedron/Scene_c3t3_item.h index 762700d7b3c..b6ff8276846 100644 --- a/Polyhedron/demo/Polyhedron/Scene_c3t3_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_c3t3_item.h @@ -100,7 +100,7 @@ public: // Indicate if rendering mode is supported bool supportsRenderingMode(RenderingMode m) const { - return (m != Gouraud && m != PointsPlusNormals && m != Splatting && m != Points); + return (m != Gouraud && m != PointsPlusNormals && m != Splatting && m != Points && m != ShadedPoints); } void draw(CGAL::Three::Viewer_interface* viewer) const; diff --git a/Polyhedron/demo/Polyhedron/Scene_nef_polyhedron_item.h b/Polyhedron/demo/Polyhedron/Scene_nef_polyhedron_item.h index 818c27ac7a0..8e7b07f2e49 100644 --- a/Polyhedron/demo/Polyhedron/Scene_nef_polyhedron_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_nef_polyhedron_item.h @@ -29,7 +29,7 @@ public: virtual void invalidateOpenGLBuffers(); virtual void selection_changed(bool); // Indicate if rendering mode is supported - virtual bool supportsRenderingMode(RenderingMode m) const { return m != Gouraud && m!=Splatting; } // CHECK THIS! + virtual bool supportsRenderingMode(RenderingMode m) const { return m != Gouraud && m!=Splatting && m!=ShadedPoints; } // CHECK THIS! // OpenGL drawing in a display list void direct_draw() const; diff --git a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp index fafbc8ff7ea..d106883002d 100644 --- a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp @@ -536,9 +536,17 @@ Scene_points_with_normal_item::toolTip() const bool Scene_points_with_normal_item::supportsRenderingMode(RenderingMode m) const { - return m==Points || - ( has_normals() && - ( m==PointsPlusNormals || m==ShadedPoints || m==Splatting ) ); + switch ( m ) + { + case Points: + case ShadedPoints: + case PointsPlusNormals: + case Splatting: + return true; + + default: + return false; + } } void Scene_points_with_normal_item::drawSplats(CGAL::Three::Viewer_interface* viewer) const diff --git a/Polyhedron/demo/Polyhedron/Scene_polygon_soup_item.h b/Polyhedron/demo/Polyhedron/Scene_polygon_soup_item.h index 96374c1b98b..d3f561b6054 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polygon_soup_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_polygon_soup_item.h @@ -125,7 +125,7 @@ public: QString toolTip() const; // Indicate if rendering mode is supported - virtual bool supportsRenderingMode(RenderingMode m) const { return ( m!=PointsPlusNormals && m!=Splatting); } + virtual bool supportsRenderingMode(RenderingMode m) const { return ( m!=PointsPlusNormals && m!=Splatting && m!=ShadedPoints); } // OpenGL drawing in a display list virtual void draw() const {} virtual void draw(CGAL::Three::Viewer_interface*) const; diff --git a/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.h b/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.h index bda2600e728..641be971390 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.h @@ -70,7 +70,7 @@ public: QMenu* contextMenu(); // Indicate if rendering mode is supported - virtual bool supportsRenderingMode(RenderingMode m) const { return (m!=PointsPlusNormals && m!=Splatting); } + virtual bool supportsRenderingMode(RenderingMode m) const { return (m!=PointsPlusNormals && m!=Splatting && m!=ShadedPoints); } // Points/Wireframe/Flat/Gouraud OpenGL drawing in a display list void draw() const {} virtual void draw(CGAL::Three::Viewer_interface*) const; diff --git a/Polyhedron/demo/Polyhedron/Scene_textured_polyhedron_item.h b/Polyhedron/demo/Polyhedron/Scene_textured_polyhedron_item.h index 963439b1601..65f212ccd3f 100644 --- a/Polyhedron/demo/Polyhedron/Scene_textured_polyhedron_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_textured_polyhedron_item.h @@ -29,7 +29,7 @@ public: virtual QString toolTip() const; // Indicate if rendering mode is supported - virtual bool supportsRenderingMode(RenderingMode m) const { return (m != Splatting && m != PointsPlusNormals && m != Points && m != Gouraud ); } + virtual bool supportsRenderingMode(RenderingMode m) const { return (m != Splatting && m != PointsPlusNormals && m != Points && m != Gouraud && m != ShadedPoints); } // Points/Wireframe/Flat/Gouraud OpenGL drawing in a display list void draw() const {} virtual void draw(CGAL::Three::Viewer_interface*) const;