Salome HOME
#878 Segmentation fault when setting distance on the two same points
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_ConstraintCoincidence.cpp
index fe63928257371a02f9b8f2f6ec4a1257438ff1c7..85a255bfb8fa924fa459ec9bbb82439fb9e35009 100644 (file)
@@ -1,12 +1,18 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:    SketchPlugin_ConstraintCoincidence.cpp
 // Created: 08 May 2014
 // Author:  Artem ZHIDKOV
 
 #include "SketchPlugin_ConstraintCoincidence.h"
 
+#include <SketcherPrs_Factory.h>
+
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_Data.h>
 #include <SketchPlugin_Point.h>
+#include <GeomDataAPI_Dir.h>
+#include <GeomDataAPI_Point.h>
 
 SketchPlugin_ConstraintCoincidence::SketchPlugin_ConstraintCoincidence()
 {
@@ -14,11 +20,22 @@ SketchPlugin_ConstraintCoincidence::SketchPlugin_ConstraintCoincidence()
 
 void SketchPlugin_ConstraintCoincidence::initAttributes()
 {
-  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
-  data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+  data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
 }
 
 void SketchPlugin_ConstraintCoincidence::execute()
 {
 }
 
+AISObjectPtr SketchPlugin_ConstraintCoincidence::getAISObject(AISObjectPtr thePrevious)
+{
+  if (!sketch())
+    return thePrevious;
+
+  AISObjectPtr anAIS = thePrevious;
+  if (!anAIS) {
+    anAIS = SketcherPrs_Factory::coincidentConstraint(this, sketch()->coordinatePlane());
+  }
+  return anAIS;
+}