From 2df7e30011f986854dc207198014e8040a8b3947 Mon Sep 17 00:00:00 2001 From: Pierre Kraemer Date: Tue, 12 Nov 2013 09:50:06 +0100 Subject: [PATCH] surface selection : within sphere method for edges and faces --- .../src/surface_selection.cpp | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/SCHNApps/Plugins/surface_selection/src/surface_selection.cpp b/SCHNApps/Plugins/surface_selection/src/surface_selection.cpp index c95b1722..b2782be4 100644 --- a/SCHNApps/Plugins/surface_selection/src/surface_selection.cpp +++ b/SCHNApps/Plugins/surface_selection/src/surface_selection.cpp @@ -151,6 +151,21 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map) break; } case WithinSphere : { + std::vector selectionPoint; + selectionPoint.push_back(p.positionAttribute[m_selectingEdge]); + m_selectionSphereVBO->updateData(selectionPoint); + + m_pointSprite->setAttributePosition(m_selectionSphereVBO); + m_pointSprite->setColor(CGoGN::Geom::Vec4f(0.0f, 0.0f, 1.0f, 0.5f)); + m_pointSprite->setLightPosition(CGoGN::Geom::Vec3f(0.0f, 0.0f, 1.0f)); + m_pointSprite->setSize(m_selectionRadius); + + m_pointSprite->enableVertexAttribs(); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glDrawArrays(GL_POINTS, 0, 1); + glDisable(GL_BLEND); + m_pointSprite->disableVertexAttribs(); break; } } @@ -177,6 +192,21 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map) break; } case WithinSphere : { + std::vector selectionPoint; + selectionPoint.push_back(p.positionAttribute[m_selectingFace]); + m_selectionSphereVBO->updateData(selectionPoint); + + m_pointSprite->setAttributePosition(m_selectionSphereVBO); + m_pointSprite->setColor(CGoGN::Geom::Vec4f(0.0f, 0.0f, 1.0f, 0.5f)); + m_pointSprite->setLightPosition(CGoGN::Geom::Vec3f(0.0f, 0.0f, 1.0f)); + m_pointSprite->setSize(m_selectionRadius); + + m_pointSprite->enableVertexAttribs(); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glDrawArrays(GL_POINTS, 0, 1); + glDisable(GL_BLEND); + m_pointSprite->disableVertexAttribs(); break; } } @@ -264,6 +294,12 @@ void Surface_Selection_Plugin::mousePress(View* view, QMouseEvent* event) break; } case WithinSphere : { + Algo::Surface::Selection::Collector_WithinSphere neigh(*map, p.positionAttribute, m_selectionRadius); + neigh.collectAll(m_selectingEdge); + if(event->button() == Qt::LeftButton) + selector->select(neigh.getInsideEdges()); + else if(event->button() == Qt::RightButton) + selector->unselect(neigh.getInsideEdges()); break; } } @@ -284,6 +320,12 @@ void Surface_Selection_Plugin::mousePress(View* view, QMouseEvent* event) break; } case WithinSphere : { + Algo::Surface::Selection::Collector_WithinSphere neigh(*map, p.positionAttribute, m_selectionRadius); + neigh.collectAll(m_selectingFace); + if(event->button() == Qt::LeftButton) + selector->select(neigh.getInsideFaces()); + else if(event->button() == Qt::RightButton) + selector->unselect(neigh.getInsideFaces()); break; } } -- GitLab