Salome HOME
Composite Feature implementation. Sketch now is Composite.
[modules/shaper.git] / src / Model / Model_AttributeRefList.cpp
index 3d3af3467a634402939bdce3243832fce39e4701..014592f0d3eebd58a02679f862777e510745c69c 100644 (file)
@@ -26,7 +26,7 @@ void Model_AttributeRefList::remove(ObjectPtr theObject)
   owner()->data()->sendAttributeUpdated(this);
 }
 
-int Model_AttributeRefList::size()
+int Model_AttributeRefList::size() const
 {
   return myRef->Extent();
 }
@@ -46,6 +46,21 @@ list<ObjectPtr> Model_AttributeRefList::list()
   return aResult;
 }
 
+ObjectPtr Model_AttributeRefList::object(const int theIndex) const
+{
+  boost::shared_ptr<Model_Document> aDoc = boost::dynamic_pointer_cast<Model_Document>(
+      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;