From 55120de482247ff91c0acf8394f995a5e22b14c1 Mon Sep 17 00:00:00 2001 From: mpv Date: Tue, 17 Nov 2015 10:15:15 +0300 Subject: [PATCH] Fix for the issue #1089 --- src/Model/Model_Objects.cpp | 13 +++++----- src/Model/Model_Update.cpp | 45 ++++++--------------------------- src/ModelAPI/ModelAPI_Tools.cpp | 18 +++++++++++++ src/ModelAPI/ModelAPI_Tools.h | 5 ++++ 4 files changed, 38 insertions(+), 43 deletions(-) diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index 87848db84..045dfe44e 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -792,14 +792,15 @@ void Model_Objects::synchronizeBackRefs() synchronizeBackRefsForObject(aFound->second, aFeature); } // also for results - const std::list >& aResults = aFeature->results(); - std::list >::const_iterator aRes = aResults.cbegin(); - for(; aRes != aResults.cend(); aRes++) { - aFound = allRefs.find(*aRes); + std::list aResults; + ModelAPI_Tools::allResults(aFeature, aResults); + std::list::iterator aRIter = aResults.begin(); + for(; aRIter != aResults.cend(); aRIter++) { + aFound = allRefs.find(*aRIter); if (aFound == allRefs.end()) { // not found => erase all back references - synchronizeBackRefsForObject(anEmpty, *aRes); + synchronizeBackRefsForObject(anEmpty, *aRIter); } else { - synchronizeBackRefsForObject(aFound->second, *aRes); + synchronizeBackRefsForObject(aFound->second, *aRIter); } } } diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index 96db87ded..e6d83e197 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -398,9 +398,11 @@ void Model_Update::redisplayWithResults(FeaturePtr theFeature, const ModelAPI_Ex { // make updated and redisplay all results static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY); - const std::list >& aResults = theFeature->results(); - std::list >::const_iterator aRIter = aResults.begin(); - for (; aRIter != aResults.cend(); aRIter++) { + + std::list allResults; + ModelAPI_Tools::allResults(theFeature, allResults); + std::list::iterator aRIter = allResults.begin(); + for (; aRIter != allResults.cend(); aRIter++) { std::shared_ptr aRes = *aRIter; if (!aRes->isDisabled()) {// update state only for enabled results (Placement Result Part may make the original Part Result as invalid) aRes->data()->execState(theState); @@ -411,23 +413,6 @@ void Model_Update::redisplayWithResults(FeaturePtr theFeature, const ModelAPI_Ex aRes->data()->setUpdateID(theFeature->data()->updateID()); } ModelAPI_EventCreator::get()->sendUpdated(aRes, EVENT_DISP); - // iterate sub-bodies of compsolid - ResultCompSolidPtr aComp = std::dynamic_pointer_cast(aRes); - if (aComp.get()) { - int aNumSub = aComp->numberOfSubs(); - for(int a = 0; a < aNumSub; a++) { - ResultPtr aSub = aComp->subResult(a); - if (!aSub->isDisabled()) {// update state only for enabled results (Placement Result Part may make the original Part Result as invalid) - aSub->data()->execState(theState); - if (theState == ModelAPI_StateDone) // feature become "done", so execution changed results - myUpdated[aSub] = myModification; - } - if (theFeature->data()->updateID() > aSub->data()->updateID()) { - aSub->data()->setUpdateID(theFeature->data()->updateID()); - } - ModelAPI_EventCreator::get()->sendUpdated(aSub, EVENT_DISP); - } - } } // to redisplay "presentable" feature (for ex. distance constraint) ModelAPI_EventCreator::get()->sendUpdated(theFeature, EVENT_DISP); @@ -463,8 +448,9 @@ bool Model_Update::isOlder(std::shared_ptr theFeature, // for the modification IDs compare results: modification ID of feature means only that attributes // of this feature were updated, but if results are obsolete relatively to the referenced results, // the feature must be updated - const std::list >& aResults = theFeature->results(); - std::list >::const_iterator aRIter = aResults.begin(); + std::list aResults; + ModelAPI_Tools::allResults(theFeature, aResults); + std::list::iterator aRIter = aResults.begin(); for (; aRIter != aResults.cend(); aRIter++) { std::shared_ptr aRes = *aRIter; if (!aRes->isDisabled()) { @@ -473,21 +459,6 @@ bool Model_Update::isOlder(std::shared_ptr theFeature, return true; if (anRIter->second < anAIter->second) return true; - // iterate sub-bodies of compsolid - ResultCompSolidPtr aComp = std::dynamic_pointer_cast(aRes); - if (aComp.get()) { - int aNumSub = aComp->numberOfSubs(); - for(int a = 0; a < aNumSub; a++) { - ResultPtr aSub = aComp->subResult(a); - if (!aSub->isDisabled()) {// update state only for enabled results (Placement Result Part may make the original Part Result as invalid) - std::map, int >::iterator anSIter = myUpdated.find(aSub); - if (anSIter == myUpdated.end()) // not updated at all - return true; - if (anSIter->second < anAIter->second) - return true; - } - } - } } } // also check a feature: some have no parameters, diff --git a/src/ModelAPI/ModelAPI_Tools.cpp b/src/ModelAPI/ModelAPI_Tools.cpp index 56c2a0fe6..4fa9775d6 100755 --- a/src/ModelAPI/ModelAPI_Tools.cpp +++ b/src/ModelAPI/ModelAPI_Tools.cpp @@ -211,5 +211,23 @@ bool hasSubResults(const ResultPtr& theResult) return aCompSolid.get() && aCompSolid->numberOfSubs() > 0; } +void allResults(const FeaturePtr& theFeature, std::list& theResults) +{ + const std::list >& aResults = theFeature->results(); + std::list >::const_iterator aRIter = aResults.begin(); + for (; aRIter != aResults.cend(); aRIter++) { + theResults.push_back(*aRIter); + // iterate sub-bodies of compsolid + ResultCompSolidPtr aComp = std::dynamic_pointer_cast(*aRIter); + if (aComp.get()) { + int aNumSub = aComp->numberOfSubs(); + for(int a = 0; a < aNumSub; a++) { + theResults.push_back(aComp->subResult(a)); + } + } + } +} + } // namespace ModelAPI_Tools + diff --git a/src/ModelAPI/ModelAPI_Tools.h b/src/ModelAPI/ModelAPI_Tools.h index e40494835..9d544cbf8 100755 --- a/src/ModelAPI/ModelAPI_Tools.h +++ b/src/ModelAPI/ModelAPI_Tools.h @@ -74,6 +74,11 @@ MODELAPI_EXPORT ResultCompSolidPtr compSolidOwner(const ResultPtr& theSub); */ MODELAPI_EXPORT bool hasSubResults(const ResultPtr& theResult); +/*! +* Adds the results of the given feature to theResults list: including disabled and sub-results +*/ +MODELAPI_EXPORT void allResults(const FeaturePtr& theFeature, std::list& theResults); + } #endif -- 2.39.2