1 // File: ModelAPI_AttributeRefList.cxx
3 // Author: Mikhail PONIKAROV
5 #include "Model_AttributeRefList.h"
6 #include "Model_Application.h"
7 #include "Model_Events.h"
8 #include "Model_Data.h"
9 #include <ModelAPI_Feature.h>
10 #include <Events_Loop.h>
11 #include <TDF_ListIteratorOfLabelList.hxx>
15 void Model_AttributeRefList::append(boost::shared_ptr<ModelAPI_Feature> theFeature)
17 boost::shared_ptr<Model_Data> aData =
18 boost::dynamic_pointer_cast<Model_Data>(theFeature->data());
19 myRef->Append(aData->label());
21 static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED);
22 Model_FeatureUpdatedMessage aMsg(feature(), anEvent);
23 Events_Loop::loop()->send(aMsg);
26 void Model_AttributeRefList::remove(boost::shared_ptr<ModelAPI_Feature> theFeature)
28 boost::shared_ptr<Model_Data> aData =
29 boost::dynamic_pointer_cast<Model_Data>(theFeature->data());
30 myRef->Remove(aData->label());
34 int Model_AttributeRefList::size()
36 return myRef->Extent();
39 list<boost::shared_ptr<ModelAPI_Feature> > Model_AttributeRefList::list()
41 std::list< boost::shared_ptr<ModelAPI_Feature> > aResult;
42 boost::shared_ptr<Model_Document> aDoc =
43 boost::dynamic_pointer_cast<Model_Document>(feature()->document());
45 const TDF_LabelList& aList = myRef->List();
46 for(TDF_ListIteratorOfLabelList aLIter(aList); aLIter.More(); aLIter.Next()) {
47 aResult.push_back(aDoc->feature(aLIter.Value()));
53 Model_AttributeRefList::Model_AttributeRefList(TDF_Label& theLabel)
55 // check the attribute could be already presented in this doc (after load document)
56 if (!theLabel.FindAttribute(TDataStd_ReferenceList::GetID(), myRef)) {
57 myRef = TDataStd_ReferenceList::Set(theLabel);