Commit c3d604f7 authored by Pierre Kraemer's avatar Pierre Kraemer

SCHNApps: Surface_selection: debug crash when selecting cell on MacOS

parent d3f9eb39
...@@ -47,7 +47,7 @@ public: ...@@ -47,7 +47,7 @@ public:
virtual bool enable(); virtual bool enable();
virtual void disable(); virtual void disable();
virtual void draw(View *view); virtual void draw(View *view) {}
virtual void drawMap(View* view, MapHandlerGen* map); virtual void drawMap(View* view, MapHandlerGen* map);
virtual void keyPress(View* view, QKeyEvent* event); virtual void keyPress(View* view, QKeyEvent* event);
...@@ -97,6 +97,10 @@ protected: ...@@ -97,6 +97,10 @@ protected:
Utils::Drawer* m_selectingCellDrawer; Utils::Drawer* m_selectingCellDrawer;
bool m_selectedVertices_dirty;
bool m_selectedEdges_dirty;
bool m_selectedFaces_dirty;
// WithinSphere parameters // WithinSphere parameters
Utils::VBO* m_selectionSphereVBO; Utils::VBO* m_selectionSphereVBO;
PFP2::REAL m_selectionRadiusBase; PFP2::REAL m_selectionRadiusBase;
......
...@@ -18,6 +18,9 @@ namespace SCHNApps ...@@ -18,6 +18,9 @@ namespace SCHNApps
Surface_Selection_Plugin::Surface_Selection_Plugin() : Surface_Selection_Plugin::Surface_Selection_Plugin() :
m_selecting(false), m_selecting(false),
m_selectedVertices_dirty(false),
m_selectedEdges_dirty(false),
m_selectedFaces_dirty(false),
m_selectionRadiusBase(1), m_selectionRadiusBase(1),
m_selectionRadiusCoeff(1), m_selectionRadiusCoeff(1),
m_normalAngleThreshold(10) m_normalAngleThreshold(10)
...@@ -79,10 +82,6 @@ void Surface_Selection_Plugin::disable() ...@@ -79,10 +82,6 @@ void Surface_Selection_Plugin::disable()
disconnect(m_schnapps, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(mapRemoved(MapHandlerGen*))); disconnect(m_schnapps, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(mapRemoved(MapHandlerGen*)));
} }
void Surface_Selection_Plugin::draw(View *view)
{
}
void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map) void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map)
{ {
if(map->isSelectedMap()) if(map->isSelectedMap())
...@@ -98,14 +97,20 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map) ...@@ -98,14 +97,20 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map)
switch(orbit) switch(orbit)
{ {
case VERTEX : { case VERTEX : {
m_pointSprite->setAttributePosition(m_selectedVerticesVBO); if (selector->getNbSelectedCells() > 0)
m_pointSprite->setSize(20 * map->getBBdiagSize() / nbCells); {
m_pointSprite->setColor(CGoGN::Geom::Vec4f(1.0f, 0.0f, 0.0f, 1.0f)); if (m_selectedVertices_dirty)
m_pointSprite->setLightPosition(CGoGN::Geom::Vec3f(0.0f, 0.0f, 1.0f)); updateSelectedCellsRendering();
m_pointSprite->enableVertexAttribs(); m_pointSprite->setAttributePosition(m_selectedVerticesVBO);
glDrawArrays(GL_POINTS, 0, selector->getNbSelectedCells()); m_pointSprite->setColor(CGoGN::Geom::Vec4f(1.0f, 0.0f, 0.0f, 1.0f));
m_pointSprite->disableVertexAttribs(); m_pointSprite->setLightPosition(CGoGN::Geom::Vec3f(0.0f, 0.0f, 1.0f));
m_pointSprite->setSize(20 * map->getBBdiagSize() / nbCells);
m_pointSprite->enableVertexAttribs();
glDrawArrays(GL_POINTS, 0, selector->getNbSelectedCells());
m_pointSprite->disableVertexAttribs();
}
if(m_selecting && m_selectingVertex.valid()) if(m_selecting && m_selectingVertex.valid())
{ {
...@@ -140,7 +145,12 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map) ...@@ -140,7 +145,12 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map)
break; break;
} }
case EDGE : { case EDGE : {
m_selectedEdgesDrawer->callList(); if (selector->getNbSelectedCells() > 0)
{
if (m_selectedEdges_dirty)
updateSelectedCellsRendering();
m_selectedEdgesDrawer->callList();
}
if(m_selecting && m_selectingEdge.valid()) if(m_selecting && m_selectingEdge.valid())
{ {
...@@ -182,7 +192,12 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map) ...@@ -182,7 +192,12 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map)
break; break;
} }
case FACE : { case FACE : {
m_selectedFacesDrawer->callList(); if (selector->getNbSelectedCells() > 0)
{
if (m_selectedFaces_dirty)
updateSelectedCellsRendering();
m_selectedFacesDrawer->callList();
}
if(m_selecting && m_selectingFace.valid()) if(m_selecting && m_selectingFace.valid())
{ {
...@@ -269,6 +284,7 @@ void Surface_Selection_Plugin::mousePress(View* view, QMouseEvent* event) ...@@ -269,6 +284,7 @@ void Surface_Selection_Plugin::mousePress(View* view, QMouseEvent* event)
CellSelector<PFP2::MAP, VERTEX>* cs = static_cast<CellSelector<PFP2::MAP, VERTEX>*>(selector); CellSelector<PFP2::MAP, VERTEX>* cs = static_cast<CellSelector<PFP2::MAP, VERTEX>*>(selector);
if(m_selectingVertex.valid()) if(m_selectingVertex.valid())
{ {
m_selectedVertices_dirty = true;
switch(p.selectionMethod) switch(p.selectionMethod)
{ {
case SingleCell : { case SingleCell : {
...@@ -300,7 +316,6 @@ void Surface_Selection_Plugin::mousePress(View* view, QMouseEvent* event) ...@@ -300,7 +316,6 @@ void Surface_Selection_Plugin::mousePress(View* view, QMouseEvent* event)
break; break;
} }
} }
updateSelectedCellsRendering();
} }
break; break;
} }
...@@ -308,6 +323,7 @@ void Surface_Selection_Plugin::mousePress(View* view, QMouseEvent* event) ...@@ -308,6 +323,7 @@ void Surface_Selection_Plugin::mousePress(View* view, QMouseEvent* event)
CellSelector<PFP2::MAP, EDGE>* cs = static_cast<CellSelector<PFP2::MAP, EDGE>*>(selector); CellSelector<PFP2::MAP, EDGE>* cs = static_cast<CellSelector<PFP2::MAP, EDGE>*>(selector);
if(m_selectingEdge.valid()) if(m_selectingEdge.valid())
{ {
m_selectedEdges_dirty = true;
switch(p.selectionMethod) switch(p.selectionMethod)
{ {
case SingleCell : { case SingleCell : {
...@@ -339,7 +355,6 @@ void Surface_Selection_Plugin::mousePress(View* view, QMouseEvent* event) ...@@ -339,7 +355,6 @@ void Surface_Selection_Plugin::mousePress(View* view, QMouseEvent* event)
break; break;
} }
} }
updateSelectedCellsRendering();
} }
break; break;
} }
...@@ -347,6 +362,7 @@ void Surface_Selection_Plugin::mousePress(View* view, QMouseEvent* event) ...@@ -347,6 +362,7 @@ void Surface_Selection_Plugin::mousePress(View* view, QMouseEvent* event)
CellSelector<PFP2::MAP, FACE>* cs = static_cast<CellSelector<PFP2::MAP, FACE>*>(selector); CellSelector<PFP2::MAP, FACE>* cs = static_cast<CellSelector<PFP2::MAP, FACE>*>(selector);
if(m_selectingFace.valid()) if(m_selectingFace.valid())
{ {
m_selectedFaces_dirty = true;
switch(p.selectionMethod) switch(p.selectionMethod)
{ {
case SingleCell : { case SingleCell : {
...@@ -378,7 +394,6 @@ void Surface_Selection_Plugin::mousePress(View* view, QMouseEvent* event) ...@@ -378,7 +394,6 @@ void Surface_Selection_Plugin::mousePress(View* view, QMouseEvent* event)
break; break;
} }
} }
updateSelectedCellsRendering();
} }
break; break;
} }
...@@ -494,11 +509,13 @@ void Surface_Selection_Plugin::selectedMapChanged(MapHandlerGen *prev, MapHandle ...@@ -494,11 +509,13 @@ void Surface_Selection_Plugin::selectedMapChanged(MapHandlerGen *prev, MapHandle
void Surface_Selection_Plugin::updateSelectedCellsRendering() void Surface_Selection_Plugin::updateSelectedCellsRendering()
{ {
MapHandlerGen* map = m_schnapps->getSelectedMap(); MapHandlerGen* map = m_schnapps->getSelectedMap();
const MapParameters& p = h_parameterSet[map]; const MapParameters& p = h_parameterSet[map];
if(p.positionAttribute.isValid()) if(p.positionAttribute.isValid())
{ {
unsigned int orbit = m_schnapps->getCurrentOrbit(); unsigned int orbit = m_schnapps->getCurrentOrbit();
CellSelectorGen* selector = m_schnapps->getSelectedSelector(orbit); CellSelectorGen* selector = m_schnapps->getSelectedSelector(orbit);
switch(orbit) switch(orbit)
{ {
case VERTEX : { case VERTEX : {
...@@ -508,6 +525,7 @@ void Surface_Selection_Plugin::updateSelectedCellsRendering() ...@@ -508,6 +525,7 @@ void Surface_Selection_Plugin::updateSelectedCellsRendering()
for(std::vector<Vertex>::const_iterator v = selectedCells.begin(); v != selectedCells.end(); ++v) for(std::vector<Vertex>::const_iterator v = selectedCells.begin(); v != selectedCells.end(); ++v)
selectedPoints.push_back(p.positionAttribute[*v]); selectedPoints.push_back(p.positionAttribute[*v]);
m_selectedVerticesVBO->updateData(selectedPoints); m_selectedVerticesVBO->updateData(selectedPoints);
m_selectedVertices_dirty = false;
break; break;
} }
case EDGE : { case EDGE : {
...@@ -527,6 +545,7 @@ void Surface_Selection_Plugin::updateSelectedCellsRendering() ...@@ -527,6 +545,7 @@ void Surface_Selection_Plugin::updateSelectedCellsRendering()
} }
m_selectedEdgesDrawer->end(); m_selectedEdgesDrawer->end();
m_selectedEdgesDrawer->endList(); m_selectedEdgesDrawer->endList();
m_selectedEdges_dirty = false;
break; break;
} }
case FACE : { case FACE : {
...@@ -546,16 +565,11 @@ void Surface_Selection_Plugin::updateSelectedCellsRendering() ...@@ -546,16 +565,11 @@ void Surface_Selection_Plugin::updateSelectedCellsRendering()
} }
m_selectedFacesDrawer->end(); m_selectedFacesDrawer->end();
m_selectedFacesDrawer->endList(); m_selectedFacesDrawer->endList();
m_selectedFaces_dirty = false;
break; break;
} }
} }
} }
foreach(View* view, l_views)
{
if(view->isLinkedToMap(map))
view->updateGL();
}
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment