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

SCHNApps: new addMap method

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