From: mpv Date: Fri, 19 Dec 2014 08:54:22 +0000 (+0300) Subject: Make sketch point also selectable from external features and correctly parametrically... X-Git-Tag: V_0.7.0_rc1~62 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=869145c3cd63a59f3d37f7b3d24d3b99afdc2bce;p=modules%2Fshaper.git Make sketch point also selectable from external features and correctly parametrically updated --- diff --git a/src/GeomAPI/GeomAPI_Vertex.cpp b/src/GeomAPI/GeomAPI_Vertex.cpp index 6c3d05e35..4c5190871 100644 --- a/src/GeomAPI/GeomAPI_Vertex.cpp +++ b/src/GeomAPI/GeomAPI_Vertex.cpp @@ -46,5 +46,5 @@ bool GeomAPI_Vertex::isEqual(std::shared_ptr theVert) TopoDS_Vertex aVertex2 = TopoDS::Vertex(aInShape); gp_Pnt aPoint2 = BRep_Tool::Pnt(aVertex2); - return aPoint1.IsEqual(aPoint2, Precision::Confusion()); + return aPoint1.IsEqual(aPoint2, Precision::Confusion()) == Standard_True; } diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index 16c6a25bf..f76344f55 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -264,7 +264,7 @@ bool Model_AttributeSelection::update() // searching for deltas int aVertexNum = 0; if (aSubIds->Contains(aFeatureID + kSTART_VERTEX_DELTA)) aVertexNum = 1; - else if (aSubIds->Contains(aFeatureID + kSTART_VERTEX_DELTA)) aVertexNum = 2; + else if (aSubIds->Contains(aFeatureID + kSTART_VERTEX_DELTA * 2)) aVertexNum = 2; // found the feature with appropriate edge FeaturePtr aFeature = aComposite->subFeature(a); std::list >::const_iterator aResIter = diff --git a/src/SketchPlugin/SketchPlugin_Point.cpp b/src/SketchPlugin/SketchPlugin_Point.cpp index 6545a6e35..97c74f476 100644 --- a/src/SketchPlugin/SketchPlugin_Point.cpp +++ b/src/SketchPlugin/SketchPlugin_Point.cpp @@ -14,7 +14,7 @@ #include #include - +#include #include #include @@ -72,3 +72,16 @@ double SketchPlugin_Point::distanceToPoint(const std::shared_ptr& bool SketchPlugin_Point::isFixed() { return data()->selection(EXTERNAL_ID())->context(); } + +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())); + } + } +} diff --git a/src/SketchPlugin/SketchPlugin_Point.h b/src/SketchPlugin/SketchPlugin_Point.h index a60f9beba..c855dd32a 100644 --- a/src/SketchPlugin/SketchPlugin_Point.h +++ b/src/SketchPlugin/SketchPlugin_Point.h @@ -56,6 +56,9 @@ class SketchPlugin_Point : public SketchPlugin_Feature /// \param thePoint the point virtual double distanceToPoint(const std::shared_ptr& thePoint); + /// Called on change of any argument-attribute of this object: for external point + SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID); + /// Use plugin manager for features creation SketchPlugin_Point(); };