]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Make data located on the same level for features and results
authormpv <mikhail.ponikarov@opencascade.com>
Fri, 18 Jul 2014 06:17:24 +0000 (10:17 +0400)
committermpv <mikhail.ponikarov@opencascade.com>
Fri, 18 Jul 2014 06:17:24 +0000 (10:17 +0400)
src/Model/Model_AttributeRefAttr.cpp
src/Model/Model_AttributeRefList.cpp
src/Model/Model_AttributeReference.cpp
src/Model/Model_Document.cpp

index 77a89ba40868cb6ce030610e3c438b79f9e80ef0..09ea70ef775211f01bb9791b1839982e12bc9248 100644 (file)
@@ -22,7 +22,7 @@ void Model_AttributeRefAttr::setAttr(boost::shared_ptr<ModelAPI_Attribute> theAt
   if (myIsInitialized && object() == theAttr->owner() && myID->Get().IsEqual(anID.c_str()))
     return; // nothing is changed
 
-  myRef->Set(aData->label());
+  myRef->Set(aData->label().Father());
   myID->Set(aData->id(theAttr).c_str());
   owner()->data()->sendAttributeUpdated(this);
 }
@@ -44,7 +44,7 @@ void Model_AttributeRefAttr::setObject(ObjectPtr theObject)
   if (!myIsInitialized || myID->Get().Length() != 0 || object() != theObject) {
     boost::shared_ptr<Model_Data> aData = 
       boost::dynamic_pointer_cast<Model_Data>(theObject->data());
-    myRef->Set(aData->label());
+    myRef->Set(aData->label().Father());
     myID->Set(""); // feature is identified by the empty ID
     owner()->data()->sendAttributeUpdated(this);
   }
@@ -57,7 +57,6 @@ ObjectPtr Model_AttributeRefAttr::object()
       boost::dynamic_pointer_cast<Model_Document>(owner()->document());
     if (aDoc) {
       TDF_Label aRefLab = myRef->Get();
-      TDF_Label anObjLab = aRefLab.Father();
       return aDoc->object(aRefLab);
     }
   }
index 83e6b9c44624c74fb8d39f3c9085dcf3750f12e4..a341ad2bd2edbfbef69c984f40f4b7107b0a85cb 100644 (file)
@@ -14,7 +14,7 @@ void Model_AttributeRefList::append(ObjectPtr theObject)
 {
   boost::shared_ptr<Model_Data> aData = 
     boost::dynamic_pointer_cast<Model_Data>(theObject->data());
-  myRef->Append(aData->label());
+  myRef->Append(aData->label().Father()); // store label of the object
 
   owner()->data()->sendAttributeUpdated(this);
 }
@@ -23,7 +23,7 @@ void Model_AttributeRefList::remove(ObjectPtr theObject)
 {
   boost::shared_ptr<Model_Data> aData = 
     boost::dynamic_pointer_cast<Model_Data>(theObject->data());
-  myRef->Remove(aData->label());
+  myRef->Remove(aData->label().Father());
 
   owner()->data()->sendAttributeUpdated(this);
 }
@@ -42,9 +42,6 @@ list<ObjectPtr> Model_AttributeRefList::list()
     const TDF_LabelList& aList = myRef->List();
     for(TDF_ListIteratorOfLabelList aLIter(aList); aLIter.More(); aLIter.Next()) {
       ObjectPtr anObj = aDoc->object(aLIter.Value());
-      if (!anObj) { // try to use father (for feature)
-        anObj = aDoc->object(aLIter.Value().Father());
-      }
       aResult.push_back(anObj);
     }
   }
index 9cfd4a91c3ef72ee3df11bdd76f6deadcb5e650f..a5540e7415845b1791a2860e8b40cfe6a8d30527 100644 (file)
@@ -18,7 +18,7 @@ void Model_AttributeReference::setValue(ObjectPtr theObject)
     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());
+      myRef = TDF_Reference::Set(aMyData->label(), aData->label().Father());
     } else {
       myRef->Set(aData->label());
     }
index c35f09e6cc9d1242265cdba0b38d98ff5273e105..1d693b73cadc8eda4f84d910fa707a9be16dc9a6 100644 (file)
@@ -444,10 +444,12 @@ FeaturePtr Model_Document::feature(TDF_Label& theLabel)
 
 ObjectPtr Model_Document::object(TDF_Label theLabel)
 {
-  if (feature(theLabel)) // feature by label
+  // try feature by label
+  FeaturePtr aFeature = feature(theLabel);
+  if (aFeature)
     return feature(theLabel);
   TDF_Label aFeatureLabel = theLabel.Father().Father(); // let's suppose it is result
-  FeaturePtr aFeature = feature(aFeatureLabel);
+  aFeature = feature(aFeatureLabel);
   if (aFeature) {
     const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = aFeature->results();
     std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.cbegin();
@@ -673,8 +675,8 @@ void Model_Document::storeResult(boost::shared_ptr<ModelAPI_Data> theFeatureData
   boost::shared_ptr<ModelAPI_Document> aThis = 
     Model_Application::getApplication()->getDocument(myID);
   theResult->setDoc(aThis);
-  initData(theResult, boost::dynamic_pointer_cast<Model_Data>(theFeatureData)->
-    label().Father().FindChild(TAG_FEATURE_RESULTS), theResultIndex + 1);
+  initData(theResult, boost::dynamic_pointer_cast<Model_Data>(theFeatureData)->label().
+    Father().FindChild(TAG_FEATURE_RESULTS).FindChild(theResultIndex + 1), TAG_FEATURE_ARGUMENTS);
   if (theResult->data()->name().empty()) { // if was not initialized, generate event and set a name
     theResult->data()->setName(theFeatureData->name());
   }