X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_AttributeRefList.cpp;h=a1e0aeb666779046950ce637308c46a517661ec3;hb=061a63480f6840b6d945f7744b3b972e2d4cb25d;hp=ee9b20d749bdc785f6c7919eff937de7aa9310e0;hpb=dc90df3ac278c727aca81131746a9806e4f27499;p=modules%2Fshaper.git diff --git a/src/Model/Model_AttributeRefList.cpp b/src/Model/Model_AttributeRefList.cpp index ee9b20d74..a1e0aeb66 100644 --- a/src/Model/Model_AttributeRefList.cpp +++ b/src/Model/Model_AttributeRefList.cpp @@ -100,6 +100,9 @@ list Model_AttributeRefList::list() bool Model_AttributeRefList::isInList(const ObjectPtr& theObj) { + if(!theObj.get()) { + return false; + } std::list aResult; std::shared_ptr aDoc = std::dynamic_pointer_cast( owner()->document()); @@ -209,6 +212,32 @@ void Model_AttributeRefList::removeLast() } } +void Model_AttributeRefList::remove(const std::set& theIndices) +{ + std::shared_ptr aDoc = std::dynamic_pointer_cast( + owner()->document()); + if (aDoc && !myRef->IsEmpty()) { + // collet labels that will be removed + TDF_LabelList aLabelsToRemove; + TDF_ListIteratorOfLabelList aLabIter(myRef->List()); + for(int aCurrent = 0; aLabIter.More(); aLabIter.Next(), aCurrent++) { + if (theIndices.find(aCurrent) != theIndices.end()) + aLabelsToRemove.Append(aLabIter.Value()); + } + // remove labels + for(aLabIter.Initialize(aLabelsToRemove); aLabIter.More(); aLabIter.Next()) { + ObjectPtr anObj = aDoc->objects()->object(aLabIter.Value()); + if (anObj.get()) { + myRef->Remove(aLabIter.Value()); + REMOVE_BACK_REF(anObj); + } + } + if (!aLabelsToRemove.IsEmpty()) { + owner()->data()->sendAttributeUpdated(this); + } + } +} + Model_AttributeRefList::Model_AttributeRefList(TDF_Label& theLabel) { myIsInitialized = theLabel.FindAttribute(TDataStd_ReferenceList::GetID(), myRef) == Standard_True;