From: nds Date: Thu, 28 Apr 2016 12:57:06 +0000 (+0300) Subject: Issue #1037 : using of: implementation of cashing of values for method isInList X-Git-Tag: V_2.3.0~77 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5eeda0e68cc0addac6ec3ab46e820ba8c4728384;p=modules%2Fshaper.git Issue #1037 : using of: implementation of cashing of values for method isInList --- diff --git a/src/Model/Model_AttributeSelectionList.cpp b/src/Model/Model_AttributeSelectionList.cpp index 9fbef11c6..03dde11ab 100644 --- a/src/Model/Model_AttributeSelectionList.cpp +++ b/src/Model/Model_AttributeSelectionList.cpp @@ -35,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); @@ -187,7 +191,7 @@ bool Model_AttributeSelectionList::isInList(const ResultPtr& theContext, const std::shared_ptr& theSubShape, const bool theTemporarily) { - if (!myCash.empty()) { // the cashing is active + if (myIsCashed) { // the cashing is active std::map > >::iterator aContext = myCash.find(theContext); if (aContext != myCash.end()) { @@ -293,7 +297,9 @@ Model_AttributeSelectionList::Model_AttributeSelectionList(TDF_Label& theLabel) } } -void Model_AttributeSelectionList::cashValues(const bool theEnabled) { +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--) { diff --git a/src/Model/Model_AttributeSelectionList.h b/src/Model/Model_AttributeSelectionList.h index 99f2dfdd8..c0f36fd7c 100644 --- a/src/Model/Model_AttributeSelectionList.h +++ b/src/Model/Model_AttributeSelectionList.h @@ -29,6 +29,7 @@ class Model_AttributeSelectionList : public ModelAPI_AttributeSelectionList std::shared_ptr myTmpAttr; ///< temporary attribute (the last one) /// the cashed shapes to optimize isInList method: from context to set of shapes in this context std::map > > myCash; + bool myIsCashed; ///< true if cashing is performed public: /// Adds the new reference to the end of the list /// \param theContext object where the sub-shape was selected