Merge branch 'CGAL-Qt5_support-GF' of github.com:CGAL/cgal-public-dev into CGAL-Qt5_support-GF

This commit is contained in:
Maxime Gimeno 2015-07-16 13:37:45 +02:00
commit fb765fe7d1
30 changed files with 37 additions and 151 deletions

View File

@ -12,7 +12,6 @@ class Scene_item;
// OpenGL rendering mode
enum RenderingMode { Points = 0,
PointsPlusNormals,
Splatting,
Wireframe,
Flat,
FlatPlusEdges,

View File

@ -94,6 +94,7 @@ private:
mutable QOpenGLShaderProgram *program;
using Scene_item::initialize_buffers;
void initialize_buffers(Viewer_interface *viewer)const
{
program = getShaderProgram(PROGRAM_WITHOUT_LIGHT, viewer);
@ -211,6 +212,7 @@ private:
mutable QOpenGLShaderProgram *program;
using Scene_item::initialize_buffers;
void initialize_buffers(Viewer_interface *viewer)const
{
program = getShaderProgram(PROGRAM_WITHOUT_LIGHT, viewer);

View File

@ -151,7 +151,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); // CHECK THIS!
}
void draw(Viewer_interface* viewer) const {
@ -403,6 +403,7 @@ private:
mutable QOpenGLShaderProgram *program;
using Scene_item::initialize_buffers;
void initialize_buffers(Viewer_interface *viewer)const
{
//vao containing the data for the facets

View File

@ -73,6 +73,7 @@ private:
std::vector<float> positions_lines;
mutable QOpenGLShaderProgram *program;
using Scene_item::initialize_buffers;
void initialize_buffers(Viewer_interface *viewer)const
{

View File

@ -1,8 +1,3 @@
//#include "GlSplat/GlSplat.h"
#include <CGAL/check_gl_error.h>
#include "config.h"
#include "Scene.h"
@ -29,15 +24,6 @@ void CGALglcolor(QColor c)
}
}
//GlSplat::SplatRenderer* Scene::ms_splatting = 0;
//int Scene::ms_splattingCounter = 0;
//GlSplat::SplatRenderer* Scene::splatting()
//{
// assert(ms_splatting!=0 && "A Scene object must be created before requesting the splatting object");
// return ms_splatting;
//}
Scene::Scene(QObject* parent)
: QAbstractListModel(parent),
selected_item(-1),
@ -49,13 +35,8 @@ Scene::Scene(QObject* parent)
double, double, double)),
this, SLOT(setSelectionRay(double, double, double,
double, double, double)));
/* if(ms_splatting==0)
ms_splatting = new GlSplat::SplatRenderer();
ms_splattingCounter++;
*/
}
Scene::Item_id
Scene::addItem(Scene_item* item)
{
@ -170,9 +151,6 @@ Scene::~Scene()
delete item_ptr;
}
m_entries.clear();
// if((--ms_splattingCounter)==0)
// delete ms_splatting;
}
Scene_item*
@ -216,8 +194,6 @@ Scene::duplicate(Item_id index)
void Scene::initializeGL()
{
// ms_splatting->init();
//Setting the light options
// Create light components
@ -406,47 +382,8 @@ Scene::draw_aux(bool with_names, Viewer_interface* viewer)
::glPopName();
}
}
// Splatting
/* if(!with_names && ms_splatting->isSupported())
{
ms_splatting->beginVisibilityPass();
for(int index = 0; index < m_entries.size(); ++index)
{
Scene_item& item = *m_entries[index];
if(item.visible() && item.renderingMode() == Splatting)
{
if(viewer)
{
item.draw_splats(viewer);
}
else
item.draw_splats();
}
}
ms_splatting->beginAttributePass();
for(int index = 0; index < m_entries.size(); ++index)
{ Scene_item& item = *m_entries[index];
if(item.visible() && item.renderingMode() == Splatting)
{
CGALglcolor(item.color());
if(viewer)
item.draw_splats(viewer);
else
item.draw_splats();
}
}
ms_splatting->finalize();
}*/
}
// workaround for Qt-4.2 (see above)
#undef lighter
int
Scene::rowCount(const QModelIndex & parent) const
{
@ -604,9 +541,7 @@ Scene::setData(const QModelIndex &index,
{
RenderingMode rendering_mode = static_cast<RenderingMode>(value.toInt());
// Find next supported rendering mode
while ( ! item->supportsRenderingMode(rendering_mode)
// || (rendering_mode==Splatting && !Scene::splatting()->isSupported())
)
while ( ! item->supportsRenderingMode(rendering_mode) )
{
rendering_mode = static_cast<RenderingMode>( (rendering_mode+1) % NumberOfRenderingMode );
}

View File

@ -21,7 +21,6 @@
class QEvent;
class QMouseEvent;
namespace GlSplat { class SplatRenderer; }
class Viewer_interface;
@ -149,12 +148,6 @@ private:
QList<int> selected_items_list;
int item_A;
int item_B;
#ifdef CGAL_GLEW_ENABLED
static GlSplat::SplatRenderer* ms_splatting;
static int ms_splattingCounter;
public:
static GlSplat::SplatRenderer* splatting();
#endif
}; // end class Scene
class SCENE_EXPORT SceneDelegate : public QItemDelegate

View File

@ -73,7 +73,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); // CHECK THIS!
}
void draw() const {

View File

@ -38,7 +38,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); } // CHECK THIS!
//Event handling
virtual bool keyPressEvent(QKeyEvent*);
// OpenGL drawing in a display list

View File

@ -289,6 +289,7 @@ private:
mutable QOpenGLShaderProgram bbox_program;
mutable QOpenGLBuffer *in_bu;
using Scene_item::initialize_buffers;
void initialize_buffers(Viewer_interface *viewer) const;
void compute_normals_and_vertices(void);
void compute_bbox(const Scene_interface::Bbox&);

View File

@ -455,7 +455,6 @@ Scene_implicit_function_item::supportsRenderingMode(RenderingMode m) const
{
switch ( m )
{
case Splatting:
case Gouraud:
return false;
@ -477,7 +476,7 @@ void Scene_implicit_function_item::compute_texture(int i, int j)
double v = (implicit_grid_[i][j]).second;
if(is_nan(v)) {
texture->setData(i,j,0.2,0.2,0.2);
texture->setData(i,j,51,51,51);
} else
// determines grey level
if ( v > 0 )

View File

@ -107,6 +107,7 @@ private:
GLuint vao;
GLuint buffer[4];
using Scene_item::initialize_buffers;
void initialize_buffers(Viewer_interface *viewer) const;
void compute_vertices_and_texmap(void);
void compute_texture(int, int);

View File

@ -39,8 +39,6 @@ QString modeName(RenderingMode mode) {
return QObject::tr("Gouraud");
case PointsPlusNormals:
return QObject::tr("pts+normals");
case Splatting:
return QObject::tr("splats");
default:
Q_ASSERT(false);
return QObject::tr("unknown");
@ -62,8 +60,6 @@ const char* slotName(RenderingMode mode) {
return SLOT(setGouraudMode());
case PointsPlusNormals:
return SLOT(setPointsPlusNormalsMode());
case Splatting:
return SLOT(setSplattingMode());
default:
Q_ASSERT(false);
return "";

View File

@ -104,9 +104,6 @@ public:
// Points OpenGL drawing
virtual void draw_points() const { draw(); }
virtual void draw_points(Viewer_interface*) const { draw_points(); }
// Splats OpenGL drawing
virtual void draw_splats() const {}
virtual void draw_splats(Viewer_interface*) const {draw_splats();}
virtual void selection_changed(bool);
// Functions for displaying meta-data of the item
@ -181,10 +178,6 @@ public Q_SLOTS:
setRenderingMode(PointsPlusNormals);
}
void setSplattingMode(){
setRenderingMode(Splatting);
}
virtual void itemAboutToBeDestroyed(Scene_item*);
virtual void select(double orig_x,

View File

@ -245,7 +245,7 @@ void Scene_nef_polyhedron_item::compute_normals_and_vertices(void)
}
//check if the facet is external or internal
std::queue<typename CDT::Face_handle> face_queue;
std::queue<CDT::Face_handle> face_queue;
face_queue.push(cdt.infinite_vertex()->face());
while(! face_queue.empty() ) {

View File

@ -29,7 +29,7 @@ public:
virtual void changed();
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; } // CHECK THIS!
// OpenGL drawing in a display list
void direct_draw() const;
@ -85,6 +85,7 @@ private:
mutable QOpenGLShaderProgram *program;
using Scene_item::initialize_buffers;
void initialize_buffers(Viewer_interface *viewer) const;
void compute_normals_and_vertices(void);

View File

@ -158,6 +158,7 @@ private:
mutable bool smooth_shading;
mutable QOpenGLShaderProgram *program;
using Scene_item::initialize_buffers;
void initialize_buffers(Viewer_interface*)const;
void compute_normals_and_vertices(void);
};

View File

@ -365,29 +365,7 @@ 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==Splatting ) );
}
void Scene_points_with_normal_item::draw_splats(Viewer_interface* viewer) const
{
//Needs to be re-thinked because the GlSplat Renderer is deprecated and is a big part of the scene class.
// TODO add support for selection
/* ::glBegin(GL_POINTS);
for ( Point_set_3<Kernel>::const_iterator it = m_points->begin(); it != m_points->end(); it++)
{
const UI_point& p = *it;
::glNormal3dv(&p.normal().x());
::glMultiTexCoord1d(GL_TEXTURE2, p.radius());
::glVertex3dv(&p.x());
}
::glEnd();
*/
( has_normals() && m==PointsPlusNormals );
}
void Scene_points_with_normal_item::draw_edges(Viewer_interface* viewer) const
@ -529,10 +507,6 @@ QMenu* Scene_points_with_normal_item::contextMenu()
void Scene_points_with_normal_item::setRenderingMode(RenderingMode m)
{
Scene_item::setRenderingMode(m);
if (rendering_mode==Splatting && (!m_points->are_radii_uptodate()))
{
computes_local_spacing(6); // default value = small
}
}
bool Scene_points_with_normal_item::has_normals() const { return m_has_normals; }

View File

@ -52,8 +52,6 @@ public:
virtual void draw_edges(Viewer_interface* viewer) const;
virtual void draw_points(Viewer_interface*) const;
virtual void draw_splats(Viewer_interface*) const;
// Gets wrapped point set
Point_set* point_set();
const Point_set* point_set() const;
@ -95,6 +93,7 @@ private:
mutable QOpenGLShaderProgram *program;
using Scene_item::initialize_buffers;
void initialize_buffers(Viewer_interface *viewer) const;
void compute_normals_and_vertices(void);

View File

@ -188,7 +188,7 @@ Scene_polygon_soup_item::triangulate_polygon(Polygons_iterator pit)
}
//check if the facet is external or internal
std::queue<typename CDT::Face_handle> face_queue;
std::queue<CDT::Face_handle> face_queue;
face_queue.push(cdt.infinite_vertex()->face());
while(! face_queue.empty() ) {
CDT::Face_handle fh = face_queue.front();

View File

@ -136,7 +136,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); } // CHECK THIS!
// OpenGL drawing in a display list
virtual void draw() const {}
virtual void draw(Viewer_interface*) const;
@ -170,6 +170,7 @@ private:
std::vector<float> positions_lines;
std::vector<float> normals;
using Scene_item::initialize_buffers;
void initialize_buffers(Viewer_interface *viewer) const;
void compute_normals_and_vertices(void);
void triangulate_polygon(Polygons_iterator );

View File

@ -153,7 +153,7 @@ Scene_polyhedron_item::triangulate_facet(Facet_iterator fit)
fit2->info().is_external = false;
}
//check if the facet is external or internal
std::queue<typename CDT::Face_handle> face_queue;
std::queue<CDT::Face_handle> face_queue;
face_queue.push(cdt.infinite_vertex()->face());
while(! face_queue.empty() ) {
CDT::Face_handle fh = face_queue.front();
@ -251,7 +251,7 @@ Scene_polyhedron_item::triangulate_facet_color(Facet_iterator fit)
afit->info().is_external = false;
}
//check if the facet is external or internal
std::queue<typename CDT::Face_handle> face_queue;
std::queue<CDT::Face_handle> face_queue;
face_queue.push(cdt.infinite_vertex()->face());
while(! face_queue.empty() ) {
CDT::Face_handle fh = face_queue.front();
@ -469,7 +469,7 @@ Scene_polyhedron_item::compute_normals_and_vertices(void)
else if (cur_shading == Gouraud)
{
Vector n = compute_vertex_normal<typename Polyhedron::Vertex,Kernel>(*he->vertex());
Vector n = compute_vertex_normal<Polyhedron::Vertex,Kernel>(*he->vertex());
normals.push_back(n.x());
normals.push_back(n.y());
normals.push_back(n.z());

View File

@ -44,7 +44,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); }
// Points/Wireframe/Flat/Gouraud OpenGL drawing in a display list
void draw() const {}
virtual void draw(Viewer_interface*) const;
@ -120,6 +120,7 @@ private:
mutable QOpenGLShaderProgram *program;
using Scene_item::initialize_buffers;
void initialize_buffers(Viewer_interface *viewer = 0) const;
void compute_normals_and_vertices(void);
void compute_colors();

View File

@ -27,7 +27,7 @@ public:
// QMenu* contextMenu();
// Indicate if rendering mode is supported
bool supportsRenderingMode(RenderingMode m) const { return (m!=PointsPlusNormals && m!=Splatting); }
bool supportsRenderingMode(RenderingMode m) const { return m!=PointsPlusNormals; }
// Points/Wireframe/Flat/Gouraud OpenGL drawing in a display list
// dispatch to poly_item direct_draw and direct_draw_edges
void draw() const;

View File

@ -240,7 +240,7 @@ public:
typedef boost::unordered_set<Facet_handle, CGAL::Handle_hash_function> Selection_set_facet;
typedef boost::unordered_set<edge_descriptor, CGAL::Handle_hash_function> Selection_set_edge;
using Scene_polyhedron_item_decorator::draw;
virtual void draw(Viewer_interface*) const;
virtual void draw_edges() const { }
virtual void draw_edges(Viewer_interface*) const;
@ -704,6 +704,7 @@ private:
std::vector<float> positions_points;
mutable QOpenGLShaderProgram *program;
using Scene_item::initialize_buffers;
void initialize_buffers(Viewer_interface *viewer) const;
void compute_elements();

View File

@ -104,6 +104,7 @@ private:
std::vector<float> vertices;
mutable QOpenGLShaderProgram *program;
using Scene_polyhedron_item_decorator::initialize_buffers;
void initialize_buffers(Viewer_interface *viewer = 0) const;
void compute_elements(void);
@ -120,6 +121,7 @@ public:
Primitives_mode get_primitives_mode() const;
virtual bool supportsRenderingMode(RenderingMode m) const;
using Scene_polyhedron_item_decorator::draw;
virtual void draw(Viewer_interface*) const;
// Points OpenGL drawing
virtual void draw_points(Viewer_interface*) const;

View File

@ -38,6 +38,7 @@ private:
qglviewer::Vec center_;
mutable QOpenGLShaderProgram *program;
std::vector<float> positions_lines;
using Scene_item::initialize_buffers;
void initialize_buffers(Viewer_interface *viewer) const;
void compute_elements();

View File

@ -463,7 +463,7 @@ Scene_polylines_item::compute_elements()
//Convert the triangle coordinates to lines coordinates for the
//Wiremode in the spheres
for(int i=0; i< (int) positions_spheres.size(); i=i)
for(int i=0; i< (int) positions_spheres.size();)
{
//draw triangles
if(i< (360/sectors)*12)

View File

@ -109,6 +109,7 @@ private:
typedef std::map<Point_3, int> Point_to_int_map;
typedef Point_to_int_map::iterator iterator;
void create_Sphere(double);
using Scene_item::initialize_buffers;
void initialize_buffers(Viewer_interface *viewer) const;
void compute_elements();

View File

@ -28,7 +28,7 @@ public:
virtual QString toolTip() const;
// Indicate if rendering mode is supported
virtual bool supportsRenderingMode(RenderingMode m) const { return m != Splatting; }
virtual bool supportsRenderingMode(RenderingMode) const { return true; }
// Points/Wireframe/Flat/Gouraud OpenGL drawing in a display list
void draw() const {}
virtual void draw(Viewer_interface*) const;
@ -62,6 +62,8 @@ private:
mutable QOpenGLShaderProgram* program;
bool smooth_shading;
using Scene_item::initialize_buffers;
void initialize_buffers(Viewer_interface *viewer) const;
void compute_normals_and_vertices(void);

View File

@ -280,24 +280,6 @@ public:
::glEnd();
}
}
// Draw oriented points with radius using OpenGL calls.
// Preconditions: must be used inbetween calls to GlSplat library
void gl_draw_splats() const
{
// TODO add support for selection
::glBegin(GL_POINTS);
for (const_iterator it = begin(); it != end(); it++)
{
const UI_point& p = *it;
::glNormal3dv(&p.normal().x());
#ifdef CGAL_GLEW_ENABLED
::glMultiTexCoord1d(GL_TEXTURE2, p.radius());
#endif
::glVertex3dv(&p.x());
}
::glEnd();
}
bool are_radii_uptodate() const { return m_radii_are_uptodate; }
void set_radii_uptodate(bool /*on*/) { m_radii_are_uptodate = false; }
@ -344,7 +326,6 @@ private:
// Computes bounding sphere
typedef CGAL::Min_sphere_of_points_d_traits_3<Gt,FT> Traits;
typedef CGAL::Min_sphere_of_spheres_d<Traits> Min_sphere;
typedef typename Traits::Sphere Traits_sphere;
Min_sphere ms(begin(),end());