Commit 222b9959 authored by Pierre Kraemer's avatar Pierre Kraemer
Browse files

SCHNApps: new addMap method

parent 4b478c61
...@@ -20,28 +20,29 @@ void ImportSurfacePlugin::importFromFile(const QString& fileName) ...@@ -20,28 +20,29 @@ void ImportSurfacePlugin::importFromFile(const QString& fileName)
QFileInfo fi(fileName); QFileInfo fi(fileName);
if(fi.exists()) if(fi.exists())
{ {
GenericMap* m = m_window->createMap(2); MapHandlerGen* mhg = m_window->addMap(fi.baseName(), 2);
PFP2::MAP* map = static_cast<PFP2::MAP*>(m); if(mhg)
MapHandler<PFP2>* h = new MapHandler<PFP2>(fi.baseName(), m_window, map); {
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(mhg);
PFP2::MAP* map = mh->getMap();
std::vector<std::string> attrNames ; std::vector<std::string> attrNames ;
Algo::Surface::Import::importMesh<PFP2>(*map, fileName.toUtf8().constData(), attrNames); Algo::Surface::Import::importMesh<PFP2>(*map, fileName.toUtf8().constData(), 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, CGoGN::VERTEX>(attrNames[0]);
// create VBO for vertex position attribute // create VBO for vertex position attribute
h->createVBO(position); mh->createVBO(position);
// compute map bounding box // compute map bounding box
h->updateBB(position); mh->updateBB(position);
// compute primitive connectivity VBOs // compute primitive connectivity VBOs
h->updatePrimitives(Algo::Render::GL2::POINTS); mh->updatePrimitives(Algo::Render::GL2::POINTS);
h->updatePrimitives(Algo::Render::GL2::LINES); mh->updatePrimitives(Algo::Render::GL2::LINES);
h->updatePrimitives(Algo::Render::GL2::TRIANGLES); mh->updatePrimitives(Algo::Render::GL2::TRIANGLES);
}
m_window->addMap(h);
} }
} }
......
...@@ -213,8 +213,7 @@ public: ...@@ -213,8 +213,7 @@ public:
* MANAGE MAPS * MANAGE MAPS
*********************************************************/ *********************************************************/
GenericMap* createMap(unsigned int dim); MapHandlerGen* addMap(const QString& name, unsigned int dim);
bool addMap(MapHandlerGen* map);
void removeMap(const QString& name); void removeMap(const QString& name);
MapHandlerGen* getMap(const QString& name) const; MapHandlerGen* getMap(const QString& name) const;
QList<MapHandlerGen*> getMapsList() const { return h_maps.values(); } QList<MapHandlerGen*> getMapsList() const { return h_maps.values(); }
......
...@@ -514,8 +514,11 @@ Plugin* Window::checkPluginDependencie(QString name, Plugin* dependantPlugin) ...@@ -514,8 +514,11 @@ Plugin* Window::checkPluginDependencie(QString name, Plugin* dependantPlugin)
* MANAGE MAPS * MANAGE MAPS
*********************************************************/ *********************************************************/
GenericMap* Window::createMap(unsigned int dim) MapHandlerGen* Window::addMap(const QString& name, unsigned int dim)
{ {
if (h_maps.contains(name))
return NULL;
GenericMap* map = NULL; GenericMap* map = NULL;
switch(dim) switch(dim)
{ {
...@@ -526,19 +529,13 @@ GenericMap* Window::createMap(unsigned int dim) ...@@ -526,19 +529,13 @@ GenericMap* Window::createMap(unsigned int dim)
map = new PFP3::MAP(); map = new PFP3::MAP();
break; break;
} }
return map;
}
bool Window::addMap(MapHandlerGen* map) MapHandlerGen* mh = new MapHandlerGen(name, this, map);
{ h_maps.insert(name, mh);
if (h_maps.contains(map->getName()))
return false;
h_maps.insert(map->getName(), map); emit(mapAdded(mh));
emit(mapAdded(map)); return mh;
return true;
} }
void Window::removeMap(const QString& name) void Window::removeMap(const QString& name)
......
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