X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FSketchPlugin_Point.cpp;h=798140611b2755a7b86248a055617fa84aed4e44;hb=074b1d850036614d4a08999c4bc4e8630db63d2b;hp=6545a6e358d762b9ddaf4dd54b4114b7e2642cc8;hpb=3874b57fe5aba25ff5aee2a07654fc23c1ee8eb0;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/SketchPlugin_Point.cpp b/src/SketchPlugin/SketchPlugin_Point.cpp index 6545a6e35..798140611 100644 --- a/src/SketchPlugin/SketchPlugin_Point.cpp +++ b/src/SketchPlugin/SketchPlugin_Point.cpp @@ -14,18 +14,21 @@ #include #include - +#include #include #include using namespace std; SketchPlugin_Point::SketchPlugin_Point() + : SketchPlugin_SketchEntity() { } void SketchPlugin_Point::initAttributes() { + SketchPlugin_SketchEntity::initAttributes(); + data()->addAttribute(SketchPlugin_Point::COORD_ID(), GeomDataAPI_Point2D::type()); data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::type()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EXTERNAL_ID()); @@ -70,5 +73,18 @@ double SketchPlugin_Point::distanceToPoint(const std::shared_ptr& } bool SketchPlugin_Point::isFixed() { - return data()->selection(EXTERNAL_ID())->context(); + return data()->selection(EXTERNAL_ID())->context().get(); +} + +void SketchPlugin_Point::attributeChanged(const std::string& theID) { + 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->isVertex()) { + std::shared_ptr aVertex(new GeomAPI_Vertex(aSelection)); + std::shared_ptr aCoordAttr = + std::dynamic_pointer_cast(attribute(COORD_ID())); + aCoordAttr->setValue(sketch()->to2D(aVertex->point())); + } + } }