1 // File: ModelAPI_AttributeRefList.cxx
3 // Author: Mikhail PONIKAROV
5 #include "Model_AttributeRefList.h"
6 #include "Model_Application.h"
7 #include "Model_Data.h"
8 #include <ModelAPI_Feature.h>
9 #include <TDF_ListIteratorOfLabelList.hxx>
13 void Model_AttributeRefList::append(ObjectPtr theObject)
15 boost::shared_ptr<Model_Data> aData =
16 boost::dynamic_pointer_cast<Model_Data>(theObject->data());
17 myRef->Append(aData->label().Father()); // store label of the object
19 owner()->data()->sendAttributeUpdated(this);
22 void Model_AttributeRefList::remove(ObjectPtr theObject)
24 boost::shared_ptr<Model_Data> aData =
25 boost::dynamic_pointer_cast<Model_Data>(theObject->data());
26 myRef->Remove(aData->label().Father());
28 owner()->data()->sendAttributeUpdated(this);
31 int Model_AttributeRefList::size()
33 return myRef->Extent();
36 list<ObjectPtr> Model_AttributeRefList::list()
38 std::list< ObjectPtr > aResult;
39 boost::shared_ptr<Model_Document> aDoc =
40 boost::dynamic_pointer_cast<Model_Document>(owner()->document());
42 const TDF_LabelList& aList = myRef->List();
43 for(TDF_ListIteratorOfLabelList aLIter(aList); aLIter.More(); aLIter.Next()) {
44 ObjectPtr anObj = aDoc->object(aLIter.Value());
45 aResult.push_back(anObj);
51 Model_AttributeRefList::Model_AttributeRefList(TDF_Label& theLabel)
53 myIsInitialized = theLabel.FindAttribute(TDataStd_ReferenceList::GetID(), myRef) == Standard_True;
54 if (!myIsInitialized) {
55 myRef = TDataStd_ReferenceList::Set(theLabel);