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 = boost::dynamic_pointer_cast<Model_Data>(theObject->data());
16 myRef->Append(aData->label().Father()); // store label of the object
18 owner()->data()->sendAttributeUpdated(this);
21 void Model_AttributeRefList::remove(ObjectPtr theObject)
23 boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(theObject->data());
24 myRef->Remove(aData->label().Father());
26 owner()->data()->sendAttributeUpdated(this);
29 int Model_AttributeRefList::size()
31 return myRef->Extent();
34 list<ObjectPtr> Model_AttributeRefList::list()
36 std::list<ObjectPtr> aResult;
37 boost::shared_ptr<Model_Document> aDoc = boost::dynamic_pointer_cast<Model_Document>(
40 const TDF_LabelList& aList = myRef->List();
41 for (TDF_ListIteratorOfLabelList aLIter(aList); aLIter.More(); aLIter.Next()) {
42 ObjectPtr anObj = aDoc->object(aLIter.Value());
43 aResult.push_back(anObj);
49 Model_AttributeRefList::Model_AttributeRefList(TDF_Label& theLabel)
51 myIsInitialized = theLabel.FindAttribute(TDataStd_ReferenceList::GetID(), myRef) == Standard_True;
52 if (!myIsInitialized) {
53 myRef = TDataStd_ReferenceList::Set(theLabel);