Commit 8c66db32 authored by Sylvain Thery's avatar Sylvain Thery

Merge branch 'develop' of cgogn.u-strasbg.fr:~kraemer/CGoGN into develop

parents 248431e8 5fa57ec1
...@@ -99,39 +99,11 @@ public: ...@@ -99,39 +99,11 @@ public:
const AttributeSet& getAttributeSet(unsigned int orbit) const { return m_attribs[orbit]; } const AttributeSet& getAttributeSet(unsigned int orbit) const { return m_attribs[orbit]; }
void notifyAttributeModification(const AttributeHandlerGen& attr) void notifyAttributeModification(const AttributeHandlerGen& attr);
{
QString nameAttr = QString::fromStdString(attr.name());
if(m_vbo.contains(nameAttr))
m_vbo[nameAttr]->updateData(attr);
emit(attributeModified(attr.getOrbit(), nameAttr));
foreach(View* view, l_views)
view->updateGL();
}
void notifyConnectivityModification()
{
if (m_render)
{
m_render->setPrimitiveDirty(Algo::Render::GL2::POINTS);
m_render->setPrimitiveDirty(Algo::Render::GL2::LINES);
m_render->setPrimitiveDirty(Algo::Render::GL2::TRIANGLES);
m_render->setPrimitiveDirty(Algo::Render::GL2::BOUNDARY);
}
for(unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit)
{
foreach (CellSelectorGen* cs, m_cellSelectors[orbit])
cs->rebuild();
}
emit(connectivityModified()); void notifyConnectivityModification();
foreach(View* view, l_views) void clear(bool removeAttrib);
view->updateGL();
}
/********************************************************* /*********************************************************
* MANAGE VBOs * MANAGE VBOs
...@@ -184,6 +156,7 @@ signals: ...@@ -184,6 +156,7 @@ signals:
void attributeAdded(unsigned int orbit, const QString& nameAttr); void attributeAdded(unsigned int orbit, const QString& nameAttr);
void attributeModified(unsigned int orbit, QString nameAttr); void attributeModified(unsigned int orbit, QString nameAttr);
void attributeRemoved(unsigned int orbit, const QString& nameAttr);
void vboAdded(Utils::VBO* vbo); void vboAdded(Utils::VBO* vbo);
void vboRemoved(Utils::VBO* vbo); void vboRemoved(Utils::VBO* vbo);
......
...@@ -29,6 +29,96 @@ MapHandlerGen::~MapHandlerGen() ...@@ -29,6 +29,96 @@ MapHandlerGen::~MapHandlerGen()
delete vbo; delete vbo;
} }
/*********************************************************
* MANAGE ATTRIBUTES
*********************************************************/
void MapHandlerGen::notifyAttributeModification(const AttributeHandlerGen& attr)
{
QString nameAttr = QString::fromStdString(attr.name());
if(m_vbo.contains(nameAttr))
m_vbo[nameAttr]->updateData(attr);
emit(attributeModified(attr.getOrbit(), nameAttr));
foreach(View* view, l_views)
view->updateGL();
}
void MapHandlerGen::notifyConnectivityModification()
{
if (m_render)
{
m_render->setPrimitiveDirty(Algo::Render::GL2::POINTS);
m_render->setPrimitiveDirty(Algo::Render::GL2::LINES);
m_render->setPrimitiveDirty(Algo::Render::GL2::TRIANGLES);
m_render->setPrimitiveDirty(Algo::Render::GL2::BOUNDARY);
}
for(unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit)
{
foreach (CellSelectorGen* cs, m_cellSelectors[orbit])
cs->rebuild();
}
emit(connectivityModified());
foreach(View* view, l_views)
view->updateGL();
}
void MapHandlerGen::clear(bool removeAttrib)
{
if (m_render)
{
m_render->setPrimitiveDirty(Algo::Render::GL2::POINTS);
m_render->setPrimitiveDirty(Algo::Render::GL2::LINES);
m_render->setPrimitiveDirty(Algo::Render::GL2::TRIANGLES);
m_render->setPrimitiveDirty(Algo::Render::GL2::BOUNDARY);
}
for(unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit)
{
foreach (CellSelectorGen* cs, m_cellSelectors[orbit])
cs->rebuild();
}
std::vector<std::string> attrs[NB_ORBITS];
for (unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit)
{
if(m_map->isOrbitEmbedded(orbit))
{
AttributeContainer& cont = m_map->getAttributeContainer(orbit);
cont.getAttributesNames(attrs[orbit]);
}
}
m_map->clear(removeAttrib);
for (unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit)
{
for (unsigned int i = 0; i < attrs[orbit].size(); ++i)
{
QString name = QString::fromStdString(attrs[orbit][i]);
if (removeAttrib)
{
if (orbit == VERTEX)
deleteVBO(name);
emit(attributeRemoved(orbit, name));
}
else
{
if (orbit == VERTEX)
updateVBO(name);
emit(attributeModified(orbit, name));
}
}
}
emit(connectivityModified());
}
/********************************************************* /*********************************************************
* MANAGE VBOs * MANAGE VBOs
*********************************************************/ *********************************************************/
......
...@@ -126,9 +126,13 @@ public: ...@@ -126,9 +126,13 @@ public:
/** /**
* Apply a functor on each dart of the map * Apply a functor on each dart of the map
* @param f a ref to the functor obj * @param f a callable taking a Dart parameter
*/ */
bool foreach_dart(FunctorType& f) ; template <typename FUNC>
void foreach_dart(FUNC f) ;
template <typename FUNC>
void foreach_dart(FUNC& f) ;
/**************************************** /****************************************
* SAVE & LOAD * * SAVE & LOAD *
......
...@@ -228,7 +228,19 @@ inline void MapMono::next(Dart& d) const ...@@ -228,7 +228,19 @@ inline void MapMono::next(Dart& d) const
m_attribs[DART].next(d.index) ; m_attribs[DART].next(d.index) ;
} }
inline bool MapMono::foreach_dart(FunctorType& f) template <typename FUNC>
inline void MapMono::foreach_dart(FUNC f)
{
for (Dart d = begin(); d != end(); next(d))
{
if (f(d))
return true;
}
return false;
}
template <typename FUNC>
inline void MapMono::foreach_dart(FUNC& f)
{ {
for (Dart d = begin(); d != end(); next(d)) for (Dart d = begin(); d != end(); next(d))
{ {
......
...@@ -280,9 +280,13 @@ public: ...@@ -280,9 +280,13 @@ public:
/** /**
* Apply a functor on each dart of the map * Apply a functor on each dart of the map
* @param f a ref to the functor obj * @param f a callable taking a Dart parameter
*/ */
bool foreach_dart(FunctorType& f) ; template <typename FUNC>
void foreach_dart(FUNC f) ;
template <typename FUNC>
void foreach_dart(FUNC& f) ;
/**************************************** /****************************************
* SAVE & LOAD * * SAVE & LOAD *
......
...@@ -439,7 +439,19 @@ inline void MapMulti::next(Dart& d) const ...@@ -439,7 +439,19 @@ inline void MapMulti::next(Dart& d) const
d.index = m_mrattribs.end(); d.index = m_mrattribs.end();
} }
inline bool MapMulti::foreach_dart(FunctorType& f) template <typename FUNC>
inline void MapMulti::foreach_dart(FUNC f)
{
for (Dart d = begin(); d != end(); next(d))
{
if (f(d))
return true;
}
return false;
}
template <typename FUNC>
inline void MapMulti::foreach_dart(FUNC& f)
{ {
for (Dart d = begin(); d != end(); next(d)) for (Dart d = begin(); d != end(); next(d))
{ {
......
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