X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FSketchPlugin_Point.cpp;h=17dbb0a3fe63e4ac097c687e09664a554938b684;hb=b234852f214beada2b07507e1ed35827ce8988c4;hp=6545a6e358d762b9ddaf4dd54b4114b7e2642cc8;hpb=38afbd899a8645c83e17f2c24a17a2b7414911b4;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/SketchPlugin_Point.cpp b/src/SketchPlugin/SketchPlugin_Point.cpp index 6545a6e35..17dbb0a3f 100644 --- a/src/SketchPlugin/SketchPlugin_Point.cpp +++ b/src/SketchPlugin/SketchPlugin_Point.cpp @@ -14,20 +14,21 @@ #include #include - +#include #include #include using namespace std; SketchPlugin_Point::SketchPlugin_Point() + : SketchPlugin_SketchEntity() { } -void SketchPlugin_Point::initAttributes() +void SketchPlugin_Point::initDerivedClassAttributes() { - data()->addAttribute(SketchPlugin_Point::COORD_ID(), GeomDataAPI_Point2D::type()); - data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::type()); + data()->addAttribute(SketchPlugin_Point::COORD_ID(), GeomDataAPI_Point2D::typeId()); + data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::typeId()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EXTERNAL_ID()); } @@ -60,15 +61,20 @@ void SketchPlugin_Point::move(double theDeltaX, double theDeltaY) aPoint1->move(theDeltaX, theDeltaY); } -double SketchPlugin_Point::distanceToPoint(const std::shared_ptr& thePoint) -{ - std::shared_ptr aData = data(); - std::shared_ptr aPoint = std::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Point::COORD_ID())); - - return aPoint->pnt()->distance(thePoint); +bool SketchPlugin_Point::isFixed() { + return data()->selection(EXTERNAL_ID())->context().get() != NULL; } -bool SketchPlugin_Point::isFixed() { - return data()->selection(EXTERNAL_ID())->context(); +void SketchPlugin_Point::attributeChanged(const std::string& theID) { + // the second condition for unability to move external point anywhere + if (theID == EXTERNAL_ID() || isFixed()) { + 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())); + } + } }