From 79fc082f788625bbef0f7a55136dd3ec84fbdda4 Mon Sep 17 00:00:00 2001 From: mpv Date: Fri, 21 Sep 2018 18:37:17 +0300 Subject: [PATCH] Fix for the issue #2640 and issue #2642 : incorrect update of the sketcher naming on open of the document --- src/Model/Model_Objects.cpp | 3 ++ src/Model/Model_ResultConstruction.cpp | 34 ++++++++++++---------- src/Model/Model_ResultConstruction.h | 3 +- src/ModelAPI/ModelAPI_ResultConstruction.h | 3 +- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index 70183795c..505a8a812 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -1882,6 +1882,9 @@ void Model_Objects::updateResults(FeaturePtr theFeature, std::set& t theFeature->execute(); } else if (aGroup->Get() == ModelAPI_ResultConstruction::group().c_str()) { theFeature->execute(); // construction shapes are needed for sketch solver + if (!theFeature->results().empty()) // to fix #2640 : update sketch, but not naming + std::dynamic_pointer_cast(theFeature->firstResult()) + ->facesNum(false); } else if (aGroup->Get() == ModelAPI_ResultGroup::group().c_str()) { aNewBody = createGroup(theFeature->data(), aResIndex); } else if (aGroup->Get() == ModelAPI_ResultField::group().c_str()) { diff --git a/src/Model/Model_ResultConstruction.cpp b/src/Model/Model_ResultConstruction.cpp index a0c8a519b..ad9c9a307 100644 --- a/src/Model/Model_ResultConstruction.cpp +++ b/src/Model/Model_ResultConstruction.cpp @@ -68,12 +68,12 @@ void Model_ResultConstruction::setShape(std::shared_ptr theShape) if (!theShape.get() || !theShape->isEqual(myShape)) { static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), anEvent); + if (theShape.get()) { + myFacesUpToDate = false; + myFaces.clear(); + } } myShape = theShape; - if (theShape.get()) { - myFacesUpToDate = false; - myFaces.clear(); - } } } @@ -94,7 +94,7 @@ void Model_ResultConstruction::setIsInHistory(const bool isInHistory) myIsInHistory = isInHistory; } -int Model_ResultConstruction::facesNum() +int Model_ResultConstruction::facesNum(const bool theUpdateNaming) { if (!myFacesUpToDate) { std::shared_ptr aWirePtr = @@ -113,17 +113,19 @@ int Model_ResultConstruction::facesNum() myFacesUpToDate = true; // update all the faces and sub-elements in the naming structure - DocumentPtr anEmptyExt; - bool aNotExt = false; - TDF_Label aDataLab = startLabel(anEmptyExt, aNotExt); - TDF_ChildIterator aSubsIter(aDataLab, Standard_False); - for(; aSubsIter.More(); aSubsIter.Next()) { - const TDF_Label aLab = aSubsIter.Value(); - if (aLab.Tag() == 1) // skip the root shape label - continue; - Handle(TNaming_NamedShape) aNS; - if (aLab.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { - update(aLab.Tag() - 1, anEmptyExt, aNotExt); + if (theUpdateNaming) { + DocumentPtr anEmptyExt; + bool aNotExt = false; + TDF_Label aDataLab = startLabel(anEmptyExt, aNotExt); + TDF_ChildIterator aSubsIter(aDataLab, Standard_False); + for(; aSubsIter.More(); aSubsIter.Next()) { + const TDF_Label aLab = aSubsIter.Value(); + if (aLab.Tag() == 1) // skip the root shape label + continue; + Handle(TNaming_NamedShape) aNS; + if (aLab.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { + update(aLab.Tag() - 1, anEmptyExt, aNotExt); + } } } } diff --git a/src/Model/Model_ResultConstruction.h b/src/Model/Model_ResultConstruction.h index 7b1cfcd17..b5ea41cd9 100644 --- a/src/Model/Model_ResultConstruction.h +++ b/src/Model/Model_ResultConstruction.h @@ -64,7 +64,8 @@ class Model_ResultConstruction : public ModelAPI_ResultConstruction MODEL_EXPORT virtual void setIsInHistory(const bool myIsInHistory); /// if the construction result may be used as faces, this method returns not zero number of faces - MODEL_EXPORT virtual int facesNum(); + /// \param theUpdateNaming is false of keeping the naming structure untouched (on load) + MODEL_EXPORT virtual int facesNum(const bool theUpdateNaming = true); /// if the construction result may be used as faces, this method returns face by zero based index MODEL_EXPORT virtual std::shared_ptr face(const int theIndex); diff --git a/src/ModelAPI/ModelAPI_ResultConstruction.h b/src/ModelAPI/ModelAPI_ResultConstruction.h index d8428f9e1..ff637277d 100644 --- a/src/ModelAPI/ModelAPI_ResultConstruction.h +++ b/src/ModelAPI/ModelAPI_ResultConstruction.h @@ -67,7 +67,8 @@ class ModelAPI_ResultConstruction : public ModelAPI_Result virtual void setIsInHistory(const bool isInHistory) = 0; /// if the construction result may be used as faces, this method returns not zero number of faces - virtual int facesNum() = 0; + /// \param theUpdateNaming is false of keeping the naming structure untouched (on load) + virtual int facesNum(const bool theUpdateNaming = true) = 0; /// if the construction result may be used as faces, this method returns face by zero based index virtual std::shared_ptr face(const int theIndex) = 0; -- 2.39.2