From: azv Date: Fri, 22 Apr 2016 07:50:08 +0000 (+0300) Subject: Update SketchPlugin_Projection X-Git-Tag: V_2.3.0~141 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0fe7f1dfd08e026cc2a6fe8561724416a7fc82f7;p=modules%2Fshaper.git Update SketchPlugin_Projection --- diff --git a/src/SketchPlugin/SketchPlugin_Projection.cpp b/src/SketchPlugin/SketchPlugin_Projection.cpp index de39ac781..c4af99b80 100644 --- a/src/SketchPlugin/SketchPlugin_Projection.cpp +++ b/src/SketchPlugin/SketchPlugin_Projection.cpp @@ -53,56 +53,14 @@ void SketchPlugin_Projection::execute() return; FeaturePtr aProjection = ModelAPI_Feature::feature(aRefAttr->object()); - bool hasResult = lastResult(); + if (!lastResult()) { + ResultConstructionPtr aConstr = document()->createConstruction(data()); + aConstr->setShape(std::shared_ptr()); + aConstr->setIsInHistory(false); + setResult(aConstr); - std::shared_ptr anEdge; - if (aProjection->getKind() == SketchPlugin_Line::ID()) { - std::shared_ptr aStartPnt = std::dynamic_pointer_cast( - aProjection->attribute(SketchPlugin_Line::START_ID())); - std::shared_ptr aEndPnt = std::dynamic_pointer_cast( - aProjection->attribute(SketchPlugin_Line::END_ID())); - - // edge to store result - std::shared_ptr aFirst = sketch()->to3D(aStartPnt->x(), aStartPnt->y()); - std::shared_ptr aLast = sketch()->to3D(aEndPnt->x(), aEndPnt->y()); - anEdge = GeomAlgoAPI_EdgeBuilder::line(aFirst, aLast); - } - else { - std::shared_ptr aSketchPlane = sketch()->plane(); - std::shared_ptr aNormal = aSketchPlane->direction(); - - if (aProjection->getKind() == SketchPlugin_Circle::ID()) { - std::shared_ptr aCenterPnt = std::dynamic_pointer_cast( - aProjection->attribute(SketchPlugin_Circle::CENTER_ID())); - - // edge to store result - std::shared_ptr aCenter = sketch()->to3D(aCenterPnt->x(), aCenterPnt->y()); - double aRadius = aProjection->real(SketchPlugin_Circle::RADIUS_ID())->value(); - anEdge = GeomAlgoAPI_EdgeBuilder::lineCircle(aCenter, aNormal, aRadius); - } - else if (aProjection->getKind() == SketchPlugin_Arc::ID()) { - std::shared_ptr aCenterPnt = std::dynamic_pointer_cast( - aProjection->attribute(SketchPlugin_Arc::CENTER_ID())); - std::shared_ptr aStartPnt = std::dynamic_pointer_cast( - aProjection->attribute(SketchPlugin_Arc::START_ID())); - std::shared_ptr aEndPnt = std::dynamic_pointer_cast( - aProjection->attribute(SketchPlugin_Arc::END_ID())); - - // edge to store result - std::shared_ptr aCenter = sketch()->to3D(aCenterPnt->x(), aCenterPnt->y()); - std::shared_ptr aFirst = sketch()->to3D(aStartPnt->x(), aStartPnt->y()); - std::shared_ptr aLast = sketch()->to3D(aEndPnt->x(), aEndPnt->y()); - anEdge = GeomAlgoAPI_EdgeBuilder::lineCircleArc(aCenter, aFirst, aLast, aNormal); - } - } - - std::shared_ptr aConstr = document()->createConstruction(data()); - aConstr->setShape(anEdge); - aConstr->setIsInHistory(false); - setResult(aConstr); - - if (!hasResult) aProjection->selection(EXTERNAL_ID())->setValue(lastResult(), lastResult()->shape()); + } } void SketchPlugin_Projection::move(double theDeltaX, double theDeltaY) diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index 3a03d1474..f30753752 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -107,7 +107,7 @@ - + - - + +