From b0d2c2eb9107fe9e69b321bfc0ecba9cb5eab961 Mon Sep 17 00:00:00 2001 From: mpv Date: Fri, 4 Apr 2014 17:41:54 +0400 Subject: [PATCH] Don't add the feature on iteration: bug fix --- src/Model/Model_AttributeDouble.cxx | 1 - src/Model/Model_Document.cxx | 3 ++- src/Model/Model_PluginManager.cxx | 5 +++-- src/Model/Model_PluginManager.h | 3 ++- src/ModelAPI/ModelAPI.i | 3 +++ src/ModelAPI/ModelAPI_Plugin.h | 3 ++- src/ModelAPI/ModelAPI_PluginManager.h | 3 ++- src/PartSetPlugin/PartSetPlugin_Plugin.cxx | 5 +++-- src/PartSetPlugin/PartSetPlugin_Plugin.h | 3 ++- 9 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/Model/Model_AttributeDouble.cxx b/src/Model/Model_AttributeDouble.cxx index 7e2ed83e1..23e15f0e1 100644 --- a/src/Model/Model_AttributeDouble.cxx +++ b/src/Model/Model_AttributeDouble.cxx @@ -24,4 +24,3 @@ Model_AttributeDouble::Model_AttributeDouble(TDF_Label& theLabel) myReal = TDataStd_Real::Set(theLabel, 0.); } } - diff --git a/src/Model/Model_Document.cxx b/src/Model/Model_Document.cxx index d435a0127..8ae42585b 100644 --- a/src/Model/Model_Document.cxx +++ b/src/Model/Model_Document.cxx @@ -177,7 +177,8 @@ std::shared_ptr Model_Document::feature(TDF_Label& theLabel) Handle(TDataStd_Comment) aFeatureID; if (theLabel.FindAttribute(TDataStd_Comment::GetID(), aFeatureID)) { string anID(TCollection_AsciiString(aFeatureID->Get()).ToCString()); - std::shared_ptr aResult = Model_PluginManager::get()->createFeature(anID); + std::shared_ptr aResult = + Model_PluginManager::get()->createFeature(anID, false); std::shared_ptr aData(new Model_Object); aData->setLabel(theLabel); aResult->setData(aData); diff --git a/src/Model/Model_PluginManager.cxx b/src/Model/Model_PluginManager.cxx index ce53ba069..4c3e3da6d 100644 --- a/src/Model/Model_PluginManager.cxx +++ b/src/Model/Model_PluginManager.cxx @@ -16,7 +16,8 @@ using namespace std; static Model_PluginManager* myImpl = new Model_PluginManager(); -std::shared_ptr Model_PluginManager::createFeature(string theFeatureID) +std::shared_ptr Model_PluginManager::createFeature( + string theFeatureID, const bool theAddToDoc) { if (this != myImpl) return myImpl->createFeature(theFeatureID); @@ -29,7 +30,7 @@ std::shared_ptr Model_PluginManager::createFeature(string theF } if (myPluginObjs.find(myCurrentPluginName) != myPluginObjs.end()) { std::shared_ptr aCreated = - myPluginObjs[myCurrentPluginName]->createFeature(theFeatureID); + myPluginObjs[myCurrentPluginName]->createFeature(theFeatureID, theAddToDoc); return aCreated; } } diff --git a/src/Model/Model_PluginManager.h b/src/Model/Model_PluginManager.h index c0cc31e5f..64811f82f 100644 --- a/src/Model/Model_PluginManager.h +++ b/src/Model/Model_PluginManager.h @@ -28,7 +28,8 @@ class Model_PluginManager : public ModelAPI_PluginManager, public Event_Listener std::shared_ptr myCurrentDoc; ///< current working document public: /// Creates the feature object using plugins functionality - MODEL_EXPORT virtual std::shared_ptr createFeature(std::string theFeatureID); + MODEL_EXPORT virtual std::shared_ptr createFeature( + std::string theFeatureID, const bool theAddToDoc = true); /// Returns the root document of the application (that may contains sub-documents) MODEL_EXPORT virtual std::shared_ptr rootDocument(); diff --git a/src/ModelAPI/ModelAPI.i b/src/ModelAPI/ModelAPI.i index ad58d4228..96d4414a9 100644 --- a/src/ModelAPI/ModelAPI.i +++ b/src/ModelAPI/ModelAPI.i @@ -9,6 +9,7 @@ #include "ModelAPI_Attribute.h" #include "ModelAPI_AttributeDocRef.h" #include "ModelAPI_AttributeDouble.h" + #include "ModelAPI_Iterator.h" %} // to avoid error on this @@ -28,6 +29,7 @@ %shared_ptr(ModelAPI_Attribute) %shared_ptr(ModelAPI_AttributeDocRef) %shared_ptr(ModelAPI_AttributeDouble) +%shared_ptr(ModelAPI_Iterator) // all supported interfaces %include "ModelAPI_Document.h" @@ -37,3 +39,4 @@ %include "ModelAPI_Attribute.h" %include "ModelAPI_AttributeDocRef.h" %include "ModelAPI_AttributeDouble.h" +%include "ModelAPI_Iterator.h" diff --git a/src/ModelAPI/ModelAPI_Plugin.h b/src/ModelAPI/ModelAPI_Plugin.h index 0605d8b6f..f26cab7b0 100644 --- a/src/ModelAPI/ModelAPI_Plugin.h +++ b/src/ModelAPI/ModelAPI_Plugin.h @@ -20,7 +20,8 @@ class MODELAPI_EXPORT ModelAPI_Plugin { public: /// Creates the feature object of this plugin by the feature string ID - virtual std::shared_ptr createFeature(std::string theFeatureID) = 0; + virtual std::shared_ptr createFeature( + std::string theFeatureID, const bool theAddToDoc) = 0; protected: /// Is needed for python wrapping by swig diff --git a/src/ModelAPI/ModelAPI_PluginManager.h b/src/ModelAPI/ModelAPI_PluginManager.h index 34e5cca94..fdf8e69eb 100644 --- a/src/ModelAPI/ModelAPI_PluginManager.h +++ b/src/ModelAPI/ModelAPI_PluginManager.h @@ -24,7 +24,8 @@ class MODELAPI_EXPORT ModelAPI_PluginManager { public: /// Creates the feature object using plugins functionality - virtual std::shared_ptr createFeature(std::string theFeatureID) = 0; + virtual std::shared_ptr createFeature(std::string theFeatureID, + const bool theAddToDoc = true) = 0; /// Returns the real implementation (the alone instance per application) of the plugin manager static std::shared_ptr get(); diff --git a/src/PartSetPlugin/PartSetPlugin_Plugin.cxx b/src/PartSetPlugin/PartSetPlugin_Plugin.cxx index c1998aefa..89f7084fa 100644 --- a/src/PartSetPlugin/PartSetPlugin_Plugin.cxx +++ b/src/PartSetPlugin/PartSetPlugin_Plugin.cxx @@ -15,7 +15,8 @@ PartSetPlugin_Plugin::PartSetPlugin_Plugin() ModelAPI_PluginManager::get()->registerPlugin(this); } -std::shared_ptr PartSetPlugin_Plugin::createFeature(string theFeatureID) +std::shared_ptr PartSetPlugin_Plugin::createFeature( + string theFeatureID, const bool theAddToDoc) { std::shared_ptr aCreated; bool isCurrent = true; // to create a feature in the current document @@ -27,7 +28,7 @@ std::shared_ptr PartSetPlugin_Plugin::createFeature(string the } // add to a root document for the current moment - if (aCreated) { + if (aCreated && theAddToDoc) { shared_ptr aDoc = isCurrent ? ModelAPI_PluginManager::get()->currentDocument() : ModelAPI_PluginManager::get()->rootDocument(); diff --git a/src/PartSetPlugin/PartSetPlugin_Plugin.h b/src/PartSetPlugin/PartSetPlugin_Plugin.h index 74f6e73c0..a4c7e336d 100644 --- a/src/PartSetPlugin/PartSetPlugin_Plugin.h +++ b/src/PartSetPlugin/PartSetPlugin_Plugin.h @@ -13,7 +13,8 @@ class PARTSETPLUGIN_EXPORT PartSetPlugin_Plugin: public ModelAPI_Plugin { public: /// Creates the feature object of this plugin by the feature string ID - virtual std::shared_ptr createFeature(std::string theFeatureID); + virtual std::shared_ptr createFeature( + std::string theFeatureID, const bool theAddToDoc); public: /// Is needed for python wrapping by swig -- 2.39.2