]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/Model/Model_AttributeRefAttr.cpp
Salome HOME
Added the system of reinitialization of attributes instead of re-creation of them...
[modules/shaper.git] / src / Model / Model_AttributeRefAttr.cpp
index f399ba5be5405853d6c4ed7882c27d37ba30af77..6456b68a8bd1b2fc98a3164beca9a2bdb6c5d0ea 100644 (file)
@@ -46,7 +46,7 @@ void Model_AttributeRefAttr::setObject(ObjectPtr theObject)
 {
   // the back reference from the previous object to the attribute should be removed
   ObjectPtr anObject = object();
-  if (theObject && (!myIsInitialized || myID->Get().Length() != 0 || object() != theObject)) {
+  if (theObject.get() && (!myIsInitialized || myID->Get().Length() != 0 || object() != theObject)) {
     REMOVE_BACK_REF(anObject);
 
     std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(
@@ -84,14 +84,28 @@ ObjectPtr Model_AttributeRefAttr::object()
   return ObjectPtr();
 }
 
+bool Model_AttributeRefAttr::isInitialized()
+{
+  if (myRef->Get() == myRef->Label()) { // empty is not initialized: sketch parallelity
+    return false;
+  }
+  return ModelAPI_AttributeRefAttr::isInitialized();
+}
+
 Model_AttributeRefAttr::Model_AttributeRefAttr(TDF_Label& theLabel)
 {
-  myIsInitialized = theLabel.FindAttribute(TDataStd_Comment::GetID(), myID) == Standard_True;
+  myLab = theLabel;
+  reinit();
+}
+
+void Model_AttributeRefAttr::reinit()
+{
+  myIsInitialized = myLab.FindAttribute(TDataStd_Comment::GetID(), myID) == Standard_True;
   if (!myIsInitialized) {
     // create attribute: not initialized by value yet
-    myID = TDataStd_Comment::Set(theLabel, "");
-    myRef = TDF_Reference::Set(theLabel, theLabel);  // not initialized: reference to itself
+    myID = TDataStd_Comment::Set(myLab, "");
+    myRef = TDF_Reference::Set(myLab, myLab);  // not initialized: reference to itself
   } else {
-    theLabel.FindAttribute(TDF_Reference::GetID(), myRef);
+    myLab.FindAttribute(TDF_Reference::GetID(), myRef);
   }
 }