diff --git a/GraphicsView/include/CGAL/Qt/DemosMainWindow_impl.h b/GraphicsView/include/CGAL/Qt/DemosMainWindow_impl.h index 5f8c85c1d7f..75816b4ff2a 100644 --- a/GraphicsView/include/CGAL/Qt/DemosMainWindow_impl.h +++ b/GraphicsView/include/CGAL/Qt/DemosMainWindow_impl.h @@ -221,7 +221,10 @@ void DemosMainWindow::popupAboutBox(QString title, QString html_resource_name) { QFile about_CGAL(html_resource_name); - about_CGAL.open(QIODevice::ReadOnly); + if (!about_CGAL.open(QIODevice::ReadOnly)) { + QMessageBox::warning(this, tr("Error"), tr("Could not open resource file: %1").arg(html_resource_name)); + return; + } QString about_CGAL_txt = QTextStream(&about_CGAL).readAll(); #ifdef CGAL_VERSION_STR QString cgal_version(CGAL_VERSION_STR); diff --git a/Triangulation_3/demo/Triangulation_3/CMakeLists.txt b/Triangulation_3/demo/Triangulation_3/CMakeLists.txt index 2333c9a9ffc..b579a045676 100644 --- a/Triangulation_3/demo/Triangulation_3/CMakeLists.txt +++ b/Triangulation_3/demo/Triangulation_3/CMakeLists.txt @@ -63,9 +63,6 @@ if(CGAL_Qt6_FOUND AND Qt6_FOUND) include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) cgal_add_compilation_test(T3_demo) - include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) - cgal_add_compilation_test(T3_demo) - else(CGAL_Qt6_FOUND AND Qt6_FOUND) set(TRIANGULATION_3_MISSING_DEPS "") diff --git a/Triangulation_3/demo/Triangulation_3/MainWindow.cpp b/Triangulation_3/demo/Triangulation_3/MainWindow.cpp index aad061f5e44..3f60296c955 100644 --- a/Triangulation_3/demo/Triangulation_3/MainWindow.cpp +++ b/Triangulation_3/demo/Triangulation_3/MainWindow.cpp @@ -209,31 +209,3 @@ void MainWindow::on_actionClear_Scene_triggered() // update viewer Q_EMIT( sceneChanged() ); } - -void MainWindow::popupAboutCGAL() -{ - // read contents from .html file - QFile about_CGAL(":/documentation/documentation/about_CGAL.html"); - about_CGAL.open(QIODevice::ReadOnly|QIODevice::Text); - QString about_CGAL_txt = QTextStream(&about_CGAL).readAll(); - - // popup a message box - QMessageBox mb(QMessageBox::NoIcon, - tr("About CGAL..."), - about_CGAL_txt, - QMessageBox::Ok, - this); - - // set links to be accessible by mouse or keyboard - QLabel* mb_label = mb.findChild("qt_msgbox_label"); - if(mb_label) { - mb_label->setTextInteractionFlags(mb_label->textInteractionFlags() | - ::Qt::LinksAccessibleByMouse | - ::Qt::LinksAccessibleByKeyboard); - } else { - std::cerr << "Cannot find child \"qt_msgbox_label\" in QMessageBox\n" - << " with Qt version " << QT_VERSION_STR << "!\n"; - } - - mb.exec(); -} diff --git a/Triangulation_3/demo/Triangulation_3/MainWindow.h b/Triangulation_3/demo/Triangulation_3/MainWindow.h index 6d126222450..6aba4346894 100644 --- a/Triangulation_3/demo/Triangulation_3/MainWindow.h +++ b/Triangulation_3/demo/Triangulation_3/MainWindow.h @@ -36,9 +36,6 @@ public Q_SLOTS: // show menu void on_actionClear_Scene_triggered(); - // about menu - void popupAboutCGAL(); - Q_SIGNALS: void sceneChanged(); diff --git a/Triangulation_3/demo/Triangulation_3/T3_demo.cpp b/Triangulation_3/demo/Triangulation_3/T3_demo.cpp index aef465639ff..38b5c83168b 100644 --- a/Triangulation_3/demo/Triangulation_3/T3_demo.cpp +++ b/Triangulation_3/demo/Triangulation_3/T3_demo.cpp @@ -25,6 +25,9 @@ int main(int argc, char** argv) app.setOrganizationName("INRIA"); app.setApplicationName("3D Triangulation Demo"); + // Import resources from libCGALQt (Qt6). + CGAL_QT_INIT_RESOURCES; + MainWindow mw; mw.show(); diff --git a/Triangulation_3/demo/Triangulation_3/Viewer.cpp b/Triangulation_3/demo/Triangulation_3/Viewer.cpp index 12308b48517..30786c8d44a 100644 --- a/Triangulation_3/demo/Triangulation_3/Viewer.cpp +++ b/Triangulation_3/demo/Triangulation_3/Viewer.cpp @@ -183,13 +183,13 @@ void Viewer::compile_shaders() "} \n" "\n" }; - QOpenGLShader *vertex_shader = new QOpenGLShader(QOpenGLShader::Vertex); + QOpenGLShader *vertex_shader = new QOpenGLShader(QOpenGLShader::Vertex, this); if(!vertex_shader->compileSourceCode(vertex_source)) { std::cerr<<"Compiling vertex source FAILED"<compileSourceCode(fragment_source)) { std::cerr<<"Compiling fragmentsource FAILED"<compileSourceCode(vertex_source_spheres)) { std::cerr<<"Compiling vertex source FAILED"<compileSourceCode(fragment_source_spheres)) { std::cerr<<"Compiling fragmentsource FAILED"<compileSourceCode(vertex_source_cylinders)) { std::cerr<<"Compiling vertex source FAILED"< *vertices) +void Viewer::drawVertex(const Point_3& p, Coords_ptr& vertices) { vertices->push_back(p.x()); vertices->push_back(p.y()); vertices->push_back(p.z()); @@ -1636,13 +1636,13 @@ void Viewer::drawVertex(const Point_3& p, std::vector *vertices) } -void Viewer::drawEdge(const Point_3& from, const Point_3& to, std::vector *vertices) +void Viewer::drawEdge(const Point_3& from, const Point_3& to, Coords_ptr& vertices) { vertices->push_back( from.x()); vertices->push_back(from.y()); vertices->push_back(from.z()); vertices->push_back( to.x()); vertices->push_back(to.y()); vertices->push_back(to.z()); } -void Viewer::drawFacet(const Triangle_3& t, std::vector *vertices) +void Viewer::drawFacet(const Triangle_3& t, Coords_ptr& vertices) { Point_3 p0 = t.vertex(0); Point_3 p1 = t.vertex(1); @@ -2482,7 +2482,7 @@ void Viewer::incremental_insert() { } -void Viewer::draw_cylinder(float R, int prec, std::vector *vertices, std::vector *normals) +void Viewer::draw_cylinder(float R, int prec, Coords_ptr& vertices, Coords_ptr& normals) { vertices->resize(0); normals->resize(0); @@ -2551,7 +2551,7 @@ void Viewer::draw_cylinder(float R, int prec, std::vector *vertices, std: } } -void Viewer::draw_sphere(float R, int prec, std::vector *vertices, std::vector *normals) +void Viewer::draw_sphere(float R, int prec, Coords_ptr& vertices, Coords_ptr& normals) { vertices->resize(0); normals->resize(0); diff --git a/Triangulation_3/demo/Triangulation_3/Viewer.h b/Triangulation_3/demo/Triangulation_3/Viewer.h index e46753c6d4f..70c72181a29 100644 --- a/Triangulation_3/demo/Triangulation_3/Viewer.h +++ b/Triangulation_3/demo/Triangulation_3/Viewer.h @@ -42,42 +42,41 @@ public: , m_hasEmptyS(false) , m_showTrackball(true) , m_pDlgPrefer(nullptr) - { - pos_emptyFacet = new std::vector(); - pos_emptySphere= new std::vector(); - points_emptySphere = new std::vector(); - pos_points = new std::vector(); - pos_newPoint = new std::vector(); - pos_selectedVertex = new std::vector(); - pos_movingPoint = new std::vector(); - pos_queryPoint = new std::vector(); - pos_trackBall = new std::vector(); - pos_voronoi = new std::vector(); - pos_delaunay = new std::vector(); - pos_facets = new std::vector(); - pos_newFacet = new std::vector(); - pos_nearest_neighbor = new std::vector(); - points_locationSphere = new std::vector(); - points_cylinder = new std::vector(); - normals_cylinder = new std::vector(); - points_sphere = new std::vector(); - points_trackBall = new std::vector(); - normals_sphere = new std::vector(); - normals_emptySphere = new std::vector(); - normals_trackBall= new std::vector(); - transfo1_voronoi = new std::vector(); - transfo2_voronoi = new std::vector(); - transfo3_voronoi = new std::vector(); - transfo4_voronoi = new std::vector(); - transfo1_delaunay = new std::vector(); - transfo2_delaunay = new std::vector(); - transfo3_delaunay = new std::vector(); - transfo4_delaunay = new std::vector(); - incremental_points = new std::vector(); - incremental_next_point = new std::vector(); - incremental_facet = new std::vector(); - incremental_conflict = new std::vector(); - } + , pos_emptyFacet{new Coords} + , pos_emptySphere{new Coords} + , points_emptySphere{new Coords} + , pos_points{new Coords} + , pos_newPoint{new Coords} + , pos_selectedVertex{new Coords} + , pos_movingPoint{new Coords} + , pos_queryPoint{new Coords} + , pos_trackBall{ new Coords} + , pos_voronoi{new Coords} + , pos_delaunay{new Coords} + , pos_facets{new Coords} + , pos_newFacet{new Coords} + , pos_nearest_neighbor{new Coords} + , points_locationSphere{new Coords} + , points_cylinder{new Coords} + , normals_cylinder{new Coords} + , points_sphere{new Coords} + , points_trackBall{new Coords} + , normals_sphere{new Coords} + , normals_emptySphere{new Coords} + , normals_trackBall{new Coords} + , transfo1_voronoi{new Coords} + , transfo2_voronoi{new Coords} + , transfo3_voronoi{new Coords} + , transfo4_voronoi{new Coords} + , transfo1_delaunay{new Coords} + , transfo2_delaunay{new Coords} + , transfo3_delaunay{new Coords} + , transfo4_delaunay{new Coords} + , incremental_points{new Coords} + , incremental_next_point{new Coords} + , incremental_facet{new Coords} + , incremental_conflict{new Coords} + {} ~Viewer() { @@ -269,12 +268,15 @@ protected: QString helpString() const; private: + using Coords = std::vector; + using Coords_ptr = std::unique_ptr>; + // draw a 3d effect vertex - void drawVertex(const Point_3& p, std::vector *vertices); + void drawVertex(const Point_3& p, Coords_ptr& vertices); // draw a 3d effect edge - void drawEdge(const Point_3& from, const Point_3 &to, std::vector *vertices); + void drawEdge(const Point_3& from, const Point_3 &to, Coords_ptr& vertices); // draw a facet - void drawFacet(const Triangle_3& t, std::vector *vertices); + void drawFacet(const Triangle_3& t, Coords_ptr& vertices); // test whether the give 3D point is on the sphere inline bool isOnSphere( const Point_3 & pt ) { return ( (pt.x()*pt.x() + pt.y()*pt.y() + pt.z()*pt.z()) == (m_fRadius*m_fRadius) ); @@ -347,75 +349,74 @@ private: static const int vaoSize = 29; static const int vboSize = 34; // define material - QVector4D ambient; - QVector4D diffuse; - QVector4D specular; - GLfloat shininess ; - int poly_vertexLocation[3]; - int normalsLocation[3]; - int mvpLocation[3]; - int mvLocation[2]; - int centerLocation[5]; - int colorLocation[3]; - int lightLocation[5*2]; + QVector4D ambient; + QVector4D diffuse; + QVector4D specular; + GLfloat shininess ; + int poly_vertexLocation[3]; + int normalsLocation[3]; + int mvpLocation[3]; + int mvLocation[2]; + int centerLocation[5]; + int colorLocation[3]; + int lightLocation[5*2]; - bool are_buffers_initialized; - bool extension_is_found; + bool are_buffers_initialized; + bool extension_is_found; - std::vector *pos_emptyFacet; - std::vector *pos_emptySphere; - std::vector *points_emptySphere; - std::vector *pos_points; - std::vector *pos_newPoint; - std::vector *pos_selectedVertex; - std::vector *pos_movingPoint; - std::vector *pos_queryPoint; - std::vector *pos_trackBall; - std::vector *points_trackBall; - std::vector *pos_voronoi; - std::vector *pos_delaunay; - std::vector *pos_facets; - std::vector *pos_newFacet; - std::vector *pos_nearest_neighbor; - std::vector *points_locationSphere; - std::vector *points_cylinder; - std::vector *normals_cylinder; - std::vector *points_sphere; - std::vector *normals_sphere; - std::vector *normals_emptySphere; - std::vector *normals_trackBall; - std::vector *transfo1_voronoi; - std::vector *transfo2_voronoi; - std::vector *transfo3_voronoi; - std::vector *transfo4_voronoi; - std::vector *transfo1_delaunay; - std::vector *transfo2_delaunay; - std::vector *transfo3_delaunay; - std::vector *transfo4_delaunay; - std::vector *incremental_points; - std::vector *incremental_next_point; - std::vector *incremental_facet; - std::vector *incremental_conflict; + Coords_ptr pos_emptyFacet; + Coords_ptr pos_emptySphere; + Coords_ptr points_emptySphere; + Coords_ptr pos_points; + Coords_ptr pos_newPoint; + Coords_ptr pos_selectedVertex; + Coords_ptr pos_movingPoint; + Coords_ptr pos_queryPoint; + Coords_ptr pos_trackBall; + Coords_ptr pos_voronoi; + Coords_ptr pos_delaunay; + Coords_ptr pos_facets; + Coords_ptr pos_newFacet; + Coords_ptr pos_nearest_neighbor; + Coords_ptr points_locationSphere; + Coords_ptr points_cylinder; + Coords_ptr normals_cylinder; + Coords_ptr points_sphere; + Coords_ptr points_trackBall; + Coords_ptr normals_sphere; + Coords_ptr normals_emptySphere; + Coords_ptr normals_trackBall; + Coords_ptr transfo1_voronoi; + Coords_ptr transfo2_voronoi; + Coords_ptr transfo3_voronoi; + Coords_ptr transfo4_voronoi; + Coords_ptr transfo1_delaunay; + Coords_ptr transfo2_delaunay; + Coords_ptr transfo3_delaunay; + Coords_ptr transfo4_delaunay; + Coords_ptr incremental_points; + Coords_ptr incremental_next_point; + Coords_ptr incremental_facet; + Coords_ptr incremental_conflict; + //pickin + QMap picked_IDs; + QPoint picking_pos; - //picking - QMap picked_IDs; - QPoint picking_pos; - - QOpenGLBuffer buffers[vboSize]; - QOpenGLVertexArrayObject vao[vaoSize]; - QOpenGLShaderProgram rendering_program; - QOpenGLShaderProgram rendering_program_spheres; - QOpenGLShaderProgram rendering_program_cylinders; - typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); - typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); - PFNGLDRAWARRAYSINSTANCEDARBPROC glDrawArraysInstanced; - PFNGLVERTEXATTRIBDIVISORARBPROC glVertexAttribDivisor; - void initialize_buffers(); - void compute_elements(); - void attrib_buffers(CGAL::QGLViewer*); - void compile_shaders(); - void draw_cylinder(float R, int prec, std::vector *vertices, std::vector *normals); - void draw_sphere(float R, int prec, std::vector *vertices, std::vector *normals); + QOpenGLBuffer buffers[vboSize]; + QOpenGLVertexArrayObject vao[vaoSize]; + QOpenGLShaderProgram rendering_program; + QOpenGLShaderProgram rendering_program_spheres; + QOpenGLShaderProgram rendering_program_cylinders; + typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); + typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); + PFNGLDRAWARRAYSINSTANCEDARBPROC glDrawArraysInstanced; + PFNGLVERTEXATTRIBDIVISORARBPROC glVertexAttribDivisor; + void initialize_buffers(); + void compute_elements(); + void attrib_buffers(CGAL::QGLViewer*); + void compile_shaders(); + void draw_cylinder(float R, int prec, Coords_ptr& vertices, Coords_ptr& normals); + void draw_sphere(float R, int prec, Coords_ptr& vertices, Coords_ptr& normals); }; #endif