X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_Update.cpp;h=91751aa772becc664787e5ce6007dfe6f0c17507;hb=7ba8e2b57ff8965ae644b538c167b7b301e6e41b;hp=ca900b86bb4cceac6174e139f23a44a866a314d6;hpb=eb46781716082e5c57561426894fe4c0c989224e;p=modules%2Fshaper.git diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index ca900b86b..91751aa77 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // File: Model_Update.cxx // Created: 25 Jun 2014 // Author: Mikhail PONIKAROV @@ -80,6 +82,8 @@ void Model_Update::processEvent(const std::shared_ptr& theMessag std::set::const_iterator anObjIter = anObjs.cbegin(); for(; anObjIter != anObjs.cend(); anObjIter++) { myJustCreatedOrUpdated.insert(*anObjIter); + // TODO(mpv): check the next line. Came into dev 0.6.1 from BR_PYTHON_PLUGIN + // (*anObjIter)->data()->mustBeUpdated(true); // object must be updated because it was changed } if (theMessage->eventID() == kMovedEvent) return; // this event is for solver update, not here @@ -115,37 +119,15 @@ void Model_Update::processEvent(const std::shared_ptr& theMessag //Events_LongOp::start(this); isExecuted = true; - std::list > aDocs; std::shared_ptr aMsg = std::dynamic_pointer_cast(theMessage); if (aMsg) myInitial = aMsg->objects(); else { myInitial.clear(); - // on change flag all documents must be updated - if (isAutomatic) { - aDocs = ModelAPI_Session::get()->allOpenedDocuments(); - } - } - // collect all documents involved into the update process - set >::iterator aFIter = myInitial.begin(); - for (; aFIter != myInitial.end(); aFIter++) { - aDocs.push_back((*aFIter)->document()); - } - // iterate all features of features-documents to update them (including hidden) - std::set > alreadyUsed; - list >::iterator aDIter = aDocs.begin(); - for (; aDIter != aDocs.end(); aDIter++) { - if (alreadyUsed.find(*aDIter) != alreadyUsed.end()) - continue; - alreadyUsed.insert(*aDIter); - int aNbFeatures = (*aDIter)->size(ModelAPI_Feature::group(), true); - for (int aFIndex = 0; aFIndex < aNbFeatures; aFIndex++) { - FeaturePtr aFeature = std::dynamic_pointer_cast( - (*aDIter)->object(ModelAPI_Feature::group(), aFIndex, true)); - if (aFeature) - updateFeature(aFeature); - } } + // iterate all documents: features in Root first, then - subs + updateInDoc(ModelAPI_Session::get()->moduleDocument()); + myUpdated.clear(); // flush to update display static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY); @@ -160,9 +142,32 @@ void Model_Update::processEvent(const std::shared_ptr& theMessag isExecuted = false; } +void Model_Update::updateInDoc(std::shared_ptr theDoc) +{ + // all features one by one + int aNbFeatures = theDoc->size(ModelAPI_Feature::group(), true); + for (int aFIndex = 0; aFIndex < aNbFeatures; aFIndex++) { + FeaturePtr aFeature = std::dynamic_pointer_cast( + theDoc->object(ModelAPI_Feature::group(), aFIndex, true)); + if (aFeature) + updateFeature(aFeature); + } + // all sub-documents one by one + std::shared_ptr aDoc = std::dynamic_pointer_cast(theDoc); + if (aDoc) { + const std::set& aSubs = aDoc->subDocuments(); + for(std::set::iterator aSub = aSubs.begin(); aSub != aSubs.end(); aSub++) { + DocumentPtr aSubDoc = theDoc->subDocument(*aSub); + if (aSubDoc) { + updateInDoc(aSubDoc); + } + } + } +} + void Model_Update::redisplayWithResults(FeaturePtr theFeature, const ModelAPI_ExecState theState) { - // maske updated and redisplay all results + // 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(); @@ -326,7 +331,9 @@ bool Model_Update::updateFeature(FeaturePtr theFeature) } else { // for automatically updated features (on abort, etc) it is necessary to redisplay anyway redisplayWithResults(theFeature, ModelAPI_StateNothing); } - } else { // returns also true is results were updated: for sketch that refers to sub-features but results of sub-features were changed + } else { + // returns also true is results were updated: for sketch that + // refers to sub-features but results of sub-features were changed const std::list >& aResults = theFeature->results(); std::list >::const_iterator aRIter = aResults.begin(); for (; aRIter != aResults.cend(); aRIter++) {