X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_AttributeRefList.cpp;h=014592f0d3eebd58a02679f862777e510745c69c;hb=2060965fb573ad7eb9a2ea2f2a11786b40c4b963;hp=f6520fce869300ecaacfa0ee092dd0fece340583;hpb=277db1718bb7a3226515e4cc2272d83b463b3434;p=modules%2Fshaper.git diff --git a/src/Model/Model_AttributeRefList.cpp b/src/Model/Model_AttributeRefList.cpp index f6520fce8..014592f0d 100644 --- a/src/Model/Model_AttributeRefList.cpp +++ b/src/Model/Model_AttributeRefList.cpp @@ -4,56 +4,67 @@ #include "Model_AttributeRefList.h" #include "Model_Application.h" -#include "Model_Events.h" #include "Model_Data.h" #include -#include #include using namespace std; -void Model_AttributeRefList::append(boost::shared_ptr theFeature) +void Model_AttributeRefList::append(ObjectPtr theObject) { - boost::shared_ptr aData = - boost::dynamic_pointer_cast(theFeature->data()); - myRef->Append(aData->label()); + boost::shared_ptr aData = boost::dynamic_pointer_cast(theObject->data()); + myRef->Append(aData->label().Father()); // store label of the object - static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED); - Model_FeatureUpdatedMessage aMsg(owner(), anEvent); - Events_Loop::loop()->send(aMsg); + owner()->data()->sendAttributeUpdated(this); } -void Model_AttributeRefList::remove(boost::shared_ptr theFeature) +void Model_AttributeRefList::remove(ObjectPtr theObject) { - boost::shared_ptr aData = - boost::dynamic_pointer_cast(theFeature->data()); - myRef->Remove(aData->label()); + boost::shared_ptr aData = boost::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() +list Model_AttributeRefList::list() { - std::list< boost::shared_ptr > aResult; - boost::shared_ptr aDoc = - boost::dynamic_pointer_cast(owner()->document()); + std::list aResult; + boost::shared_ptr aDoc = boost::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->feature(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 +{ + boost::shared_ptr aDoc = boost::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) { - // check the attribute could be already presented in this doc (after load document) - if (!theLabel.FindAttribute(TDataStd_ReferenceList::GetID(), myRef)) { + myIsInitialized = theLabel.FindAttribute(TDataStd_ReferenceList::GetID(), myRef) == Standard_True; + if (!myIsInitialized) { myRef = TDataStd_ReferenceList::Set(theLabel); } }