From f881b598c3829550675c0349d8769663a8eb883f Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 12 Nov 2015 09:49:41 +0300 Subject: [PATCH] Fix for the issue #1051 the obsolete results were not taken into account, so, sometimes update was not valid for all features --- src/Model/Model_Update.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index e9cec6c46..96db87ded 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -432,6 +432,7 @@ void Model_Update::redisplayWithResults(FeaturePtr theFeature, const ModelAPI_Ex // to redisplay "presentable" feature (for ex. distance constraint) ModelAPI_EventCreator::get()->sendUpdated(theFeature, EVENT_DISP); theFeature->data()->execState(theState); + myUpdated[theFeature] = myModification; // feature is also updated to avoid re-updation of it } /// Updates the state by the referenced object: if something bad with it, set state for this one @@ -459,6 +460,38 @@ bool Model_Update::isOlder(std::shared_ptr theFeature, std::map, int >::iterator anAIter = myUpdated.find(theArgument); if (anAIter == myUpdated.end()) return false; + // 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(); + for (; aRIter != aResults.cend(); aRIter++) { + std::shared_ptr aRes = *aRIter; + if (!aRes->isDisabled()) { + std::map, int >::iterator anRIter = myUpdated.find(aRes); + if (anRIter == myUpdated.end()) // not updated at all + 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, + // but must be updated anyway (like Coincidence of sketch) to be redisplayed std::map, int >::iterator aFIter = myUpdated.find(theFeature); if (aFIter == myUpdated.end()) return true; // argument is updated, but feature is not updated at all -- 2.39.2