From: azv Date: Wed, 27 Apr 2016 11:05:20 +0000 (+0300) Subject: Update SketchPlugin_Projection feature (issue #1459) X-Git-Tag: V_2.3.0~93 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e32f95642855a63da2727cb324ce2a75632a712f;p=modules%2Fshaper.git Update SketchPlugin_Projection feature (issue #1459) --- diff --git a/src/SketchPlugin/SketchPlugin_Projection.cpp b/src/SketchPlugin/SketchPlugin_Projection.cpp index 9adacbb67..6240c933b 100644 --- a/src/SketchPlugin/SketchPlugin_Projection.cpp +++ b/src/SketchPlugin/SketchPlugin_Projection.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -55,7 +56,7 @@ void SketchPlugin_Projection::execute() if (!lastResult().get()) { ResultConstructionPtr aConstr = document()->createConstruction(data()); - aConstr->setShape(std::shared_ptr()); + aConstr->setShape(aProjection->lastResult()->shape()); aConstr->setIsInHistory(false); setResult(aConstr); @@ -75,6 +76,16 @@ void SketchPlugin_Projection::attributeChanged(const std::string& theID) computeProjection(theID); myIsComputing = false; } + else if (theID == AUXILIARY_ID()) + { + AttributeRefAttrPtr aRefAttr = data()->refattr(PROJECTED_FEATURE_ID()); + if (!aRefAttr || !aRefAttr->isInitialized()) + return; + FeaturePtr aProjection = ModelAPI_Feature::feature(aRefAttr->object()); + if (!aProjection) + return; + aProjection->boolean(AUXILIARY_ID())->setValue(boolean(AUXILIARY_ID())->value()); + } } void SketchPlugin_Projection::computeProjection(const std::string& theID) @@ -97,7 +108,8 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID) aProjection = ModelAPI_Feature::feature(aRefAttr->object()); // if the type of feature differs with already selected, remove it and create once again - if (aProjection) { + bool hasPrevProj = aProjection.get() != 0; + if (hasPrevProj) { if ((anEdge->isLine() && aProjection->getKind() != SketchPlugin_Line::ID()) || (anEdge->isCircle() && aProjection->getKind() != SketchPlugin_Circle::ID()) || (anEdge->isArc() && aProjection->getKind() != SketchPlugin_Arc::ID())) { @@ -119,7 +131,7 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID) if (aFirstInSketch->distance(aLastInSketch) < tolerance) return; // line is semi-orthogonal to the sketch plane - if (!aProjection) + if (!hasPrevProj) aProjection = sketch()->addFeature(SketchPlugin_Line::ID()); // update attributes of projection @@ -137,7 +149,7 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID) std::shared_ptr aCenter = aSketchPlane->project(aCircle->center()); std::shared_ptr aCenterInSketch = sketch()->to2D(aCenter); - if (!aProjection) + if (!hasPrevProj) aProjection = sketch()->addFeature(SketchPlugin_Circle::ID()); // update attributes of projection @@ -156,7 +168,7 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID) std::shared_ptr aCenter = aSketchPlane->project(aCircle->center()); std::shared_ptr aCenterInSketch = sketch()->to2D(aCenter); - if (!aProjection) + if (!hasPrevProj) aProjection = sketch()->addFeature(SketchPlugin_Arc::ID()); // update attributes of projection @@ -174,6 +186,12 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID) 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()); } diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index 592f7503d..dab490931 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -139,6 +139,7 @@ label="Edge" tooltip="Select external edge." shape_types="edge" + use_external="false" use_sketch_plane="false">