Salome HOME
Merge branch 'Dev_1.2.0' of newgeom:newgeom.git into Dev_1.2.0
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_ConstraintCoincidence.cpp
index 6cd5c1b582cb3c36798bf6e5726285dd2d2fca38..ce8fa25de2daa4b3f1637189d2bf912210e683ef 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,17 +20,25 @@ SketchPlugin_ConstraintCoincidence::SketchPlugin_ConstraintCoincidence()
 
 void SketchPlugin_ConstraintCoincidence::initAttributes()
 {
-  data()->addAttribute(CONSTRAINT_ATTR_ENTITY_A, ModelAPI_AttributeRefAttr::type());
-  data()->addAttribute(CONSTRAINT_ATTR_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()
 {
 }
 
-const boost::shared_ptr<GeomAPI_Shape>&  SketchPlugin_ConstraintCoincidence::preview()
+AISObjectPtr SketchPlugin_ConstraintCoincidence::getAISObject(AISObjectPtr thePrevious)
 {
-  /// \todo Preview for point coincidence
-  return getPreview();
-}
+  if (!sketch())
+    return thePrevious;
 
+  AISObjectPtr anAIS = thePrevious;
+  if (!anAIS) {
+    anAIS = SketcherPrs_Factory::coincidentConstraint(this, sketch()->coordinatePlane());
+  std::vector<int> aRGB = Config_PropManager::color("Visualization", "sketch_constraint_color",
+                                                    SKETCH_DIMENSION_COLOR);
+  anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
+  }
+  return anAIS;
+}