diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_normal_estimation_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_normal_estimation_plugin.cpp index 398f08f707d..ab53c6c887b 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_normal_estimation_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_normal_estimation_plugin.cpp @@ -275,8 +275,8 @@ void Polyhedron_demo_point_set_normal_estimation_plugin::on_actionNormalEstimati << (memory>>20) << " Mb allocated" << std::endl; } - - item->setRenderingMode(PointsPlusNormals); + item->resetMenu(); + item->setRenderingMode(ShadedPoints); //*************************************** // normal orientation diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_selection_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_selection_plugin.cpp index 1d8dd937ef2..f405bc5f106 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_selection_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_selection_plugin.cpp @@ -652,12 +652,12 @@ protected: shift_pressing = modifiers.testFlag(Qt::ShiftModifier); ctrl_pressing = modifiers.testFlag(Qt::ControlModifier); - background = static_cast(*CGAL::QGLViewer::QGLViewerPool().begin())->grabFramebuffer(); } // mouse events if(shift_pressing && event->type() == QEvent::MouseButtonPress) { + background = static_cast(*CGAL::QGLViewer::QGLViewerPool().begin())->grabFramebuffer(); QMouseEvent *mouseEvent = static_cast(event); // Start selection if (mouseEvent->button() == Qt::LeftButton) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_shape_detection_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_shape_detection_plugin.cpp index eef452a345c..aa620cd84b3 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_shape_detection_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Point_set_shape_detection_plugin.cpp @@ -358,6 +358,7 @@ private: ++ nb_colored_pts; colored_item->point_set()->set_color(*it, r, g, b); } + colored_item->invalidateOpenGLBuffers(); } // Providing a useful name consisting of the order of detection, name of type and number of inliers @@ -418,7 +419,7 @@ private: poly_item->setName(QString("%1%2_alpha_shape").arg(QString::fromStdString(ss.str())) .arg (QString::number (shape->indices_of_assigned_points().size()))); poly_item->setRenderingMode (Flat); - + poly_item->invalidateOpenGLBuffers(); scene->addItem(poly_item); if(scene->item_id(groups[0]) == -1) scene->addItem(groups[0]); @@ -452,6 +453,7 @@ private: point_item->setRenderingMode(item->renderingMode()); if (dialog.generate_subset()){ + point_item->invalidateOpenGLBuffers(); scene->addItem(point_item); if (dynamic_cast *>(shape.get())) { @@ -469,6 +471,7 @@ private: if(scene->item_id(groups[0]) == -1) scene->addItem(groups[0]); + point_item->invalidateOpenGLBuffers(); scene->changeGroup(point_item, groups[0]); } else if (dynamic_cast *>(shape.get())) @@ -523,6 +526,7 @@ private: pts_full->setName(tr("%1 (structured)").arg(item->name())); pts_full->setRenderingMode(PointsPlusNormals); pts_full->setColor(Qt::blue); + pts_full->invalidateOpenGLBuffers(); scene->addItem (pts_full); } std::cerr << "done" << std::endl; diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Surface_reconstruction_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Surface_reconstruction_plugin.cpp index 8b62dbf4cc1..78639ba1c8c 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Surface_reconstruction_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Surface_reconstruction_plugin.cpp @@ -893,6 +893,7 @@ private: reco_item->setName(tr("%1 (RANSAC-based reconstruction)").arg(scene->item(index)->name())); reco_item->setColor(Qt::magenta); reco_item->setRenderingMode(FlatPlusEdges); + reco_item->invalidateOpenGLBuffers(); scene->addItem(reco_item); } else @@ -1090,6 +1091,7 @@ void Polyhedron_demo_surface_reconstruction_plugin::automatic_reconstruction reco_item->setName(tr("%1 (advancing front)").arg(scene->item(index)->name())); reco_item->setColor(Qt::lightGray); reco_item->setRenderingMode(FlatPlusEdges); + reco_item->invalidateOpenGLBuffers(); scene->addItem(reco_item); } else @@ -1122,6 +1124,7 @@ void Polyhedron_demo_surface_reconstruction_plugin::automatic_reconstruction reco_item->setColor(Qt::lightGray); reco_item->setRenderingMode(FlatPlusEdges); scene->addItem(reco_item); + reco_item->invalidateOpenGLBuffers(); } else { @@ -1173,6 +1176,7 @@ void Polyhedron_demo_surface_reconstruction_plugin::automatic_reconstruction Scene_polyhedron_item* reco_item = new Scene_polyhedron_item(pRemesh); reco_item->setName(tr("%1 (poisson)").arg(pts_item->name())); reco_item->setColor(Qt::lightGray); + reco_item->invalidateOpenGLBuffers(); scene->addItem(reco_item); } else if(smRemesh) @@ -1232,6 +1236,7 @@ void Polyhedron_demo_surface_reconstruction_plugin::advancing_front_reconstructi reco_item->setName(tr("%1 (advancing front)").arg(scene->item(index)->name())); reco_item->setColor(Qt::lightGray); reco_item->setRenderingMode(FlatPlusEdges); + reco_item->invalidateOpenGLBuffers(); scene->addItem(reco_item); } else diff --git a/Polyhedron/demo/Polyhedron/Scene_group_item.cpp b/Polyhedron/demo/Polyhedron/Scene_group_item.cpp index 0a3c31f6653..ce41b1615b4 100644 --- a/Polyhedron/demo/Polyhedron/Scene_group_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_group_item.cpp @@ -31,7 +31,21 @@ bool Scene_group_item::isEmpty() const { Scene_group_item::Bbox Scene_group_item::bbox() const { - return Bbox(0, 0, 0, 0, 0,0); + Scene_item* first_non_empty = nullptr; + Q_FOREACH(Scene_interface::Item_id id, children) + if(!getChild(id)->isEmpty()) + { + first_non_empty = getChild(id); + } + + if(first_non_empty) + { + Bbox b =first_non_empty->bbox(); + Q_FOREACH(Scene_interface::Item_id id, children) + b+=getChild(id)->bbox(); + return b; + } + return Bbox(0,0,0,0,0,0); } diff --git a/Polyhedron/demo/Polyhedron/Scene_item.cpp b/Polyhedron/demo/Polyhedron/Scene_item.cpp index fb69699861a..99e3ec5e3ec 100644 --- a/Polyhedron/demo/Polyhedron/Scene_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_item.cpp @@ -135,6 +135,11 @@ QMenu* CGAL::Three::Scene_item::contextMenu() return defaultContextMenu; } +void CGAL::Three::Scene_item::resetMenu() +{ + delete defaultContextMenu; + defaultContextMenu = nullptr; +} CGAL::Three::Scene_group_item* CGAL::Three::Scene_item::parentGroup() const { return parent_group; } diff --git a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp index cf53bbbb9eb..b2f92df5055 100644 --- a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.cpp @@ -231,7 +231,7 @@ Scene_points_with_normal_item::Scene_points_with_normal_item(const Scene_points_ d = new Scene_points_with_normal_item_priv(toCopy, this); if (has_normals()) { - setRenderingMode(PointsPlusNormals); + setRenderingMode(ShadedPoints); is_selected = true; } else @@ -254,7 +254,7 @@ Scene_points_with_normal_item::Scene_points_with_normal_item(const SMesh& input_ // Converts Polyhedron vertices to point set. // Computes vertices normal from connectivity. d = new Scene_points_with_normal_item_priv(input_mesh, this); - setRenderingMode(PointsPlusNormals); + setRenderingMode(ShadedPoints); is_selected = true; if(d->m_points->number_of_points() < 30 ) d->point_Slider->setValue(5); @@ -269,7 +269,7 @@ Scene_points_with_normal_item::Scene_points_with_normal_item(const Polyhedron& i // Converts Polyhedron vertices to point set. // Computes vertices normal from connectivity. d = new Scene_points_with_normal_item_priv(input_mesh, this); - setRenderingMode(PointsPlusNormals); + setRenderingMode(ShadedPoints); is_selected = true; if(d->m_points->number_of_points() < 30 ) d->point_Slider->setValue(5); @@ -616,7 +616,7 @@ bool Scene_points_with_normal_item::read_las_point_set(std::istream& stream) std::cerr << d->m_points->info(); if (d->m_points->has_normal_map()) - setRenderingMode(PointsPlusNormals); + setRenderingMode(ShadedPoints); if (d->m_points->check_colors()) std::cerr << "-> Point set has colors" << std::endl; @@ -654,7 +654,7 @@ bool Scene_points_with_normal_item::read_ply_point_set(std::istream& stream) std::cerr << d->m_points->info(); if (d->m_points->has_normal_map()) - setRenderingMode(PointsPlusNormals); + setRenderingMode(ShadedPoints); if (d->m_points->check_colors()) std::cerr << "-> Point set has colors" << std::endl; diff --git a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp index 98d944a91d0..8c8bf3bc5e3 100644 --- a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp @@ -831,9 +831,6 @@ void Scene_surface_mesh_item_priv::triangulate_convex_facet(face_descriptor fd, Scene_item_rendering_helper::Gl_data_names name, bool index) const { - const CGAL::qglviewer::Vec v_offset = static_cast(CGAL::QGLViewer::QGLViewerPool().first())->offset(); - EPICK::Vector_3 offset = EPICK::Vector_3(v_offset.x, v_offset.y, v_offset.z); - Point p0,p1,p2; SMesh::Halfedge_around_face_circulator he(halfedge(fd, *smesh_), *smesh_); SMesh::Halfedge_around_face_circulator he_end = he; @@ -844,9 +841,9 @@ void Scene_surface_mesh_item_priv::triangulate_convex_facet(face_descriptor fd, vertex_descriptor v0(target(*he_end, *smesh_)), v1(target(*he, *smesh_)), v2(target(next(*he, *smesh_), *smesh_)); - p0 = smesh_->point(v0) + offset; - p1 = smesh_->point(v1) + offset; - p2 = smesh_->point(v2) + offset; + p0 = smesh_->point(v0); + p1 = smesh_->point(v1); + p2 = smesh_->point(v2); if(!index) { CGAL::Color* color; diff --git a/Three/include/CGAL/Three/Scene_item.h b/Three/include/CGAL/Three/Scene_item.h index 07470eee936..1b00fea5fc4 100644 --- a/Three/include/CGAL/Three/Scene_item.h +++ b/Three/include/CGAL/Three/Scene_item.h @@ -246,6 +246,9 @@ public: //! int getId()const; + //! invalidates the context menu. Call it when supportsRenderingMode() changes, + //! for example. + void resetMenu(); //!Handles key press events. virtual bool keyPressEvent(QKeyEvent*){return false;}