Commit ad631239 authored by Sylvain Thery's avatar Sylvain Thery

update views from selector change

parent 938b9d3a
...@@ -182,7 +182,7 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map) ...@@ -182,7 +182,7 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map)
break; break;
} }
case WithinSphere : { case WithinSphere : {
PFP2::MAP* m = static_cast<MapHandler<PFP2>*>(map)->getMap(); // PFP2::MAP* m = static_cast<MapHandler<PFP2>*>(map)->getMap();
std::vector<PFP2::VEC3> selectionPoint; std::vector<PFP2::VEC3> selectionPoint;
selectionPoint.push_back(p.positionAttribute[m_selectingEdge.dart]); selectionPoint.push_back(p.positionAttribute[m_selectingEdge.dart]);
m_selectionSphereVBO->updateData(selectionPoint); m_selectionSphereVBO->updateData(selectionPoint);
...@@ -234,7 +234,7 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map) ...@@ -234,7 +234,7 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map)
break; break;
} }
case WithinSphere : { case WithinSphere : {
PFP2::MAP* m = static_cast<MapHandler<PFP2>*>(map)->getMap(); // PFP2::MAP* m = static_cast<MapHandler<PFP2>*>(map)->getMap();
std::vector<PFP2::VEC3> selectionPoint; std::vector<PFP2::VEC3> selectionPoint;
selectionPoint.push_back(p.positionAttribute[m_selectingFace.dart]); selectionPoint.push_back(p.positionAttribute[m_selectingFace.dart]);
...@@ -549,73 +549,78 @@ void Surface_Selection_Plugin::updateSelectedCellsRendering() ...@@ -549,73 +549,78 @@ void Surface_Selection_Plugin::updateSelectedCellsRendering()
{ {
unsigned int orbit = m_schnapps->getCurrentOrbit(); unsigned int orbit = m_schnapps->getCurrentOrbit();
CellSelectorGen* selector = m_schnapps->getSelectedSelector(orbit); CellSelectorGen* selector = m_schnapps->getSelectedSelector(orbit);
if (selector == NULL) if (selector != NULL)
return;
switch(orbit)
{ {
case VERTEX : { switch(orbit)
CellSelector<PFP2::MAP, VERTEX>* cs = static_cast<CellSelector<PFP2::MAP, VERTEX>*>(selector); {
const std::vector<Vertex>& selectedCells = cs->getSelectedCells(); case VERTEX : {
std::vector<PFP2::VEC3> selectedPoints; CellSelector<PFP2::MAP, VERTEX>* cs = static_cast<CellSelector<PFP2::MAP, VERTEX>*>(selector);
for(std::vector<Vertex>::const_iterator v = selectedCells.begin(); v != selectedCells.end(); ++v) const std::vector<Vertex>& selectedCells = cs->getSelectedCells();
selectedPoints.push_back(p.positionAttribute[*v]); std::vector<PFP2::VEC3> selectedPoints;
m_selectedVerticesVBO->updateData(selectedPoints); for(std::vector<Vertex>::const_iterator v = selectedCells.begin(); v != selectedCells.end(); ++v)
m_selectedVertices_dirty = false; selectedPoints.push_back(p.positionAttribute[*v]);
break; m_selectedVerticesVBO->updateData(selectedPoints);
} m_selectedVertices_dirty = false;
case EDGE : { break;
PFP2::MAP* m = static_cast<MapHandler<PFP2>*>(map)->getMap();
CellSelector<PFP2::MAP, EDGE>* cs = static_cast<CellSelector<PFP2::MAP, EDGE>*>(selector);
const std::vector<Edge>& selectedCells = cs->getSelectedCells();
m_selectedEdgesDrawer->newList(GL_COMPILE);
m_selectedEdgesDrawer->lineWidth(3.0f);
// m_selectedEdgesDrawer->color3f(1.0f, 0.0f, 0.0f);
m_selectedEdgesDrawer->color3f(p.color.redF(), p.color.greenF(), p.color.blueF());
m_selectedEdgesDrawer->begin(GL_LINES);
for(std::vector<Edge>::const_iterator e = selectedCells.begin(); e != selectedCells.end(); ++e)
{
m_selectedEdgesDrawer->vertex(p.positionAttribute[(*e).dart]);
m_selectedEdgesDrawer->vertex(p.positionAttribute[m->phi1((*e).dart)]);
} }
m_selectedEdgesDrawer->end(); case EDGE : {
m_selectedEdgesDrawer->endList(); PFP2::MAP* m = static_cast<MapHandler<PFP2>*>(map)->getMap();
m_selectedEdges_dirty = false;
break; CellSelector<PFP2::MAP, EDGE>* cs = static_cast<CellSelector<PFP2::MAP, EDGE>*>(selector);
} const std::vector<Edge>& selectedCells = cs->getSelectedCells();
case FACE : {
PFP2::MAP* m = static_cast<MapHandler<PFP2>*>(map)->getMap(); m_selectedEdgesDrawer->newList(GL_COMPILE);
m_selectedEdgesDrawer->lineWidth(3.0f);
// m_selectedEdgesDrawer->color3f(1.0f, 0.0f, 0.0f);
m_selectedEdgesDrawer->color3f(p.color.redF(), p.color.greenF(), p.color.blueF());
m_selectedEdgesDrawer->begin(GL_LINES);
for(std::vector<Edge>::const_iterator e = selectedCells.begin(); e != selectedCells.end(); ++e)
{
m_selectedEdgesDrawer->vertex(p.positionAttribute[(*e).dart]);
m_selectedEdgesDrawer->vertex(p.positionAttribute[m->phi1((*e).dart)]);
}
m_selectedEdgesDrawer->end();
m_selectedEdgesDrawer->endList();
m_selectedEdges_dirty = false;
break;
}
case FACE : {
PFP2::MAP* m = static_cast<MapHandler<PFP2>*>(map)->getMap();
CellSelector<PFP2::MAP, FACE>* cs = static_cast<CellSelector<PFP2::MAP, FACE>*>(selector); CellSelector<PFP2::MAP, FACE>* cs = static_cast<CellSelector<PFP2::MAP, FACE>*>(selector);
const std::vector<Face>& selectedCells = cs->getSelectedCells(); const std::vector<Face>& selectedCells = cs->getSelectedCells();
m_selectedFacesDrawer->newList(GL_COMPILE); m_selectedFacesDrawer->newList(GL_COMPILE);
m_selectedFacesDrawer->color3f(p.color.redF(), p.color.greenF(), p.color.blueF()); m_selectedFacesDrawer->color3f(p.color.redF(), p.color.greenF(), p.color.blueF());
m_selectedFacesDrawer->begin(GL_TRIANGLES); m_selectedFacesDrawer->begin(GL_TRIANGLES);
for(std::vector<Face>::const_iterator f = selectedCells.begin(); f != selectedCells.end(); ++f) for(std::vector<Face>::const_iterator f = selectedCells.begin(); f != selectedCells.end(); ++f)
{
Dart d = m->phi1((*f).dart);
Dart e = m->phi1(d);
do
{ {
m_selectedFacesDrawer->vertex(p.positionAttribute[f->dart]); Dart d = m->phi1((*f).dart);
m_selectedFacesDrawer->vertex(p.positionAttribute[d]); Dart e = m->phi1(d);
m_selectedFacesDrawer->vertex(p.positionAttribute[e]); do
d = e; {
e = m->phi1(d); m_selectedFacesDrawer->vertex(p.positionAttribute[f->dart]);
} while (e != f->dart); m_selectedFacesDrawer->vertex(p.positionAttribute[d]);
m_selectedFacesDrawer->vertex(p.positionAttribute[e]);
d = e;
e = m->phi1(d);
} while (e != f->dart);
}
m_selectedFacesDrawer->end();
m_selectedFacesDrawer->endList();
m_selectedFaces_dirty = false;
break;
} }
m_selectedFacesDrawer->end();
m_selectedFacesDrawer->endList();
m_selectedFaces_dirty = false;
break;
} }
} }
} }
const QList<View*>& lv = this->getLinkedViews();
foreach(View* v, lv)
{
v->updateGL();
}
} }
void Surface_Selection_Plugin::updateRemovedSelector(unsigned int orbit, const QString& name) void Surface_Selection_Plugin::updateRemovedSelector(unsigned int orbit, const QString& name)
{ {
updateSelectedCellsRendering(); updateSelectedCellsRendering();
......
...@@ -235,12 +235,12 @@ void ControlDock_MapTab::selectedSelectorChanged() ...@@ -235,12 +235,12 @@ void ControlDock_MapTab::selectedSelectorChanged()
if (!items.empty()) if (!items.empty())
{ {
m_selectedSelector[orbit] = m_selectedMap->getCellSelector(orbit, items[0]->text()); m_selectedSelector[orbit] = m_selectedMap->getCellSelector(orbit, items[0]->text());
m_schnapps->notifySelectedCellSelectorChanged(m_selectedSelector[orbit]);
QTextStream* rec = m_schnapps->pythonStreamRecorder(); QTextStream* rec = m_schnapps->pythonStreamRecorder();
if (rec) if (rec)
*rec << "schnapps.setSelectedSelectorCurrentMap(" << orbit << ", \"" << items[0]->text() << "\");" << endl; *rec << "schnapps.setSelectedSelectorCurrentMap(" << orbit << ", \"" << items[0]->text() << "\");" << endl;
} }
m_schnapps->notifySelectedCellSelectorChanged(m_selectedSelector[orbit]); // notify even if nothing selected !
} }
} }
......
...@@ -806,6 +806,7 @@ void SCHNApps::setSelectedSelectorCurrentMap(unsigned int orbit, const QString& ...@@ -806,6 +806,7 @@ void SCHNApps::setSelectedSelectorCurrentMap(unsigned int orbit, const QString&
case FACE: items = m_controlMapTab->list_faceSelectors->findItems(name, Qt::MatchExactly); break; case FACE: items = m_controlMapTab->list_faceSelectors->findItems(name, Qt::MatchExactly); break;
case VOLUME: items = m_controlMapTab->list_volumeSelectors->findItems(name, Qt::MatchExactly); break; case VOLUME: items = m_controlMapTab->list_volumeSelectors->findItems(name, Qt::MatchExactly); break;
} }
m_controlMapTab->tabWidget_mapInfo->setCurrentIndex(orbit);
if (!items.empty()) if (!items.empty())
items[0]->setSelected(true); items[0]->setSelected(true);
} }
......
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