From b67c6daf990a0edffeb41739fcd59da49136b39d Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 9 Apr 2015 12:30:52 +0300 Subject: [PATCH] Make external arc possible to create and manipulate --- src/SketchPlugin/SketchPlugin_Arc.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/SketchPlugin/SketchPlugin_Arc.cpp b/src/SketchPlugin/SketchPlugin_Arc.cpp index 026266a30..5599f3b0b 100644 --- a/src/SketchPlugin/SketchPlugin_Arc.cpp +++ b/src/SketchPlugin/SketchPlugin_Arc.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -209,14 +210,28 @@ void SketchPlugin_Arc::attributeChanged(const std::string& theID) { std::shared_ptr aCenterAttr = std::dynamic_pointer_cast< GeomDataAPI_Point2D>(data()->attribute(CENTER_ID())); - if (!aCenterAttr->isInitialized()) - return; std::shared_ptr aStartAttr = std::dynamic_pointer_cast< GeomDataAPI_Point2D>(data()->attribute(START_ID())); - if (!aStartAttr->isInitialized()) - return; std::shared_ptr anEndAttr = std::dynamic_pointer_cast< GeomDataAPI_Point2D>(data()->attribute(END_ID())); + if (theID == EXTERNAL_ID()) { + std::shared_ptr aSelection = data()->selection(EXTERNAL_ID())->value(); + // update arguments due to the selection value + if (aSelection && !aSelection->isNull() && aSelection->isEdge()) { + std::shared_ptr anEdge( new GeomAPI_Edge(aSelection)); + std::shared_ptr aCirc = anEdge->circle(); + if (aCirc.get()) { + aStartAttr->setValue(sketch()->to2D(anEdge->firstPoint())); + anEndAttr->setValue(sketch()->to2D(anEdge->lastPoint())); + aCenterAttr->setValue(sketch()->to2D(aCirc->center())); + } + } + return; + } + if (!aCenterAttr->isInitialized()) + return; + if (!aStartAttr->isInitialized()) + return; if (!anEndAttr->isInitialized()) return; -- 2.39.2