diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_remeshing_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_remeshing_plugin.cpp index 51eb095efce..545dfca8395 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_remeshing_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_remeshing_plugin.cpp @@ -6,6 +6,8 @@ #include #include #include +#include +#include #include #include #include "Scene_polyhedron_item.h" @@ -35,6 +37,18 @@ public: connect(actionRemeshing, SIGNAL(triggered()), this, SLOT(remesh())); } + actionShowSpheres = new QAction("Show protecting spheres", mw); + actionShowSpheres->setCheckable(true); + actionShowSpheres->setChecked(false); + QMenu* menuView = mw->findChild("menuView"); + if(menuView) + { + menuView->addAction(actionShowSpheres); + } + else { + std::cerr << "Error: cannot find menu \"menuView\" in QMainWindow \"" + << qPrintable(mw->objectName()) << "\"!\n"; + } } QList actions() const { @@ -45,6 +59,7 @@ public slots: private: QAction* actionRemeshing; + QAction* actionShowSpheres; }; // end class Polyhedron_demo_remeshing_plugin void Polyhedron_demo_remeshing_plugin::remesh() @@ -128,6 +143,14 @@ void Polyhedron_demo_remeshing_plugin::remesh() new_item->setRenderingMode(item->renderingMode()); item->setVisible(false); scene->itemChanged(index); + QObject::connect(actionShowSpheres, SIGNAL(toggled(bool)), + new_item, SLOT(show_spheres(bool))); + // meta-call, to avoid the inclusing of the CGAL headers + QMetaObject::invokeMethod(new_item, + "show_spheres", + Qt::DirectConnection, + Q_ARG(bool, actionShowSpheres->isChecked())); + scene->addItem(new_item); } diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_remeshing_plugin_cgal_code.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_remeshing_plugin_cgal_code.cpp index 2312d9ad006..aafc192ebb5 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_remeshing_plugin_cgal_code.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_remeshing_plugin_cgal_code.cpp @@ -320,8 +320,14 @@ public: draw_triangle(pa, pb, pc); } ::glEnd(); + + GLenum gl_error = ::glGetError(); + if(gl_error != GL_NO_ERROR) + std::cerr << "GL error: " << gluErrorString(gl_error) << std::endl; + + if(!draw_spheres) + return; - return; // force wireframe for protecting spheres GLint polygon_mode[2]; ::glGetIntegerv(GL_POLYGON_MODE, &polygon_mode[0]); @@ -365,6 +371,11 @@ public: } } +public slots: + void show_spheres(bool b) { + draw_spheres = b; + } + private: static void draw_triangle(const Tr::Point& pa, const Tr::Point& pb, @@ -383,6 +394,7 @@ private: mutable GLuint sphere_display_list; mutable GLUquadric* quadric; C2t3 c2t3_; + bool draw_spheres; }; typedef Tr::Geom_traits GT;