mirror of https://github.com/CGAL/cgal
Add an action, in the remeshing plugin, to show/hide protecting spheres
(hidden by default).
This commit is contained in:
parent
ed3ba834fe
commit
bc7541bfb8
|
|
@ -6,6 +6,8 @@
|
|||
#include <QObject>
|
||||
#include <QAction>
|
||||
#include <QMainWindow>
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
#include <QApplication>
|
||||
#include <QtPlugin>
|
||||
#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<QMenu*>("menuView");
|
||||
if(menuView)
|
||||
{
|
||||
menuView->addAction(actionShowSpheres);
|
||||
}
|
||||
else {
|
||||
std::cerr << "Error: cannot find menu \"menuView\" in QMainWindow \""
|
||||
<< qPrintable(mw->objectName()) << "\"!\n";
|
||||
}
|
||||
}
|
||||
|
||||
QList<QAction*> 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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue