From 56b43fa7eef0b09ec2e4c12532cf21e2021ca534 Mon Sep 17 00:00:00 2001 From: mpv Date: Wed, 19 Aug 2015 11:44:23 +0300 Subject: [PATCH] Added removeLast method in the list to optimize the selection algorithm further --- src/Model/Model_AttributeSelectionList.cpp | 15 +++++++++++++++ src/Model/Model_AttributeSelectionList.h | 3 +++ src/ModelAPI/ModelAPI_AttributeSelectionList.h | 3 +++ 3 files changed, 21 insertions(+) diff --git a/src/Model/Model_AttributeSelectionList.cpp b/src/Model/Model_AttributeSelectionList.cpp index f547a797f..8191553d1 100644 --- a/src/Model/Model_AttributeSelectionList.cpp +++ b/src/Model/Model_AttributeSelectionList.cpp @@ -60,6 +60,21 @@ 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); + owner()->data()->sendAttributeUpdated(this); + } +} + int Model_AttributeSelectionList::size() { return mySize->Get(); diff --git a/src/Model/Model_AttributeSelectionList.h b/src/Model/Model_AttributeSelectionList.h index 5865b8562..e0eba6b71 100644 --- a/src/Model/Model_AttributeSelectionList.h +++ b/src/Model/Model_AttributeSelectionList.h @@ -33,6 +33,9 @@ public: /// The type of shape is taken from the current selection type MODEL_EXPORT virtual void append(std::string theNamingName); + /// Removes the last element in the list + MODEL_EXPORT virtual void removeLast(); + /// Returns the number ofselection attributes in the list MODEL_EXPORT virtual int size(); diff --git a/src/ModelAPI/ModelAPI_AttributeSelectionList.h b/src/ModelAPI/ModelAPI_AttributeSelectionList.h index 7994c37a6..68c7eed8e 100644 --- a/src/ModelAPI/ModelAPI_AttributeSelectionList.h +++ b/src/ModelAPI/ModelAPI_AttributeSelectionList.h @@ -27,6 +27,9 @@ class ModelAPI_AttributeSelectionList : public ModelAPI_Attribute /// The type of shape is taken from the current selection type virtual void append(std::string theNamingName) = 0; + /// Removes the last element in the list + virtual void removeLast() = 0; + /// Returns the number of selection attributes in the list virtual int size() = 0; -- 2.39.2