X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FSketchPlugin_Projection.cpp;h=2a034e0f5f72c8bd6db7f6e6ab68263df23e8c41;hb=b5893b0a30fac08134c24de4565cb513a43affa6;hp=5cccf4c2bad3ed7b5be4c778e7eb6fe502da12a5;hpb=947de864e5ab5bb127e34c316b9ac37a5418cc4b;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/SketchPlugin_Projection.cpp b/src/SketchPlugin/SketchPlugin_Projection.cpp index 5cccf4c2b..2a034e0f5 100644 --- a/src/SketchPlugin/SketchPlugin_Projection.cpp +++ b/src/SketchPlugin/SketchPlugin_Projection.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -65,6 +66,10 @@ void SketchPlugin_Projection::execute() aProjection->selection(EXTERNAL_ID())->setValue(lastResult(), lastResult()->shape()); } + + // is sketch plane is changed (issue 1791), attribute of projection is not changed, but + // projection must be fully recomputed + computeProjection(EXTERNAL_FEATURE_ID()); } void SketchPlugin_Projection::move(double theDeltaX, double theDeltaY) @@ -89,7 +94,8 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID) std::shared_ptr anEdge; if (aExtFeature && aExtFeature->value() && aExtFeature->value()->isEdge()) { anEdge = std::shared_ptr(new GeomAPI_Edge(aExtFeature->value())); - } else if (aExtFeature->context() && aExtFeature->context()->shape() && aExtFeature->context()->shape()->isEdge()) { + } else if (aExtFeature->context() && aExtFeature->context()->shape() && + aExtFeature->context()->shape()->isEdge()) { anEdge = std::shared_ptr(new GeomAPI_Edge(aExtFeature->context()->shape())); } if (!anEdge.get()) @@ -107,7 +113,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); } @@ -117,7 +126,7 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID) ResultConstructionPtr aResult = std::dynamic_pointer_cast(lastResult()); - if (aResult && aResult->shape()) { + if (aResult && aResult->shape() && theID == EXTERNAL_FEATURE_ID()) { aResult->setShape(std::shared_ptr()); aProjection->selection(EXTERNAL_ID())->setValue(lastResult(), lastResult()->shape()); } @@ -153,7 +162,8 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID) aProjection = sketch()->addFeature(SketchPlugin_Circle::ID()); // update attributes of projection - std::shared_ptr aCenterPnt = std::dynamic_pointer_cast( + std::shared_ptr aCenterPnt = + std::dynamic_pointer_cast( aProjection->attribute(SketchPlugin_Circle::CENTER_ID())); aCenterPnt->setValue(aCenterInSketch); aProjection->real(SketchPlugin_Circle::RADIUS_ID())->setValue(aRadius); @@ -172,28 +182,26 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID) aProjection = sketch()->addFeature(SketchPlugin_Arc::ID()); // update attributes of projection - std::shared_ptr aCenterPnt = std::dynamic_pointer_cast( + std::shared_ptr aCenterPnt = + std::dynamic_pointer_cast( aProjection->attribute(SketchPlugin_Arc::CENTER_ID())); - std::shared_ptr aStartPnt = std::dynamic_pointer_cast( + std::shared_ptr aStartPnt = + std::dynamic_pointer_cast( aProjection->attribute(SketchPlugin_Arc::START_ID())); - std::shared_ptr aEndPnt = std::dynamic_pointer_cast( + std::shared_ptr aEndPnt = + std::dynamic_pointer_cast( aProjection->attribute(SketchPlugin_Arc::END_ID())); aStartPnt->setValue(aFirstInSketch); aEndPnt->setValue(aLastInSketch); aCenterPnt->setValue(aCenterInSketch); } + aProjection->boolean(COPY_ID())->setValue(true); aProjection->execute(); aRefAttr->setObject(aProjection); - if (!hasPrevProj) { - FeaturePtr aFixed = sketch()->addFeature(SketchPlugin_ConstraintRigid::ID()); - aFixed->refattr(SketchPlugin_Constraint::ENTITY_A())->setObject(aProjection->lastResult()); - aFixed->execute(); - } - if (theID == EXTERNAL_FEATURE_ID()) { - selection(EXTERNAL_ID())->setValue(aExtFeature->context(), aExtFeature->context()->shape()); + selection(EXTERNAL_ID())->setValue(aExtFeature->context(), aExtFeature->value()); if (aResult) { aResult->setShape(aProjection->lastResult()->shape());