X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_ResultBody.cpp;h=f7492cc9534cfb7d71a92083b6e66dfefe547a3e;hb=refs%2Ftags%2FV_1.2.1;hp=9b639f9a7153c894e51421fed92dc6f8321e8e68;hpb=96912644cf6607688466ac69f1f098fd2fff37b7;p=modules%2Fshaper.git diff --git a/src/Model/Model_ResultBody.cpp b/src/Model/Model_ResultBody.cpp index 9b639f9a7..f7492cc95 100644 --- a/src/Model/Model_ResultBody.cpp +++ b/src/Model/Model_ResultBody.cpp @@ -40,6 +40,7 @@ Model_ResultBody::Model_ResultBody() { + myIsDisabled = true; // by default it is not initialized and false to be after created setIsConcealed(false); } @@ -58,6 +59,57 @@ void Model_ResultBody::colorConfigInfo(std::string& theSection, std::string& the theDefault = DEFAULT_COLOR(); } +// Converts evolution of naming shape to selection evelution and back to avoid +// naming support on the disabled results. Deeply in the labels tree, recursively. +static void EvolutionToSelection(TDF_Label theLab, const bool theFlag) { + std::list > aShapePairs; // to store old and new shapes + Handle(TNaming_NamedShape) aName; + int anEvolution = -1; + if (theLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) { + TNaming_Evolution aNSEvol = aName->Evolution(); + if ((aNSEvol == TNaming_SELECTED && theFlag) || + (aNSEvol != TNaming_SELECTED && !theFlag)) { // nothing to do, it is already correct + return; + } + anEvolution = (int)(aNSEvol); + if (!theFlag) { + Handle(TDataStd_Integer) anAttrEvol; + if (theLab.FindAttribute(TDataStd_Integer::GetID(), anAttrEvol)) { + anEvolution = anAttrEvol->Get(); + } + } else { + TDataStd_Integer::Set(theLab, anEvolution); + } + + for(TNaming_Iterator anIter(aName); anIter.More(); anIter.Next()) { + aShapePairs.push_back(std::pair + (anIter.OldShape(), anIter.NewShape())); + } + } + // create new + TNaming_Builder aBuilder(theLab); + TNaming_Evolution anEvol = (TNaming_Evolution)(anEvolution); + std::list >::iterator aPairsIter = aShapePairs.begin(); + for(; aPairsIter != aShapePairs.end(); aPairsIter++) { + if (theFlag) { // disabled => make selection + aBuilder.Select(aPairsIter->first, aPairsIter->second); + } else 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); + } + } + // recursive call for all sub-labels + TDF_ChildIterator anIter(theLab, Standard_False); + for(; anIter.More(); anIter.Next()) { + EvolutionToSelection(anIter.Value(), theFlag); + } +} + bool Model_ResultBody::setDisabled(std::shared_ptr theThis, const bool theFlag) { bool aChanged = ModelAPI_ResultBody::setDisabled(theThis, theFlag); @@ -66,32 +118,7 @@ bool Model_ResultBody::setDisabled(std::shared_ptr theThis, con if (!aData) // unknown case return aChanged; TDF_Label& aShapeLab = aData->shapeLab(); - - std::list > aShapePairs; // to store old and new shapes - Handle(TNaming_NamedShape) aName; - int anEvolution = -1; - if (aShapeLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) { - anEvolution = (int)(aName->Evolution()); - for(TNaming_Iterator anIter(aName); anIter.More(); anIter.Next()) { - aShapePairs.push_back(std::pair - (anIter.OldShape(), anIter.NewShape())); - } - } - // remove old - aShapeLab.ForgetAttribute(TNaming_NamedShape::GetID()); - // create new - TNaming_Builder aBuilder(aShapeLab); - TNaming_Evolution anEvol = (TNaming_Evolution)(anEvolution); - std::list >::iterator aPairsIter = aShapePairs.begin(); - for(; aPairsIter != aShapePairs.end(); aPairsIter++) { - if (theFlag) { // disabled => make selection - aBuilder.Select(aPairsIter->first, aPairsIter->second); - } else if (anEvol == TNaming_GENERATED) { - aBuilder.Generated(aPairsIter->first, aPairsIter->second); - } else if (anEvol == TNaming_MODIFY) { - aBuilder.Modify(aPairsIter->first, aPairsIter->second); - } - } + EvolutionToSelection(aShapeLab, theFlag); } return aChanged; }