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(
SCHNApps_FILES
${SCHNApps_ROOT_DIR}/src/*.cpp
${SCHNApps_ROOT_DIR}/include/*.h
${SCHNApps_ROOT_DIR}/include/*.hpp
)
file(
......
......@@ -28,6 +28,8 @@ public slots:
void addMapToList(MapHandlerGen* m);
void removeMapFromList(MapHandlerGen* m);
void addAttributeToList(unsigned int orbit, const QString& nameAttr);
void attributeModified(unsigned int orbit, QString nameAttr);
};
} // namespace SCHNApps
......
......@@ -72,6 +72,15 @@ private:
QAction* m_computeNormalAction;
QAction* m_computeCurvatureAction;
struct ComputeNormalParameters
{
ComputeNormalParameters() {}
ComputeNormalParameters(QString p, QString n) : positionName(p), normalName(n) {}
QString positionName;
QString normalName;
};
QHash<QString, ComputeNormalParameters> computeNormalLastParameters;
};
#endif
......@@ -25,7 +25,11 @@ ComputeNormalDialog::ComputeNormalDialog(Window* w) :
const QList<MapHandlerGen*>& maps = m_window->getMapsList();
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()
......@@ -71,7 +75,8 @@ void ComputeNormalDialog::selectedMapChanged()
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)
......@@ -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 CGoGN
......@@ -139,6 +139,9 @@ void DifferentialPropertiesPlugin::computeNormal(
if(createNormalVBO)
mh->createVBO(normal);
computeNormalLastParameters[mapName] =
ComputeNormalParameters(positionAttributeName, normalAttributeName) ;
QList<View*> views = mh->getLinkedViews();
foreach(View* view, views)
view->updateGL();
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>174</width>
<height>547</height>
<height>545</height>
</rect>
</property>
<property name="windowTitle">
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>174</width>
<height>553</height>
<height>545</height>
</rect>
</property>
<property name="windowTitle">
......
......@@ -192,7 +192,9 @@ void SurfaceDeformationPlugin::keyPress(View* view, QKeyEvent* event)
if(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();
}
}
......@@ -318,6 +320,7 @@ void SurfaceDeformationPlugin::mouseMove(View* view, QMouseEvent* event)
asRigidAsPossible(view, params->selectedMap);
params->selectedMap->updateVBO(perMap->positionAttribute);
params->selectedMap->notifyAttributeModification(perMap->positionAttribute);
view->updateGL();
}
......
......@@ -29,107 +29,68 @@ public:
MapHandlerGen(const QString& name, Window* window, GenericMap* map);
virtual ~MapHandlerGen();
const QString& getName() const { return m_name; }
inline const QString& getName() const { return m_name; }
public slots:
QString getName() { return m_name; }
void setName(const QString& name) { m_name = name; }
inline QString getName() { return m_name; }
inline void setName(const QString& name) { m_name = name; }
Window* getWindow() const { return m_window; }
void setWindow(Window* w) { m_window = w; }
inline Window* getWindow() const { return m_window; }
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; }
const qglviewer::Vec& getBBmax() const { return m_bbMax; }
float getBBdiagSize() const { return m_bbDiagSize; }
inline const qglviewer::Vec& getBBmin() const { return m_bbMin; }
inline const qglviewer::Vec& getBBmax() const { return m_bbMax; }
inline float getBBdiagSize() const { return m_bbDiagSize; }
bool isUsed() const { return !l_views.empty(); }
inline bool isUsed() const { return !l_views.empty(); }
public:
virtual void draw(Utils::GLSLShader* shader, int primitive) = 0;
void setPrimitiveDirty(int primitive)
{
m_render->setPrimitiveDirty(primitive);
}
inline void setPrimitiveDirty(int primitive) { m_render->setPrimitiveDirty(primitive); }
/*********************************************************
* MANAGE ATTRIBUTES
*********************************************************/
template <typename T, unsigned int ORBIT>
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());
}
AttributeHandler<T, ORBIT> getAttribute(const QString& nameAttr, bool onlyRegistered = true) const;
template <typename T, unsigned int ORBIT>
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;
}
AttributeHandler<T, ORBIT> addAttribute(const QString& nameAttr, bool registerAttr = true);
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))
return h_attribs[orbit][nameAttr];
else
return "";
emit(connectivityModified());
}
const AttributeHash& getAttributesList(unsigned int orbit) const { return h_attribs[orbit]; }
/*********************************************************
* MANAGE VBOs
*********************************************************/
template <typename ATTR_HANDLER>
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;
}
Utils::VBO* createVBO(const ATTR_HANDLER& attr);
template <typename ATTR_HANDLER>
void updateVBO(const ATTR_HANDLER& attr)
{
Utils::VBO* vbo = getVBO(QString::fromStdString(attr.name()));
if(vbo)
vbo->updateData(attr);
}
void updateVBO(const ATTR_HANDLER& attr);
Utils::VBO* getVBO(const QString& name) const;
QList<Utils::VBO*> getVBOList() const { return h_vbo.values(); }
QList<Utils::VBO*> getVBOList(const std::string& typeName) const;
inline QList<Utils::VBO*> getVBOList() const { return h_vbo.values(); }
void deleteVBO(const QString& name);
/*********************************************************
......@@ -138,8 +99,8 @@ public:
void linkView(View* view);
void unlinkView(View* view);
const QList<View*>& getLinkedViews() const { return l_views; }
bool isLinkedToView(View* view) const { return l_views.contains(view); }
inline const QList<View*>& getLinkedViews() const { return l_views; }
inline bool isLinkedToView(View* view) const { return l_views.contains(view); }
protected:
QString m_name;
......@@ -158,7 +119,11 @@ protected:
AttributeHash h_attribs[NB_ORBITS];
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 vboRemoved(Utils::VBO* vbo);
};
......@@ -177,26 +142,17 @@ public:
delete m_map;
}
virtual 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);
}
void draw(Utils::GLSLShader* shader, int 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)
{
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();
}
void updateBB(const VertexAttribute<typename PFP::VEC3>& position);
};
} // namespace SCHNApps
} // namespace CGoGN
#include "mapHandler.hpp"
#endif
......@@ -19,8 +19,8 @@ CameraViewDialog::CameraViewDialog(Window* window, View* view) :
m_view(view),
b_refreshingUI(false)
{
this->setupUi(this);
this->setWindowTitle(m_view->getName() + QString(" : camera"));
setupUi(this);
setWindowTitle(m_view->getName() + QString(" : camera"));
connect(cameraList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedCameraChanged()));
......
......@@ -16,8 +16,8 @@ CamerasDialog::CamerasDialog(Window* window) :
QDialog(window),
m_window(window)
{
this->setupUi(this);
this->setModal(false);
setupUi(this);
setModal(false);
connect(addCameraButton, SIGNAL(clicked()), this, SLOT(cb_addCamera()));
connect(removeCamerasButton, SIGNAL(clicked()), this, SLOT(cb_removeCameras()));
......
......@@ -16,8 +16,8 @@ MapsDialog::MapsDialog(Window* window) :
QDialog(window),
m_window(window)
{
this->setupUi(this);
this->setModal(false);
setupUi(this);
setModal(false);
connect(button_removeMap, SIGNAL(clicked()), this, SLOT(cb_removeMap()));
connect(button_refreshMapInfo, SIGNAL(clicked()), this, SLOT(cb_selectedMapChanged()));
......
......@@ -20,8 +20,8 @@ MapsViewDialog::MapsViewDialog(Window* window, View* view) :
m_view(view),
b_refreshingUI(false)
{
this->setupUi(this);
this->setWindowTitle(m_view->getName() + QString(" : maps"));
setupUi(this);
setWindowTitle(m_view->getName() + QString(" : maps"));
connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedMapsChanged()));
......
......@@ -17,7 +17,8 @@ PluginsDialog::PluginsDialog(Window* window) :
m_window(window),
b_refreshingUI(false)
{
this->setupUi(this);
setupUi(this);
setModal(false);
connect(button_registerDirectory, SIGNAL(pressed()), this, SLOT(registerPluginsDirectory()));
connect(list_plugins, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(togglePlugin(QListWidgetItem*)));
......
......@@ -19,8 +19,8 @@ PluginsViewDialog::PluginsViewDialog(Window* window, View* view) :
m_view(view),
b_refreshingUI(false)
{
this->setupUi(this);
this->setWindowTitle(m_view->getName() + QString(" : plugins"));
setupUi(this);
setWindowTitle(m_view->getName() + QString(" : plugins"));
connect(pluginList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedPluginsChanged()));
......
......@@ -32,19 +32,6 @@ Utils::VBO* MapHandlerGen::getVBO(const QString& name) const
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)
{
if (h_vbo.contains(name))
......
......@@ -69,7 +69,7 @@ void computeVoronoiAreaVertices(typename PFP::MAP& map, const VertexAttribute<ty
} // namespace Geometry
}
} // namespace Surface
} // namespace Algo
......
......@@ -85,7 +85,7 @@ public:
/**
* 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);
......@@ -163,7 +163,7 @@ public:
/**
* update position of VBO of drawer
* @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
*/
void updatePositions(unsigned int first, unsigned int nb, const Geom::Vec3f* P);
......@@ -171,7 +171,7 @@ public:
/**
* update position of VBO of drawer
* @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
*/
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!
Please register or to comment