# HG changeset patch # User lbajardsilogic # Date 1213281615 0 # Node ID 8bdd4752c2b2efee0bdc49612c517cfea4fc97f6 # Parent 82d17c4d4b397d5a1f94887de813bf51567a3179 remove/add layer without command. patch for bug: impossibility to re-load a layer as it was only set to dormant in the command not very clean but it works. diff -r 82d17c4d4b39 -r 8bdd4752c2b2 data/fileio/ModelReader.cpp --- a/data/fileio/ModelReader.cpp Thu Jun 12 13:36:37 2008 +0000 +++ b/data/fileio/ModelReader.cpp Thu Jun 12 14:40:15 2008 +0000 @@ -240,7 +240,7 @@ } if (m_pane && m_layer) { - m_document->addLayerToView(m_pane, m_layer); + m_document->addLayerToViewWithoutCommand(m_pane, m_layer); } } diff -r 82d17c4d4b39 -r 8bdd4752c2b2 sv/document/Document.cpp --- a/sv/document/Document.cpp Thu Jun 12 13:36:37 2008 +0000 +++ b/sv/document/Document.cpp Thu Jun 12 14:40:15 2008 +0000 @@ -585,6 +585,31 @@ } void +Document::addLayerToViewWithoutCommand(View *view, Layer *layer) +{ + Model *model = layer->getModel(); + if (!model) { +// std::cerr << "Document::addLayerToView: Layer (\"" +// << layer->objectName().toStdString() +// << "\") with no model being added to view: " +// << "normally you want to set the model first" << std::endl; + } else { + if (model != m_mainModel && + m_models.find(model) == m_models.end()) { + std::cerr << "ERROR: Document::addLayerToView: Layer " << layer + << " has unregistered model " << model + << " -- register the layer's model before adding the layer!" << std::endl; + return; + } + } + + view->addLayer(layer); + layer->setLayerDormant(view, false); + + addToLayerViewMap(layer, view); +} + +void Document::removeLayerFromView(View *view, Layer *layer) { CommandHistory::getInstance()->addCommand @@ -592,6 +617,14 @@ } void +Document::removeLayerFromViewWithoutCommand(View *view, Layer *layer) +{ + view->removeLayer(layer); + removeFromLayerViewMap(layer, view); + deleteLayer(layer); +} + +void Document::addToLayerViewMap(Layer *layer, View *view) { bool firstView = (m_layerViewMap.find(layer) == m_layerViewMap.end() || diff -r 82d17c4d4b39 -r 8bdd4752c2b2 sv/document/Document.h --- a/sv/document/Document.h Thu Jun 12 13:36:37 2008 +0000 +++ b/sv/document/Document.h Thu Jun 12 14:40:15 2008 +0000 @@ -194,10 +194,13 @@ */ void addLayerToView(View *, Layer *); - /** + void addLayerToViewWithoutCommand(View *, Layer *); + + /** * Remove the given layer from the given view. */ void removeLayerFromView(View *, Layer *); + void removeLayerFromViewWithoutCommand(View *, Layer *); inline std::set& getLayers(){return m_layers;} diff -r 82d17c4d4b39 -r 8bdd4752c2b2 sv/main/MainWindow.cpp --- a/sv/main/MainWindow.cpp Thu Jun 12 13:36:37 2008 +0000 +++ b/sv/main/MainWindow.cpp Thu Jun 12 14:40:15 2008 +0000 @@ -4086,7 +4086,7 @@ if (pane) { Layer *layer = pane->getSelectedLayer(); if (layer) { - m_document->/*deleteLayer(layer);*/removeLayerFromView(pane, layer); + m_document->removeLayerFromViewWithoutCommand(pane, layer); } } updateMenuStates();