Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_ConstraintDistance.cpp
index db309bae3b9fb51ff85e20311f3508236029ed28..3c46ab4a557ac098c9488f49eca7a04b4a989cf3 100644 (file)
@@ -18,6 +18,8 @@
 
 #include <Config_PropManager.h>
 
+const double tolerance = 1e-7;
+
 SketchPlugin_ConstraintDistance::SketchPlugin_ConstraintDistance()
 {
 }
@@ -98,6 +100,10 @@ bool SketchPlugin_ConstraintDistance::compute(const std::string& theAttributeId)
 
   std::shared_ptr<GeomAPI_Pnt> aPoint1 = sketch()->to3D(aPnt_A->x(), aPnt_A->y());
   std::shared_ptr<GeomAPI_Pnt> aPoint2 = sketch()->to3D(aPnt_B->x(), aPnt_B->y());
+  // it is not possible to create lin2d on the points with equal position
+  if (aPoint1->distance(aPoint1) < tolerance)
+    return false;
+
   std::shared_ptr<GeomAPI_Lin2d> aLine = std::shared_ptr<GeomAPI_Lin2d>(new GeomAPI_Lin2d(aPnt_A, aPnt_B));
   double aDist = aPoint1->distance(aPoint2)/5.;
   std::shared_ptr<GeomAPI_Pnt2d> aFPnt = aLine->shiftedLocation(aDist);
@@ -169,8 +175,8 @@ AISObjectPtr SketchPlugin_ConstraintDistance::getAISObject(AISObjectPtr thePrevi
   anAIS->createDistance(aPoint1, aPoint2, aFlyoutPnt, aPlane, aValue);
 
   // Set color from preferences
-  std::vector<int> aRGB = Config_PropManager::color("Visualization", "distance_color",
-                                                    DISTANCE_COLOR);
+  std::vector<int> aRGB = Config_PropManager::color("Visualization", "sketch_dimension_color",
+                                                    SKETCH_DIMENSION_COLOR);
   anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
   return anAIS;
 }