From: mpv Date: Thu, 20 Aug 2015 06:53:21 +0000 (+0300) Subject: Added the removeLast method into AttributeRefList X-Git-Tag: V_1.4.0_beta4~331 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=dc50f2f6b509a5dd5de0be397a3fe4564cb8d98d;p=modules%2Fshaper.git Added the removeLast method into AttributeRefList --- diff --git a/src/Model/Model_AttributeRefList.cpp b/src/Model/Model_AttributeRefList.cpp index 443d089bb..01e288ab9 100644 --- a/src/Model/Model_AttributeRefList.cpp +++ b/src/Model/Model_AttributeRefList.cpp @@ -159,6 +159,20 @@ void Model_AttributeRefList::substitute(const ObjectPtr& theCurrent, const Objec } } +void Model_AttributeRefList::removeLast() +{ + std::shared_ptr aDoc = std::dynamic_pointer_cast( + owner()->document()); + if (aDoc && !myRef->IsEmpty()) { + ObjectPtr anObj = aDoc->objects()->object(myRef->Last()); + if (anObj.get()) { + myRef->Remove(myRef->Last()); + REMOVE_BACK_REF(anObj); + owner()->data()->sendAttributeUpdated(this); + } + } +} + Model_AttributeRefList::Model_AttributeRefList(TDF_Label& theLabel) { myIsInitialized = theLabel.FindAttribute(TDataStd_ReferenceList::GetID(), myRef) == Standard_True; diff --git a/src/Model/Model_AttributeRefList.h b/src/Model/Model_AttributeRefList.h index c7d909b6b..52de359b1 100644 --- a/src/Model/Model_AttributeRefList.h +++ b/src/Model/Model_AttributeRefList.h @@ -50,6 +50,9 @@ class Model_AttributeRefList : public ModelAPI_AttributeRefList /// Substitutes the feature by another one. Does nothing if such object is not found. MODEL_EXPORT virtual void substitute(const ObjectPtr& theCurrent, const ObjectPtr& theNew); + /// Removes the last element in the list. + MODEL_EXPORT virtual void removeLast(); + /// Returns true if attribute was initialized by some value MODEL_EXPORT virtual bool isInitialized(); protected: diff --git a/src/ModelAPI/ModelAPI_AttributeRefList.h b/src/ModelAPI/ModelAPI_AttributeRefList.h index 91c2741cf..2a282108f 100644 --- a/src/ModelAPI/ModelAPI_AttributeRefList.h +++ b/src/ModelAPI/ModelAPI_AttributeRefList.h @@ -55,6 +55,9 @@ class ModelAPI_AttributeRefList : public ModelAPI_Attribute /// Substitutes the feature by another one. Does nothing if such object is not found. virtual void substitute(const ObjectPtr& theCurrent, const ObjectPtr& theNew) = 0; + /// Removes the last element in the list. + virtual void removeLast() = 0; + MODELAPI_EXPORT virtual ~ModelAPI_AttributeRefList(); protected: /// Objects are created for features automatically