Commit 9da47178 authored by Pierre Kraemer's avatar Pierre Kraemer

SCHNApps: first step towards attributes modifications notification & handling

parent a75d3772
...@@ -112,6 +112,7 @@ file( ...@@ -112,6 +112,7 @@ file(
SCHNApps_FILES SCHNApps_FILES
${SCHNApps_ROOT_DIR}/src/*.cpp ${SCHNApps_ROOT_DIR}/src/*.cpp
${SCHNApps_ROOT_DIR}/include/*.h ${SCHNApps_ROOT_DIR}/include/*.h
${SCHNApps_ROOT_DIR}/include/*.hpp
) )
file( file(
......
...@@ -28,6 +28,8 @@ public slots: ...@@ -28,6 +28,8 @@ 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
......
...@@ -72,6 +72,15 @@ private: ...@@ -72,6 +72,15 @@ private:
QAction* m_computeNormalAction; QAction* m_computeNormalAction;
QAction* m_computeCurvatureAction; QAction* m_computeCurvatureAction;
struct ComputeNormalParameters
{
ComputeNormalParameters() {}
ComputeNormalParameters(QString p, QString n) : positionName(p), normalName(n) {}
QString positionName;
QString normalName;
};
QHash<QString, ComputeNormalParameters> computeNormalLastParameters;
}; };
#endif #endif
...@@ -25,7 +25,11 @@ ComputeNormalDialog::ComputeNormalDialog(Window* w) : ...@@ -25,7 +25,11 @@ ComputeNormalDialog::ComputeNormalDialog(Window* w) :
const QList<MapHandlerGen*>& maps = m_window->getMapsList(); const QList<MapHandlerGen*>& maps = m_window->getMapsList();
foreach(MapHandlerGen* map, maps) foreach(MapHandlerGen* map, maps)
mapList->addItem(map->getName()); {
QListWidgetItem* item = new QListWidgetItem(map->getName(), mapList);
item->setCheckState(Qt::Unchecked);
connect(map, SIGNAL(attributeModified(unsigned int, QString)), this, SLOT(attributeModified(unsigned int, QString)));
}
} }
void ComputeNormalDialog::selectedMapChanged() void ComputeNormalDialog::selectedMapChanged()
...@@ -71,7 +75,8 @@ void ComputeNormalDialog::selectedMapChanged() ...@@ -71,7 +75,8 @@ void ComputeNormalDialog::selectedMapChanged()
void ComputeNormalDialog::addMapToList(MapHandlerGen* m) void ComputeNormalDialog::addMapToList(MapHandlerGen* m)
{ {
mapList->addItem(m->getName()); QListWidgetItem* item = new QListWidgetItem(m->getName(), mapList);
item->setCheckState(Qt::Unchecked);
} }
void ComputeNormalDialog::removeMapFromList(MapHandlerGen* m) void ComputeNormalDialog::removeMapFromList(MapHandlerGen* m)
...@@ -100,6 +105,15 @@ void ComputeNormalDialog::addAttributeToList(unsigned int orbit, const QString& ...@@ -100,6 +105,15 @@ 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
...@@ -139,6 +139,9 @@ void DifferentialPropertiesPlugin::computeNormal( ...@@ -139,6 +139,9 @@ void DifferentialPropertiesPlugin::computeNormal(
if(createNormalVBO) if(createNormalVBO)
mh->createVBO(normal); mh->createVBO(normal);
computeNormalLastParameters[mapName] =
ComputeNormalParameters(positionAttributeName, normalAttributeName) ;
QList<View*> views = mh->getLinkedViews(); QList<View*> views = mh->getLinkedViews();
foreach(View* view, views) foreach(View* view, views)
view->updateGL(); view->updateGL();
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>174</width> <width>174</width>
<height>547</height> <height>545</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>174</width> <width>174</width>
<height>553</height> <height>545</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
......
...@@ -192,7 +192,9 @@ void SurfaceDeformationPlugin::keyPress(View* view, QKeyEvent* event) ...@@ -192,7 +192,9 @@ void SurfaceDeformationPlugin::keyPress(View* view, QKeyEvent* event)
if(map) if(map)
{ {
asRigidAsPossible(view, map); asRigidAsPossible(view, map);
params->selectedMap->updateVBO(params->getCurrentMapParameterSet()->positionAttribute); PerMapParameterSet* perMap = params->perMap[map->getName()];
params->selectedMap->updateVBO(perMap->positionAttribute);
params->selectedMap->notifyAttributeModification(perMap->positionAttribute);
view->updateGL(); view->updateGL();
} }
} }
...@@ -318,6 +320,7 @@ void SurfaceDeformationPlugin::mouseMove(View* view, QMouseEvent* event) ...@@ -318,6 +320,7 @@ void SurfaceDeformationPlugin::mouseMove(View* view, QMouseEvent* event)
asRigidAsPossible(view, params->selectedMap); asRigidAsPossible(view, params->selectedMap);
params->selectedMap->updateVBO(perMap->positionAttribute); params->selectedMap->updateVBO(perMap->positionAttribute);
params->selectedMap->notifyAttributeModification(perMap->positionAttribute);
view->updateGL(); view->updateGL();
} }
......
...@@ -29,107 +29,68 @@ public: ...@@ -29,107 +29,68 @@ public:
MapHandlerGen(const QString& name, Window* window, GenericMap* map); MapHandlerGen(const QString& name, Window* window, GenericMap* map);
virtual ~MapHandlerGen(); virtual ~MapHandlerGen();
const QString& getName() const { return m_name; } inline const QString& getName() const { return m_name; }
public slots: public slots:
QString getName() { return m_name; } inline QString getName() { return m_name; }
void setName(const QString& name) { m_name = name; } inline void setName(const QString& name) { m_name = name; }
Window* getWindow() const { return m_window; } inline Window* getWindow() const { return m_window; }
void setWindow(Window* w) { m_window = w; } inline void setWindow(Window* w) { m_window = w; }
GenericMap* getGenericMap() const { return m_map; } inline GenericMap* getGenericMap() const { return m_map; }
const qglviewer::Vec& getBBmin() const { return m_bbMin; } inline const qglviewer::Vec& getBBmin() const { return m_bbMin; }
const qglviewer::Vec& getBBmax() const { return m_bbMax; } inline const qglviewer::Vec& getBBmax() const { return m_bbMax; }
float getBBdiagSize() const { return m_bbDiagSize; } inline float getBBdiagSize() const { return m_bbDiagSize; }
bool isUsed() const { return !l_views.empty(); } inline bool isUsed() const { return !l_views.empty(); }
public: public:
virtual void draw(Utils::GLSLShader* shader, int primitive) = 0; virtual void draw(Utils::GLSLShader* shader, int primitive) = 0;
void setPrimitiveDirty(int primitive) inline void setPrimitiveDirty(int primitive) { m_render->setPrimitiveDirty(primitive); }
{
m_render->setPrimitiveDirty(primitive);
}
/********************************************************* /*********************************************************
* MANAGE ATTRIBUTES * MANAGE ATTRIBUTES
*********************************************************/ *********************************************************/
template <typename T, unsigned int ORBIT> template <typename T, unsigned int ORBIT>
AttributeHandler<T, ORBIT> getAttribute(const QString& nameAttr, bool onlyRegistered = true) const AttributeHandler<T, ORBIT> getAttribute(const QString& nameAttr, bool onlyRegistered = true) const;
{
if(onlyRegistered)
{
if(h_attribs[ORBIT].contains(nameAttr))
return static_cast<AttribMap*>(m_map)->getAttribute<T,ORBIT>(nameAttr.toStdString());
else
return AttributeHandler<T, ORBIT>();
}
else
return static_cast<AttribMap*>(m_map)->getAttribute<T,ORBIT>(nameAttr.toStdString());
}
template <typename T, unsigned int ORBIT> template <typename T, unsigned int ORBIT>
AttributeHandler<T, ORBIT> addAttribute(const QString& nameAttr, bool registerAttr = true) AttributeHandler<T, ORBIT> addAttribute(const QString& nameAttr, bool registerAttr = true);
{
AttributeHandler<T,ORBIT> ah = static_cast<AttribMap*>(m_map)->addAttribute<T,ORBIT>(nameAttr.toStdString());
if(ah.isValid() && registerAttr)
{
registerAttribute(ah);
emit(attributeAdded(ORBIT, nameAttr));
}
return ah;
}
template <typename T, unsigned int ORBIT> template <typename T, unsigned int ORBIT>
void registerAttribute(const AttributeHandler<T, ORBIT>& ah) inline void registerAttribute(const AttributeHandler<T, ORBIT>& ah);
inline QString getAttributeTypeName(unsigned int orbit, const QString& nameAttr) const;
inline const AttributeHash& getAttributesList(unsigned int orbit) const { return h_attribs[orbit]; }
template <typename T, unsigned int ORBIT>
inline void notifyAttributeModification(const AttributeHandler<T, ORBIT>& attr)
{ {
h_attribs[ORBIT].insert(QString::fromStdString(ah.name()), QString::fromStdString(nameOfType(T()))); emit(attributeModified(ORBIT, QString::fromStdString(attr.name())));
} }
QString getAttributeTypeName(unsigned int orbit, const QString& nameAttr) const inline void notifyConnectivityModification()
{ {
if(h_attribs[orbit].contains(nameAttr)) emit(connectivityModified());
return h_attribs[orbit][nameAttr];
else
return "";
} }
const AttributeHash& getAttributesList(unsigned int orbit) const { return h_attribs[orbit]; }
/********************************************************* /*********************************************************
* MANAGE VBOs * MANAGE VBOs
*********************************************************/ *********************************************************/
template <typename ATTR_HANDLER> template <typename ATTR_HANDLER>
Utils::VBO* createVBO(const ATTR_HANDLER& attr) Utils::VBO* createVBO(const ATTR_HANDLER& attr);
{
QString name = QString::fromStdString(attr.name());
Utils::VBO* vbo = getVBO(name);
if(!vbo)
{
vbo = new Utils::VBO();
h_vbo.insert(name, vbo);
}
vbo->updateData(attr);
emit(vboAdded(vbo));
return vbo;
}
template <typename ATTR_HANDLER> template <typename ATTR_HANDLER>
void updateVBO(const ATTR_HANDLER& attr) void updateVBO(const ATTR_HANDLER& attr);
{
Utils::VBO* vbo = getVBO(QString::fromStdString(attr.name()));
if(vbo)
vbo->updateData(attr);
}
Utils::VBO* getVBO(const QString& name) const; Utils::VBO* getVBO(const QString& name) const;
QList<Utils::VBO*> getVBOList() const { return h_vbo.values(); } inline QList<Utils::VBO*> getVBOList() const { return h_vbo.values(); }
QList<Utils::VBO*> getVBOList(const std::string& typeName) const;
void deleteVBO(const QString& name); void deleteVBO(const QString& name);
/********************************************************* /*********************************************************
...@@ -138,8 +99,8 @@ public: ...@@ -138,8 +99,8 @@ public:
void linkView(View* view); void linkView(View* view);
void unlinkView(View* view); void unlinkView(View* view);
const QList<View*>& getLinkedViews() const { return l_views; } inline const QList<View*>& getLinkedViews() const { return l_views; }
bool isLinkedToView(View* view) const { return l_views.contains(view); } inline bool isLinkedToView(View* view) const { return l_views.contains(view); }
protected: protected:
QString m_name; QString m_name;
...@@ -158,7 +119,11 @@ protected: ...@@ -158,7 +119,11 @@ protected:
AttributeHash h_attribs[NB_ORBITS]; AttributeHash h_attribs[NB_ORBITS];
signals: signals:
void attributeAdded(unsigned int orbit, const QString& name); void connectivityModified();
void attributeAdded(unsigned int orbit, const QString& nameAttr);
void attributeModified(unsigned int orbit, QString nameAttr);
void vboAdded(Utils::VBO* vbo); void vboAdded(Utils::VBO* vbo);
void vboRemoved(Utils::VBO* vbo); void vboRemoved(Utils::VBO* vbo);
}; };
...@@ -177,26 +142,17 @@ public: ...@@ -177,26 +142,17 @@ public:
delete m_map; delete m_map;
} }
virtual void draw(Utils::GLSLShader* shader, int primitive) void draw(Utils::GLSLShader* shader, int primitive);
{
if(!m_render->isPrimitiveUpToDate(primitive))
m_render->initPrimitives<PFP>(*(static_cast<typename PFP::MAP*>(m_map)), allDarts, primitive) ;
m_render->draw(shader, primitive);
}
typename PFP::MAP* getMap() { return static_cast<typename PFP::MAP*>(m_map); } inline typename PFP::MAP* getMap() { return static_cast<typename PFP::MAP*>(m_map); }
void updateBB(const VertexAttribute<typename PFP::VEC3>& position) void updateBB(const VertexAttribute<typename PFP::VEC3>& position);
{
CGoGN::Geom::BoundingBox<typename PFP::VEC3> bb = CGoGN::Algo::Geometry::computeBoundingBox<PFP>(*(static_cast<typename PFP::MAP*>(m_map)), position);
m_bbMin = qglviewer::Vec(bb.min()[0], bb.min()[1], bb.min()[2]);
m_bbMax = qglviewer::Vec(bb.max()[0], bb.max()[1], bb.max()[2]);
m_bbDiagSize = (m_bbMax - m_bbMin).norm();
}
}; };
} // namespace SCHNApps } // namespace SCHNApps
} // namespace CGoGN } // namespace CGoGN
#include "mapHandler.hpp"
#endif #endif
...@@ -19,8 +19,8 @@ CameraViewDialog::CameraViewDialog(Window* window, View* view) : ...@@ -19,8 +19,8 @@ CameraViewDialog::CameraViewDialog(Window* window, View* view) :
m_view(view), m_view(view),
b_refreshingUI(false) b_refreshingUI(false)
{ {
this->setupUi(this); setupUi(this);
this->setWindowTitle(m_view->getName() + QString(" : camera")); setWindowTitle(m_view->getName() + QString(" : camera"));
connect(cameraList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedCameraChanged())); connect(cameraList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedCameraChanged()));
......
...@@ -16,8 +16,8 @@ CamerasDialog::CamerasDialog(Window* window) : ...@@ -16,8 +16,8 @@ CamerasDialog::CamerasDialog(Window* window) :
QDialog(window), QDialog(window),
m_window(window) m_window(window)
{ {
this->setupUi(this); setupUi(this);
this->setModal(false); setModal(false);
connect(addCameraButton, SIGNAL(clicked()), this, SLOT(cb_addCamera())); connect(addCameraButton, SIGNAL(clicked()), this, SLOT(cb_addCamera()));
connect(removeCamerasButton, SIGNAL(clicked()), this, SLOT(cb_removeCameras())); connect(removeCamerasButton, SIGNAL(clicked()), this, SLOT(cb_removeCameras()));
......
...@@ -16,8 +16,8 @@ MapsDialog::MapsDialog(Window* window) : ...@@ -16,8 +16,8 @@ MapsDialog::MapsDialog(Window* window) :
QDialog(window), QDialog(window),
m_window(window) m_window(window)
{ {
this->setupUi(this); setupUi(this);
this->setModal(false); setModal(false);
connect(button_removeMap, SIGNAL(clicked()), this, SLOT(cb_removeMap())); connect(button_removeMap, SIGNAL(clicked()), this, SLOT(cb_removeMap()));
connect(button_refreshMapInfo, SIGNAL(clicked()), this, SLOT(cb_selectedMapChanged())); connect(button_refreshMapInfo, SIGNAL(clicked()), this, SLOT(cb_selectedMapChanged()));
......
...@@ -20,8 +20,8 @@ MapsViewDialog::MapsViewDialog(Window* window, View* view) : ...@@ -20,8 +20,8 @@ MapsViewDialog::MapsViewDialog(Window* window, View* view) :
m_view(view), m_view(view),
b_refreshingUI(false) b_refreshingUI(false)
{ {
this->setupUi(this); setupUi(this);
this->setWindowTitle(m_view->getName() + QString(" : maps")); setWindowTitle(m_view->getName() + QString(" : maps"));
connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedMapsChanged())); connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedMapsChanged()));
......
...@@ -17,7 +17,8 @@ PluginsDialog::PluginsDialog(Window* window) : ...@@ -17,7 +17,8 @@ PluginsDialog::PluginsDialog(Window* window) :
m_window(window), m_window(window),
b_refreshingUI(false) b_refreshingUI(false)
{ {
this->setupUi(this); setupUi(this);
setModal(false);
connect(button_registerDirectory, SIGNAL(pressed()), this, SLOT(registerPluginsDirectory())); connect(button_registerDirectory, SIGNAL(pressed()), this, SLOT(registerPluginsDirectory()));
connect(list_plugins, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(togglePlugin(QListWidgetItem*))); connect(list_plugins, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(togglePlugin(QListWidgetItem*)));
......
...@@ -19,8 +19,8 @@ PluginsViewDialog::PluginsViewDialog(Window* window, View* view) : ...@@ -19,8 +19,8 @@ PluginsViewDialog::PluginsViewDialog(Window* window, View* view) :
m_view(view), m_view(view),
b_refreshingUI(false) b_refreshingUI(false)
{ {
this->setupUi(this); setupUi(this);
this->setWindowTitle(m_view->getName() + QString(" : plugins")); setWindowTitle(m_view->getName() + QString(" : plugins"));
connect(pluginList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedPluginsChanged())); connect(pluginList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedPluginsChanged()));
......
...@@ -32,19 +32,6 @@ Utils::VBO* MapHandlerGen::getVBO(const QString& name) const ...@@ -32,19 +32,6 @@ Utils::VBO* MapHandlerGen::getVBO(const QString& name) const
return NULL; return NULL;
} }
QList<Utils::VBO*> MapHandlerGen::getVBOList(const std::string& typeName) const
{
QList<Utils::VBO*> res;
VBOHash::const_iterator i = h_vbo.begin();
while (i != h_vbo.end())
{
if(i.value()->typeName() == typeName)
res.append(i.value());
++i;
}
return res;
}
void MapHandlerGen::deleteVBO(const QString& name) void MapHandlerGen::deleteVBO(const QString& name)
{ {
if (h_vbo.contains(name)) if (h_vbo.contains(name))
......
...@@ -69,7 +69,7 @@ void computeVoronoiAreaVertices(typename PFP::MAP& map, const VertexAttribute<ty ...@@ -69,7 +69,7 @@ void computeVoronoiAreaVertices(typename PFP::MAP& map, const VertexAttribute<ty
} // namespace Geometry } // namespace Geometry
} } // namespace Surface
} // namespace Algo } // namespace Algo
......
...@@ -85,7 +85,7 @@ public: ...@@ -85,7 +85,7 @@ public:
/** /**
* init the data structure * init the data structure
* @param com say if compile only, or compile and execute (GL_COMPILE/ GL_COMPILE_AND_EXECUTE) * @param comp say if compile only, or compile and execute (GL_COMPILE / GL_COMPILE_AND_EXECUTE)
*/ */
void newList(GLenum comp = GL_COMPILE); void newList(GLenum comp = GL_COMPILE);
...@@ -163,7 +163,7 @@ public: ...@@ -163,7 +163,7 @@ public:
/** /**
* update position of VBO of drawer * update position of VBO of drawer
* @param first index of vertex to update * @param first index of vertex to update
* @param nb number of vertex tp update * @param nb number of vertices to update
* @param P ptr to table of vertices * @param P ptr to table of vertices
*/ */
void updatePositions(unsigned int first, unsigned int nb, const Geom::Vec3f* P); void updatePositions(unsigned int first, unsigned int nb, const Geom::Vec3f* P);
...@@ -171,7 +171,7 @@ public: ...@@ -171,7 +171,7 @@ public:
/** /**
* update position of VBO of drawer * update position of VBO of drawer
* @param first index of vertex to update * @param first index of vertex to update
* @param nb number of vertex tp update * @param nb number of vertices to update
* @param P ptr to table of vertices * @param P ptr to table of vertices
*/ */
void updatePositions(unsigned int first, unsigned int nb, const float* P); void updatePositions(unsigned int first, unsigned int nb, const float* P);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!