Commit 6c8638bf authored by Pierre Kraemer's avatar Pierre Kraemer
Browse files

connect attribute update in renderScalar plugin

parent 17bd0a69
...@@ -86,6 +86,8 @@ public slots: ...@@ -86,6 +86,8 @@ public slots:
void changePositionVBO(View* view, MapHandlerGen* map, Utils::VBO* vbo, bool fromUI = false); void changePositionVBO(View* view, MapHandlerGen* map, Utils::VBO* vbo, bool fromUI = false);
void changeScalarVBO(View* view, MapHandlerGen* map, Utils::VBO* vbo, bool fromUI = false); void changeScalarVBO(View* view, MapHandlerGen* map, Utils::VBO* vbo, bool fromUI = false);
void changeExpansion(View* view, MapHandlerGen* map, int i, bool fromUI = false); void changeExpansion(View* view, MapHandlerGen* map, int i, bool fromUI = false);
void attributeModified(unsigned int orbit, QString nameAttr);
}; };
} // namespace SCHNApps } // namespace SCHNApps
......
...@@ -60,7 +60,7 @@ void RenderScalarPlugin::redraw(View* view) ...@@ -60,7 +60,7 @@ void RenderScalarPlugin::redraw(View* view)
foreach(MapHandlerGen* m, maps) foreach(MapHandlerGen* m, maps)
{ {
PerMapParameterSet* p = params->perMap[m->getName()]; PerMapParameterSet* p = params->perMap[m->getName()];
if(p->positionVBO != NULL && p->scalarVBO != NULL) if(p->positionVBO && p->scalarVBO)
{ {
m_scalarShader->setAttributePosition(p->positionVBO); m_scalarShader->setAttributePosition(p->positionVBO);
m_scalarShader->setAttributeScalar(p->scalarVBO); m_scalarShader->setAttributeScalar(p->scalarVBO);
...@@ -130,7 +130,7 @@ void RenderScalarPlugin::mapUnlinked(MapHandlerGen* m) ...@@ -130,7 +130,7 @@ void RenderScalarPlugin::mapUnlinked(MapHandlerGen* m)
void RenderScalarPlugin::addManagedMap(View* v, MapHandlerGen *m) void RenderScalarPlugin::addManagedMap(View* v, MapHandlerGen *m)
{ {
// connect(m, SIGNAL(attributeModified(unsigned int, QString)), this, SLOT(attributeModified(unsigned int, QString))); connect(m, SIGNAL(attributeModified(unsigned int, QString)), this, SLOT(attributeModified(unsigned int, QString)));
// connect(m, SIGNAL(connectivityModified()), this, SLOT(connectivityModified())); // connect(m, SIGNAL(connectivityModified()), this, SLOT(connectivityModified()));
ParameterSet* params = h_viewParams[v]; ParameterSet* params = h_viewParams[v];
...@@ -146,7 +146,7 @@ void RenderScalarPlugin::addManagedMap(View* v, MapHandlerGen *m) ...@@ -146,7 +146,7 @@ void RenderScalarPlugin::addManagedMap(View* v, MapHandlerGen *m)
void RenderScalarPlugin::removeManagedMap(View *v, MapHandlerGen *m) void RenderScalarPlugin::removeManagedMap(View *v, MapHandlerGen *m)
{ {
// disconnect(m, SIGNAL(attributeModified(unsigned int, QString)), this, SLOT(attributeModified(unsigned int, QString))); disconnect(m, SIGNAL(attributeModified(unsigned int, QString)), this, SLOT(attributeModified(unsigned int, QString)));
// disconnect(m, SIGNAL(connectivityModified()), this, SLOT(connectivityModified())); // disconnect(m, SIGNAL(connectivityModified()), this, SLOT(connectivityModified()));
ParameterSet* params = h_viewParams[v]; ParameterSet* params = h_viewParams[v];
...@@ -208,7 +208,7 @@ void RenderScalarPlugin::changeScalarVBO(View* view, MapHandlerGen* map, Utils:: ...@@ -208,7 +208,7 @@ void RenderScalarPlugin::changeScalarVBO(View* view, MapHandlerGen* map, Utils::
{ {
const VertexAttribute<PFP2::REAL>& attr = map->getAttribute<PFP2::REAL, VERTEX>(QString::fromStdString(vbo->name())); const VertexAttribute<PFP2::REAL>& attr = map->getAttribute<PFP2::REAL, VERTEX>(QString::fromStdString(vbo->name()));
perMap->scalarMin = 1e20; perMap->scalarMin = 1e20;
perMap->scalarMax= -1e20; perMap->scalarMax = -1e20;
for(unsigned int i = attr.begin(); i != attr.end(); attr.next(i)) for(unsigned int i = attr.begin(); i != attr.end(); attr.next(i))
{ {
perMap->scalarMin = attr[i] < perMap->scalarMin ? attr[i] : perMap->scalarMin; perMap->scalarMin = attr[i] < perMap->scalarMin ? attr[i] : perMap->scalarMin;
...@@ -237,6 +237,33 @@ void RenderScalarPlugin::changeExpansion(View* view, MapHandlerGen* map, int i, ...@@ -237,6 +237,33 @@ void RenderScalarPlugin::changeExpansion(View* view, MapHandlerGen* map, int i,
} }
} }
void RenderScalarPlugin::attributeModified(unsigned int orbit, QString nameAttr)
{
if(orbit == VERTEX)
{
MapHandlerGen* map = static_cast<MapHandlerGen*>(QObject::sender());
foreach(View* view, l_views)
{
ParameterSet* params = h_viewParams[view];
if(params->perMap.contains(map->getName()))
{
PerMapParameterSet* perMap = params->perMap[map->getName()];
if(perMap->scalarVBO && nameAttr == QString::fromStdString(perMap->scalarVBO->name()))
{
const VertexAttribute<PFP2::REAL>& attr = map->getAttribute<PFP2::REAL, VERTEX>(nameAttr);
perMap->scalarMin = 1e20;
perMap->scalarMax = -1e20;
for(unsigned int i = attr.begin(); i != attr.end(); attr.next(i))
{
perMap->scalarMin = attr[i] < perMap->scalarMin ? attr[i] : perMap->scalarMin;
perMap->scalarMax = attr[i] > perMap->scalarMax ? attr[i] : perMap->scalarMax;
}
}
}
}
}
}
#ifndef DEBUG #ifndef DEBUG
Q_EXPORT_PLUGIN2(RenderScalarPlugin, RenderScalarPlugin) Q_EXPORT_PLUGIN2(RenderScalarPlugin, RenderScalarPlugin)
#else #else
......
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