Commit f96d3d6f authored by Pierre Kraemer's avatar Pierre Kraemer

SCHNApps: several updates & bug fixes

parent 1713106d
......@@ -67,41 +67,6 @@
<string>Computed attributes</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Kmax :</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Existing attribute :</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="combo_KmaxAttribute">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
......@@ -116,16 +81,6 @@
</item>
</layout>
</item>
<item row="0" column="3">
<widget class="QCheckBox" name="check_KmaxCreateVBO">
<property name="text">
<string>create VBO</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_10">
<property name="font">
......@@ -175,16 +130,6 @@
</item>
</layout>
</item>
<item row="1" column="3">
<widget class="QCheckBox" name="check_kmaxCreateVBO">
<property name="text">
<string>create VBO</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_7">
<property name="font">
......@@ -234,16 +179,6 @@
</item>
</layout>
</item>
<item row="2" column="3">
<widget class="QCheckBox" name="check_KminCreateVBO">
<property name="text">
<string>create VBO</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_13">
<property name="font">
......@@ -293,16 +228,6 @@
</item>
</layout>
</item>
<item row="3" column="3">
<widget class="QCheckBox" name="check_kminCreateVBO">
<property name="text">
<string>create VBO</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_15">
<property name="font">
......@@ -352,16 +277,41 @@
</item>
</layout>
</item>
<item row="4" column="3">
<widget class="QCheckBox" name="check_KnormalCreateVBO">
<property name="text">
<string>create VBO</string>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
</font>
</property>
<property name="checked">
<bool>true</bool>
<property name="text">
<string>Kmax :</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Existing attribute :</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="combo_KmaxAttribute">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>447</width>
<height>311</height>
<width>472</width>
<height>276</height>
</rect>
</property>
<property name="windowTitle">
......@@ -75,16 +75,6 @@
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="check_createVBO">
<property name="text">
<string>create VBO</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......
......@@ -51,8 +51,7 @@ public slots:
void computeNormal(const QString& mapName,
const QString& positionAttributeName = "position",
const QString& normalAttributeName = "normal",
bool createNormalVBO = true,
bool autoUpdateNormal = true);
bool autoUpdate = true);
void computeCurvature(
const QString& mapName,
......@@ -63,16 +62,7 @@ public slots:
const QString& KminAttributeName = "Kmin",
const QString& kminAttributeName = "kmin",
const QString& KnormalAttributeName = "Knormal",
bool createKmaxVBO = true,
bool createkmaxVBO = true,
bool createKminVBO = true,
bool createkminVBO = true,
bool createKnormalVBO = true,
bool autoUpdateKmax = true,
bool autoUpdatekmax = true,
bool autoUpdateKmin = true,
bool autoUpdatekmin = true,
bool autoUpdateKnormal = true
bool autoUpdate = true
);
private:
......@@ -85,15 +75,36 @@ private:
struct ComputeNormalParameters
{
ComputeNormalParameters() {}
ComputeNormalParameters(QString p, QString n, bool vbo, bool update) :
positionName(p), normalName(n), createVBO(vbo), autoUpdate(update)
ComputeNormalParameters(const QString& p, const QString& n, bool update) :
positionName(p), normalName(n), autoUpdate(update)
{}
QString positionName;
QString normalName;
bool createVBO;
bool autoUpdate;
};
QHash<QString, ComputeNormalParameters> computeNormalLastParameters;
struct ComputeCurvatureParameters
{
ComputeCurvatureParameters() {}
ComputeCurvatureParameters(
const QString& p, const QString& n,
const QString& Kmax, const QString& kmax, const QString& Kmin, const QString& kmin, const QString& Knormal,
bool update) :
positionName(p), normalName(n),
KmaxName(Kmax), kmaxName(kmax), KminName(Kmin), kminName(kmin), KnormalName(Knormal),
autoUpdate(update)
{}
QString positionName;
QString normalName;
QString KmaxName;
QString kmaxName;
QString KminName;
QString kminName;
QString KnormalName;
bool autoUpdate;
};
QHash<QString, ComputeCurvatureParameters> computeCurvatureLastParameters;
};
#endif
......@@ -50,7 +50,7 @@ void DifferentialPropertiesPlugin::attributeModified(unsigned int orbit, QString
{
ComputeNormalParameters& params = computeNormalLastParameters[map->getName()];
if(params.positionName == nameAttr && params.autoUpdate)
computeNormal(map->getName(), params.positionName, params.normalName, params.createVBO);
computeNormal(map->getName(), params.positionName, params.normalName);
}
}
}
......@@ -80,11 +80,9 @@ void DifferentialPropertiesPlugin::computeNormalFromDialog()
else
normalName = m_computeNormalDialog->normalAttributeName->text();
bool createVBO = (m_computeNormalDialog->check_createVBO->checkState() == Qt::Checked);
bool autoUpdate = (currentItems[0]->checkState() == Qt::Checked);
computeNormal(mapName, positionName, normalName, createVBO, autoUpdate);
computeNormal(mapName, positionName, normalName, autoUpdate);
}
}
......@@ -103,39 +101,38 @@ void DifferentialPropertiesPlugin::computeCurvatureFromDialog()
KmaxName = m_computeCurvatureDialog->combo_KmaxAttribute->currentText();
else
KmaxName = m_computeCurvatureDialog->KmaxAttributeName->text();
bool KmaxVBO = (m_computeCurvatureDialog->check_KmaxCreateVBO->checkState() == Qt::Checked);
QString kmaxName;
if(m_computeCurvatureDialog->kmaxAttributeName->text().isEmpty())
kmaxName = m_computeCurvatureDialog->combo_kmaxAttribute->currentText();
else
kmaxName = m_computeCurvatureDialog->kmaxAttributeName->text();
bool kmaxVBO = (m_computeCurvatureDialog->check_kmaxCreateVBO->checkState() == Qt::Checked);
QString KminName;
if(m_computeCurvatureDialog->KminAttributeName->text().isEmpty())
KminName = m_computeCurvatureDialog->combo_KminAttribute->currentText();
else
KminName = m_computeCurvatureDialog->KminAttributeName->text();
bool KminVBO = (m_computeCurvatureDialog->check_KminCreateVBO->checkState() == Qt::Checked);
QString kminName;
if(m_computeCurvatureDialog->kminAttributeName->text().isEmpty())
kminName = m_computeCurvatureDialog->combo_kminAttribute->currentText();
else
kminName = m_computeCurvatureDialog->kminAttributeName->text();
bool kminVBO = (m_computeCurvatureDialog->check_kminCreateVBO->checkState() == Qt::Checked);
QString KnormalName;
if(m_computeCurvatureDialog->KnormalAttributeName->text().isEmpty())
KnormalName = m_computeCurvatureDialog->combo_KnormalAttribute->currentText();
else
KnormalName = m_computeCurvatureDialog->KnormalAttributeName->text();
bool KnormalVBO = (m_computeCurvatureDialog->check_KnormalCreateVBO->checkState() == Qt::Checked);
bool autoUpdate = (currentItems[0]->checkState() == Qt::Checked);
computeCurvature(
mapName, positionName, normalName, KmaxName, kmaxName, KminName, kminName, KnormalName,
KmaxVBO, kmaxVBO, KminVBO, kminVBO, KnormalVBO
mapName,
positionName, normalName,
KmaxName, kmaxName, KminName, kminName, KnormalName,
autoUpdate
);
}
}
......@@ -144,8 +141,7 @@ void DifferentialPropertiesPlugin::computeNormal(
const QString& mapName,
const QString& positionAttributeName,
const QString& normalAttributeName,
bool createNormalVBO,
bool autoUpdateNormal)
bool autoUpdate)
{
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_window->getMap(mapName));
if(mh == NULL)
......@@ -162,17 +158,12 @@ void DifferentialPropertiesPlugin::computeNormal(
PFP2::MAP* map = mh->getMap();
Algo::Surface::Geometry::computeNormalVertices<PFP2>(*map, position, normal);
if(createNormalVBO)
mh->createVBO(normal);
computeNormalLastParameters[mapName] =
ComputeNormalParameters(positionAttributeName, normalAttributeName, createNormalVBO, autoUpdateNormal) ;
ComputeNormalParameters(positionAttributeName, normalAttributeName, autoUpdate);
mh->notifyAttributeModification(normal);
mh->createVBO(normal);
QList<View*> views = mh->getLinkedViews();
foreach(View* view, views)
view->updateGL();
mh->notifyAttributeModification(normal);
}
void DifferentialPropertiesPlugin::computeCurvature(
......@@ -184,16 +175,7 @@ void DifferentialPropertiesPlugin::computeCurvature(
const QString& KminAttributeName,
const QString& kminAttributeName,
const QString& KnormalAttributeName,
bool createKmaxVBO,
bool createkmaxVBO,
bool createKminVBO,
bool createkminVBO,
bool createKnormalVBO,
bool autoUpdateKmax,
bool autoUpdatekmax,
bool autoUpdateKmin,
bool autoUpdatekmin,
bool autoUpdateKnormal)
bool autoUpdate)
{
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_window->getMap(mapName));
if(mh == NULL)
......@@ -235,15 +217,23 @@ void DifferentialPropertiesPlugin::computeCurvature(
Algo::Surface::Geometry::computeAnglesBetweenNormalsOnEdges<PFP2>(*map, position, edgeAngle);
Algo::Surface::Geometry::computeCurvatureVertices_NormalCycles_Projected<PFP2>(*map, 0.02f * mh->getBBdiagSize(), position, normal, edgeAngle, kmax, kmin, Kmax, Kmin, Knormal);
if(createKmaxVBO) mh->createVBO(Kmax);
if(createkmaxVBO) mh->createVBO(kmax);
if(createKminVBO) mh->createVBO(Kmin);
if(createkminVBO) mh->createVBO(kmin);
if(createKnormalVBO) mh->createVBO(Knormal);
QList<View*> views = mh->getLinkedViews();
foreach(View* view, views)
view->updateGL();
computeCurvatureLastParameters[mapName] =
ComputeCurvatureParameters(
positionAttributeName, normalAttributeName,
KmaxAttributeName, kmaxAttributeName, KminAttributeName, kminAttributeName, KnormalAttributeName,
autoUpdate);
mh->createVBO(Kmax);
mh->createVBO(kmax);
mh->createVBO(Kmin);
mh->createVBO(kmin);
mh->createVBO(Knormal);
mh->notifyAttributeModification(Kmax);
mh->notifyAttributeModification(kmax);
mh->notifyAttributeModification(Kmin);
mh->notifyAttributeModification(kmin);
mh->notifyAttributeModification(Knormal);
}
#ifndef DEBUG
......
......@@ -39,7 +39,7 @@ MapHandlerGen* ImportSurfacePlugin::importFromFile(const QString& fileName)
VertexAttribute<PFP2::VEC3> position = map->getAttribute<PFP2::VEC3, VERTEX>(attrNames[0]);
mh->registerAttribute(position);
// create VBO for vertex position attribute
// create position VBO
mh->createVBO(position);
// update corresponding VBO & emit attribute update signal
......
......@@ -39,7 +39,7 @@ MapHandlerGen* ImportVolumePlugin::importFromFile(const QString& fileName)
VertexAttribute<PFP3::VEC3> position = map->getAttribute<PFP3::VEC3, VERTEX>(attrNames[0]);
mh->registerAttribute(position);
// create VBO for vertex position attribute
// create position VBO
mh->createVBO(position);
// update corresponding VBO & emit attribute update signal
......
......@@ -100,14 +100,14 @@ public slots:
void vboAdded(Utils::VBO* vbo);
void vboRemoved(Utils::VBO* vbo);
void changeSelectedMap(View* view, MapHandlerGen* map);
void changePositionVBO(View* view, MapHandlerGen* map, Utils::VBO* vbo);
void changeNormalVBO(View* view, MapHandlerGen* map, Utils::VBO* vbo);
void changeRenderVertices(View* view, MapHandlerGen* map, bool b);
void changeVerticesScaleFactor(View* view, MapHandlerGen* map, int i);
void changeRenderEdges(View* view, MapHandlerGen* map, bool b);
void changeRenderFaces(View* view, MapHandlerGen* map, bool b);
void changeFacesStyle(View* view, MapHandlerGen* map, FaceShadingStyle style);
void changeSelectedMap(View* view, MapHandlerGen* map, bool fromUI = false);
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);
void changeVerticesScaleFactor(View* view, MapHandlerGen* map, int i, 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 changeFacesStyle(View* view, MapHandlerGen* map, FaceShadingStyle style, bool fromUI = false);
};
} // namespace SCHNApps
......
......@@ -30,6 +30,8 @@ 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);
......
......@@ -215,7 +215,10 @@ void RenderPlugin::mapUnlinked(MapHandlerGen* m)
void RenderPlugin::vboAdded(Utils::VBO* vbo)
{
m_dockTab->refreshUI(h_viewParams[m_window->getCurrentView()]);
MapHandlerGen* map = static_cast<MapHandlerGen*>(QObject::sender());
assert(h_viewParams[m_window->getCurrentView()]->selectedMap == map);
if(vbo->dataSize() == 3)
m_dockTab->addVBOToList(QString::fromStdString(vbo->name()));
}
void RenderPlugin::vboRemoved(Utils::VBO* vbo)
......@@ -232,7 +235,7 @@ void RenderPlugin::vboRemoved(Utils::VBO* vbo)
m_dockTab->refreshUI(h_viewParams[view]);
}
void RenderPlugin::changeSelectedMap(View* view, MapHandlerGen* map)
void RenderPlugin::changeSelectedMap(View* view, MapHandlerGen* map, bool fromUI)
{
ParameterSet* params = h_viewParams[view];
......@@ -246,91 +249,99 @@ void RenderPlugin::changeSelectedMap(View* view, MapHandlerGen* map)
if(map)
connect(map, SIGNAL(vboAdded(Utils::VBO*)), this, SLOT(vboAdded(Utils::VBO*)));
m_dockTab->refreshUI(params);
if(!fromUI)
m_dockTab->refreshUI(params);
view->updateGL();
}
}
void RenderPlugin::changePositionVBO(View* view, MapHandlerGen* map, Utils::VBO* vbo)
void RenderPlugin::changePositionVBO(View* view, MapHandlerGen* map, Utils::VBO* vbo, bool fromUI)
{
ParameterSet* params = h_viewParams[view];
params->perMap[map->getName()].positionVBO = vbo;
if(view->isCurrentView())
{
m_dockTab->refreshUI(params);
if(!fromUI)
m_dockTab->refreshUI(params);
view->updateGL();
}
}
void RenderPlugin::changeNormalVBO(View* view, MapHandlerGen* map, Utils::VBO* vbo)
void RenderPlugin::changeNormalVBO(View* view, MapHandlerGen* map, Utils::VBO* vbo, bool fromUI)
{
ParameterSet* params = h_viewParams[view];
params->perMap[map->getName()].normalVBO = vbo;
if(view->isCurrentView())
{
m_dockTab->refreshUI(params);
if(!fromUI)
m_dockTab->refreshUI(params);
view->updateGL();
}
}
void RenderPlugin::changeRenderVertices(View* view, MapHandlerGen* map, bool b)
void RenderPlugin::changeRenderVertices(View* view, MapHandlerGen* map, bool b, bool fromUI)
{
ParameterSet* params = h_viewParams[view];
params->perMap[map->getName()].renderVertices = b;
if(view->isCurrentView())
{
m_dockTab->refreshUI(params);
if(!fromUI)
m_dockTab->refreshUI(params);
view->updateGL();
}
}
void RenderPlugin::changeVerticesScaleFactor(View* view, MapHandlerGen* map, int i)
void RenderPlugin::changeVerticesScaleFactor(View* view, MapHandlerGen* map, int i, bool fromUI)
{
ParameterSet* params = h_viewParams[view];
params->perMap[map->getName()].verticesScaleFactor = i / 50.0;
if(view->isCurrentView())
{
m_dockTab->refreshUI(params);
if(!fromUI)
m_dockTab->refreshUI(params);
view->updateGL();
}
}
void RenderPlugin::changeRenderEdges(View* view, MapHandlerGen* map, bool b)
void RenderPlugin::changeRenderEdges(View* view, MapHandlerGen* map, bool b, bool fromUI)
{
ParameterSet* params = h_viewParams[view];
params->perMap[map->getName()].renderEdges = b;
if(view->isCurrentView())
{
m_dockTab->refreshUI(params);
if(!fromUI)
m_dockTab->refreshUI(params);
view->updateGL();
}
}
void RenderPlugin::changeRenderFaces(View* view, MapHandlerGen* map, bool b)
void RenderPlugin::changeRenderFaces(View* view, MapHandlerGen* map, bool b, bool fromUI)
{
ParameterSet* params = h_viewParams[view];
params->perMap[map->getName()].renderFaces = b;
if(view->isCurrentView())
{
m_dockTab->refreshUI(params);
if(!fromUI)
m_dockTab->refreshUI(params);
view->updateGL();
}
}
void RenderPlugin::changeFacesStyle(View* view, MapHandlerGen* map, FaceShadingStyle style)
void RenderPlugin::changeFacesStyle(View* view, MapHandlerGen* map, FaceShadingStyle style, bool fromUI)
{
ParameterSet* params = h_viewParams[view];
params->perMap[map->getName()].faceStyle = style;
if(view->isCurrentView())
{
m_dockTab->refreshUI(params);
if(!fromUI)
m_dockTab->refreshUI(params);
view->updateGL();
}
}
......
......@@ -87,17 +87,34 @@ void RenderDockTab::selectedMapChanged()
{
QList<QListWidgetItem*> currentItems = mapList->selectedItems();
if(!currentItems.empty())
m_plugin->changeSelectedMap(m_window->getCurrentView(), m_window->getMap(currentItems[0]->text()));
m_plugin->changeSelectedMap(m_window->getCurrentView(), m_window->getMap(currentItems[0]->text()), true);
}
}
void RenderDockTab::addVBOToList(QString name)
{
combo_positionVBO->addItem(name);
combo_normalVBO->addItem(name);
}
void RenderDockTab::removeVBOFromList(QString name)