Commit c4a807a7 authored by Pierre Kraemer's avatar Pierre Kraemer

uniformize per map parameters management in plugins

parent 63ee02b0
......@@ -49,7 +49,7 @@ struct ParameterSet
ParameterSet() : selectedMap(NULL)
{}
QHash<QString, PerMapParameterSet> perMap;
QHash<QString, PerMapParameterSet*> perMap;
MapHandlerGen* selectedMap;
};
......@@ -97,10 +97,17 @@ public slots:
void mapLinked(MapHandlerGen* m);
void mapUnlinked(MapHandlerGen* m);
protected:
void addManagedMap(View *v, MapHandlerGen* m);
void removeManagedMap(View *v, MapHandlerGen* m);
public slots:
void vboAdded(Utils::VBO* vbo);
void vboRemoved(Utils::VBO* vbo);
void changeSelectedMap(View* view, MapHandlerGen* map, bool fromUI = false);
void changeSelectedMap(View* view, MapHandlerGen* map);
void changePositionVBO(View* view, MapHandlerGen* map, Utils::VBO* vbo, bool fromUI = false);
void changeNormalVBO(View* view, MapHandlerGen* map, Utils::VBO* vbo, bool fromUI = false);
void changeRenderVertices(View* view, MapHandlerGen* map, bool b, bool fromUI = false);
......
......@@ -2,6 +2,7 @@
#define _RENDER_DOCK_TAB_H_
#include "ui_render.h"
#include "Utils/vbo.h"
namespace CGoGN
{
......@@ -30,8 +31,7 @@ public slots:
void refreshUI(ParameterSet* params);
void selectedMapChanged();
void addVBOToList(QString name);
void removeVBOFromList(QString name);
void positionVBOChanged(int index);
void normalVBOChanged(int index);
void renderVerticesChanged(bool b);
......@@ -39,6 +39,8 @@ public slots:
void renderEdgesChanged(bool b);
void renderFacesChanged(bool b);
void faceStyleChanged(QAbstractButton* b);
void addVBOToList(Utils::VBO* vbo);
};
} // namespace SCHNApps
......
......@@ -92,40 +92,40 @@ void RenderPlugin::redraw(View* view)
const QList<MapHandlerGen*>& maps = view->getLinkedMaps();
foreach(MapHandlerGen* m, maps)
{
const PerMapParameterSet& p = params->perMap[m->getName()];
if(p.positionVBO != NULL)
PerMapParameterSet* p = params->perMap[m->getName()];
if(p->positionVBO != NULL)
{
if(p.renderVertices)
if(p->renderVertices)
{
m_pointSprite->setSize(m->getBBdiagSize() / 200.0f * p.verticesScaleFactor);
m_pointSprite->setAttributePosition(p.positionVBO);
m_pointSprite->setSize(m->getBBdiagSize() / 200.0f * p->verticesScaleFactor);
m_pointSprite->setAttributePosition(p->positionVBO);
m_pointSprite->predraw(CGoGN::Geom::Vec3f(0.0f, 0.0f, 1.0f));
m->draw(m_pointSprite, CGoGN::Algo::Render::GL2::POINTS);
m_pointSprite->postdraw();
}
if(p.renderEdges)
if(p->renderEdges)
{
glLineWidth(1.0f);
m_simpleColorShader->setAttributePosition(p.positionVBO);
m_simpleColorShader->setAttributePosition(p->positionVBO);
m->draw(m_simpleColorShader, CGoGN::Algo::Render::GL2::LINES);
}
if(p.renderFaces)
if(p->renderFaces)
{
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_LIGHTING);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(1.0f, 1.0f);
switch(p.faceStyle)
switch(p->faceStyle)
{
case FLAT :
m_flatShader->setAttributePosition(p.positionVBO);
m_flatShader->setAttributePosition(p->positionVBO);
m->draw(m_flatShader, CGoGN::Algo::Render::GL2::TRIANGLES);
break ;
case PHONG :
if(p.normalVBO != NULL)
if(p->normalVBO != NULL)
{
m_phongShader->setAttributePosition(p.positionVBO) ;
m_phongShader->setAttributeNormal(p.normalVBO) ;
m_phongShader->setAttributePosition(p->positionVBO) ;
m_phongShader->setAttributeNormal(p->normalVBO) ;
m->draw(m_phongShader, CGoGN::Algo::Render::GL2::TRIANGLES);
}
break ;
......@@ -142,14 +142,10 @@ void RenderPlugin::viewLinked(View* view, Plugin* plugin)
{
ParameterSet* params = new ParameterSet();
h_viewParams.insert(view, params);
const QList<MapHandlerGen*>& maps = view->getLinkedMaps();
foreach(MapHandlerGen* map, maps)
{
PerMapParameterSet p(map);
params->perMap.insert(map->getName(), p);
}
if (!maps.empty())
changeSelectedMap(view, maps[0]);
foreach(MapHandlerGen* mh, maps)
addManagedMap(view, mh);
connect(view, SIGNAL(mapLinked(MapHandlerGen*)), this, SLOT(mapLinked(MapHandlerGen*)));
connect(view, SIGNAL(mapUnlinked(MapHandlerGen*)), this, SLOT(mapUnlinked(MapHandlerGen*)));
......@@ -163,6 +159,12 @@ void RenderPlugin::viewUnlinked(View* view, Plugin* plugin)
{
if(plugin == this)
{
const QList<MapHandlerGen*>& maps = view->getLinkedMaps();
foreach(MapHandlerGen* mh, maps)
removeManagedMap(view, mh);
ParameterSet* params = h_viewParams[view];
delete params;
h_viewParams.remove(view);
disconnect(view, SIGNAL(mapLinked(MapHandlerGen*)), this, SLOT(mapLinked(MapHandlerGen*)));
......@@ -173,68 +175,62 @@ void RenderPlugin::viewUnlinked(View* view, Plugin* plugin)
void RenderPlugin::currentViewChanged(View* view)
{
if(isLinkedToView(view))
{
ParameterSet* params = h_viewParams[view];
changeSelectedMap(view, params->selectedMap);
m_dockTab->refreshUI(h_viewParams[view]);
}
}
void RenderPlugin::mapLinked(MapHandlerGen* m)
{
View* view = static_cast<View*>(QObject::sender());
assert(isLinkedToView(view));
addManagedMap(view, m);
}
void RenderPlugin::mapUnlinked(MapHandlerGen* m)
{
View* view = static_cast<View*>(QObject::sender());
assert(isLinkedToView(view));
removeManagedMap(view, m);
}
void RenderPlugin::addManagedMap(View* v, MapHandlerGen *m)
{
// connect(m, SIGNAL(attributeModified(unsigned int, QString)), this, SLOT(attributeModified(unsigned int, QString)));
// connect(m, SIGNAL(connectivityModified()), this, SLOT(connectivityModified()));
ParameterSet* params = h_viewParams[v];
PerMapParameterSet* perMap = new PerMapParameterSet(m);
params->perMap.insert(m->getName(), perMap);
ParameterSet* params = h_viewParams[view];
PerMapParameterSet p(m);
params->perMap.insert(m->getName(), p);
if(params->selectedMap == NULL || params->perMap.count() == 1)
changeSelectedMap(view, m);
changeSelectedMap(v, m);
else
m_dockTab->refreshUI(params);
}
void RenderPlugin::mapUnlinked(MapHandlerGen* m)
void RenderPlugin::removeManagedMap(View *v, MapHandlerGen *m)
{
View* view = static_cast<View*>(QObject::sender());
assert(isLinkedToView(view));
// disconnect(m, SIGNAL(attributeModified(unsigned int, QString)), this, SLOT(attributeModified(unsigned int, QString)));
// disconnect(m, SIGNAL(connectivityModified()), this, SLOT(connectivityModified()));
ParameterSet* params = h_viewParams[view];
ParameterSet* params = h_viewParams[v];
PerMapParameterSet* perMap = params->perMap[m->getName()];
delete perMap;
params->perMap.remove(m->getName());
if(params->selectedMap == m)
{
if(!params->perMap.empty())
changeSelectedMap(view, m_window->getMap(params->perMap.begin().key()));
changeSelectedMap(v, m_window->getMap(params->perMap.begin().key()));
else
changeSelectedMap(view, NULL);
changeSelectedMap(v, NULL);
}
else
m_dockTab->refreshUI(params);
}
void RenderPlugin::vboAdded(Utils::VBO* vbo)
{
assert(h_viewParams[m_window->getCurrentView()]->selectedMap == static_cast<MapHandlerGen*>(QObject::sender()));
if(vbo->dataSize() == 3)
m_dockTab->addVBOToList(QString::fromStdString(vbo->name()));
}
void RenderPlugin::vboRemoved(Utils::VBO* vbo)
{
MapHandlerGen* map = static_cast<MapHandlerGen*>(QObject::sender());
View* view = m_window->getCurrentView();
ParameterSet* params = h_viewParams[view];
if(params->perMap[map->getName()].positionVBO == vbo)
changePositionVBO(view, map, NULL);
if(params->perMap[map->getName()].normalVBO == vbo)
changeNormalVBO(view, map, NULL);
m_dockTab->refreshUI(h_viewParams[view]);
}
void RenderPlugin::changeSelectedMap(View* view, MapHandlerGen* map, bool fromUI)
void RenderPlugin::changeSelectedMap(View* view, MapHandlerGen* map)
{
ParameterSet* params = h_viewParams[view];
......@@ -244,19 +240,18 @@ void RenderPlugin::changeSelectedMap(View* view, MapHandlerGen* map, bool fromUI
if(view->isCurrentView())
{
if(prev)
disconnect(prev, SIGNAL(vboAdded(Utils::VBO*)), this, SLOT(vboAdded(Utils::VBO*)));
disconnect(prev, SIGNAL(vboAdded(Utils::VBO*)), m_dockTab, SLOT(addVBOToList(Utils::VBO*)));
if(map)
connect(map, SIGNAL(vboAdded(Utils::VBO*)), this, SLOT(vboAdded(Utils::VBO*)));
connect(map, SIGNAL(vboAdded(Utils::VBO*)), m_dockTab, SLOT(addVBOToList(Utils::VBO*)));
if(!fromUI)
m_dockTab->refreshUI(params);
m_dockTab->refreshUI(params);
}
}
void RenderPlugin::changePositionVBO(View* view, MapHandlerGen* map, Utils::VBO* vbo, bool fromUI)
{
ParameterSet* params = h_viewParams[view];
params->perMap[map->getName()].positionVBO = vbo;
params->perMap[map->getName()]->positionVBO = vbo;
if(view->isCurrentView())
{
......@@ -269,7 +264,7 @@ void RenderPlugin::changePositionVBO(View* view, MapHandlerGen* map, Utils::VBO*
void RenderPlugin::changeNormalVBO(View* view, MapHandlerGen* map, Utils::VBO* vbo, bool fromUI)
{
ParameterSet* params = h_viewParams[view];
params->perMap[map->getName()].normalVBO = vbo;
params->perMap[map->getName()]->normalVBO = vbo;
if(view->isCurrentView())
{
......@@ -282,7 +277,7 @@ void RenderPlugin::changeNormalVBO(View* view, MapHandlerGen* map, Utils::VBO* v
void RenderPlugin::changeRenderVertices(View* view, MapHandlerGen* map, bool b, bool fromUI)
{
ParameterSet* params = h_viewParams[view];
params->perMap[map->getName()].renderVertices = b;
params->perMap[map->getName()]->renderVertices = b;
if(view->isCurrentView())
{
......@@ -295,7 +290,7 @@ void RenderPlugin::changeRenderVertices(View* view, MapHandlerGen* map, bool b,
void RenderPlugin::changeVerticesScaleFactor(View* view, MapHandlerGen* map, int i, bool fromUI)
{
ParameterSet* params = h_viewParams[view];
params->perMap[map->getName()].verticesScaleFactor = i / 50.0;
params->perMap[map->getName()]->verticesScaleFactor = i / 50.0;
if(view->isCurrentView())
{
......@@ -308,7 +303,7 @@ void RenderPlugin::changeVerticesScaleFactor(View* view, MapHandlerGen* map, int
void RenderPlugin::changeRenderEdges(View* view, MapHandlerGen* map, bool b, bool fromUI)
{
ParameterSet* params = h_viewParams[view];
params->perMap[map->getName()].renderEdges = b;
params->perMap[map->getName()]->renderEdges = b;
if(view->isCurrentView())
{
......@@ -321,7 +316,7 @@ void RenderPlugin::changeRenderEdges(View* view, MapHandlerGen* map, bool b, boo
void RenderPlugin::changeRenderFaces(View* view, MapHandlerGen* map, bool b, bool fromUI)
{
ParameterSet* params = h_viewParams[view];
params->perMap[map->getName()].renderFaces = b;
params->perMap[map->getName()]->renderFaces = b;
if(view->isCurrentView())
{
......@@ -334,7 +329,7 @@ void RenderPlugin::changeRenderFaces(View* view, MapHandlerGen* map, bool b, boo
void RenderPlugin::changeFacesStyle(View* view, MapHandlerGen* map, FaceShadingStyle style, bool fromUI)
{
ParameterSet* params = h_viewParams[view];
params->perMap[map->getName()].faceStyle = style;
params->perMap[map->getName()]->faceStyle = style;
if(view->isCurrentView())
{
......
......@@ -39,7 +39,7 @@ void RenderDockTab::refreshUI(ParameterSet* params)
MapHandlerGen* map = params->selectedMap;
QHash<QString, PerMapParameterSet>::const_iterator i = params->perMap.constBegin();
QHash<QString, PerMapParameterSet*>::const_iterator i = params->perMap.constBegin();
while (i != params->perMap.constEnd())
{
mapList->addItem(i.key());
......@@ -48,7 +48,7 @@ void RenderDockTab::refreshUI(ParameterSet* params)
QList<QListWidgetItem*> item = mapList->findItems(map->getName(), Qt::MatchExactly);
item[0]->setSelected(true);
PerMapParameterSet& p = params->perMap[map->getName()];
PerMapParameterSet* p = params->perMap[map->getName()];
QList<Utils::VBO*> vbos = map->getVBOList();
unsigned int j = 0;
......@@ -57,23 +57,23 @@ void RenderDockTab::refreshUI(ParameterSet* params)
if(vbos[i]->dataSize() == 3)
{
combo_positionVBO->addItem(QString::fromStdString(vbos[i]->name()));
if(vbos[i] == p.positionVBO)
if(vbos[i] == p->positionVBO)
combo_positionVBO->setCurrentIndex(j);
combo_normalVBO->addItem(QString::fromStdString(vbos[i]->name()));
if(vbos[i] == p.normalVBO)
if(vbos[i] == p->normalVBO)
combo_normalVBO->setCurrentIndex(j);
++j;
}
}
check_renderVertices->setChecked(p.renderVertices);
slider_verticesScaleFactor->setSliderPosition(p.verticesScaleFactor * 50.0);
check_renderEdges->setChecked(p.renderEdges);
check_renderFaces->setChecked(p.renderFaces);
radio_flatShading->setChecked(p.faceStyle == FLAT);
radio_phongShading->setChecked(p.faceStyle == PHONG);
check_renderVertices->setChecked(p->renderVertices);
slider_verticesScaleFactor->setSliderPosition(p->verticesScaleFactor * 50.0);
check_renderEdges->setChecked(p->renderEdges);
check_renderFaces->setChecked(p->renderFaces);
radio_flatShading->setChecked(p->faceStyle == FLAT);
radio_phongShading->setChecked(p->faceStyle == PHONG);
}
++i;
}
......@@ -87,27 +87,10 @@ void RenderDockTab::selectedMapChanged()
{
QList<QListWidgetItem*> currentItems = mapList->selectedItems();
if(!currentItems.empty())
m_plugin->changeSelectedMap(m_window->getCurrentView(), m_window->getMap(currentItems[0]->text()), true);
m_plugin->changeSelectedMap(m_window->getCurrentView(), m_window->getMap(currentItems[0]->text()));
}
}
void RenderDockTab::addVBOToList(QString name)
{
combo_positionVBO->addItem(name);
combo_normalVBO->addItem(name);
}
void RenderDockTab::removeVBOFromList(QString name)
{
int itemIdx = combo_positionVBO->findText(name, Qt::MatchExactly);
if(itemIdx != -1)
combo_positionVBO->removeItem(itemIdx);
itemIdx = combo_normalVBO->findText(name, Qt::MatchExactly);
if(itemIdx != -1)
combo_normalVBO->removeItem(itemIdx);
}
void RenderDockTab::positionVBOChanged(int index)
{
if(!b_refreshingUI)
......@@ -181,6 +164,16 @@ void RenderDockTab::faceStyleChanged(QAbstractButton* b)
}
}
void RenderDockTab::addVBOToList(Utils::VBO* vbo)
{
if(vbo->dataSize() == 3)
{
QString name = QString::fromStdString(vbo->name());
combo_positionVBO->addItem(name);
combo_normalVBO->addItem(name);
}
}
} // namespace SCHNApps
} // namespace CGoGN
......@@ -25,10 +25,11 @@ struct PerMapParameterSet
void updateRender();
Algo::Render::GL2::ExplodeVolumeRender* m_renderExplod;
MapHandlerGen* mh;
Algo::Render::GL2::ExplodeVolumeRender* m_renderExplod;
VertexAttribute<PFP3::VEC3> positionAttribute;
VolumeAttribute<PFP3::VEC3> colorAttribute;
float facesScaleFactor;
float volumesScaleFactor;
bool renderEdges;
......@@ -84,13 +85,15 @@ public slots:
void mapLinked(MapHandlerGen* m);
void mapUnlinked(MapHandlerGen* m);
//void addAttributeToList(unsigned int orbit, const QString& nameAttr);
protected:
void addManagedMap(View *v, MapHandlerGen* m);
void removeManagedMap(View *v, MapHandlerGen* m);
void changeSelectedMap(View* view, MapHandlerGen* map, bool fromUI = false);
public slots:
void changeSelectedMap(View* view, MapHandlerGen* map);
void changePositionAttribute(View* view, MapHandlerGen* map, VertexAttribute<PFP3::VEC3> attribute, bool fromUI = false);
void changeColorAttribute(View* view, MapHandlerGen* map, VertexAttribute<PFP3::VEC3> attribute, bool fromUI = false);
void changeRenderEdges(View* view, MapHandlerGen* map, bool b, bool fromUI = false);
void changeRenderFaces(View* view, MapHandlerGen* map, bool b, bool fromUI = false);
void changeFacesScaleFactor(View* view, MapHandlerGen* map, int i, bool fromUI = false);
......
......@@ -36,6 +36,8 @@ public slots:
void renderFacesChanged(bool b);
void facesScaleFactorChanged(int i);
void volumesScaleFactorChanged(int i);
void addAttributeToList(unsigned int orbit, const QString& nameAttr);
};
} // namespace SCHNApps
......
......@@ -16,7 +16,6 @@ PerMapParameterSet::PerMapParameterSet(MapHandlerGen* m) :
renderFaces(true),
faceStyle(FLAT)
{
m_renderExplod = new Algo::Render::GL2::ExplodeVolumeRender(false, false, false);
m_renderExplod->setNoClippingPlane();
......@@ -50,16 +49,12 @@ PerMapParameterSet::~PerMapParameterSet()
void PerMapParameterSet::updateRender()
{
MapHandler<PFP3>* mh3 = static_cast<MapHandler<PFP3>*>(mh);
if(mh3 == NULL)
return;
PFP3::MAP* m = mh3->getMap();
PFP3::MAP* m = static_cast<MapHandler<PFP3>*>(mh)->getMap();
//if(!color.isValid())
m_renderExplod->updateData<PFP3>(*m,positionAttribute);
m_renderExplod->updateData<PFP3>(*m, positionAttribute);
}
bool RenderExplodPlugin::enable()
{
m_dockTab = new RenderExplodDockTab(m_window, this);
......@@ -69,13 +64,12 @@ bool RenderExplodPlugin::enable()
connect(m_window, SIGNAL(viewAndPluginUnlinked(View*, Plugin*)), this, SLOT(viewUnlinked(View*, Plugin*)));
connect(m_window, SIGNAL(currentViewChanged(View*)), this, SLOT(currentViewChanged(View*)));
return true;
}
void RenderExplodPlugin::disable()
{
//delete m_renderExplod;
}
void RenderExplodPlugin::redraw(View* view)
......@@ -112,16 +106,10 @@ void RenderExplodPlugin::viewLinked(View* view, Plugin* plugin)
{
ParameterSet* params = new ParameterSet();
h_viewParams.insert(view, params);
const QList<MapHandlerGen*>& maps = view->getLinkedMaps();
foreach(MapHandlerGen* mh, maps)
{
PerMapParameterSet* p = new PerMapParameterSet(mh);
registerShader(p->m_renderExplod->shaderFaces());
registerShader(p->m_renderExplod->shaderLines());
params->perMap.insert(mh->getName(), p);
}
if (!maps.empty())
changeSelectedMap(view, maps[0]);
addManagedMap(view, mh);
connect(view, SIGNAL(mapLinked(MapHandlerGen*)), this, SLOT(mapLinked(MapHandlerGen*)));
connect(view, SIGNAL(mapUnlinked(MapHandlerGen*)), this, SLOT(mapUnlinked(MapHandlerGen*)));
......@@ -135,6 +123,12 @@ void RenderExplodPlugin::viewUnlinked(View* view, Plugin* plugin)
{
if(plugin == this)
{
const QList<MapHandlerGen*>& maps = view->getLinkedMaps();
foreach(MapHandlerGen* mh, maps)
removeManagedMap(view, mh);
ParameterSet* params = h_viewParams[view];
delete params;
h_viewParams.remove(view);
disconnect(view, SIGNAL(mapLinked(MapHandlerGen*)), this, SLOT(mapLinked(MapHandlerGen*)));
......@@ -145,60 +139,68 @@ void RenderExplodPlugin::viewUnlinked(View* view, Plugin* plugin)
void RenderExplodPlugin::currentViewChanged(View* view)
{
if(isLinkedToView(view))
{
ParameterSet* params = h_viewParams[view];
changeSelectedMap(view, params->selectedMap);
m_dockTab->refreshUI(h_viewParams[view]);
}
}
void RenderExplodPlugin::mapLinked(MapHandlerGen* m)
{
View* view = static_cast<View*>(QObject::sender());
assert(isLinkedToView(view));
addManagedMap(view, m);
}
void RenderExplodPlugin::mapUnlinked(MapHandlerGen* m)
{
View* view = static_cast<View*>(QObject::sender());
assert(isLinkedToView(view));
removeManagedMap(view, m);
}
void RenderExplodPlugin::addManagedMap(View* v, MapHandlerGen *m)
{
connect(m, SIGNAL(attributeModified(unsigned int, QString)), this, SLOT(attributeModified(unsigned int, QString)));
connect(m, SIGNAL(connectivityModified()), this, SLOT(connectivityModified()));
ParameterSet* params = h_viewParams[v];
PerMapParameterSet* perMap = new PerMapParameterSet(m);
ParameterSet* params = h_viewParams[view];
registerShader(perMap->m_renderExplod->shaderFaces());
registerShader(perMap->m_renderExplod->shaderLines());
PerMapParameterSet* p = new PerMapParameterSet(m);
registerShader(p->m_renderExplod->shaderFaces());
registerShader(p->m_renderExplod->shaderLines());
params->perMap.insert(m->getName(), p);
params->perMap.insert(m->getName(), perMap);
if(params->selectedMap == NULL || params->perMap.count() == 1)
changeSelectedMap(view, m);
changeSelectedMap(v, m);
else
m_dockTab->refreshUI(params);
}
void RenderExplodPlugin::mapUnlinked(MapHandlerGen* m)
void RenderExplodPlugin::removeManagedMap(View *v, MapHandlerGen *m)
{
View* view = static_cast<View*>(QObject::sender());
assert(isLinkedToView(view));
disconnect(m, SIGNAL(attributeModified(unsigned int, QString)), this, SLOT(attributeModified(unsigned int, QString)));
disconnect(m, SIGNAL(connectivityModified()), this, SLOT(connectivityModified()));
ParameterSet* params = h_viewParams[v];
PerMapParameterSet* perMap = params->perMap[m->getName()];
ParameterSet* params = h_viewParams[view];
unregisterShader(perMap->m_renderExplod->shaderFaces());
unregisterShader(perMap->m_renderExplod->shaderLines());
delete perMap;
params->perMap.remove(m->getName());
if(params->selectedMap == m)
{
if(!params->perMap.empty())
changeSelectedMap(view, m_window->getMap(params->perMap.begin().key()));
changeSelectedMap(v, m_window->getMap(params->perMap.begin().key()));
else
changeSelectedMap(view, NULL);
changeSelectedMap(v, NULL);
}
else
m_dockTab->refreshUI(params);
}
void RenderExplodPlugin::changeSelectedMap(View* view, MapHandlerGen* map, bool fromUI)
void RenderExplodPlugin::changeSelectedMap(View* view, MapHandlerGen* map)
{
ParameterSet* params = h_viewParams[view];
......@@ -207,9 +209,12 @@ void RenderExplodPlugin::changeSelectedMap(View* view, MapHandlerGen* map, bool
if(view->isCurrentView())
{
if(!fromUI)
m_dockTab->refreshUI(params);
view->updateGL();
if(prev)
disconnect(prev, SIGNAL(attributeAdded(unsigned int, const QString&)), m_dockTab, SLOT(addAttributeToList(unsigned int, const QString&)));
if(map)
connect(map, SIGNAL(attributeAdded(unsigned int, const QString&)), m_dockTab, SLOT(addAttributeToList(unsigned int, const QString&)));
m_dockTab->refreshUI(params);
}
}
......
......@@ -89,7 +89,7 @@ void RenderExplodDockTab::selectedMapChanged()
{
QList<QListWidgetItem*> currentItems = mapList->selectedItems();
if(!currentItems.empty())
m_plugin->changeSelectedMap(m_window->getCurrentView(), m_window->getMap(currentItems[0]->text()), true);
m_plugin->changeSelectedMap(m_window->getCurrentView(), m_window->getMap(currentItems[0]->text()));
}
}
......@@ -153,6 +153,19 @@ void RenderExplodDockTab::volumesScaleFactorChanged(int i)
}
}
void RenderExplodDockTab::addAttributeToList(unsigned int orbit, const QString& nameAttr)
{
QString vec3TypeName = QString::fromStdString(nameOfType(PFP2::VEC3()));
const QString& typeAttr = m_currentParams->selectedMap->getAttributeTypeName(orbit, nameAttr);
if(typeAttr == vec3TypeName)
{
combo_positionAttribute->addItem(nameAttr);
combo_colorAttribute->addItem(nameAttr);
}
}
} // namespace SCHNApps
} // namespace CGoGN
......@@ -81,7 +81,13 @@ public slots:
void mapLinked(MapHandlerGen* m);
void mapUnlinked(MapHandlerGen* m);
void changeSelectedMap(View* view, MapHandlerGen* map, bool fromUI = false);
protected:
void addManagedMap(View *v, MapHandlerGen* m);
void removeManagedMap(View *v, MapHandlerGen* m);
public slots:
void changeSelectedMap(View* view, MapHandlerGen* map);
void changePositionAttribute(View* view, MapHandlerGen* map, VertexAttribute<PFP2::VEC3> attribute, bool fromUI = false);
void changeDrawDarts(View* view, MapHandlerGen* map, bool b, bool fromUI = false);
void changeDartsColor(View* view, MapHandlerGen* map, QColor c, bool fromUI = false);
......
......@@ -39,6 +39,7 @@ public slots:
void phi2ColorChanged(int);
void edgesScaleFactorChanged(int i);
void facesScaleFactorChanged(int i);
void addAttributeToList(unsigned int orbit, const QString& nameAttr);
};
......
......@@ -92,18 +92,10 @@ void RenderTopoSurfacePlugin::viewLinked(View* view, Plugin* plugin)
{
ParameterSet* params = new ParameterSet();
h_viewParams.insert(view, params);
const QList<MapHandlerGen*>& maps = view->getLinkedMaps();
foreach(MapHandlerGen* mh, maps)
{
connect(mh, SIGNAL(attributeModified(unsigned int, QString)), this, SLOT(attributeModified(unsigned int, QString)));
connect(mh, SIGNAL(connectivityModified()), this, SLOT(connectivityModified()));