}
}
+void Model_AttributeRefList::removeLast()
+{
+ std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(
+ 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;
/// 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:
/// 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