X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_AttributeSelectionList.cpp;h=07e62e2bcf45bcad212b5e9c1995413d16e13bf7;hb=283433d9c2f39fbd332d6eba691b6a0cd875e29d;hp=3b67df9eb0a9063e23a7874fde696432fdaa9857;hpb=a2ddb0f84f00241a308497a921e1a06ed5c56437;p=modules%2Fshaper.git diff --git a/src/Model/Model_AttributeSelectionList.cpp b/src/Model/Model_AttributeSelectionList.cpp index 3b67df9eb..07e62e2bc 100644 --- a/src/Model/Model_AttributeSelectionList.cpp +++ b/src/Model/Model_AttributeSelectionList.cpp @@ -1,6 +1,6 @@ // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -// File: Model_AttributeSelectionList.h +// File: Model_AttributeSelectionList.cpp // Created: 22 Oct 2014 // Author: Mikhail PONIKAROV @@ -21,7 +21,8 @@ using namespace std; void Model_AttributeSelectionList::append( - const ResultPtr& theContext, const std::shared_ptr& theSubShape) + const ResultPtr& theContext, const std::shared_ptr& theSubShape, + const bool theTemporarily) { // do not use the degenerated edge as a shape, a list is not incremented in this case if (theSubShape.get() && !theSubShape->isNull() && theSubShape->isEdge()) { @@ -41,7 +42,11 @@ void Model_AttributeSelectionList::append( } aNewAttr->setID(id()); mySize->Set(aNewTag); - aNewAttr->setValue(theContext, theSubShape); + aNewAttr->setValue(theContext, theSubShape, theTemporarily); + if (theTemporarily) + myTmpAttr = aNewAttr; + else + myTmpAttr.reset(); owner()->data()->sendAttributeUpdated(this); } @@ -60,6 +65,22 @@ void Model_AttributeSelectionList::append(std::string theNamingName) owner()->data()->sendAttributeUpdated(this); } +void Model_AttributeSelectionList::removeLast() +{ + int anOldSize = mySize->Get(); + if (anOldSize != 0) { + mySize->Set(anOldSize - 1); + TDF_Label aLab = mySize->Label().FindChild(anOldSize); + std::shared_ptr aOldAttr = + std::shared_ptr(new Model_AttributeSelection(aLab)); + aOldAttr->setObject(owner()); + REMOVE_BACK_REF(aOldAttr->context()); + aLab.ForgetAllAttributes(Standard_True); + myTmpAttr.reset(); + owner()->data()->sendAttributeUpdated(this); + } +} + int Model_AttributeSelectionList::size() { return mySize->Get(); @@ -78,6 +99,9 @@ void Model_AttributeSelectionList::setSelectionType(const std::string& theType) std::shared_ptr Model_AttributeSelectionList::value(const int theIndex) { + if (myTmpAttr.get() && theIndex == size() - 1) { + return myTmpAttr; + } 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 @@ -94,9 +118,18 @@ void Model_AttributeSelectionList::clear() { if (mySize->Get() != 0) { mySize->Set(0); + myTmpAttr.reset(); TDF_ChildIterator aSubIter(mySize->Label()); for(; aSubIter.More(); aSubIter.Next()) { - aSubIter.Value().ForgetAllAttributes(Standard_True); + TDF_Label aLab = aSubIter.Value(); + std::shared_ptr aNewAttr = + std::shared_ptr(new Model_AttributeSelection(aLab)); + if (owner()) { + aNewAttr->setObject(owner()); + } + REMOVE_BACK_REF(aNewAttr->context()); + + aLab.ForgetAllAttributes(Standard_True); } owner()->data()->sendAttributeUpdated(this); }