X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_ExternalObjectsMgr.cpp;h=54608476b671021210654dc4ff9ca73fe3a3b1fc;hb=0d9a107853208317a6352bb7f8c77eb54d5efbe1;hp=2ba5b86688e4d2373476f4977238243678234862;hpb=58185df5c4d0877054ea33a0fe8ebded75bd9d7b;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_ExternalObjectsMgr.cpp b/src/PartSet/PartSet_ExternalObjectsMgr.cpp old mode 100644 new mode 100755 index 2ba5b8668..54608476b --- 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,46 +24,74 @@ 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) + const CompositeFeaturePtr& theSketch, + const bool theTemporary) { - ObjectPtr aSelectedObject = PartSet_Tools::findFixedObjectByExternal(theShape->impl(), - theSelectedObject, theSketch); + ObjectPtr aSelectedObject = PartSet_Tools::findFixedObjectByExternal( + theShape->impl(), theSelectedObject, theSketch); if (!aSelectedObject.get()) { // Processing of external (non-sketch) object aSelectedObject = PartSet_Tools::createFixedObjectByExternal(theShape->impl(), - theSelectedObject, theSketch); - if (aSelectedObject.get()) - myExternalObjects.append(aSelectedObject); + theSelectedObject, theSketch, theTemporary); + if (aSelectedObject.get() && theTemporary) + myExternalObjectValidated = aSelectedObject; } return aSelectedObject; } //******************************************************************** void PartSet_ExternalObjectsMgr::removeExternal(const CompositeFeaturePtr& theSketch, - const FeaturePtr& theFeature) + const FeaturePtr& theFeature, + ModuleBase_IWorkshop* theWorkshop, + const bool theTemporary) { - QObjectPtrList::const_iterator anIt = myExternalObjects.begin(), aLast = myExternalObjects.end(); - for (; anIt != aLast; anIt++) { - ObjectPtr anObject = *anIt; - if (anObject.get()) { - DocumentPtr aDoc = anObject->document(); - FeaturePtr aFeature = ModelAPI_Feature::feature(anObject); - if (aFeature.get() != NULL) { - QObjectPtrList anObjects; - 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); - } + if (theTemporary) + removeExternalObject(myExternalObjectValidated, theSketch, theFeature, theWorkshop); +} + +void PartSet_ExternalObjectsMgr::removeExternalObject(const ObjectPtr& theObject, + const CompositeFeaturePtr& /*theSketch*/, + const FeaturePtr& theFeature, + ModuleBase_IWorkshop* theWorkshop) +{ + if (theObject.get()) { + DocumentPtr aDoc = theObject->document(); + FeaturePtr aFeature = ModelAPI_Feature::feature(theObject); + if (aFeature.get() != NULL) { + QObjectPtrList anObjects; + anObjects.append(aFeature); + // the external feature should be removed with all references, sketch feature should be ignored + std::set anIgnoredFeatures; + // 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); + workshop(theWorkshop)->deleteFeatures(anObjects, anIgnoredFeatures); } } - myExternalObjects.clear(); +} + +XGUI_Workshop* PartSet_ExternalObjectsMgr::workshop(ModuleBase_IWorkshop* theWorkshop) +{ + XGUI_ModuleConnector* aConnector = dynamic_cast(theWorkshop); + return aConnector->workshop(); }