From: mpv Date: Mon, 13 Apr 2015 13:30:15 +0000 (+0300) Subject: Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0 X-Git-Tag: V_1.1.0~36^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9db45503b9ec9a48ee30e9ea7ce14eb34c139d5e;hp=d5c0128fc1e984053a2c50e1937a6c8998d76d1e;p=modules%2Fshaper.git Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0 --- diff --git a/src/Model/Model_AttributeRefList.cpp b/src/Model/Model_AttributeRefList.cpp index 13233fb9c..b1fcda046 100644 --- a/src/Model/Model_AttributeRefList.cpp +++ b/src/Model/Model_AttributeRefList.cpp @@ -54,6 +54,14 @@ int Model_AttributeRefList::size() const return myRef->Extent(); } +bool Model_AttributeRefList::isInitialized() +{ + if (size() == 0) { // empty list is not initialized list: sketch will be not valid after add/undo + return false; + } + return ModelAPI_AttributeRefList::isInitialized(); +} + list Model_AttributeRefList::list() { std::list aResult; diff --git a/src/Model/Model_AttributeRefList.h b/src/Model/Model_AttributeRefList.h index 2a4550a80..f59229a1a 100644 --- a/src/Model/Model_AttributeRefList.h +++ b/src/Model/Model_AttributeRefList.h @@ -37,6 +37,8 @@ class Model_AttributeRefList : public ModelAPI_AttributeRefList /// Returns the list of features MODEL_EXPORT virtual ObjectPtr object(const int theIndex) const; + /// Returns true if attribute was initialized by some value + MODEL_EXPORT virtual bool isInitialized(); protected: /// Objects are created for features automatically MODEL_EXPORT Model_AttributeRefList(TDF_Label& theLabel); diff --git a/src/Model/Model_AttributeSelectionList.cpp b/src/Model/Model_AttributeSelectionList.cpp index 79eb5c714..3b67df9eb 100644 --- a/src/Model/Model_AttributeSelectionList.cpp +++ b/src/Model/Model_AttributeSelectionList.cpp @@ -102,6 +102,14 @@ void Model_AttributeSelectionList::clear() } } +bool Model_AttributeSelectionList::isInitialized() +{ + if (size() == 0) { // empty list is not initialized list: sketch will be not valid after add/undo + return false; + } + return ModelAPI_AttributeSelectionList::isInitialized(); +} + Model_AttributeSelectionList::Model_AttributeSelectionList(TDF_Label& theLabel) { myIsInitialized = theLabel.FindAttribute(TDataStd_Integer::GetID(), mySize) == Standard_True; diff --git a/src/Model/Model_AttributeSelectionList.h b/src/Model/Model_AttributeSelectionList.h index 584c170e9..5865b8562 100644 --- a/src/Model/Model_AttributeSelectionList.h +++ b/src/Model/Model_AttributeSelectionList.h @@ -50,6 +50,9 @@ public: /// Returns all attributes MODEL_EXPORT virtual void clear(); + /// Returns true if attribute was initialized by some value + MODEL_EXPORT virtual bool isInitialized(); + protected: /// Objects are created for features automatically MODEL_EXPORT Model_AttributeSelectionList(TDF_Label& theLabel); diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 00531ba84..ec0c236f6 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -557,13 +557,18 @@ FeaturePtr Model_Document::addFeature(std::string theID) { TDF_Label anEmptyLab; FeaturePtr anEmptyFeature; - FeaturePtr aFeature = - std::dynamic_pointer_cast(ModelAPI_Session::get())->createFeature(theID, this); + std::shared_ptr aSession = + std::dynamic_pointer_cast(ModelAPI_Session::get()); + FeaturePtr aFeature = aSession->createFeature(theID, this); if (!aFeature) return aFeature; Model_Document* aDocToAdd; - if (aFeature->documentToAdd().get()) { // use the customized document to add - aDocToAdd = std::dynamic_pointer_cast(aFeature->documentToAdd()).get(); + if (!aFeature->documentToAdd().empty()) { // use the customized document to add + if (aFeature->documentToAdd() != kind()) { // the root document by default + aDocToAdd = std::dynamic_pointer_cast(aSession->moduleDocument()).get(); + } else { + aDocToAdd = this; + } } else { // if customized is not presented, add to "this" document aDocToAdd = this; } diff --git a/src/ModelAPI/ModelAPI_Attribute.h b/src/ModelAPI/ModelAPI_Attribute.h index e3b1b056d..442e4e4a0 100644 --- a/src/ModelAPI/ModelAPI_Attribute.h +++ b/src/ModelAPI/ModelAPI_Attribute.h @@ -44,7 +44,7 @@ class ModelAPI_Attribute MODELAPI_EXPORT const std::shared_ptr& owner() const; /// Returns true if attribute was initialized by some value - MODELAPI_EXPORT bool isInitialized(); + MODELAPI_EXPORT virtual bool isInitialized(); /// Makes attribute initialized MODELAPI_EXPORT void setInitialized(); diff --git a/src/ModelAPI/ModelAPI_Feature.cpp b/src/ModelAPI/ModelAPI_Feature.cpp index ef212d23f..d9533e83e 100644 --- a/src/ModelAPI/ModelAPI_Feature.cpp +++ b/src/ModelAPI/ModelAPI_Feature.cpp @@ -132,10 +132,11 @@ void ModelAPI_Feature::eraseResults() } } -std::shared_ptr ModelAPI_Feature::documentToAdd() +const std::string& ModelAPI_Feature::documentToAdd() { - // null pointer t ouse the current document - return std::shared_ptr(); + // empty to use the current document + static const std::string anEmpty; + return anEmpty; } void ModelAPI_Feature::erase() diff --git a/src/ModelAPI/ModelAPI_Feature.h b/src/ModelAPI/ModelAPI_Feature.h index b80583544..85ebe38b5 100644 --- a/src/ModelAPI/ModelAPI_Feature.h +++ b/src/ModelAPI/ModelAPI_Feature.h @@ -99,8 +99,8 @@ class ModelAPI_Feature : public ModelAPI_Object } /// Must return document where the new feature must be added to - /// By default it is null document: it is added to the document this method is called to - MODELAPI_EXPORT virtual std::shared_ptr documentToAdd(); + /// By default it is empty: it is added to the document this method is called to + MODELAPI_EXPORT virtual const std::string& documentToAdd(); /// To virtually destroy the fields of successors MODELAPI_EXPORT virtual ~ModelAPI_Feature(); diff --git a/src/ModelAPI/ModelAPI_Result.h b/src/ModelAPI/ModelAPI_Result.h index daad432e7..472fe0056 100644 --- a/src/ModelAPI/ModelAPI_Result.h +++ b/src/ModelAPI/ModelAPI_Result.h @@ -43,7 +43,8 @@ class ModelAPI_Result : public ModelAPI_Object } // Retuns the parameters of color definition in the resources config manager - virtual void colorConfigInfo(std::string& theSection, std::string& theName, std::string& theDefault) {} + virtual void colorConfigInfo(std::string& theSection, std::string& theName, + std::string& theDefault) {} /// Request for initialization of data model of the result: adding all attributes virtual void initAttributes() {}; diff --git a/src/PartSetPlugin/PartSetPlugin_Part.cpp b/src/PartSetPlugin/PartSetPlugin_Part.cpp index 58c2d85fd..95fa5f06b 100644 --- a/src/PartSetPlugin/PartSetPlugin_Part.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Part.cpp @@ -31,7 +31,8 @@ void PartSetPlugin_Part::execute() } } -std::shared_ptr PartSetPlugin_Part::documentToAdd() +const std::string& PartSetPlugin_Part::documentToAdd() { - return ModelAPI_Session::get()->moduleDocument(); + // part must be added only to the module document + return ModelAPI_Session::get()->moduleDocument()->kind(); } diff --git a/src/PartSetPlugin/PartSetPlugin_Part.h b/src/PartSetPlugin/PartSetPlugin_Part.h index 5b7d63e49..e7f23387c 100644 --- a/src/PartSetPlugin/PartSetPlugin_Part.h +++ b/src/PartSetPlugin/PartSetPlugin_Part.h @@ -43,7 +43,7 @@ class PartSetPlugin_Part : public ModelAPI_Feature /// Request for initialization of data model of the feature: adding all attributes PARTSETPLUGIN_EXPORT virtual void initAttributes(); - PARTSETPLUGIN_EXPORT virtual std::shared_ptr documentToAdd(); + PARTSETPLUGIN_EXPORT virtual const std::string& documentToAdd(); /// Returns true if this feature must be displayed in the history (top level of Part tree) PARTSETPLUGIN_EXPORT virtual bool isInHistory()