From: mpv Date: Wed, 15 Jul 2015 11:58:21 +0000 (+0300) Subject: Fix for the issue #743 X-Git-Tag: V_1.3.0~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5a6a8781dcd0886446f5ef607fd2fc7d5f2aa1d4;p=modules%2Fshaper.git Fix for the issue #743 --- diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index 561882b7c..617436218 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -33,7 +33,7 @@ using namespace std; Model_Update MY_UPDATER_INSTANCE; /// the only one instance initialized on load of the library -//#define DEB_UPDATE +#define DEB_UPDATE Model_Update::Model_Update() { @@ -101,6 +101,27 @@ void Model_Update::processEvent(const std::shared_ptr& theMessag // created objects are always must be up to date (python box feature) // and updated not in internal uptation chain myJustUpdated.insert(*anObjIter); + + // something is updated during the execution: re-execute it (sketch update by parameters) + if (myIsExecuted) { + FeaturePtr anUpdated = std::dynamic_pointer_cast(*anObjIter); + if (anUpdated.get() && anUpdated->data()->isValid() && + myProcessed.find(anUpdated) != myProcessed.end()) { + if (anUpdated->isPreviewNeeded() || myIsFinish) { + ModelAPI_ExecState aState = anUpdated->data()->execState(); + static ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators(); + if (aFactory->validate(anUpdated)) { + #ifdef DEB_UPDATE + std::cout<<"Execute immideately "<name()<eraseResults(); + redisplayWithResults(anUpdated, ModelAPI_StateInvalidArgument); // result also must be updated + } + } + } + } #ifdef DEB_UPDATE if ((*anObjIter)->data() && (*anObjIter)->data()->isValid()) { std::cout<<"Add updated "<<(*anObjIter)->groupName()<<" " @@ -188,15 +209,15 @@ void Model_Update::processOperation(const bool theTotalUpdate, const bool theFin if (!anObjs) return; // two cycles: parameters are first to process FeaturePtr aFeatureIter = anObjs->firstFeature(); - std::set aProcessedFeatures; // to avoid processing twice + myProcessed.clear(); // to avoid processing twice for (; aFeatureIter.get(); aFeatureIter = anObjs->nextFeature(aFeatureIter)) { if (aFeatureIter->getKind() == "Parameter") - updateFeature(aFeatureIter, aProcessedFeatures); + updateFeature(aFeatureIter); } aFeatureIter = anObjs->firstFeature(); for (; aFeatureIter.get(); aFeatureIter = anObjs->nextFeature(aFeatureIter)) { if (aFeatureIter->getKind() != "Parameter") - updateFeature(aFeatureIter, aProcessedFeatures); + updateFeature(aFeatureIter); } if (isAutomaticChanged) myIsAutomatic = false; @@ -212,14 +233,14 @@ void Model_Update::processOperation(const bool theTotalUpdate, const bool theFin } } -void Model_Update::updateFeature(FeaturePtr theFeature, std::set& theProcessed) +void Model_Update::updateFeature(FeaturePtr theFeature) { // check all features this feature depended on (recursive call of updateFeature) static ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators(); - if (theProcessed.find(theFeature) != theProcessed.end()) + if (myProcessed.find(theFeature) != myProcessed.end()) return; - theProcessed.insert(theFeature); + myProcessed.insert(theFeature); if (theFeature->isDisabled()) return; @@ -246,14 +267,17 @@ void Model_Update::updateFeature(FeaturePtr theFeature, std::set& th for(int a = 0; a < aCompos->numberOfSubs(); a++) { FeaturePtr aSub = aCompos->subFeature(a); if (aSub->getKind() == "Parameter") - updateFeature(aSub, theProcessed); + updateFeature(aSub); } // number of subs can be changed in execution: like fillet for(int a = 0; a < aCompos->numberOfSubs(); a++) { FeaturePtr aSub = aCompos->subFeature(a); if (aSub->getKind() != "Parameter") - updateFeature(aSub, theProcessed); + updateFeature(aSub); } + // reupdate arguments of composite feature: it may be changed during subs execution + if (theFeature->data()->execState() != ModelAPI_StateMustBeUpdated) + updateArguments(theFeature); } // this checking must be after the composite feature sub-elements processing: // composite feature status may depend on it's subelements @@ -320,8 +344,11 @@ void Model_Update::redisplayWithResults(FeaturePtr theFeature, const ModelAPI_Ex std::list >::const_iterator aRIter = aResults.begin(); for (; aRIter != aResults.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) + if (!aRes->isDisabled()) {// update state only for enabled results (Placement Result Part may make the original Part Result as invalid) aRes->data()->execState(theState); + if (theState == ModelAPI_StateDone) // feature become "done", so execution changed results + myJustUpdated.insert(aRes); + } if (theFeature->data()->updateID() > aRes->data()->updateID()) { aRes->data()->setUpdateID(theFeature->data()->updateID()); } diff --git a/src/Model/Model_Update.h b/src/Model/Model_Update.h index d8d590497..aed04adae 100644 --- a/src/Model/Model_Update.h +++ b/src/Model/Model_Update.h @@ -35,6 +35,8 @@ class Model_Update : public Events_Listener bool myIsParamUpdated; /// to execute features of finish if perview is not needed bool myIsFinish; + /// Set of already processed features in the "processOperation" method + std::set > myProcessed; public: /// Is called only once, on startup of the application @@ -46,8 +48,7 @@ class Model_Update : public Events_Listener protected: /// Recoursively checks and updates the feature if needed (calls the execute method) /// Returns true if feature was updated. - void updateFeature(std::shared_ptr theFeature, - std::set >& theProcessed); + void updateFeature(std::shared_ptr theFeature); /// Updates the selection and parametrical arguments before the later feature analysis /// Returns true if something really was updated