From: nds Date: Thu, 19 May 2016 09:05:05 +0000 (+0300) Subject: Issue #1489 Multi-rotation problem if there is a reference to copied objects X-Git-Tag: V_2.3.1~81 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ae33c07e2efa77780d5a45079a625ae4b8824090;p=modules%2Fshaper.git Issue #1489 Multi-rotation problem if there is a reference to copied objects --- diff --git a/src/SketchPlugin/SketchPlugin_Arc.cpp b/src/SketchPlugin/SketchPlugin_Arc.cpp index 18380c7ec..29031a04b 100644 --- a/src/SketchPlugin/SketchPlugin_Arc.cpp +++ b/src/SketchPlugin/SketchPlugin_Arc.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -751,10 +752,12 @@ void SketchPlugin_Arc::tangencyArcConstraints() // Remove all obtained constraints which use current arc, because // there is no information which of them were used to build tangency arc. DocumentPtr aDoc = sketch()->document(); + std::set aFeaturesToBeRemoved; for (aCIt = aCoincidence.begin(); aCIt != aCoincidence.end(); ++aCIt) - aDoc->removeFeature(*aCIt); + aFeaturesToBeRemoved.insert(*aCIt); for (aTIt = aTangency.begin(); aTIt != aTangency.end(); ++aTIt) - aDoc->removeFeature(*aTIt); + aFeaturesToBeRemoved.insert(*aTIt); + ModelAPI_Tools::removeFeaturesAndReferences(aFeaturesToBeRemoved); // Send events to update the sub-features by the solver. if (isDeleteFlushed) Events_Loop::loop()->setFlushed(aDeleteEvent, true); diff --git a/src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp b/src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp index e17a704c5..2161806eb 100755 --- a/src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -70,6 +71,7 @@ void SketchPlugin_ConstraintMirror::execute() std::list::iterator anInitIter = anInitialList.begin(); std::list::iterator aMirrorIter = aMirroredList.begin(); std::vector::iterator aUsedIter = isUsed.begin(); + std::set aFeaturesToBeRemoved; for (; aUsedIter != isUsed.end(); aUsedIter++) { if (!(*aUsedIter)) { aRefListOfShapes->remove(*anInitIter); @@ -81,7 +83,7 @@ void SketchPlugin_ConstraintMirror::execute() DocumentPtr aDoc = aRC ? aRC->document() : DocumentPtr(); FeaturePtr aFeature = aDoc ? aDoc->feature(aRC) : FeaturePtr(); if (aFeature) - aDoc->removeFeature(aFeature); + aFeaturesToBeRemoved.insert(aFeature); } } if (anInitIter != anInitialList.end()) @@ -89,6 +91,7 @@ void SketchPlugin_ConstraintMirror::execute() if (aMirrorIter != aMirroredList.end()) aMirrorIter++; } + ModelAPI_Tools::removeFeaturesAndReferences(aFeaturesToBeRemoved); static Events_ID aRedisplayEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY); diff --git a/src/SketchPlugin/SketchPlugin_MultiRotation.cpp b/src/SketchPlugin/SketchPlugin_MultiRotation.cpp index 4737cd172..0ef30f7a1 100755 --- a/src/SketchPlugin/SketchPlugin_MultiRotation.cpp +++ b/src/SketchPlugin/SketchPlugin_MultiRotation.cpp @@ -121,7 +121,6 @@ void SketchPlugin_MultiRotation::execute() FeaturePtr aFeature = aDoc ? aDoc->feature(aRC) : FeaturePtr(); if (aFeature) aFeaturesToBeRemoved.insert(aFeature); - //aDoc->removeFeature(aFeature); } } else { for (int i = 0; i <= aNbCopies && aTargetIter != aTargetList.end(); i++) @@ -165,7 +164,6 @@ void SketchPlugin_MultiRotation::execute() FeaturePtr aFeature = aDoc ? aDoc->feature(aRC) : FeaturePtr(); if (aFeature) aFeaturesToBeRemoved.insert(aFeature); - //aDoc->removeFeature(aFeature); } ind++; } @@ -350,7 +348,6 @@ void SketchPlugin_MultiRotation::attributeChanged(const std::string& theID) FeaturePtr aFeature = aDoc ? aDoc->feature(aRC) : FeaturePtr(); if (aFeature) aFeaturesToBeRemoved.insert(aFeature); - //aDoc->removeFeature(aFeature); } } ModelAPI_Tools::removeFeaturesAndReferences(aFeaturesToBeRemoved); diff --git a/src/SketchPlugin/SketchPlugin_MultiTranslation.cpp b/src/SketchPlugin/SketchPlugin_MultiTranslation.cpp index 5e0a93098..d6e1d5dd2 100755 --- a/src/SketchPlugin/SketchPlugin_MultiTranslation.cpp +++ b/src/SketchPlugin/SketchPlugin_MultiTranslation.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -104,6 +105,7 @@ void SketchPlugin_MultiTranslation::execute() std::list::iterator anInitIter = anInitialList.begin(); std::list::iterator aTargetIter = aTargetList.begin(); std::vector::iterator aUsedIter = isUsed.begin(); + std::set aFeaturesToBeRemoved; for (; aUsedIter != isUsed.end(); aUsedIter++) { if (!(*aUsedIter)) { aRefListOfShapes->remove(*anInitIter); @@ -116,7 +118,7 @@ void SketchPlugin_MultiTranslation::execute() DocumentPtr aDoc = aRC ? aRC->document() : DocumentPtr(); FeaturePtr aFeature = aDoc ? aDoc->feature(aRC) : FeaturePtr(); if (aFeature) - aDoc->removeFeature(aFeature); + aFeaturesToBeRemoved.insert(aFeature); } } else { for (int i = 0; i <= aNbCopies && aTargetIter != aTargetList.end(); i++) @@ -125,6 +127,7 @@ void SketchPlugin_MultiTranslation::execute() if (anInitIter != anInitialList.end()) anInitIter++; } + ModelAPI_Tools::removeFeaturesAndReferences(aFeaturesToBeRemoved); // change number of copies if (aCurrentNbCopies != 0 && aNbCopies != aCurrentNbCopies) { bool isAdd = aNbCopies > aCurrentNbCopies; diff --git a/src/SketchPlugin/SketchPlugin_Projection.cpp b/src/SketchPlugin/SketchPlugin_Projection.cpp index 36df5bb1e..eaf073c8b 100644 --- a/src/SketchPlugin/SketchPlugin_Projection.cpp +++ b/src/SketchPlugin/SketchPlugin_Projection.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -107,7 +108,10 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID) (anEdge->isCircle() && aProjection->getKind() != SketchPlugin_Circle::ID()) || (anEdge->isArc() && aProjection->getKind() != SketchPlugin_Arc::ID())) { DocumentPtr aDoc = sketch()->document(); - aDoc->removeFeature(aProjection); + + std::set aFeaturesToBeRemoved; + aFeaturesToBeRemoved.insert(aProjection); + ModelAPI_Tools::removeFeaturesAndReferences(aFeaturesToBeRemoved); aProjection = FeaturePtr(); aRefAttr->setObject(aProjection); }