X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_AttributeRefList.cpp;h=9287cf0415079707b7ecfb17c91b01c51742deb4;hb=965adcb3288bda478cdd045d4b2f90c92980d099;hp=0a6eee7c45cb9b66de20009239fc98ccb6eba55a;hpb=8b714c0bc3795b0a18977d2fdefbe741a8ef10c0;p=modules%2Fshaper.git diff --git a/src/Model/Model_AttributeRefList.cpp b/src/Model/Model_AttributeRefList.cpp index 0a6eee7c4..9287cf041 100644 --- a/src/Model/Model_AttributeRefList.cpp +++ b/src/Model/Model_AttributeRefList.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // File: ModelAPI_AttributeRefList.cxx // Created: 8 May 2014 // Author: Mikhail PONIKAROV @@ -12,41 +14,55 @@ using namespace std; void Model_AttributeRefList::append(ObjectPtr theObject) { - boost::shared_ptr aData = - boost::dynamic_pointer_cast(theObject->data()); - myRef->Append(aData->label()); + std::shared_ptr aData = std::dynamic_pointer_cast(theObject->data()); + myRef->Append(aData->label().Father()); // store label of the object owner()->data()->sendAttributeUpdated(this); } void Model_AttributeRefList::remove(ObjectPtr theObject) { - boost::shared_ptr aData = - boost::dynamic_pointer_cast(theObject->data()); - myRef->Remove(aData->label()); + std::shared_ptr aData = std::dynamic_pointer_cast(theObject->data()); + myRef->Remove(aData->label().Father()); owner()->data()->sendAttributeUpdated(this); } -int Model_AttributeRefList::size() +int Model_AttributeRefList::size() const { return myRef->Extent(); } list Model_AttributeRefList::list() { - std::list< ObjectPtr > aResult; - boost::shared_ptr aDoc = - boost::dynamic_pointer_cast(owner()->document()); + std::list aResult; + std::shared_ptr aDoc = std::dynamic_pointer_cast( + owner()->document()); if (aDoc) { const TDF_LabelList& aList = myRef->List(); - for(TDF_ListIteratorOfLabelList aLIter(aList); aLIter.More(); aLIter.Next()) { - aResult.push_back(aDoc->object(aLIter.Value())); + for (TDF_ListIteratorOfLabelList aLIter(aList); aLIter.More(); aLIter.Next()) { + ObjectPtr anObj = aDoc->object(aLIter.Value()); + aResult.push_back(anObj); } } return aResult; } +ObjectPtr Model_AttributeRefList::object(const int theIndex) const +{ + std::shared_ptr aDoc = std::dynamic_pointer_cast( + owner()->document()); + if (aDoc) { + const TDF_LabelList& aList = myRef->List(); + int anIndex = 0; + for (TDF_ListIteratorOfLabelList aLIter(aList); aLIter.More(); aLIter.Next(), anIndex++) { + if (anIndex == theIndex) + return aDoc->object(aLIter.Value()); + } + } + return ObjectPtr(); +} + Model_AttributeRefList::Model_AttributeRefList(TDF_Label& theLabel) { myIsInitialized = theLabel.FindAttribute(TDataStd_ReferenceList::GetID(), myRef) == Standard_True;