remove warning

fixed crash when estimating normals from context menu
This commit is contained in:
Sven Oesau 2024-10-04 09:18:07 +02:00
parent a43efbfdb3
commit 42d8c22d7c
3 changed files with 24 additions and 4 deletions

View File

@ -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_points_with_normal_item*>(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<std::size_t>& region, const CGAL::Epick::Plane_3& plane, std::vector<std::vector<CGAL::Epick::Point_3> > &polys) {
if (m_pwn_item == nullptr)

View File

@ -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;
}

View File

@ -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.