X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_AttributeRefList.cpp;h=b7719ca78f5011e5b4b32980831b452729c773f8;hb=1b9dd3633d644c358424227423b330e9551be38f;hp=c9722835887b00258b8e1acbac9797dac0dd06c1;hpb=241b57ba3887bc2d239df98405c4fc4d6979119b;p=modules%2Fshaper.git diff --git a/src/Model/Model_AttributeRefList.cpp b/src/Model/Model_AttributeRefList.cpp index c97228358..b7719ca78 100644 --- a/src/Model/Model_AttributeRefList.cpp +++ b/src/Model/Model_AttributeRefList.cpp @@ -7,6 +7,7 @@ #include "Model_AttributeRefList.h" #include "Model_Application.h" #include "Model_Data.h" +#include "Model_Objects.h" #include #include @@ -18,10 +19,7 @@ void Model_AttributeRefList::append(ObjectPtr theObject) myRef->Append(aData->label().Father()); // store label of the object // do it before the transaction finish to make just created/removed objects know dependencies // and reference from composite feature is removed automatically - FeaturePtr anOwnerFeature = std::dynamic_pointer_cast(owner()); - if (anOwnerFeature.get()) { - aData->addBackReference(anOwnerFeature, id()); - } + ADD_BACK_REF(theObject); owner()->data()->sendAttributeUpdated(this); } @@ -32,6 +30,7 @@ void Model_AttributeRefList::remove(ObjectPtr theObject) if (theObject.get() != NULL) { aData = std::dynamic_pointer_cast(theObject->data()); myRef->Remove(aData->label().Father()); + REMOVE_BACK_REF(theObject); } else { // in case of empty object remove, the first empty object is removed from the list std::shared_ptr aDoc = std::dynamic_pointer_cast( @@ -39,9 +38,10 @@ void Model_AttributeRefList::remove(ObjectPtr theObject) if (aDoc) { const TDF_LabelList& aList = myRef->List(); for (TDF_ListIteratorOfLabelList aLIter(aList); aLIter.More(); aLIter.Next()) { - ObjectPtr anObj = aDoc->object(aLIter.Value()); + ObjectPtr anObj = aDoc->objects()->object(aLIter.Value()); if (anObj.get() == NULL) { myRef->Remove(aLIter.Value()); + REMOVE_BACK_REF(theObject); break; } } @@ -50,11 +50,29 @@ void Model_AttributeRefList::remove(ObjectPtr theObject) owner()->data()->sendAttributeUpdated(this); } +void Model_AttributeRefList::clear() +{ + std::list anOldList = list(); + myRef->Clear(); + std::list::iterator anOldIter = anOldList.begin(); + for(; anOldIter != anOldList.end(); anOldIter++) { + REMOVE_BACK_REF((*anOldIter)); + } +} + int Model_AttributeRefList::size() const { return myRef->Extent(); } +bool Model_AttributeRefList::isInitialized() +{ + if (size() == 0) { // empty list is not initialized list: sketch will be not valid after add/undo + return false; + } + return ModelAPI_AttributeRefList::isInitialized(); +} + list Model_AttributeRefList::list() { std::list aResult; @@ -63,7 +81,7 @@ list Model_AttributeRefList::list() if (aDoc) { const TDF_LabelList& aList = myRef->List(); for (TDF_ListIteratorOfLabelList aLIter(aList); aLIter.More(); aLIter.Next()) { - ObjectPtr anObj = aDoc->object(aLIter.Value()); + ObjectPtr anObj = aDoc->objects()->object(aLIter.Value()); aResult.push_back(anObj); } } @@ -79,7 +97,7 @@ ObjectPtr Model_AttributeRefList::object(const int theIndex) const int anIndex = 0; for (TDF_ListIteratorOfLabelList aLIter(aList); aLIter.More(); aLIter.Next(), anIndex++) { if (anIndex == theIndex) - return aDoc->object(aLIter.Value()); + return aDoc->objects()->object(aLIter.Value()); } } return ObjectPtr();