From: azv Date: Wed, 23 Dec 2015 10:28:00 +0000 (+0300) Subject: Fix regression found in squish test for Platine X-Git-Tag: V_2.1.0~98 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c850e432aa527cd9249ba90f41cf6d31838b802e;p=modules%2Fshaper.git Fix regression found in squish test for Platine --- diff --git a/src/SketchSolver/SketchSolver_Group.cpp b/src/SketchSolver/SketchSolver_Group.cpp index d62f995e1..b019c7ed3 100644 --- a/src/SketchSolver/SketchSolver_Group.cpp +++ b/src/SketchSolver/SketchSolver_Group.cpp @@ -212,11 +212,19 @@ bool SketchSolver_Group::updateFeature(FeaturePtr theFeature) if (!checkFeatureValidity(theFeature)) return false; - myStorage->blockEvents(true); + bool isBlocked = myStorage->isEventsBlocked(); + if (!isBlocked) + myStorage->blockEvents(true); + myStorage->refresh(true); bool isUpdated = myStorage->update(theFeature); updateMultiConstraints(myConstraints, theFeature); + + // events were not blocked before, the feature has not been updated, + // so it is necessary to revert blocking + if (!isUpdated && !isBlocked) + myStorage->blockEvents(false); return isUpdated; } diff --git a/src/SketchSolver/SketchSolver_Storage.cpp b/src/SketchSolver/SketchSolver_Storage.cpp index acefc6396..798935ecf 100644 --- a/src/SketchSolver/SketchSolver_Storage.cpp +++ b/src/SketchSolver/SketchSolver_Storage.cpp @@ -71,7 +71,9 @@ void SketchSolver_Storage::addConstraint( for (; aCIt != theSolverConstraints.end(); ++aCIt) update(*aCIt); } - myConstraintMap[theConstraint] = theSolverConstraints; + + if (!theSolverConstraints.empty() || aFound == myConstraintMap.end()) + myConstraintMap[theConstraint] = theSolverConstraints; // block events if necessary if (myEventsBlocked && theConstraint->data() && theConstraint->data()->isValid()) theConstraint->data()->blockSendAttributeUpdated(myEventsBlocked); @@ -91,7 +93,7 @@ void SketchSolver_Storage::addEntity(FeaturePtr theFeature, theFeature->data()->attributes(GeomDataAPI_Point2D::typeId()); std::list::const_iterator anAttrIt = aPntAttrs.begin(); for (; anAttrIt != aPntAttrs.end(); ++anAttrIt) - addEntity(*anAttrIt, EntityWrapperPtr()); + addEntity(*anAttrIt, EntityWrapperPtr()); if (aFound == myFeatureMap.end()) myFeatureMap[theFeature] = theSolverEntity; } else diff --git a/src/SketchSolver/SketchSolver_Storage.h b/src/SketchSolver/SketchSolver_Storage.h index c5346906e..a35a7366b 100644 --- a/src/SketchSolver/SketchSolver_Storage.h +++ b/src/SketchSolver/SketchSolver_Storage.h @@ -150,6 +150,9 @@ public: /// \brief Block or unblock events when refreshing features SKETCHSOLVER_EXPORT void blockEvents(bool isBlocked); + /// \brief Shows the events are blocked for the features in the storage + bool isEventsBlocked() const + { return myEventsBlocked; } protected: /// \brief Change mapping feature from SketchPlugin and diff --git a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp index 169302581..5398c8870 100644 --- a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp +++ b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp @@ -1649,13 +1649,25 @@ void SolveSpaceSolver_Storage::refresh(bool theFixedOnly) const if (!isUpd[1]) aCoords[1] = aPoint2D->y(); aPoint2D->setValue(aCoords[0], aCoords[1]); // Find points coincident with this one (probably not in GID_OUTOFGROUP) - std::map::const_iterator aLocIt = - theFixedOnly ? myAttributeMap.begin() : anIt; - for (++aLocIt; aLocIt != myAttributeMap.end(); ++aLocIt) + std::map::const_iterator aLocIt; + if (theFixedOnly) + aLocIt = myAttributeMap.begin(); + else { + aLocIt = anIt; + ++aLocIt; + } + for (; aLocIt != myAttributeMap.end(); ++aLocIt) { + if (!aLocIt->second) + continue; + std::shared_ptr aSketchFeature = + std::dynamic_pointer_cast(aLocIt->first->owner()); + if (aSketchFeature && aSketchFeature->isExternal()) + continue; if (anIt->second->id() == aLocIt->second->id()) { aPoint2D = std::dynamic_pointer_cast(aLocIt->first); aPoint2D->setValue(aCoords[0], aCoords[1]); } + } } continue; }