X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_AttributeSelectionList.cpp;h=e97a2ee4918331235f52a227afc75931a4e2f9fb;hb=c62a4254fbf27b069449f4766f9c849fe2286109;hp=56f82cc6a142b9eed07722d3be44db8067d644a7;hpb=220bd2b37119be1c65abf88a88792445cb9d99f8;p=modules%2Fshaper.git diff --git a/src/Model/Model_AttributeSelectionList.cpp b/src/Model/Model_AttributeSelectionList.cpp index 56f82cc6a..e97a2ee49 100644 --- a/src/Model/Model_AttributeSelectionList.cpp +++ b/src/Model/Model_AttributeSelectionList.cpp @@ -14,11 +14,12 @@ #include #include #include - #include #include #include #include +#include +#include using namespace std; @@ -34,6 +35,10 @@ void Model_AttributeSelectionList::append( } } + if (myIsCashed && !theTemporarily) { + myCash[theContext].push_back(theSubShape); + } + int aNewTag = mySize->Get() + 1; TDF_Label aNewLab = mySize->Label().FindChild(aNewTag); @@ -85,9 +90,6 @@ void Model_AttributeSelectionList::removeLast() } } -#include -#include - // copies named shapes: we need the implementation of this static void CopyNS(const Handle(TNaming_NamedShape)& theFrom, const Handle(TDF_Attribute)& theTo) @@ -189,6 +191,25 @@ bool Model_AttributeSelectionList::isInList(const ResultPtr& theContext, const std::shared_ptr& theSubShape, const bool theTemporarily) { + if (myIsCashed) { // the cashing is active + std::map > >::iterator aContext = + myCash.find(theContext); + if (aContext != myCash.end()) { + // iterate shapes because "isEqual" method must be called for each shape + std::list >::iterator aShapes = aContext->second.begin(); + for(; aShapes != aContext->second.end(); aShapes++) { + if (!theSubShape.get()) { + if (!aShapes->get()) + return true; + } else { + if (theSubShape->isEqual(*aShapes)) + return true; + } + } + } + return false; + } + // no-cash method for(int anIndex = size() - 1; anIndex >= 0; anIndex--) { AttributeSelectionPtr anAttr = value(anIndex); if (anAttr.get()) { @@ -274,4 +295,19 @@ Model_AttributeSelectionList::Model_AttributeSelectionList(TDF_Label& theLabel) } else { // recollect mySubs theLabel.FindAttribute(TDataStd_Comment::GetID(), mySelectionType); } + myIsCashed = false; +} + +void Model_AttributeSelectionList::cashValues(const bool theEnabled) +{ + myIsCashed = theEnabled; + myCash.clear(); // empty list as indicator that cash is not used + if (theEnabled) { + for(int anIndex = size() - 1; anIndex >= 0; anIndex--) { + AttributeSelectionPtr anAttr = value(anIndex); + if (anAttr.get()) { + myCash[anAttr->context()].push_back(anAttr->value()); + } + } + } }