X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FModel%2FModel_Session.cpp;h=c73516a43069ef9382894fe3eb1456a588310bb1;hb=10671023698288fff01b8717696d150419dc4475;hp=75cb32ee044bc5eb327ba56372f7ce2dff19de79;hpb=423c10234142d14d0d5de89383f2f96a4ec5930f;p=modules%2Fshaper.git diff --git a/src/Model/Model_Session.cpp b/src/Model/Model_Session.cpp index 75cb32ee0..c73516a43 100644 --- a/src/Model/Model_Session.cpp +++ b/src/Model/Model_Session.cpp @@ -21,15 +21,22 @@ #include #include #include + +#include #include #include +#include #include #include #include #include -using namespace std; +#include +#include +#include + +#include static Model_Session* myImpl = new Model_Session(); @@ -144,7 +151,7 @@ std::list Model_Session::redoList() return ROOT_DOC->redoList(); } -FeaturePtr Model_Session::createFeature(string theFeatureID, Model_Document* theDocOwner) +FeaturePtr Model_Session::createFeature(std::string theFeatureID, Model_Document* theDocOwner) { if (this != myImpl) { return myImpl->createFeature(theFeatureID, theDocOwner); @@ -193,6 +200,7 @@ std::shared_ptr Model_Session::moduleDocument() if (aFirstCall) { // to be sure that plugins are loaded, // even before the first "createFeature" call (in unit tests) + LoadPluginsInfo(); // creation of the root document is always outside of the transaction, so, avoid checking it setCheckTransactions(false); @@ -268,7 +276,7 @@ void Model_Session::setActiveDocument( bool aWasChecked = myCheckTransactions; setCheckTransactions(false); TDF_LabelList anEmptyUpdated; - aDoc->objects()->synchronizeFeatures(anEmptyUpdated, true, true, true); + aDoc->objects()->synchronizeFeatures(anEmptyUpdated, true, true, false, true); if (aWasChecked) setCheckTransactions(true); } @@ -292,10 +300,10 @@ void Model_Session::setActiveDocument( std::list > Model_Session::allOpenedDocuments() { - list > aResult; + std::list > aResult; aResult.push_back(moduleDocument()); // add subs recursively - list >::iterator aDoc = aResult.begin(); + std::list >::iterator aDoc = aResult.begin(); for(; aDoc != aResult.end(); aDoc++) { DocumentPtr anAPIDoc = *aDoc; std::shared_ptr aDoc = std::dynamic_pointer_cast(anAPIDoc); @@ -326,12 +334,56 @@ std::shared_ptr Model_Session::copy( Handle(TDF_DataSet) aDS = new TDF_DataSet; aDS->AddLabel(aSourceRoot); TDF_ClosureTool::Closure(aDS); - Handle(TDF_RelocationTable) aRT = new TDF_RelocationTable; + Handle(TDF_RelocationTable) aRT = new TDF_RelocationTable(Standard_True); aRT->SetRelocation(aSourceRoot, aTargetRoot); TDF_CopyTool::Copy(aDS, aRT); + // TODO: remove after fix in OCCT. + // All named shapes are stored in reversed order, so to fix this we reverse them back. + for(TDF_ChildIDIterator aChildIter(aTargetRoot, TNaming_NamedShape::GetID(), true); + aChildIter.More(); + aChildIter.Next()) { + Handle(TNaming_NamedShape) aNamedShape = + Handle(TNaming_NamedShape)::DownCast(aChildIter.Value()); + if (aNamedShape.IsNull()) { + continue; + } + + TopoDS_Shape aShape = aNamedShape->Get(); + if(aShape.IsNull() || aShape.ShapeType() != TopAbs_COMPOUND) { + continue; + } + + TNaming_Evolution anEvol = aNamedShape->Evolution(); + std::list > aShapePairs; // to store old and new shapes + for(TNaming_Iterator anIter(aNamedShape); anIter.More(); anIter.Next()) { + aShapePairs.push_back( + std::pair(anIter.OldShape(), anIter.NewShape())); + } + + // Add in reverse order. + TDF_Label aLabel = aNamedShape->Label(); + TNaming_Builder aBuilder(aLabel); + for(std::list >::iterator aPairsIter = + aShapePairs.begin(); + aPairsIter != aShapePairs.end(); + aPairsIter++) { + if (anEvol == TNaming_GENERATED) { + aBuilder.Generated(aPairsIter->first, aPairsIter->second); + } else if (anEvol == TNaming_MODIFY) { + aBuilder.Modify(aPairsIter->first, aPairsIter->second); + } else if (anEvol == TNaming_DELETE) { + aBuilder.Delete(aPairsIter->first); + } else if (anEvol == TNaming_PRIMITIVE) { + aBuilder.Generated(aPairsIter->second); + } else if (anEvol == TNaming_SELECTED) { + aBuilder.Select(aPairsIter->second, aPairsIter->first); + } + } + } + TDF_LabelList anEmptyUpdated; - aNew->objects()->synchronizeFeatures(anEmptyUpdated, true, true, true); + aNew->objects()->synchronizeFeatures(anEmptyUpdated, true, true, true, true); return aNew; } @@ -424,7 +476,8 @@ void Model_Session::processEvent(const std::shared_ptr& theMessa } } if (!aFound) { // if not, the part was removed, so activate the module document - setActiveDocument(moduleDocument()); + if (myCurrentDoc.get()) + setActiveDocument(moduleDocument()); } } } @@ -435,7 +488,6 @@ void Model_Session::LoadPluginsInfo() { if (myPluginsInfoLoaded) // nothing to do return; - // Read plugins information from XML files Config_ModuleReader aModuleReader(Config_FeatureMessage::MODEL_EVENT()); aModuleReader.readAll();