Commit 0a2944b2 authored by Pierre Kraemer's avatar Pierre Kraemer

SCHNApps: select default attributes in some plugins

parent 6026763c
......@@ -42,10 +42,16 @@ void ComputeNormalsDialog::cb_selectedMapChanged()
cont.getAttributesNames(names);
cont.getAttributesTypes(types);
std::string vec3TypeName = VEC3::CGoGNnameOfType();
unsigned int j = 0;
for(unsigned int i = 0; i < names.size(); ++i)
{
if(types[i] == vec3TypeName)
{
combo_positionAttribute->addItem(QString::fromStdString(names[i]));
if(names[i] == "position") // try to select an attribute named "position"
combo_positionAttribute->setCurrentIndex(j);
++j;
}
}
}
}
......
......@@ -4,6 +4,32 @@
#include "Algo/Import/import.h"
PerMapParameterSet::PerMapParameterSet(MapHandlerGen* map) :
positionVBO(NULL),
normalVBO(NULL),
verticesScaleFactor(1.0f),
renderVertices(false),
renderEdges(false),
renderFaces(true),
faceStyle(FLAT)
{
QList<Utils::VBO*> vbos = map->getVBOList();
for(int i = 0; i < vbos.count(); ++i)
{
if(vbos[i]->name() == "position") // try to select a VBO named "position"
positionVBO = vbos[i];
if(vbos[i]->name() == "normal") // try to select a VBO named "normal"
normalVBO = vbos[i];
}
if(positionVBO == NULL && vbos.count() > 0)
positionVBO = vbos[0];
if(normalVBO == NULL && vbos.count() > 0)
normalVBO = vbos[0];
}
bool RenderPlugin::enable()
{
m_dockTab = new RenderDockTab(this);
......@@ -110,7 +136,7 @@ void RenderPlugin::viewLinked(View* view)
const QList<MapHandlerGen*>& maps = view->getLinkedMaps();
foreach(MapHandlerGen* map, maps)
{
PerMapParameterSet p;
PerMapParameterSet p(map);
params->perMap.insert(map->getName(), p);
}
......@@ -136,7 +162,7 @@ void RenderPlugin::mapLinked(View* view, MapHandlerGen* m)
{
assert(isLinkedToView(view));
ParameterSet* params = h_viewParams[view];
PerMapParameterSet p;
PerMapParameterSet p(m);
params->perMap.insert(m->getName(), p);
m_dockTab->refreshUI(params);
......@@ -293,12 +319,30 @@ void RenderDockTab::refreshUI(ParameterSet* params)
for(int i = 0; i < vbos.count(); ++i)
{
combo_positionVBO->addItem(QString::fromStdString(vbos[i]->name()));
if(vbos[i] == p.positionVBO)
if(p.positionVBO == NULL)
{ // if nothing is specified in the parameter set
if(vbos[i]->name() == "position") // try to select a VBO named "position"
{
p.positionVBO = vbos[i];
combo_positionVBO->setCurrentIndex(i);
}
}
else if(vbos[i] == p.positionVBO)
combo_positionVBO->setCurrentIndex(i);
combo_normalVBO->addItem(QString::fromStdString(vbos[i]->name()));
if(vbos[i] == p.normalVBO)
if(p.normalVBO == NULL)
{ // if nothing is specified in the parameter set
if(vbos[i]->name() == "normal") // try to select a VBO named "normal"
{
p.normalVBO = vbos[i];
combo_normalVBO->setCurrentIndex(i);
}
}
else if(vbos[i] == p.normalVBO)
combo_normalVBO->setCurrentIndex(i);
}
if(p.positionVBO == NULL && vbos.count() > 0)
{
p.positionVBO = vbos[0];
......
......@@ -32,6 +32,8 @@ struct PerMapParameterSet
faceStyle(FLAT)
{}
PerMapParameterSet(MapHandlerGen* map);
Utils::VBO* positionVBO;
Utils::VBO* normalVBO;
float verticesScaleFactor;
......
......@@ -4,6 +4,26 @@
#include "Algo/Import/import.h"
PerMapParameterSet::PerMapParameterSet(MapHandlerGen* map) :
positionVBO(NULL),
vectorVBO(NULL),
vectorsScaleFactor(1.0f)
{
QList<Utils::VBO*> vbos = map->getVBOList();
for(int i = 0; i < vbos.count(); ++i)
{
if(vbos[i]->name() == "position") // try to select a VBO named "position"
positionVBO = vbos[i];
}
if(positionVBO == NULL && vbos.count() > 0)
positionVBO = vbos[0];
if(vectorVBO == NULL && vbos.count() > 0)
vectorVBO = vbos[0];
}
bool RenderVectorPlugin::enable()
{
m_dockTab = new RenderVectorDockTab(this);
......@@ -54,7 +74,7 @@ void RenderVectorPlugin::viewLinked(View* view)
const QList<MapHandlerGen*>& maps = view->getLinkedMaps();
foreach(MapHandlerGen* map, maps)
{
PerMapParameterSet p;
PerMapParameterSet p(map);
params->perMap.insert(map->getName(), p);
}
......@@ -80,7 +100,7 @@ void RenderVectorPlugin::mapLinked(View* view, MapHandlerGen* m)
{
assert(isLinkedToView(view));
ParameterSet* params = h_viewParams[view];
PerMapParameterSet p;
PerMapParameterSet p(m);
params->perMap.insert(m->getName(), p);
m_dockTab->refreshUI(params);
......@@ -186,12 +206,22 @@ void RenderVectorDockTab::refreshUI(ParameterSet* params)
for(int i = 0; i < vbos.count(); ++i)
{
combo_positionVBO->addItem(QString::fromStdString(vbos[i]->name()));
if(vbos[i] == p.positionVBO)
if(p.positionVBO == NULL)
{ // if nothing is specified in the parameter set
if(vbos[i]->name() == "position") // try to select a VBO named "position"
{
p.positionVBO = vbos[i];
combo_positionVBO->setCurrentIndex(i);
}
}
else if(vbos[i] == p.positionVBO)
combo_positionVBO->setCurrentIndex(i);
combo_vectorVBO->addItem(QString::fromStdString(vbos[i]->name()));
if(vbos[i] == p.vectorVBO)
combo_vectorVBO->setCurrentIndex(i);
}
if(p.positionVBO == NULL && vbos.count() > 0)
{
p.positionVBO = vbos[0];
......
......@@ -19,6 +19,8 @@ struct PerMapParameterSet
vectorsScaleFactor(1.0f)
{}
PerMapParameterSet(MapHandlerGen* map);
Utils::VBO* positionVBO;
Utils::VBO* vectorVBO;
float vectorsScaleFactor;
......
......@@ -54,10 +54,16 @@ void SubdivideSurfacePlugin::cb_selectedMapChanged()
cont.getAttributesNames(names);
cont.getAttributesTypes(types);
std::string vec3TypeName = VEC3::CGoGNnameOfType();
unsigned int j = 0;
for(unsigned int i = 0; i < names.size(); ++i)
{
if(types[i] == vec3TypeName)
{
m_dockTab->combo_positionAttribute->addItem(QString::fromStdString(names[i]));
if(names[i] == "position") // try to select an attribute named "position"
m_dockTab->combo_positionAttribute->setCurrentIndex(j);
++j;
}
}
}
}
......
......@@ -68,6 +68,7 @@ public:
void registerShader(Utils::GLSLShader* shader);
void unregisterShader(Utils::GLSLShader* shader);
const QList<Utils::GLSLShader*> getShaders() const { return l_shaders; }
/*********************************************************
* MANAGE DOCK TABS
......
......@@ -46,14 +46,12 @@ void PluginsViewDialog::cb_selectedPluginsChanged()
if(pluginList->item(i)->isSelected() && !m_view->isLinkedToPlugin(plugin))
{
assert(!plugin->isLinkedToView(m_view));
std::cout << "link view : " << m_view->getName().toUtf8().constData() << " to plugin : " << plugin->getName().toUtf8().constData() << std::endl;
m_view->linkPlugin(plugin);
plugin->linkView(m_view);
}
else if(!pluginList->item(i)->isSelected() && m_view->isLinkedToPlugin(plugin))
{
assert(plugin->isLinkedToView(m_view));
std::cout << "unlink view : " << m_view->getName().toUtf8().constData() << " from plugin : " << plugin->getName().toUtf8().constData() << std::endl;
m_view->unlinkPlugin(plugin);
plugin->unlinkView(m_view);
}
......
......@@ -45,8 +45,6 @@ bool Plugin::linkView(View* view)
if(view && !l_views.contains(view))
{
l_views.push_back(view);
foreach(Utils::GLSLShader* shader, l_shaders)
Utils::GLSLShader::registerShader(view, shader);
viewLinked(view);
return true;
}
......@@ -57,11 +55,7 @@ bool Plugin::linkView(View* view)
void Plugin::unlinkView(View* view)
{
if(l_views.removeOne(view))
{
foreach(Utils::GLSLShader* shader, l_shaders)
Utils::GLSLShader::unregisterShader(view, shader);
viewUnlinked(view);
}
}
/*********************************************************
......
......@@ -106,12 +106,11 @@ void View::preDraw()
glm::mat4 mm = getCurrentModelViewMatrix();
glm::mat4 pm = getCurrentProjectionMatrix();
for(std::set< std::pair<void*, CGoGN::Utils::GLSLShader*> >::iterator it = CGoGN::Utils::GLSLShader::m_registeredShaders.begin();
it != CGoGN::Utils::GLSLShader::m_registeredShaders.end();
++it)
foreach(Plugin* plugin, l_plugins)
{
if(it->first == this || it->first == NULL)
it->second->updateMatrices(pm, mm);
const QList<CGoGN::Utils::GLSLShader*>& shaders = plugin->getShaders();
foreach(CGoGN::Utils::GLSLShader* shader, shaders)
shader->updateMatrices(pm, mm);
}
QGLViewer::preDraw();
......
......@@ -163,7 +163,6 @@ bool Window::addMenuAction(const QString& menuPath, QAction* action)
return false;
}
// for every extracted substring
unsigned int i = 0;
QMenu* lastMenu = NULL;
foreach(QString step, stepNames)
......@@ -189,9 +188,16 @@ bool Window::addMenuAction(const QString& menuPath, QAction* action)
if (!found)
{
QMenu* newMenu;
if(i == 1) newMenu = menubar->addMenu(step);
else newMenu = lastMenu->addMenu(step);
newMenu->setParent(lastMenu);
if(i == 1)
{
newMenu = menubar->addMenu(step);
newMenu->setParent(menubar);
}
else
{
newMenu = lastMenu->addMenu(step);
newMenu->setParent(lastMenu);
}
lastMenu = newMenu;
}
}
......
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