From 00927decbb32eb1ead6bad6a0fc956764db592c4 Mon Sep 17 00:00:00 2001 From: azv Date: Mon, 3 Apr 2017 08:26:55 +0300 Subject: [PATCH] Issue #2077: mirror constraint is destroyed Notify listeners about feature update only if at least one attribute is changed --- .../PlaneGCSSolver/PlaneGCSSolver_Storage.cpp | 7 ++++++- .../SketchSolver_ConstraintMirror.cpp | 20 +++++++++---------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp index 547eaef01..96235587d 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp @@ -151,10 +151,11 @@ static bool isCopyInMulti(std::shared_ptr theFeature) bool PlaneGCSSolver_Storage::update(FeaturePtr theFeature, bool theForce) { + bool sendNotify = false; bool isUpdated = false; EntityWrapperPtr aRelated = entity(theFeature); if (aRelated) // send signal to subscribers - notify(theFeature); + sendNotify = true; else { // Feature is not exist, create it std::shared_ptr aSketchFeature = std::dynamic_pointer_cast(theFeature); @@ -193,6 +194,10 @@ bool PlaneGCSSolver_Storage::update(FeaturePtr theFeature, bool theForce) (*anAttrIt)->attributeType() == ModelAPI_AttributeDouble::typeId()) isUpdated = update(*anAttrIt) || isUpdated; + // send notification to listeners due to at least one attribute is changed + if (sendNotify && isUpdated) + notify(theFeature); + // update arc if (aRelated && aRelated->type() == ENTITY_ARC) { /// TODO: this code should be shared with FeatureBuilder somehow diff --git a/src/SketchSolver/SketchSolver_ConstraintMirror.cpp b/src/SketchSolver/SketchSolver_ConstraintMirror.cpp index 80cb647d8..89bc973b2 100644 --- a/src/SketchSolver/SketchSolver_ConstraintMirror.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintMirror.cpp @@ -62,6 +62,13 @@ void SketchSolver_ConstraintMirror::getAttributes( myFeatures.insert(aFeature); } } + // add mirrored features to the list + aList = aMirroredRefList->list(); + for (anIt = aList.begin(); anIt != aList.end(); ++anIt) { + FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt); + if (aFeature) + myFeatures.insert(aFeature); + } } void SketchSolver_ConstraintMirror::process() @@ -86,7 +93,8 @@ void SketchSolver_ConstraintMirror::process() void SketchSolver_ConstraintMirror::update() { cleanErrorMsg(); - adjustConstraint(); + remove(); + process(); } void SketchSolver_ConstraintMirror::adjustConstraint() @@ -131,16 +139,6 @@ void SketchSolver_ConstraintMirror::blockEvents(bool isBlocked) for (; anIt != myFeatures.end(); ++anIt) (*anIt)->data()->blockSendAttributeUpdated(isBlocked); - AttributeRefListPtr aMirroredRefList = - myBaseConstraint->reflist(SketchPlugin_Constraint::ENTITY_C()); - std::list aMirroredList = aMirroredRefList->list(); - std::list::iterator aMIt = aMirroredList.begin(); - for (; aMIt != aMirroredList.end(); ++aMIt) { - FeaturePtr aMirrored = ModelAPI_Feature::feature(*aMIt); - aMirrored->data()->blockSendAttributeUpdated(isBlocked); - } - - SketchSolver_Constraint::blockEvents(isBlocked); } -- 2.39.2