Commit a4379092 authored by untereiner's avatar untereiner

Merge cgogn:~kraemer/CGoGN

parents dfec257e 7c2a9e25
...@@ -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>
......
...@@ -28,8 +28,6 @@ public slots: ...@@ -28,8 +28,6 @@ public slots:
void addMapToList(MapHandlerGen* m); void addMapToList(MapHandlerGen* m);
void removeMapFromList(MapHandlerGen* m); void removeMapFromList(MapHandlerGen* m);
void addAttributeToList(unsigned int orbit, const QString& nameAttr); void addAttributeToList(unsigned int orbit, const QString& nameAttr);
void attributeModified(unsigned int orbit, QString nameAttr);
}; };
} // namespace SCHNApps } // namespace SCHNApps
......
...@@ -38,18 +38,21 @@ public: ...@@ -38,18 +38,21 @@ public:
virtual void wheelEvent(View* view, QWheelEvent* event) {} virtual void wheelEvent(View* view, QWheelEvent* event) {}
public slots: public slots:
void mapAdded(MapHandlerGen* map);
void mapRemoved(MapHandlerGen* map);
void attributeModified(unsigned int orbit, QString nameAttr);
void openComputeNormalDialog(); void openComputeNormalDialog();
void openComputeCurvatureDialog(); void openComputeCurvatureDialog();
void computeNormalFromDialog(); void computeNormalFromDialog();
void computeCurvatureFromDialog(); void computeCurvatureFromDialog();
void computeNormal( void computeNormal(const QString& mapName,
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);
);
void computeCurvature( void computeCurvature(
const QString& mapName, const QString& mapName,
const QString& positionAttributeName = "position", const QString& positionAttributeName = "position",
...@@ -59,11 +62,7 @@ public slots: ...@@ -59,11 +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
); );
private: private:
...@@ -76,11 +75,36 @@ private: ...@@ -76,11 +75,36 @@ private:
struct ComputeNormalParameters struct ComputeNormalParameters
{ {
ComputeNormalParameters() {} ComputeNormalParameters() {}
ComputeNormalParameters(QString p, QString n) : positionName(p), normalName(n) {} ComputeNormalParameters(const QString& p, const QString& n, bool update) :
positionName(p), normalName(n), autoUpdate(update)
{}
QString positionName; QString positionName;
QString normalName; QString normalName;
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
...@@ -105,15 +105,6 @@ void ComputeNormalDialog::addAttributeToList(unsigned int orbit, const QString& ...@@ -105,15 +105,6 @@ void ComputeNormalDialog::addAttributeToList(unsigned int orbit, const QString&
} }
} }
void ComputeNormalDialog::attributeModified(unsigned int orbit, QString nameAttr)
{
MapHandlerGen* map = static_cast<MapHandlerGen*>(QObject::sender());
// if(orbit == VERTEX && nameAttr == )
// {
// }
}
} // namespace SCHNApps } // namespace SCHNApps
} // namespace CGoGN } // namespace CGoGN
...@@ -25,9 +25,36 @@ bool DifferentialPropertiesPlugin::enable() ...@@ -25,9 +25,36 @@ bool DifferentialPropertiesPlugin::enable()
connect(m_computeCurvatureDialog, SIGNAL(accepted()), this, SLOT(computeCurvatureFromDialog())); connect(m_computeCurvatureDialog, SIGNAL(accepted()), this, SLOT(computeCurvatureFromDialog()));
connect(m_computeCurvatureDialog->button_apply, SIGNAL(clicked()), this, SLOT(computeCurvatureFromDialog())); connect(m_computeCurvatureDialog->button_apply, SIGNAL(clicked()), this, SLOT(computeCurvatureFromDialog()));
connect(m_window, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(mapAdded(MapHandlerGen*)));
connect(m_window, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(mapRemoved(MapHandlerGen*)));
return true; return true;
} }
void DifferentialPropertiesPlugin::mapAdded(MapHandlerGen *map)
{
connect(map, SIGNAL(attributeModified(unsigned int, QString)), this, SLOT(attributeModified(unsigned int, QString)));
}
void DifferentialPropertiesPlugin::mapRemoved(MapHandlerGen *map)
{
disconnect(map, SIGNAL(attributeModified(unsigned int, QString)), this, SLOT(attributeModified(unsigned int, QString)));
}
void DifferentialPropertiesPlugin::attributeModified(unsigned int orbit, QString nameAttr)
{
if(orbit == VERTEX)
{
MapHandlerGen* map = static_cast<MapHandlerGen*>(QObject::sender());
if(computeNormalLastParameters.contains(map->getName()))
{
ComputeNormalParameters& params = computeNormalLastParameters[map->getName()];
if(params.positionName == nameAttr && params.autoUpdate)
computeNormal(map->getName(), params.positionName, params.normalName);
}
}
}
void DifferentialPropertiesPlugin::openComputeNormalDialog() void DifferentialPropertiesPlugin::openComputeNormalDialog()
{ {
m_computeNormalDialog->show(); m_computeNormalDialog->show();
...@@ -46,15 +73,16 @@ void DifferentialPropertiesPlugin::computeNormalFromDialog() ...@@ -46,15 +73,16 @@ void DifferentialPropertiesPlugin::computeNormalFromDialog()
const QString& mapName = currentItems[0]->text(); const QString& mapName = currentItems[0]->text();
QString positionName = m_computeNormalDialog->combo_positionAttribute->currentText(); QString positionName = m_computeNormalDialog->combo_positionAttribute->currentText();
QString normalName; QString normalName;
if(m_computeNormalDialog->normalAttributeName->text().isEmpty()) if(m_computeNormalDialog->normalAttributeName->text().isEmpty())
normalName = m_computeNormalDialog->combo_normalAttribute->currentText(); normalName = m_computeNormalDialog->combo_normalAttribute->currentText();
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);
computeNormal(mapName, positionName, normalName, createVBO); computeNormal(mapName, positionName, normalName, autoUpdate);
} }
} }
...@@ -98,19 +126,13 @@ void DifferentialPropertiesPlugin::computeCurvatureFromDialog() ...@@ -98,19 +126,13 @@ void DifferentialPropertiesPlugin::computeCurvatureFromDialog()
else else
KnormalName = m_computeCurvatureDialog->KnormalAttributeName->text(); KnormalName = m_computeCurvatureDialog->KnormalAttributeName->text();
bool KmaxVBO = (m_computeCurvatureDialog->check_KmaxCreateVBO->checkState() == Qt::Checked); bool autoUpdate = (currentItems[0]->checkState() == Qt::Checked);
bool kmaxVBO = (m_computeCurvatureDialog->check_kmaxCreateVBO->checkState() == Qt::Checked);
bool KminVBO = (m_computeCurvatureDialog->check_KminCreateVBO->checkState() == Qt::Checked);
bool kminVBO = (m_computeCurvatureDialog->check_kminCreateVBO->checkState() == Qt::Checked);
bool KnormalVBO = (m_computeCurvatureDialog->check_KnormalCreateVBO->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
); );
} }
} }
...@@ -119,7 +141,7 @@ void DifferentialPropertiesPlugin::computeNormal( ...@@ -119,7 +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)
{ {
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)
...@@ -136,15 +158,12 @@ void DifferentialPropertiesPlugin::computeNormal( ...@@ -136,15 +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) ; ComputeNormalParameters(positionAttributeName, normalAttributeName, autoUpdate);
QList<View*> views = mh->getLinkedViews(); mh->createVBO(normal);
foreach(View* view, views)
view->updateGL(); mh->notifyAttributeModification(normal);
} }
void DifferentialPropertiesPlugin::computeCurvature( void DifferentialPropertiesPlugin::computeCurvature(
...@@ -156,11 +175,7 @@ void DifferentialPropertiesPlugin::computeCurvature( ...@@ -156,11 +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)
{ {
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)
...@@ -202,15 +217,23 @@ void DifferentialPropertiesPlugin::computeCurvature( ...@@ -202,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
......
...@@ -4,9 +4,11 @@ ...@@ -4,9 +4,11 @@
#include "plugin.h" #include "plugin.h"
using namespace CGoGN; namespace CGoGN
using namespace SCHNApps; {
namespace SCHNApps
{
class ImportSurfacePlugin : public Plugin class ImportSurfacePlugin : public Plugin
{ {
...@@ -42,4 +44,8 @@ private: ...@@ -42,4 +44,8 @@ private:
QAction* importAction; QAction* importAction;
}; };
} // namespace SCHNApps
} // namespace CGoGN
#endif #endif
...@@ -7,6 +7,12 @@ ...@@ -7,6 +7,12 @@
#include <QFileDialog> #include <QFileDialog>
#include <QFileInfo> #include <QFileInfo>
namespace CGoGN
{
namespace SCHNApps
{
bool ImportSurfacePlugin::enable() bool ImportSurfacePlugin::enable()
{ {
importAction = new QAction("import", this); importAction = new QAction("import", this);
...@@ -30,12 +36,15 @@ MapHandlerGen* ImportSurfacePlugin::importFromFile(const QString& fileName) ...@@ -30,12 +36,15 @@ MapHandlerGen* ImportSurfacePlugin::importFromFile(const QString& fileName)
Algo::Surface::Import::importMesh<PFP2>(*map, fileName.toStdString(), attrNames); Algo::Surface::Import::importMesh<PFP2>(*map, fileName.toStdString(), attrNames);
// get vertex position attribute // get vertex position attribute
VertexAttribute<PFP2::VEC3> position = map->getAttribute<PFP2::VEC3, CGoGN::VERTEX>(attrNames[0]); VertexAttribute<PFP2::VEC3> position = map->getAttribute<PFP2::VEC3, VERTEX>(attrNames[0]);
mh->registerAttribute<PFP2::VEC3, VERTEX>(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
mh->notifyAttributeModification(position);
// compute map bounding box // compute map bounding box
mh->updateBB(position); mh->updateBB(position);
} }
...@@ -56,3 +65,7 @@ Q_EXPORT_PLUGIN2(ImportSurfacePlugin, ImportSurfacePlugin) ...@@ -56,3 +65,7 @@ Q_EXPORT_PLUGIN2(ImportSurfacePlugin, ImportSurfacePlugin)
#else #else
Q_EXPORT_PLUGIN2(ImportSurfacePluginD, ImportSurfacePlugin) Q_EXPORT_PLUGIN2(ImportSurfacePluginD, ImportSurfacePlugin)
#endif #endif
} // namespace SCHNApps