From: mpv Date: Mon, 8 Sep 2014 15:07:41 +0000 (+0400) Subject: Make part documents loaded only by activation X-Git-Tag: V_0.4.4~78^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4bf2bed6dec095bacd8069c84e21e50020db2e63;p=modules%2Fshaper.git Make part documents loaded only by activation --- diff --git a/src/Model/Model_AttributeDocRef.cpp b/src/Model/Model_AttributeDocRef.cpp index 806408d33..67486266c 100644 --- a/src/Model/Model_AttributeDocRef.cpp +++ b/src/Model/Model_AttributeDocRef.cpp @@ -11,6 +11,7 @@ using namespace std; void Model_AttributeDocRef::setValue(boost::shared_ptr theDoc) { + myDoc = theDoc; TCollection_ExtendedString aNewID(theDoc->id().c_str()); if (!myIsInitialized || myComment->Get() != aNewID) { myComment->Set(TCollection_ExtendedString(theDoc->id().c_str())); @@ -20,11 +21,7 @@ void Model_AttributeDocRef::setValue(boost::shared_ptr theDoc boost::shared_ptr Model_AttributeDocRef::value() { - if (myComment->Get().Length()) - return Model_Application::getApplication()->getDocument( - TCollection_AsciiString(myComment->Get()).ToCString()); - // not initialized - return boost::shared_ptr(); + return myDoc; } Model_AttributeDocRef::Model_AttributeDocRef(TDF_Label& theLabel) diff --git a/src/Model/Model_AttributeDocRef.h b/src/Model/Model_AttributeDocRef.h index dc731701d..6290e05a4 100644 --- a/src/Model/Model_AttributeDocRef.h +++ b/src/Model/Model_AttributeDocRef.h @@ -18,6 +18,7 @@ class Model_AttributeDocRef : public ModelAPI_AttributeDocRef { Handle_TDataStd_Comment myComment; ///< reference to document is identified as string-id + boost::shared_ptr myDoc; ///< document referenced by this attribute (if already loaded) public: /// Defines the document referenced from this attribute MODEL_EXPORT virtual void setValue(boost::shared_ptr theDoc); diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 55c0fa57f..cfe40d5f7 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -763,10 +764,16 @@ void Model_Document::storeResult(boost::shared_ptr theFeatureData } } +static const Standard_GUID ID_CONSTRUCTION("b59fa408-8ab1-42b8-980c-af5adeebe7e4"); +static const Standard_GUID ID_BODY("c1148e9a-9b17-4e9c-9160-18e918fd0013"); +static const Standard_GUID ID_PART("1b3319b9-3e0a-4298-a1dc-3fb5aaf9be59"); + boost::shared_ptr Model_Document::createConstruction( const boost::shared_ptr& theFeatureData, const int theIndex) { - ObjectPtr anOldObject = object(resultLabel(theFeatureData, theIndex)); + TDF_Label aLab = resultLabel(theFeatureData, theIndex); + TDataStd_UAttribute::Set(aLab, ID_CONSTRUCTION); + ObjectPtr anOldObject = object(aLab); boost::shared_ptr aResult; if (anOldObject) { aResult = boost::dynamic_pointer_cast(anOldObject); @@ -781,7 +788,9 @@ boost::shared_ptr Model_Document::createConstructio boost::shared_ptr Model_Document::createBody( const boost::shared_ptr& theFeatureData, const int theIndex) { - ObjectPtr anOldObject = object(resultLabel(theFeatureData, theIndex)); + TDF_Label aLab = resultLabel(theFeatureData, theIndex); + TDataStd_UAttribute::Set(aLab, ID_BODY); + ObjectPtr anOldObject = object(aLab); boost::shared_ptr aResult; if (anOldObject) { aResult = boost::dynamic_pointer_cast(anOldObject); @@ -796,7 +805,9 @@ boost::shared_ptr Model_Document::createBody( boost::shared_ptr Model_Document::createPart( const boost::shared_ptr& theFeatureData, const int theIndex) { - ObjectPtr anOldObject = object(resultLabel(theFeatureData, theIndex)); + TDF_Label aLab = resultLabel(theFeatureData, theIndex); + TDataStd_UAttribute::Set(aLab, ID_PART); + ObjectPtr anOldObject = object(aLab); boost::shared_ptr aResult; if (anOldObject) { aResult = boost::dynamic_pointer_cast(anOldObject); @@ -842,13 +853,21 @@ void Model_Document::updateResults(FeaturePtr theFeature) int aResSize = theFeature->results().size(); TDF_ChildIterator aLabIter(resultLabel(theFeature->data(), 0).Father()); for(; aLabIter.More(); aLabIter.Next()) { - // here must be at least Name + // here must be GUID of the feature int aResIndex = aLabIter.Value().Tag() - 1; - if (aLabIter.Value().FindChild(TAG_FEATURE_ARGUMENTS).HasAttribute() && - aResSize <= aResIndex) - { - ResultBodyPtr aNewBody = createBody(theFeature->data(), aResIndex); - theFeature->setResult(aNewBody, aResIndex); + ResultPtr aNewBody; + if (aResSize <= aResIndex) { + TDF_Label anArgLab = aLabIter.Value(); + if (anArgLab.IsAttribute(ID_BODY)) { + aNewBody = createBody(theFeature->data(), aResIndex); + } else if (anArgLab.IsAttribute(ID_PART)) { + aNewBody = createPart(theFeature->data(), aResIndex); + } else if (!anArgLab.IsAttribute(ID_CONSTRUCTION)) { + Events_Error::send("Unknown type of result if found in the document"); + } + if (aNewBody) { + theFeature->setResult(aNewBody, aResIndex); + } } } }