]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/Model/Model_AttributeReference.cpp
Salome HOME
Sources formated according to the codeing standards
[modules/shaper.git] / src / Model / Model_AttributeReference.cpp
index e2ff01ce7798975aa6e11d829c86281f6bfc99f5..dfb54c5f10331298e535624aba6457cb10ee2cf9 100644 (file)
 
 using namespace std;
 
-void Model_AttributeReference::setValue(FeaturePtr theFeature)
+void Model_AttributeReference::setValue(ObjectPtr theObject)
 {
-  if (!myIsInitialized || value() != theFeature) {
-    boost::shared_ptr<Model_Data> aData = 
-      boost::dynamic_pointer_cast<Model_Data>(theFeature->data());
-    if (myRef.IsNull()) {
-      boost::shared_ptr<Model_Data> aMyData = 
-        boost::dynamic_pointer_cast<Model_Data>(owner()->data());
-      myRef = TDF_Reference::Set(aMyData->label(), aData->label());
-    } else {
-      myRef->Set(aData->label());
-    }
+  if (!myIsInitialized || value() != theObject) {
+    boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(
+        theObject->data());
+    myRef->Set(aData->label().Father());  // references to the feature label
     owner()->data()->sendAttributeUpdated(this);
   }
 }
 
-FeaturePtr Model_AttributeReference::value()
+ObjectPtr Model_AttributeReference::value()
 {
-  if (!myRef.IsNull()) {
-    boost::shared_ptr<Model_Document> aDoc = 
-      boost::dynamic_pointer_cast<Model_Document>(owner()->document());
+  if (myIsInitialized) {
+    boost::shared_ptr<Model_Document> aDoc = boost::dynamic_pointer_cast<Model_Document>(
+        owner()->document());
     if (aDoc) {
       TDF_Label aRefLab = myRef->Get();
-      return aDoc->feature(aRefLab);
+      return aDoc->object(aRefLab);
     }
   }
   // not initialized
@@ -42,6 +36,7 @@ FeaturePtr Model_AttributeReference::value()
 
 Model_AttributeReference::Model_AttributeReference(TDF_Label& theLabel)
 {
-  // not initialized by value yet: attribute is not set to the label!
   myIsInitialized = theLabel.FindAttribute(TDF_Reference::GetID(), myRef) == Standard_True;
+  if (!myIsInitialized)
+    myRef = TDF_Reference::Set(theLabel, theLabel);  // not initialized references to itself
 }