X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_ExternalObjectsMgr.cpp;h=2cdcd24bf149c737ff892b8532d21d23684088df;hb=055d3c94f677cdf74eca05711fe9dcae89035d58;hp=b12f92b5f05e11978614f49697962480d3637b15;hpb=7f92207f4b32a1c02462c40f002e8d7d870529f1;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_ExternalObjectsMgr.cpp b/src/PartSet/PartSet_ExternalObjectsMgr.cpp index b12f92b5f..2cdcd24bf 100644 --- a/src/PartSet/PartSet_ExternalObjectsMgr.cpp +++ b/src/PartSet/PartSet_ExternalObjectsMgr.cpp @@ -8,6 +8,9 @@ #include "PartSet_Tools.h" #include +#include + +#include #include @@ -21,6 +24,22 @@ PartSet_ExternalObjectsMgr::PartSet_ExternalObjectsMgr(const std::string& theExt } } +bool PartSet_ExternalObjectsMgr::isValidObject(const ObjectPtr& theObject) +{ + bool aValid = true; + FeaturePtr aFeature = ModelAPI_Feature::feature(theObject); + // Do check using of external feature + std::shared_ptr aSPFeature = + std::dynamic_pointer_cast(aFeature); + + // Do check that we can use external feature + if (aSPFeature.get() != NULL && aSPFeature->isExternal() && !useExternal()) { + aValid = false; + } + + return aValid; +} + ObjectPtr PartSet_ExternalObjectsMgr::externalObject(const ObjectPtr& theSelectedObject, const GeomShapePtr& theShape, const CompositeFeaturePtr& theSketch) @@ -57,7 +76,8 @@ ObjectPtr PartSet_ExternalObjectsMgr::externalObjectValidated(const ObjectPtr& t //******************************************************************** void PartSet_ExternalObjectsMgr::removeExternal(const CompositeFeaturePtr& theSketch, - const FeaturePtr& theFeature) + const FeaturePtr& theFeature, + ModuleBase_IWorkshop* theWorkshop) { QObjectPtrList::const_iterator anIt = myExternalObjects.begin(), aLast = myExternalObjects.end(); for (; anIt != aLast; anIt++) { @@ -70,13 +90,12 @@ void PartSet_ExternalObjectsMgr::removeExternal(const CompositeFeaturePtr& theSk anObjects.append(aFeature); // the external feature should be removed with all references, sketch feature should be ignored std::set anIgnoredFeatures; - anIgnoredFeatures.insert(theSketch); // the current feature should be ignored, because it can use the external feature in the // attributes and, therefore have a references to it. So, the delete functionality tries // to delete this feature. Test case is creation of a constraint on external point, // use in this control after an external point, the point of the sketch. anIgnoredFeatures.insert(theFeature); - XGUI_Workshop::deleteFeatures(anObjects, anIgnoredFeatures); + workshop(theWorkshop)->deleteFeatures(anObjects, anIgnoredFeatures); } } //removeExternalObject(anObject, theSketch, theFeature); @@ -108,16 +127,18 @@ void PartSet_ExternalObjectsMgr::removeUnusedExternalObjects(const QObjectPtrLis //******************************************************************** void PartSet_ExternalObjectsMgr::removeExternalValidated(const CompositeFeaturePtr& theSketch, - const FeaturePtr& theFeature) + const FeaturePtr& theFeature, + ModuleBase_IWorkshop* theWorkshop) { // TODO(nds): unite with removeExternal(), remove parameters - removeExternalObject(myExternalObjectValidated, theSketch, theFeature); - myExternalObjectValidated = NULL; + removeExternalObject(myExternalObjectValidated, theSketch, theFeature, theWorkshop); + myExternalObjectValidated = ObjectPtr(); } void PartSet_ExternalObjectsMgr::removeExternalObject(const ObjectPtr& theObject, const CompositeFeaturePtr& theSketch, - const FeaturePtr& theFeature) + const FeaturePtr& theFeature, + ModuleBase_IWorkshop* theWorkshop) { if (theObject.get()) { DocumentPtr aDoc = theObject->document(); @@ -127,13 +148,18 @@ void PartSet_ExternalObjectsMgr::removeExternalObject(const ObjectPtr& theObject anObjects.append(aFeature); // the external feature should be removed with all references, sketch feature should be ignored std::set anIgnoredFeatures; - anIgnoredFeatures.insert(theSketch); // the current feature should be ignored, because it can use the external feature in the // attributes and, therefore have a references to it. So, the delete functionality tries // to delete this feature. Test case is creation of a constraint on external point, // use in this control after an external point, the point of the sketch. anIgnoredFeatures.insert(theFeature); - XGUI_Workshop::deleteFeatures(anObjects, anIgnoredFeatures); + workshop(theWorkshop)->deleteFeatures(anObjects, anIgnoredFeatures); } } } + +XGUI_Workshop* PartSet_ExternalObjectsMgr::workshop(ModuleBase_IWorkshop* theWorkshop) +{ + XGUI_ModuleConnector* aConnector = dynamic_cast(theWorkshop); + return aConnector->workshop(); +}