Commit 5600a6e5 authored by Pierre Kraemer's avatar Pierre Kraemer

SCHNApps: bug fixes

parent 0a2944b2
......@@ -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
......@@ -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();
}
}
}
......
......@@ -139,6 +139,8 @@ void RenderPlugin::viewLinked(View* view)
PerMapParameterSet p(map);
params->perMap.insert(map->getName(), p);
}
if (!maps.empty())
params->selectedMap = maps[0];
m_dockTab->refreshUI(params);
}
......@@ -164,6 +166,8 @@ void RenderPlugin::mapLinked(View* view, MapHandlerGen* m)
ParameterSet* params = h_viewParams[view];
PerMapParameterSet p(m);
params->perMap.insert(m->getName(), p);
if(params->perMap.count() == 1)
params->selectedMap = m;
m_dockTab->refreshUI(params);
}
......@@ -176,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);
}
}
......
......@@ -77,6 +77,8 @@ void RenderVectorPlugin::viewLinked(View* view)
PerMapParameterSet p(map);
params->perMap.insert(map->getName(), p);
}
if (!maps.empty())
params->selectedMap = maps[0];
m_dockTab->refreshUI(params);
}
......@@ -102,6 +104,8 @@ void RenderVectorPlugin::mapLinked(View* view, MapHandlerGen* m)
ParameterSet* params = h_viewParams[view];
PerMapParameterSet p(m);
params->perMap.insert(m->getName(), p);
if(params->perMap.count() == 1)
params->selectedMap = m;
m_dockTab->refreshUI(params);
}
......@@ -114,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);
}
}
......
......@@ -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)
......@@ -68,6 +71,60 @@ void SubdivideSurfacePlugin::cb_selectedMapChanged()
}
}
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();
}
}
}
void SubdivideSurfacePlugin::cb_trianguleFaces()
{
QList<QListWidgetItem*> currentItems = m_dockTab->mapList->selectedItems();
......@@ -78,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">
......
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