Commit d35be576 authored by Kenneth Vanhoey's avatar Kenneth Vanhoey

Merge branch 'master' of cgogn:~cgogn/CGoGN

parents 429d7284 5600a6e5
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>282</width>
<height>265</height>
<width>287</width>
<height>228</height>
</rect>
</property>
<property name="windowTitle">
......@@ -63,48 +63,63 @@
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="button_cancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_apply">
<property name="text">
<string>Apply</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_ok">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<sender>button_ok</sender>
<signal>clicked()</signal>
<receiver>ComputeNormalsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
<x>232</x>
<y>283</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
<x>140</x>
<y>156</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<sender>button_cancel</sender>
<signal>clicked()</signal>
<receiver>ComputeNormalsDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
<x>52</x>
<y>283</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
<x>140</x>
<y>156</y>
</hint>
</hints>
</connection>
......
......@@ -65,6 +65,7 @@ private:
ComputeNormalsDialog* m_computeNormalsDialog;
QAction* computeNormalsAction;
QAction* computeCurvatureAction;
};
#endif
......@@ -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;
}
}
}
}
......
......@@ -9,11 +9,17 @@ bool DifferentialPropertiesPlugin::enable()
{
m_computeNormalsDialog = new ComputeNormalsDialog(m_window);
computeNormalsAction = new QAction("import", this);
addMenuAction("Surface;DifferentialProperties;Compute Normals", computeNormalsAction);
computeNormalsAction = new QAction("Compute Normals", this);
computeCurvatureAction = new QAction("Compute Curvature", this);
addMenuAction("Surface;Differential Properties;Compute Normals", computeNormalsAction);
addMenuAction("Surface;Differential Properties;Compute Curvature", computeCurvatureAction);
connect(computeNormalsAction, SIGNAL(triggered()), this, SLOT(cb_openComputeNormalsDialog()));
connect(computeCurvatureAction, SIGNAL(triggered()), this, SLOT(cb_openComputeNormalsDialog()));
connect(m_computeNormalsDialog, SIGNAL(accepted()), this, SLOT(cb_computeNormals()));
connect(m_computeNormalsDialog->button_apply, SIGNAL(clicked()), this, SLOT(cb_computeNormals()));
return true;
}
......@@ -32,15 +38,25 @@ void DifferentialPropertiesPlugin::cb_computeNormals()
const QString& mapname = currentItems[0]->text();
MapHandler<PFP>* mh = reinterpret_cast<MapHandler<PFP>*>(m_window->getMap(mapname));
MAP* map = mh->getMap();
std::string positionName = m_computeNormalsDialog->combo_positionAttribute->currentText().toUtf8().constData();
std::string normalName = m_computeNormalsDialog->attributeName->text().toUtf8().constData();
VertexAttribute<VEC3> position = map->getAttribute<VEC3, VERTEX>(positionName);
VertexAttribute<VEC3> normal = map->getAttribute<VEC3, VERTEX>(normalName);
if(!normal.isValid())
normal = map->addAttribute<VEC3, VERTEX>(normalName);
Algo::Geometry::computeNormalVertices<PFP>(*map, position, normal);
if(m_computeNormalsDialog->check_createVBO->checkState() == Qt::Checked)
mh->createVBO(normal);
QList<View*> views = m_window->getViewsList();
foreach(View* view, views)
{
if(view->isLinkedToMap(mh))
view->updateGL();
}
}
}
......
......@@ -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,9 +136,11 @@ 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);
}
if (!maps.empty())
params->selectedMap = maps[0];
m_dockTab->refreshUI(params);
}
......@@ -136,8 +164,10 @@ 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);
if(params->perMap.count() == 1)
params->selectedMap = m;
m_dockTab->refreshUI(params);
}
......@@ -150,7 +180,10 @@ void RenderPlugin::mapUnlinked(View* view, MapHandlerGen* m)
if(params->selectedMap == m)
{
params->selectedMap = NULL;
if(!params->perMap.empty())
params->selectedMap = m_window->getMap(params->perMap.begin().key());
else
params->selectedMap = NULL;
m_dockTab->refreshUI(params);
}
}
......@@ -293,12 +326,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,9 +74,11 @@ 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);
}
if (!maps.empty())
params->selectedMap = maps[0];
m_dockTab->refreshUI(params);
}
......@@ -80,8 +102,10 @@ 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);
if(params->perMap.count() == 1)
params->selectedMap = m;
m_dockTab->refreshUI(params);
}
......@@ -94,7 +118,10 @@ void RenderVectorPlugin::mapUnlinked(View* view, MapHandlerGen* m)
if(params->selectedMap == m)
{
params->selectedMap = NULL;
if(!params->perMap.empty())
params->selectedMap = m_window->getMap(params->perMap.begin().key());
else
params->selectedMap = NULL;
m_dockTab->refreshUI(params);
}
}
......@@ -186,12 +213,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;
......
......@@ -13,7 +13,10 @@ bool SubdivideSurfacePlugin::enable()
connect(m_window, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(cb_removeMapFromList(MapHandlerGen*)));
connect(m_dockTab->mapList, SIGNAL(itemSelectionChanged()), this, SLOT(cb_selectedMapChanged()));
connect(m_dockTab->button_trianguleFaces, SIGNAL(clicked()), this, SLOT(cb_trianguleFaces()));
connect(m_dockTab->button_loopSubdivision, SIGNAL(clicked()), this, SLOT(cb_loopSubdivision()));
connect(m_dockTab->button_CCSubdivision, SIGNAL(clicked()), this, SLOT(cb_CCSubdivision()));
QList<MapHandlerGen*> maps = m_window->getMapsList();
foreach(MapHandlerGen* m, maps)
......@@ -54,10 +57,70 @@ 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;
}
}
}
}
void SubdivideSurfacePlugin::cb_loopSubdivision()
{
QList<QListWidgetItem*> currentItems = m_dockTab->mapList->selectedItems();
if(!currentItems.empty())
{
const QString& mapname = currentItems[0]->text();
MapHandler<PFP>* mh = reinterpret_cast<MapHandler<PFP>*>(m_window->getMap(mapname));
MAP* map = mh->getMap();
std::string positionName = m_dockTab->combo_positionAttribute->currentText().toUtf8().constData();
VertexAttribute<VEC3> position = map->getAttribute<VEC3, VERTEX>(positionName);
Algo::Modelisation::LoopSubdivision<PFP>(*map, position);
mh->updatePrimitives(Algo::Render::GL2::POINTS);
mh->updatePrimitives(Algo::Render::GL2::LINES);
mh->updatePrimitives(Algo::Render::GL2::TRIANGLES);
mh->updateVBO(position);
QList<View*> views = m_window->getViewsList();
foreach(View* view, views)
{
if(view->isLinkedToMap(mh))
view->updateGL();
}
}
}
void SubdivideSurfacePlugin::cb_CCSubdivision()
{
QList<QListWidgetItem*> currentItems = m_dockTab->mapList->selectedItems();
if(!currentItems.empty())
{
const QString& mapname = currentItems[0]->text();
MapHandler<PFP>* mh = reinterpret_cast<MapHandler<PFP>*>(m_window->getMap(mapname));
MAP* map = mh->getMap();
std::string positionName = m_dockTab->combo_positionAttribute->currentText().toUtf8().constData();
VertexAttribute<VEC3> position = map->getAttribute<VEC3, VERTEX>(positionName);
Algo::Modelisation::CatmullClarkSubdivision<PFP>(*map, position);
mh->updatePrimitives(Algo::Render::GL2::POINTS);
mh->updatePrimitives(Algo::Render::GL2::LINES);
mh->updatePrimitives(Algo::Render::GL2::TRIANGLES);
mh->updateVBO(position);
QList<View*> views = m_window->getViewsList();
foreach(View* view, views)
{
if(view->isLinkedToMap(mh))
view->updateGL();
}
}
}
......@@ -72,11 +135,14 @@ void SubdivideSurfacePlugin::cb_trianguleFaces()
MAP* map = mh->getMap();
std::string positionName = m_dockTab->combo_positionAttribute->currentText().toUtf8().constData();
VertexAttribute<VEC3> position = map->getAttribute<VEC3, VERTEX>(positionName);
Algo::Modelisation::trianguleFaces<PFP>(*map, position);
mh->updatePrimitives(Algo::Render::GL2::POINTS);
mh->updatePrimitives(Algo::Render::GL2::LINES);
mh->updatePrimitives(Algo::Render::GL2::TRIANGLES);
mh->updateVBO(position);
QList<View*> views = m_window->getViewsList();
foreach(View* view, views)
{
......
......@@ -70,6 +70,9 @@ public slots:
void cb_addMapToList(MapHandlerGen* m);
void cb_removeMapFromList(MapHandlerGen* m);
void cb_selectedMapChanged();
void cb_loopSubdivision();
void cb_CCSubdivision();
void cb_trianguleFaces();
};
......
......@@ -38,6 +38,20 @@
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="button_loopSubdivision">
<property name="text">
<string>Loop subdivision</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_CCSubdivision">
<property name="text">
<string>Catmull-Clark subdivision</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_trianguleFaces">
<property name="text">
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>457</width>
<height>374</height>
<width>558</width>
<height>418</height>
</rect>
</property>
<property name="windowTitle">
......
......@@ -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