Commit f96d3d6f authored by Pierre Kraemer's avatar Pierre Kraemer
Browse files

SCHNApps: several updates & bug fixes

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