From f2ced587983e4e9e82c0d16dff6447fb01a5beab Mon Sep 17 00:00:00 2001 From: mpv Date: Wed, 15 Jun 2016 21:02:46 +0300 Subject: [PATCH] Fix for the issue #1556 : Part rebuilding issue --- src/Model/Model_AttributeSelection.cpp | 21 +++++++++++++------- src/Model/Model_Update.cpp | 4 ++-- src/SketchPlugin/SketchPlugin_SketchEntity.h | 2 +- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index 7f90352af..c672ed47e 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -438,18 +438,20 @@ bool Model_AttributeSelection::update() if (aSelLab.IsAttribute(kPART_REF_ID)) { // it is reference to the part object std::shared_ptr aNoSelection; bool aResult = selectPart(aContext, aNoSelection, true); + aResult = setInvalidIfFalse(aSelLab, aResult); if (aResult) { owner()->data()->sendAttributeUpdated(this); } - return setInvalidIfFalse(aSelLab, aResult); + return aResult; } if (aContext->groupName() == ModelAPI_ResultBody::group()) { // body: just a named shape, use selection mechanism from OCCT TNaming_Selector aSelector(aSelLab); bool aResult = aSelector.Solve(scope()) == Standard_True; + aResult = setInvalidIfFalse(aSelLab, aResult); // must be before sending of updated attribute (1556) owner()->data()->sendAttributeUpdated(this); - return setInvalidIfFalse(aSelLab, aResult); + return aResult; } else if (aContext->groupName() == ModelAPI_ResultConstruction::group()) { // construction: identification by the results indexes, recompute faces and // take the face that more close by the indexes @@ -565,8 +567,9 @@ bool Model_AttributeSelection::update() } } selectConstruction(aContext, aNewSelected); + setInvalidIfFalse(aSelLab, true); owner()->data()->sendAttributeUpdated(this); - return setInvalidIfFalse(aSelLab, true); + return true; } else { // if the selection is not found, put the empty shape: it's better to have disappeared shape, than the old, the lost one TNaming_Builder anEmptyBuilder(selectionLabel()); return setInvalidIfFalse(aSelLab, false); @@ -586,8 +589,9 @@ bool Model_AttributeSelection::update() std::dynamic_pointer_cast(*aResIter); if (aRes && aRes->shape() && aRes->shape()->isEdge()) { // found! selectConstruction(aContext, aRes->shape()); + setInvalidIfFalse(aSelLab, true); owner()->data()->sendAttributeUpdated(this); - return setInvalidIfFalse(aSelLab, true); + return true; } } } @@ -615,8 +619,9 @@ bool Model_AttributeSelection::update() if (aRes && aRes->shape()) { if (aRes->shape()->isVertex() && aVertexNum == 0) { // found! selectConstruction(aContext, aRes->shape()); + setInvalidIfFalse(aSelLab, true); owner()->data()->sendAttributeUpdated(this); - return setInvalidIfFalse(aSelLab, true); + return true; } else if (aRes->shape()->isEdge() && aVertexNum > 0) { const TopoDS_Shape& anEdge = aRes->shape()->impl(); int aVIndex = 1; @@ -625,8 +630,9 @@ bool Model_AttributeSelection::update() std::shared_ptr aVertex(new GeomAPI_Shape); aVertex->setImpl(new TopoDS_Shape(aVExp.Current())); selectConstruction(aContext, aVertex); + setInvalidIfFalse(aSelLab, true); owner()->data()->sendAttributeUpdated(this); - return setInvalidIfFalse(aSelLab, true); + return true; } aVIndex++; } @@ -638,8 +644,9 @@ bool Model_AttributeSelection::update() } } else { // simple construction element: the selected is that needed selectConstruction(aContext, aContext->shape()); + setInvalidIfFalse(aSelLab, true); owner()->data()->sendAttributeUpdated(this); - return setInvalidIfFalse(aSelLab, true); + return true; } } return setInvalidIfFalse(aSelLab, false); // unknown case diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index 9784ceec3..98d68fe1d 100755 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -442,7 +442,7 @@ bool Model_Update::processFeature(FeaturePtr theFeature) bool isReferencedInvalid = false; // check all features this feature depended on (recursive call of updateFeature) std::set& aReasons = myModified[theFeature]; - bool allSubsUsed = aReasons.find(theFeature) == aReasons.end(); + bool allSubsUsed = aReasons.find(theFeature) != aReasons.end(); if (allSubsUsed) { // add all subs in aReasons and temporary remove "theFeature" to avoid processing itself allReasons(theFeature, aReasons); aReasons.erase(theFeature); @@ -452,7 +452,7 @@ bool Model_Update::processFeature(FeaturePtr theFeature) while(!aReasons.empty()) { FeaturePtr aReason = *(aReasons.begin()); #ifdef DEB_UPDATE - cout<name()<<" process next reason "<name()<name()<<" process next reason "<name()<data()->isValid()) { if (processFeature(aReason)) diff --git a/src/SketchPlugin/SketchPlugin_SketchEntity.h b/src/SketchPlugin/SketchPlugin_SketchEntity.h index 8662602b6..f0fb44020 100644 --- a/src/SketchPlugin/SketchPlugin_SketchEntity.h +++ b/src/SketchPlugin/SketchPlugin_SketchEntity.h @@ -86,7 +86,7 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC { AttributeSelectionPtr aAttr = data()->selection(EXTERNAL_ID()); if (aAttr) - return aAttr->context().get() != NULL; + return aAttr->context().get() != NULL && !aAttr->isInvalid(); return false; } -- 2.39.2