]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Make sketch point also selectable from external features and correctly parametrically...
authormpv <mikhail.ponikarov@opencascade.com>
Fri, 19 Dec 2014 08:54:22 +0000 (11:54 +0300)
committermpv <mikhail.ponikarov@opencascade.com>
Fri, 19 Dec 2014 08:54:22 +0000 (11:54 +0300)
src/GeomAPI/GeomAPI_Vertex.cpp
src/Model/Model_AttributeSelection.cpp
src/SketchPlugin/SketchPlugin_Point.cpp
src/SketchPlugin/SketchPlugin_Point.h

index 6c3d05e3556f1caff93dccd40fb1d07eb92f080e..4c51908717d167c62bea1a59c1b12246ded02696 100644 (file)
@@ -46,5 +46,5 @@ bool GeomAPI_Vertex::isEqual(std::shared_ptr<GeomAPI_Shape> 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;
 }
index 16c6a25bffe76b109cec2031176ad22d22bf4089..f76344f552f6d0e976e26a7910c6dccb6b6c1666 100644 (file)
@@ -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<std::shared_ptr<ModelAPI_Result> >::const_iterator aResIter =
index 6545a6e358d762b9ddaf4dd54b4114b7e2642cc8..97c74f4760dbfc4f52e4e3bab14563effcd24c5f 100644 (file)
@@ -14,7 +14,7 @@
 #include <ModelAPI_Session.h>
 
 #include <GeomAPI_Pnt2d.h>
-
+#include <GeomAPI_Vertex.h>
 #include <GeomDataAPI_Point2D.h>
 #include <GeomAlgoAPI_PointBuilder.h>
 
@@ -72,3 +72,16 @@ double SketchPlugin_Point::distanceToPoint(const std::shared_ptr<GeomAPI_Pnt2d>&
 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<GeomAPI_Shape> aSelection = data()->selection(EXTERNAL_ID())->value();
+     // update arguments due to the selection value
+    if (aSelection && !aSelection->isNull() && aSelection->isVertex()) {
+      std::shared_ptr<GeomAPI_Vertex> aVertex(new GeomAPI_Vertex(aSelection));
+      std::shared_ptr<GeomDataAPI_Point2D> aCoordAttr = 
+        std::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(COORD_ID()));
+      aCoordAttr->setValue(sketch()->to2D(aVertex->point()));
+    }
+  }
+}
index a60f9bebab70a1e73c8619b6ebda4125aaca165e..c855dd32a95284c1d72cbbfa92213b7f2436d4d6 100644 (file)
@@ -56,6 +56,9 @@ class SketchPlugin_Point : public SketchPlugin_Feature
   /// \param thePoint the point
   virtual double distanceToPoint(const std::shared_ptr<GeomAPI_Pnt2d>& 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();
 };