]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Added removeLast method in the list to optimize the selection algorithm further
authormpv <mpv@opencascade.com>
Wed, 19 Aug 2015 08:44:23 +0000 (11:44 +0300)
committermpv <mpv@opencascade.com>
Wed, 19 Aug 2015 08:44:23 +0000 (11:44 +0300)
src/Model/Model_AttributeSelectionList.cpp
src/Model/Model_AttributeSelectionList.h
src/ModelAPI/ModelAPI_AttributeSelectionList.h

index f547a797fdcdbbc80bc10a844ed082a652a68d15..8191553d15d588e3f0c1262a0aab7e07863e1b3b 100644 (file)
@@ -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<Model_AttributeSelection> aOldAttr = 
+      std::shared_ptr<Model_AttributeSelection>(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();
index 5865b8562b6d447cd1828856194ccf6cdf7ea183..e0eba6b710f751af189c82a39235dc66b6aff742 100644 (file)
@@ -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();
 
index 7994c37a62930f135c5e5448053e153650805914..68c7eed8ec445cdfbb5243340eeabf11f0eb2a83 100644 (file)
@@ -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;