X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_AttributeRefList.cpp;h=9287cf0415079707b7ecfb17c91b01c51742deb4;hb=38afbd899a8645c83e17f2c24a17a2b7414911b4;hp=af4cbd3ea6246983a910f4bc3f177540ebe8d1e5;hpb=f581964034f8df715c46a07c5ecb762492d6b4cf;p=modules%2Fshaper.git diff --git a/src/Model/Model_AttributeRefList.cpp b/src/Model/Model_AttributeRefList.cpp index af4cbd3ea..9287cf041 100644 --- a/src/Model/Model_AttributeRefList.cpp +++ b/src/Model/Model_AttributeRefList.cpp @@ -1,59 +1,72 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // File: ModelAPI_AttributeRefList.cxx // Created: 8 May 2014 // Author: Mikhail PONIKAROV #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(FeaturePtr theFeature) +void Model_AttributeRefList::append(ObjectPtr theObject) { - boost::shared_ptr aData = - boost::dynamic_pointer_cast(theFeature->data()); - myRef->Append(aData->label()); + std::shared_ptr aData = std::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(FeaturePtr theFeature) +void Model_AttributeRefList::remove(ObjectPtr theObject) { - boost::shared_ptr aData = - boost::dynamic_pointer_cast(theFeature->data()); - myRef->Remove(aData->label()); + std::shared_ptr aData = std::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< FeaturePtr > aResult; - boost::shared_ptr aDoc = - boost::dynamic_pointer_cast(owner()->document()); + std::list aResult; + std::shared_ptr aDoc = std::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 +{ + std::shared_ptr aDoc = std::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); } }