From a3f4857aa3c3485da49092b189aefc892529d00e Mon Sep 17 00:00:00 2001 From: mpv Date: Tue, 6 Sep 2016 10:46:58 +0300 Subject: [PATCH] Fix for the issue #1714: problems with extrusion update created on the sketch after save/open --- src/Model/Model_SelectionNaming.cpp | 5 ++- src/Model/Model_Update.cpp | 55 +++++++++++++++++++++-------- src/Model/Model_Update.h | 4 +++ 3 files changed, 49 insertions(+), 15 deletions(-) diff --git a/src/Model/Model_SelectionNaming.cpp b/src/Model/Model_SelectionNaming.cpp index ecf334303..2817bea49 100644 --- a/src/Model/Model_SelectionNaming.cpp +++ b/src/Model/Model_SelectionNaming.cpp @@ -123,7 +123,10 @@ std::string Model_SelectionNaming::namingName(ResultPtr& theContext, if (theContext->groupName() == ModelAPI_ResultPart::group()) { ResultPartPtr aPart = std::dynamic_pointer_cast(theContext); int anIndex; - return aPart->data()->name() + "/" + aPart->nameInPart(theSubSh, anIndex); + if (theSubSh.get()) + return aPart->data()->name() + "/" + aPart->nameInPart(theSubSh, anIndex); + else + return aPart->data()->name(); } if (!theSubSh.get() || theSubSh->isNull()) { // no subshape, so just the whole feature name diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index 48b8dcb00..a156d4002 100755 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -71,9 +71,19 @@ bool Model_Update::addModified(FeaturePtr theFeature, FeaturePtr theReason) { if (!theFeature->data()->isValid()) return false; // delete an extrusion created on the sketch - if (theFeature->isPersistentResult()) { - if (!std::dynamic_pointer_cast((theFeature)->document())->executeFeatures()) + bool isNotExecuted = theFeature->isPersistentResult() && + !std::dynamic_pointer_cast((theFeature)->document())->executeFeatures(); + if (isNotExecuted) { + if (!theReason.get()) // no reason => no construction reason return false; + if (myNotPersistentRefs.find(theFeature) == myNotPersistentRefs.end()) { + myNotPersistentRefs[theFeature].insert(theReason); + } else { + std::set > aNewSet; + aNewSet.insert(theReason); + myNotPersistentRefs[theFeature] = aNewSet; + } + return false; } // update arguments for "apply button" state change @@ -119,7 +129,7 @@ bool Model_Update::addModified(FeaturePtr theFeature, FeaturePtr theReason) { if (theReason.get()) aNewSet.insert(theReason); } - myModified[theFeature] = aNewSet; + myModified[theFeature] = aNewSet; #ifdef DEB_UPDATE if (theReason.get()) std::cout<<"*** Add modified "<name()<<" reason "<name()<data()->execState() == ModelAPI_StateMustBeUpdated) theFeature->data()->execState(ModelAPI_StateDone); @@ -728,18 +740,33 @@ bool Model_Update::isReason(std::shared_ptr& theFeature, { std::map, std::set > > ::iterator aReasonsIt = myModified.find(theFeature); - if (aReasonsIt == myModified.end()) - return false; // this case only for not-previewed items update state, nothing is changed in args for it - if (aReasonsIt->second.find(theFeature) != aReasonsIt->second.end()) - return true; // any is reason if it contains itself - FeaturePtr aReasFeat = std::dynamic_pointer_cast(theReason); - if (!aReasFeat.get()) { // try to get feature of this result - ResultPtr aReasRes = std::dynamic_pointer_cast(theReason); - if (aReasRes.get()) - aReasFeat = theReason->document()->feature(aReasRes); - } - return aReasonsIt->second.find(aReasFeat) != aReasonsIt->second.end(); + if (aReasonsIt != myModified.end()) { + if (aReasonsIt->second.find(theFeature) != aReasonsIt->second.end()) + return true; // any is reason if it contains itself + FeaturePtr aReasFeat = std::dynamic_pointer_cast(theReason); + if (!aReasFeat.get()) { // try to get feature of this result + ResultPtr aReasRes = std::dynamic_pointer_cast(theReason); + if (aReasRes.get()) + aReasFeat = theReason->document()->feature(aReasRes); + } + if (aReasonsIt->second.find(aReasFeat) != aReasonsIt->second.end()) + return true; + } + // another try: postponed modification by not-persistences + std::map, std::set > > + ::iterator aNotPersist = myNotPersistentRefs.find(theFeature); + if (aNotPersist != myNotPersistentRefs.end()) { + FeaturePtr aReasFeat = std::dynamic_pointer_cast(theReason); + if (!aReasFeat.get()) { // try to get feature of this result + ResultPtr aReasRes = std::dynamic_pointer_cast(theReason); + if (aReasRes.get()) + aReasFeat = theReason->document()->feature(aReasRes); + } + if (aNotPersist->second.find(aReasFeat) != aNotPersist->second.end()) + return true; + } + return false; // this case only for not-previewed items update state, nothing is changed in args for it } void Model_Update::executeFeature(FeaturePtr theFeature) diff --git a/src/Model/Model_Update.h b/src/Model/Model_Update.h index 7eb4a8ef2..9e37eddd2 100644 --- a/src/Model/Model_Update.h +++ b/src/Model/Model_Update.h @@ -29,6 +29,10 @@ class Model_Update : public Events_Listener /// The second set is the objects that causes this object is modified std::map, std::set > > myModified; + /// Features which arguments were modified by not-persistent changes. + /// So, these referencing arguments must be updated due to these features info also before execution). + std::map, std::set > > + myNotPersistentRefs; /// features that must be additionally processed after execution of finish operation std::set > myWaitForFinish; /// to know that some parameter was changed during this operation (to enable update expressions) -- 2.39.2