From: azv Date: Fri, 28 Feb 2020 13:34:56 +0000 (+0300) Subject: Issue #3172: Valid partition is invalid after save/open saved document X-Git-Tag: V9_5_0a2~72 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8680157f17f82bdd61805950a9ca42d0cfebb087;p=modules%2Fshaper.git Issue #3172: Valid partition is invalid after save/open saved document * Improve AttributeSelectionList to cash whole selected features as well as the results. * Avoid sending EVENT_UPDATE_SELECTION until all the features will obtain their "disabled" flag. --- diff --git a/src/GeomAPI/GeomAPI_Shape.cpp b/src/GeomAPI/GeomAPI_Shape.cpp index 78a10ac3c..6d5649a75 100644 --- a/src/GeomAPI/GeomAPI_Shape.cpp +++ b/src/GeomAPI/GeomAPI_Shape.cpp @@ -93,11 +93,10 @@ bool GeomAPI_Shape::isEqual(const std::shared_ptr theShape) const bool GeomAPI_Shape::isSame(const std::shared_ptr theShape) const { - if (!theShape.get()) - return false; + bool isNullShape = !theShape.get() || theShape->isNull();; if (isNull()) - return theShape->isNull(); - if (theShape->isNull()) + return isNullShape; + if (isNullShape) return false; return MY_SHAPE->IsSame(theShape->impl()) == Standard_True; diff --git a/src/Model/Model_AttributeSelectionList.cpp b/src/Model/Model_AttributeSelectionList.cpp index 9e7b0b6ff..77fb51853 100644 --- a/src/Model/Model_AttributeSelectionList.cpp +++ b/src/Model/Model_AttributeSelectionList.cpp @@ -65,9 +65,7 @@ void Model_AttributeSelectionList::append( } if (myIsCashed && !theTemporarily) { - ResultPtr aResContext = std::dynamic_pointer_cast(theContext); - if (aResContext.get()) - myCash[aResContext].push_back(theSubShape); + myCash[theContext].push_back(theSubShape); } int aNewTag = mySize->Get() + 1; @@ -315,7 +313,8 @@ bool Model_AttributeSelectionList::isInList(const ObjectPtr& theContext, if (!aShapes->get()) return true; ResultPtr aRes = std::dynamic_pointer_cast(aContext->first); - if (aRes.get() && (*aShapes)->isSame(aRes->shape())) + FeaturePtr aFeat = std::dynamic_pointer_cast(aContext->first); + if ((aRes.get() && (*aShapes)->isSame(aRes->shape())) || aFeat.get()) return true; } else { // we need to call here isSame instead of isEqual to do not check shapes orientation @@ -442,7 +441,7 @@ void Model_AttributeSelectionList::cashValues(const bool theEnabled) for(int anIndex = size() - 1; anIndex >= 0; anIndex--) { AttributeSelectionPtr anAttr = value(anIndex); if (anAttr.get()) { - myCash[anAttr->context()].push_back(anAttr->value()); + myCash[anAttr->contextObject()].push_back(anAttr->value()); } } } diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 1efd395af..cff3d1840 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -1505,6 +1505,9 @@ void Model_Document::setCurrentFeature( myIsSetCurrentFeature = false; // unblock the flush signals and up them after this aLoop->activateFlushes(isActive); + + static Events_ID kUpdatedSel = aLoop->eventByName(EVENT_UPDATE_SELECTION); + aLoop->flush(kUpdatedSel); } void Model_Document::setCurrentFeatureUp() diff --git a/src/ModelAPI/ModelAPI_Feature.cpp b/src/ModelAPI/ModelAPI_Feature.cpp index 6eacd8876..14ce7f46c 100644 --- a/src/ModelAPI/ModelAPI_Feature.cpp +++ b/src/ModelAPI/ModelAPI_Feature.cpp @@ -208,11 +208,13 @@ bool ModelAPI_Feature::setDisabled(const bool theFlag) (*aResIter)->setDisabled(*aResIter, false); } // update selection for the case something was updated higher in the history - // while this feature was disabled + // while this feature was disabled, but avoid flushing it immediately and + // wait while all the previous features update myIsDisabled flag + // (flush will be called by the document) static Events_Loop* aLoop = Events_Loop::loop(); static Events_ID kUpdatedSel = aLoop->eventByName(EVENT_UPDATE_SELECTION); static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get(); - aECreator->sendUpdated(data()->owner(), kUpdatedSel, false); + aECreator->sendUpdated(data()->owner(), kUpdatedSel, true); } return true; } diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index bae232f48..0132131b9 100644 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -627,8 +627,7 @@ bool hasObject(const AttributePtr& theAttribute, const ObjectPtr& theObject, if (aType == ModelAPI_AttributeSelectionList::typeId()) { AttributeSelectionListPtr aSelectionListAttr = std::dynamic_pointer_cast(theAttribute); - ResultPtr aResult = std::dynamic_pointer_cast(theObject); - aHasObject = aSelectionListAttr->isInList(aResult, theShape, theTemporarily); + aHasObject = aSelectionListAttr->isInList(theObject, theShape, theTemporarily); } else if (aType == ModelAPI_AttributeRefList::typeId()) { AttributeRefListPtr aRefListAttr = diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index fae068235..bab6ca002 100644 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -937,13 +937,15 @@ bool ModuleBase_WidgetMultiSelector::removeUnusedAttributeObjects AttributeSelectionListPtr aSelectionListAttr = aData->selectionList(attributeID()); for (int i = 0; i < aSelectionListAttr->size(); i++) { AttributeSelectionPtr anAttr = aSelectionListAttr->value(i); - //aFeature = std::dynamic_pointer_cast(anAttr->contextObject()); - //if (!aFeature.get()) { // Feature can not be found as geometry selection - bool aFound = findInSelection( - anAttr->contextObject(), anAttr->value(), aGeomSelection, myWorkshop); - if (!aFound) - anIndicesToBeRemoved.insert(i); -// } + ObjectPtr aContextObject = anAttr->contextObject(); + GeomShapePtr aShape; + aFeature = std::dynamic_pointer_cast(aContextObject); + if (!aFeature.get()) + aShape = anAttr->value(); + + bool aFound = findInSelection(aContextObject, aShape, aGeomSelection, myWorkshop); + if (!aFound) + anIndicesToBeRemoved.insert(i); } isDone = anIndicesToBeRemoved.size() > 0; if (isDone)