GlLayer *GlScene::createLayerAfter(const string &layerName, const string &afterLayerWithName, bool is3d) { GlLayer *newLayer = NULL; GlLayer *oldLayer = getLayer(layerName); for(vector<pair<string, GlLayer *> >::iterator it = _layersList.begin() ; it != _layersList.end(); ++it) { if(it->first == afterLayerWithName) { ++it; if (!is3d) { newLayer = new GlLayer(layerName, is3d); } else { newLayer = new GlLayer(layerName, getMainLayer()->getCamera(), getMainLayer()->getLight()); } _layersList.insert(it, pair<string,GlLayer*>(layerName, newLayer)); newLayer->setScene(this); if(oldLayer != NULL) { warning() << "Warning : You have a layer in the scene with same name, previous layer will be removed" << endl; removeLayer(oldLayer); } break; } } if (newLayer) { sendEvent(GlSceneEvent(GlSceneEvent::LAYER_ADDED_IN_SCENE, this, newLayer)); } return newLayer; }
GlLayer *GlScene::createLayer(const string &name, bool is3d) { GlLayer *oldLayer = getLayer(name); if(oldLayer != NULL) { warning() << "Warning : You have a layer in the scene with same name, previous layer will be removed" << endl; removeLayer(oldLayer); } GlLayer *newLayer = NULL; if (!is3d) { newLayer = new GlLayer(name, is3d); } else { newLayer = new GlLayer(name, getMainLayer()->getCamera(), getMainLayer()->getLight()); } _layersList.push_back(pair<string,GlLayer*>(name, newLayer)); newLayer->setScene(this); sendEvent(GlSceneEvent(GlSceneEvent::LAYER_ADDED_IN_SCENE, this, newLayer)); return newLayer; }