Salome HOME
If extrusion loses sketch contour, it becomes invalid and no results are displayed
[modules/shaper.git] / src / Model / Model_AttributeSelectionList.cpp
index 24a9efca5308d5684d3030a0b55c6ac5d4fd8f54..ae079d7a1673e8158816beeb0416511202124aae 100644 (file)
@@ -39,6 +39,7 @@ void Model_AttributeSelectionList::append(
   if (owner()) {
     aNewAttr->setObject(owner());
   }
+  aNewAttr->setID(id());
   mySize->Set(aNewTag);
   aNewAttr->setValue(theContext, theSubShape);
   owner()->data()->sendAttributeUpdated(this);
@@ -95,12 +96,28 @@ void Model_AttributeSelectionList::clear()
     mySize->Set(0);
     TDF_ChildIterator aSubIter(mySize->Label());
     for(; aSubIter.More(); aSubIter.Next()) {
-      aSubIter.Value().ForgetAllAttributes(Standard_True);
+      TDF_Label aLab = aSubIter.Value();
+      std::shared_ptr<Model_AttributeSelection> aNewAttr = 
+        std::shared_ptr<Model_AttributeSelection>(new Model_AttributeSelection(aLab));
+      if (owner()) {
+        aNewAttr->setObject(owner());
+      }
+      REMOVE_BACK_REF(aNewAttr->context());
+
+      aLab.ForgetAllAttributes(Standard_True);
     }
     owner()->data()->sendAttributeUpdated(this);
   }
 }
 
+bool Model_AttributeSelectionList::isInitialized()
+{
+  if (size() == 0) { // empty list is not initialized list: sketch will be not valid after add/undo
+    return false;
+  }
+  return ModelAPI_AttributeSelectionList::isInitialized();
+}
+
 Model_AttributeSelectionList::Model_AttributeSelectionList(TDF_Label& theLabel)
 {
   myIsInitialized = theLabel.FindAttribute(TDataStd_Integer::GetID(), mySize) == Standard_True;