X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_AttributeSelectionList.cpp;h=14a684a96657ff7f13443ac8dc4ef9bff83ccc9a;hb=6958dab7cbbaf443a39b04a609c5f33573c73f9e;hp=a95510118475b39a4e03d102df82725f09fa8de9;hpb=4fcd5da2d972334e887716499b0ea75d9d6c51c2;p=modules%2Fshaper.git diff --git a/src/Model/Model_AttributeSelectionList.cpp b/src/Model/Model_AttributeSelectionList.cpp index a95510118..14a684a96 100644 --- a/src/Model/Model_AttributeSelectionList.cpp +++ b/src/Model/Model_AttributeSelectionList.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // File: Model_AttributeSelectionList.h // Created: 22 Oct 2014 // Author: Mikhail PONIKAROV @@ -13,17 +15,16 @@ using namespace std; void Model_AttributeSelectionList::append( - const ResultPtr& theContext, const boost::shared_ptr& theSubShape) + const ResultPtr& theContext, const std::shared_ptr& theSubShape) { int aNewTag = mySize->Get() + 1; TDF_Label aNewLab = mySize->Label().FindChild(aNewTag); - boost::shared_ptr aNewAttr = - boost::shared_ptr(new Model_AttributeSelection(aNewLab)); + std::shared_ptr aNewAttr = + std::shared_ptr(new Model_AttributeSelection(aNewLab)); if (owner()) { aNewAttr->setObject(owner()); } - mySubs.push_back(aNewAttr); mySize->Set(aNewTag); aNewAttr->setValue(theContext, theSubShape); owner()->data()->sendAttributeUpdated(this); @@ -34,17 +35,35 @@ int Model_AttributeSelectionList::size() return mySize->Get(); } -boost::shared_ptr +int Model_AttributeSelectionList::selectionType() +{ + return (int) mySelectionType->Get(); +} + +void Model_AttributeSelectionList::setSelectionType(int theType) +{ + mySelectionType->Set((double) theType); +} + +std::shared_ptr Model_AttributeSelectionList::value(const int theIndex) { - return mySubs[theIndex]; + TDF_Label aLabel = mySize->Label().FindChild(theIndex + 1); + // create a new attribute each time, by demand + // supporting of old attributes is too slow (synch each time) and buggy on redo + // (if attribute is deleted and created, the abort updates attriute and makes the Attr invalid) + std::shared_ptr aNewAttr = + std::shared_ptr(new Model_AttributeSelection(aLabel)); + if (owner()) { + aNewAttr->setObject(owner()); + } + return aNewAttr; } void Model_AttributeSelectionList::clear() { - if (!mySubs.empty()) { + if (mySize->Get() != 0) { mySize->Set(0); - mySubs.clear(); TDF_ChildIterator aSubIter(mySize->Label()); for(; aSubIter.More(); aSubIter.Next()) { aSubIter.Value().ForgetAllAttributes(Standard_True); @@ -58,25 +77,8 @@ Model_AttributeSelectionList::Model_AttributeSelectionList(TDF_Label& theLabel) myIsInitialized = theLabel.FindAttribute(TDataStd_Integer::GetID(), mySize) == Standard_True; if (!myIsInitialized) { mySize = TDataStd_Integer::Set(theLabel, 0); + mySelectionType = TDataStd_Real::Set(theLabel, 0); } else { // recollect mySubs - int aNum = mySize->Get(); - TDF_ChildIterator aSubIter(theLabel); - for(; aSubIter.More(), aNum != 0; aSubIter.Next(), aNum--) { - TDF_Label aChildLab = aSubIter.Value(); - boost::shared_ptr aNewAttr = - boost::shared_ptr(new Model_AttributeSelection(aChildLab)); - if (owner()) - aNewAttr->setObject(owner()); - mySubs.push_back(aNewAttr); - } - } -} - -void Model_AttributeSelectionList::setObject(const boost::shared_ptr& theObject) -{ - ModelAPI_AttributeSelectionList::setObject(theObject); - std::vector >::iterator aSubIter = mySubs.begin(); - for(; aSubIter != mySubs.end(); aSubIter++) { - (*aSubIter)->setObject(theObject); + theLabel.FindAttribute(TDataStd_Real::GetID(), mySelectionType); } }