]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Create line with coincidence on an other line
authorvsv <vitaly.smetannikov@opencascade.com>
Tue, 12 May 2015 16:26:51 +0000 (19:26 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Tue, 12 May 2015 16:26:51 +0000 (19:26 +0300)
src/PartSet/PartSet_WidgetPoint2d.cpp

index b49330a6b905764efd807fd9a6abda7320be0325..3d8c89ad1871602e7608812c70376eb572a6ed4f 100644 (file)
@@ -31,6 +31,7 @@
 #include <GeomAPI_Pnt2d.h>
 
 #include <SketchPlugin_Feature.h>
+#include <SketchPlugin_ConstraintCoincidence.h>
 
 #include <QGroupBox>
 #include <QGridLayout>
@@ -212,8 +213,7 @@ void PartSet_WidgetPoint2D::activateCustom()
 
   QIntList aModes;
   aModes << TopAbs_VERTEX;
-  if (isEditingMode())
-    aModes << TopAbs_EDGE;
+  aModes << TopAbs_EDGE;
   myWorkshop->moduleConnector()->activateSubShapesSelection(aModes);
 }
 
@@ -281,6 +281,25 @@ void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMous
       emit vertexSelected();
       emit focusOutWidget(this);
       return;
+    } else if (aShape.ShapeType() == TopAbs_EDGE) {
+      // Create point-edge coincedence
+      FeaturePtr aFeature = mySketch->addFeature(SketchPlugin_ConstraintCoincidence::ID());
+      std::shared_ptr<ModelAPI_Data> aData = aFeature->data();
+
+      std::shared_ptr<ModelAPI_AttributeRefAttr> aRef1 = std::dynamic_pointer_cast<
+          ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
+      AttributePtr aThisAttr = feature()->data()->attribute(attributeID());
+      std::shared_ptr<GeomDataAPI_Point2D> aThisPoint = 
+        std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aThisAttr);
+      aRef1->setAttr(aThisPoint);
+
+      std::shared_ptr<ModelAPI_AttributeRefAttr> aRef2 = std::dynamic_pointer_cast<
+          ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_B()));
+      aRef2->setObject(aObject);
+      aFeature->execute();
+      emit vertexSelected();
+      emit focusOutWidget(this);
+      return;
     }
   }
   // End of Bug dependent fragment