Salome HOME
Issue #1774: Can't select edge for tangent constraint creation
[modules/shaper.git] / src / Model / Model_AttributeRefAttrList.cpp
index e08420a01031ef746cc3ed7e546d4c9d502ab742..e1ffa3b62ea2987ee3f9949d06dde7c99c476613 100755 (executable)
@@ -95,7 +95,7 @@ void Model_AttributeRefAttrList::remove(AttributePtr theAttr)
         (aTheObjLab.IsNull() && aDoc->objects()->object(aRefIter.Value()) != NULL)) {
       myRef->Append(aRefIter.Value());
       myIDs->Append(anIDIter.Value());
-    } else if (aTheObjLab.IsNull() && aDoc->objects()->object(aRefIter.Value()) != NULL) {
+    } else {
       aOneisDeleted = true;
     }
   }
@@ -142,10 +142,13 @@ std::list<std::pair<ObjectPtr, AttributePtr> > Model_AttributeRefAttrList::list(
     TDataStd_ListIteratorOfListOfExtendedString anIDIter(anIDList);
     for (; aLIter.More(); aLIter.Next(), anIDIter.Next()) {
       ObjectPtr anObj;
-      if (!aLIter.Value().IsNull())
+      if (!aLIter.Value().IsNull()) {
         anObj = aDoc->objects()->object(aLIter.Value());
-      aResult.push_back(std::pair<ObjectPtr, AttributePtr>(anObj, 
-        anObj->data()->attribute(TCollection_AsciiString(anIDIter.Value()).ToCString())));
+        aResult.push_back(std::pair<ObjectPtr, AttributePtr>(anObj, 
+          anObj->data()->attribute(TCollection_AsciiString(anIDIter.Value()).ToCString())));
+      } else {
+        aResult.push_back(std::pair<ObjectPtr, AttributePtr>(ObjectPtr(), AttributePtr()));
+      }
     }
   }
   return aResult;
@@ -293,7 +296,6 @@ void Model_AttributeRefAttrList::remove(const std::set<int>& theIndices)
         aOneisDeleted = true;
         ObjectPtr anObj = aDoc->objects()->object(aRefIter.Value());
         if (anObj.get()) {
-          myRef->Remove(aRefIter.Value());
           REMOVE_BACK_REF(anObj);
         }
       }
@@ -306,11 +308,17 @@ void Model_AttributeRefAttrList::remove(const std::set<int>& theIndices)
 
 Model_AttributeRefAttrList::Model_AttributeRefAttrList(TDF_Label& theLabel)
 {
-  myIsInitialized = theLabel.FindAttribute(TDataStd_ReferenceList::GetID(), myRef) == Standard_True;
+  myLab = theLabel;
+  reinit();
+}
+
+void Model_AttributeRefAttrList::reinit()
+{
+  myIsInitialized = myLab.FindAttribute(TDataStd_ReferenceList::GetID(), myRef) == Standard_True;
   if (!myIsInitialized) {
-    myRef = TDataStd_ReferenceList::Set(theLabel);
-    myIDs = TDataStd_ExtStringList::Set(theLabel);
+    myRef = TDataStd_ReferenceList::Set(myLab);
+    myIDs = TDataStd_ExtStringList::Set(myLab);
   } else {
-    theLabel.FindAttribute(TDataStd_ExtStringList::GetID(), myIDs);
+    myLab.FindAttribute(TDataStd_ExtStringList::GetID(), myIDs);
   }
 }