diff --git a/Lab/demo/Lab/Plugins/Point_set/Kinetic_surface_reconstruction_plugin.cpp b/Lab/demo/Lab/Plugins/Point_set/Kinetic_surface_reconstruction_plugin.cpp index f107f602b3d..d0c694aa746 100644 --- a/Lab/demo/Lab/Plugins/Point_set/Kinetic_surface_reconstruction_plugin.cpp +++ b/Lab/demo/Lab/Plugins/Point_set/Kinetic_surface_reconstruction_plugin.cpp @@ -146,6 +146,7 @@ public: connect(dock_widget->partRunButton, SIGNAL(clicked(bool)), this, SLOT(run_partition())); connect(dock_widget->recRunButton, SIGNAL(clicked(bool)), this, SLOT(run_reconstruction())); connect(dock_widget->partSubdivisionCheck, SIGNAL(stateChanged(int)), this, SLOT(onSubdivisionStateChanged(int))); + connect(dock_widget, SIGNAL(visibilityChanged(bool)), this, SLOT(onVisibilityChanged(bool))); } private Q_SLOTS: void openDialog() @@ -165,6 +166,9 @@ private Q_SLOTS: } void onItemIndexSelected(int item_index) { + if (!dock_widget->isVisible()) + return; + Scene_points_with_normal_item *selection = qobject_cast(scene->item(item_index)); if (selection == nullptr) { // Keep old reference if no new point cloud has been selected. @@ -223,8 +227,7 @@ private Q_SLOTS: void onItemChanged() { // Enable detection if the point set item has normals now assert(m_pwn_item); - Point_set* points = m_pwn_item->point_set(); - std::cout << "item changed" << std::endl; + if (m_pwn_item->has_normals()) enable_detection(true); } @@ -357,6 +360,12 @@ private Q_SLOTS: dock_widget->partPolygonsPerNodeBox->setEnabled(state != 0); } + void onVisibilityChanged(bool visibility) { + if (!dock_widget->isVisible()) + return; + std::cout << "in visibility changed" << std::endl; + } + private: void convex_hull(const std::vector& region, const CGAL::Epick::Plane_3& plane, std::vector > &polys) { if (m_pwn_item == nullptr) diff --git a/Lab/demo/Lab/Scene_item.cpp b/Lab/demo/Lab/Scene_item.cpp index 1b54ec52993..104d2af1c10 100644 --- a/Lab/demo/Lab/Scene_item.cpp +++ b/Lab/demo/Lab/Scene_item.cpp @@ -15,6 +15,7 @@ CGAL::Three::Scene_item::Scene_item(int buffers_size, int vaos_size) are_buffers_filled(false), rendering_mode(FlatPlusEdges), defaultContextMenu(nullptr), + context_menu_outdated(false), buffersSize(buffers_size), vaosSize(vaos_size), vaos(vaos_size) @@ -94,6 +95,11 @@ QString CGAL::Three::Scene_item::renderingModeName() const } QMenu* CGAL::Three::Scene_item::contextMenu() { + if (context_menu_outdated && defaultContextMenu) { + delete defaultContextMenu; + defaultContextMenu = nullptr; + } + if(defaultContextMenu) { defaultContextMenu->setTitle(name()); return defaultContextMenu; @@ -111,14 +117,17 @@ QMenu* CGAL::Three::Scene_item::contextMenu() slotName(RenderingMode(mode))); defaultContextMenu->actions().last()->setProperty("is_groupable", true); } + + context_menu_outdated = false; + return defaultContextMenu; } void CGAL::Three::Scene_item::resetMenu() { - delete defaultContextMenu; - defaultContextMenu = nullptr; + context_menu_outdated = true; } + CGAL::Three::Scene_group_item* CGAL::Three::Scene_item::parentGroup() const { return parent_group; } diff --git a/Three/include/CGAL/Three/Scene_item.h b/Three/include/CGAL/Three/Scene_item.h index b517a9c9108..b94d04fa6a9 100644 --- a/Three/include/CGAL/Three/Scene_item.h +++ b/Three/include/CGAL/Three/Scene_item.h @@ -443,6 +443,8 @@ protected: RenderingMode rendering_mode; //!The default context menu. QMenu* defaultContextMenu; + //!Specifies if the context menu should be rebuild on the next call. + bool context_menu_outdated = false; /*! Contains the previous RenderingMode. * This is used to determine if invalidateOpenGLBuffers should be called or not * in certain cases.