X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_AttributeSelectionList.cpp;h=14a684a96657ff7f13443ac8dc4ef9bff83ccc9a;hb=6958dab7cbbaf443a39b04a609c5f33573c73f9e;hp=5aca20aee34c8822d9ab946131976e70c7f13827;hpb=d8fba833a4a6d6fa8526c008b3d9f9dea0861a88;p=modules%2Fshaper.git diff --git a/src/Model/Model_AttributeSelectionList.cpp b/src/Model/Model_AttributeSelectionList.cpp index 5aca20aee..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,20 +35,41 @@ 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() { - mySubs.clear(); - TDF_ChildIterator aSubIter(mySize->Label()); - for(; aSubIter.More(); aSubIter.Next()) { - aSubIter.Value().ForgetAllAttributes(Standard_True); + if (mySize->Get() != 0) { + mySize->Set(0); + TDF_ChildIterator aSubIter(mySize->Label()); + for(; aSubIter.More(); aSubIter.Next()) { + aSubIter.Value().ForgetAllAttributes(Standard_True); + } + owner()->data()->sendAttributeUpdated(this); } - owner()->data()->sendAttributeUpdated(this); } Model_AttributeSelectionList::Model_AttributeSelectionList(TDF_Label& theLabel) @@ -55,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); } }