From 919e6d70d8e318b7451524cc658a2185fd7d2bb8 Mon Sep 17 00:00:00 2001 From: mpv Date: Fri, 18 Jul 2014 10:17:24 +0400 Subject: [PATCH] Make data located on the same level for features and results --- src/Model/Model_AttributeRefAttr.cpp | 5 ++--- src/Model/Model_AttributeRefList.cpp | 7 ++----- src/Model/Model_AttributeReference.cpp | 2 +- src/Model/Model_Document.cpp | 10 ++++++---- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/Model/Model_AttributeRefAttr.cpp b/src/Model/Model_AttributeRefAttr.cpp index 77a89ba40..09ea70ef7 100644 --- a/src/Model/Model_AttributeRefAttr.cpp +++ b/src/Model/Model_AttributeRefAttr.cpp @@ -22,7 +22,7 @@ void Model_AttributeRefAttr::setAttr(boost::shared_ptr 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 aData = boost::dynamic_pointer_cast(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(owner()->document()); if (aDoc) { TDF_Label aRefLab = myRef->Get(); - TDF_Label anObjLab = aRefLab.Father(); return aDoc->object(aRefLab); } } diff --git a/src/Model/Model_AttributeRefList.cpp b/src/Model/Model_AttributeRefList.cpp index 83e6b9c44..a341ad2bd 100644 --- a/src/Model/Model_AttributeRefList.cpp +++ b/src/Model/Model_AttributeRefList.cpp @@ -14,7 +14,7 @@ void Model_AttributeRefList::append(ObjectPtr theObject) { boost::shared_ptr aData = boost::dynamic_pointer_cast(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 aData = boost::dynamic_pointer_cast(theObject->data()); - myRef->Remove(aData->label()); + myRef->Remove(aData->label().Father()); owner()->data()->sendAttributeUpdated(this); } @@ -42,9 +42,6 @@ list 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); } } diff --git a/src/Model/Model_AttributeReference.cpp b/src/Model/Model_AttributeReference.cpp index 9cfd4a91c..a5540e741 100644 --- a/src/Model/Model_AttributeReference.cpp +++ b/src/Model/Model_AttributeReference.cpp @@ -18,7 +18,7 @@ void Model_AttributeReference::setValue(ObjectPtr theObject) if (myRef.IsNull()) { boost::shared_ptr aMyData = boost::dynamic_pointer_cast(owner()->data()); - myRef = TDF_Reference::Set(aMyData->label(), aData->label()); + myRef = TDF_Reference::Set(aMyData->label(), aData->label().Father()); } else { myRef->Set(aData->label()); } diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index c35f09e6c..1d693b73c 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -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 >& aResults = aFeature->results(); std::list >::const_iterator aRIter = aResults.cbegin(); @@ -673,8 +675,8 @@ void Model_Document::storeResult(boost::shared_ptr theFeatureData boost::shared_ptr aThis = Model_Application::getApplication()->getDocument(myID); theResult->setDoc(aThis); - initData(theResult, boost::dynamic_pointer_cast(theFeatureData)-> - label().Father().FindChild(TAG_FEATURE_RESULTS), theResultIndex + 1); + initData(theResult, boost::dynamic_pointer_cast(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()); } -- 2.39.2