From: mpv Date: Tue, 11 Aug 2015 06:53:18 +0000 (+0300) Subject: The persistence mechanism of part results modification features support X-Git-Tag: V_1.4.0_beta4~409 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4c2fb25615fc2e96957aeaee177251c40a434f4e;p=modules%2Fshaper.git The persistence mechanism of part results modification features support --- diff --git a/src/Model/Model_AttributeIntArray.cpp b/src/Model/Model_AttributeIntArray.cpp index a61a9cc0e..b9cb85876 100644 --- a/src/Model/Model_AttributeIntArray.cpp +++ b/src/Model/Model_AttributeIntArray.cpp @@ -23,7 +23,7 @@ int Model_AttributeIntArray::size() if (myArray.IsNull() || !myArray->IsValid()) { // this could be on undo and then redo creation of the attribute // in result creation it may be uninitialized - myIsInitialized = myLab.FindAttribute(TDataStd_IntegerArray::GetID(), myArray); + myIsInitialized = myLab.FindAttribute(TDataStd_IntegerArray::GetID(), myArray) == Standard_True; } // checking the validity because attribute (as a field) may be presented, // but without label: it is undoed diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index 504936dc1..bf4661ad2 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -44,6 +44,10 @@ #include +#ifdef WNT // to avoid too long decorated name warning +#pragma warning( disable : 4503 ) +#endif + // myLab contains: // TDataStd_Name - name of the object // TDataStd_IntegerArray - state of the object execution, transaction ID of update @@ -583,7 +587,7 @@ std::shared_ptr Model_Data::invalidData() return kInvalid; } -bool Model_Data::isOwner(ModelAPI_Object* theOwner) +std::shared_ptr Model_Data::owner() { - return theOwner == myObject.get(); + return myObject; } diff --git a/src/Model/Model_Data.h b/src/Model/Model_Data.h index 1a502b4b0..f1d5c59e8 100644 --- a/src/Model/Model_Data.h +++ b/src/Model/Model_Data.h @@ -202,7 +202,7 @@ class Model_Data : public ModelAPI_Data /// Returns true if the given object is owner of this data (needed for correct erase of object /// with duplicated data) - MODEL_EXPORT virtual bool isOwner(ModelAPI_Object* theOwner); + MODEL_EXPORT virtual std::shared_ptr owner(); protected: /// Returns true if "is in history" custom behaviors is defined for the feature diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 2ff8141aa..d123c6b9e 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -617,8 +617,9 @@ const std::set Model_Document::subDocuments(const bool theActivated std::list::iterator aPartRes = aPartResults.begin(); for(; aPartRes != aPartResults.end(); aPartRes++) { ResultPartPtr aPart = std::dynamic_pointer_cast(*aPartRes); - if (aPart && (!theActivatedOnly || aPart->isActivated())) - aResult.insert(aPart->data()->name()); + if (aPart && (!theActivatedOnly || aPart->isActivated())) { + aResult.insert(aPart->original()->data()->name()); + } } return aResult; } diff --git a/src/Model/Model_ResultPart.cpp b/src/Model/Model_ResultPart.cpp index 246621acd..12361eb33 100644 --- a/src/Model/Model_ResultPart.cpp +++ b/src/Model/Model_ResultPart.cpp @@ -79,6 +79,14 @@ void Model_ResultPart::activate() } } +std::shared_ptr Model_ResultPart::original() +{ + if (myTrsf.get()) { + return baseRef()->original(); + } + return std::dynamic_pointer_cast(data()->owner()); +} + bool Model_ResultPart::isActivated() { if (myTrsf.get()) { diff --git a/src/Model/Model_ResultPart.h b/src/Model/Model_ResultPart.h index fee8e0ad1..b4a147bc9 100644 --- a/src/Model/Model_ResultPart.h +++ b/src/Model/Model_ResultPart.h @@ -36,6 +36,10 @@ class Model_ResultPart : public ModelAPI_ResultPart /// Returns the part-document of this result MODEL_EXPORT virtual std::shared_ptr partDoc(); + /// Returns the original part result: for transfomration features results this is + /// the original Part feature result + MODEL_EXPORT virtual std::shared_ptr original(); + /// Sets this document as current and if it is not loaded yet, loads it MODEL_EXPORT virtual void activate(); diff --git a/src/ModelAPI/ModelAPI_Data.h b/src/ModelAPI/ModelAPI_Data.h index d06d7c100..222934699 100644 --- a/src/ModelAPI/ModelAPI_Data.h +++ b/src/ModelAPI/ModelAPI_Data.h @@ -154,9 +154,8 @@ class MODELAPI_EXPORT ModelAPI_Data /// This method is called by the updater. virtual void setUpdateID(const int theID) = 0; - /// Returns true if the given object is owner of this data (needed for correct erase of object - /// with duplicated data) - virtual bool isOwner(ModelAPI_Object* theOwner) = 0; + /// Returns the owner of htis data + virtual std::shared_ptr owner() = 0; protected: /// Objects are created for features automatically diff --git a/src/ModelAPI/ModelAPI_Object.cpp b/src/ModelAPI/ModelAPI_Object.cpp index 9d08a0c37..b3f2671c9 100644 --- a/src/ModelAPI/ModelAPI_Object.cpp +++ b/src/ModelAPI/ModelAPI_Object.cpp @@ -68,7 +68,7 @@ void ModelAPI_Object::setDoc(std::shared_ptr theDoc) void ModelAPI_Object::erase() { - if (myData->isValid() && myData != myData->invalidPtr() && myData->isOwner(this)) + if (myData->isValid() && myData != myData->invalidPtr()) myData->erase(); setData(myData->invalidPtr()); } diff --git a/src/ModelAPI/ModelAPI_ResultBody.cpp b/src/ModelAPI/ModelAPI_ResultBody.cpp index 1d5d38824..93b996111 100644 --- a/src/ModelAPI/ModelAPI_ResultBody.cpp +++ b/src/ModelAPI/ModelAPI_ResultBody.cpp @@ -5,6 +5,7 @@ // Author: Mikhail PONIKAROV #include "ModelAPI_ResultBody.h" +#include ModelAPI_ResultBody::ModelAPI_ResultBody() : myBuilder(0) diff --git a/src/ModelAPI/ModelAPI_ResultPart.h b/src/ModelAPI/ModelAPI_ResultPart.h index 46d75e438..b06c3f2ac 100644 --- a/src/ModelAPI/ModelAPI_ResultPart.h +++ b/src/ModelAPI/ModelAPI_ResultPart.h @@ -52,6 +52,10 @@ class ModelAPI_ResultPart : public ModelAPI_Result /// Returns the part-document of this result virtual std::shared_ptr partDoc() = 0; + /// Returns the original part result: for transfomration features results this is + /// the original Part feature result + virtual std::shared_ptr original() = 0; + /// Sets this document as current and if it is not loaded yet, loads it virtual void activate() = 0;