From: azv Date: Mon, 3 Jun 2019 08:08:12 +0000 (+0300) Subject: Remove external links and features which produce such entities. X-Git-Tag: VEDF2019Lot4~114^2~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3226756c4fe9475a4687aefd5459a3c7d579d28e;p=modules%2Fshaper.git Remove external links and features which produce such entities. --- diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index 811ccb0bf..16527cefe 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -383,8 +383,51 @@ bool SketchPlugin_Sketch::customAction(const std::string& theActionId) return isOk; } +static bool isExternalBased(const FeaturePtr theFeature) +{ + return theFeature->getKind() == SketchPlugin_Projection::ID() || + theFeature->getKind() == SketchPlugin_IntersectionPoint::ID(); +} + bool SketchPlugin_Sketch::removeLinksToExternal() { - // TODO + std::list aRemove; + std::list aSubs = reflist(FEATURES_ID())->list(); + for (std::list::iterator anIt = aSubs.begin(); anIt != aSubs.end(); ++anIt) { + FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt); + if (!aFeature) + continue; + if (isExternalBased(aFeature)) { + // mark feature as to be removed + aRemove.push_back(aFeature); + } + else { + AttributeSelectionPtr anExtAttr = aFeature->selection(SketchPlugin_SketchEntity::EXTERNAL_ID()); + ResultPtr anExternal = anExtAttr ? anExtAttr->context() : ResultPtr(); + if (anExternal) { + FeaturePtr anExtFeature = ModelAPI_Feature::feature(anExternal); + if (anExtFeature && isExternalBased(anExtFeature)) { + // make result of projection/intersection as non-external, + aFeature->selection(SketchPlugin_SketchEntity::EXTERNAL_ID())->setValue( + ObjectPtr(), GeomShapePtr()); + // set feature auxiliary if the parent is not included into sketch result + bool isIncludedToSketchResult = false; + if (anExtFeature->getKind() == SketchPlugin_Projection::ID()) { + isIncludedToSketchResult = anExtFeature->boolean( + SketchPlugin_Projection::INCLUDE_INTO_RESULT())->value(); + } + if (anExtFeature->getKind() == SketchPlugin_IntersectionPoint::ID()) { + isIncludedToSketchResult = anExtFeature->boolean( + SketchPlugin_IntersectionPoint::INCLUDE_INTO_RESULT())->value(); + } + + aFeature->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->setValue( + !isIncludedToSketchResult); + } + } + } + } + for (std::list::iterator anIt = aRemove.begin(); anIt != aRemove.end(); ++anIt) + removeFeature(*anIt); return true; } diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp index a01474bac..44cbf86fd 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp @@ -162,12 +162,12 @@ bool PlaneGCSSolver_Storage::update(FeaturePtr theFeature, bool theForce) { bool sendNotify = false; bool isUpdated = false; + std::shared_ptr aSketchFeature = + std::dynamic_pointer_cast(theFeature); EntityWrapperPtr aRelated = entity(theFeature); if (aRelated) // send signal to subscribers sendNotify = true; else { // Feature is not exist, create it - std::shared_ptr aSketchFeature = - std::dynamic_pointer_cast(theFeature); bool isCopy = isCopyFeature(aSketchFeature); bool isProjReferred = hasReference(aSketchFeature, SketchPlugin_Projection::ID()); // the feature is a copy in "Multi" constraint and does not used in other constraints @@ -196,6 +196,16 @@ bool PlaneGCSSolver_Storage::update(FeaturePtr theFeature, bool theForce) (*anAttrIt)->attributeType() == ModelAPI_AttributeDouble::typeId()) isUpdated = update(*anAttrIt) || isUpdated; + // check external attribute is changed + bool isExternal = aSketchFeature && aSketchFeature->isExternal(); + if (aRelated && isExternal != aRelated->isExternal()) { + if (isExternal) + makeExternal(aRelated); + else + makeNonExternal(aRelated); + isUpdated = true; + } + // send notification to listeners due to at least one attribute is changed if (sendNotify && isUpdated) notify(theFeature);