Salome HOME
Auxiliary state for Intersection point
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_ConstraintAngle.cpp
index 7874be39513f2c17c99082de801dbabbed27d366..ef711f6a5af03db16b692cfa6eba9e1d02208da9 100644 (file)
@@ -40,6 +40,14 @@ void SketchPlugin_ConstraintAngle::initAttributes()
   data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
 }
 
+void SketchPlugin_ConstraintAngle::colorConfigInfo(std::string& theSection, std::string& theName,
+                                                   std::string& theDefault)
+{
+  theSection = "Visualization";
+  theName = "sketch_dimension_color";
+  theDefault = SKETCH_DIMENSION_COLOR;
+}
+
 void SketchPlugin_ConstraintAngle::execute()
 {
   std::shared_ptr<ModelAPI_Data> aData = data();
@@ -70,15 +78,8 @@ AISObjectPtr SketchPlugin_ConstraintAngle::getAISObject(AISObjectPtr thePrevious
   if (!sketch())
     return thePrevious;
 
-  AISObjectPtr anAIS = thePrevious;
-  if (!anAIS) {
-    anAIS = SketcherPrs_Factory::angleConstraint(this, sketch()->coordinatePlane());
-  }
-
-  // Set color from preferences
-  std::vector<int> aRGB = Config_PropManager::color("Visualization", "sketch_dimension_color",
-                                                    SKETCH_DIMENSION_COLOR);
-  anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
+  AISObjectPtr anAIS = SketcherPrs_Factory::angleConstraint(this, sketch()->coordinatePlane(),
+                                                            thePrevious);
   return anAIS;
 }
 
@@ -160,24 +161,14 @@ double SketchPlugin_ConstraintAngle::calculateAngle()
   };
 
   // Directions of lines
-  if (aDist[0][1] < tolerance)
+  if (aDist[0][0] > aDist[0][1])
     aEndA = aStartA;
-  if (aDist[1][1] < tolerance)
+  if (aDist[1][0] > aDist[1][1])
     aEndB = aStartB;
   std::shared_ptr<GeomAPI_Dir2d> aDirA(new GeomAPI_Dir2d(aEndA->xy()->decreased(anInter->xy())));
   std::shared_ptr<GeomAPI_Dir2d> aDirB(new GeomAPI_Dir2d(aEndB->xy()->decreased(anInter->xy())));
 
   anAngle = fabs(aDirA->angle(aDirB)) * 180.0 / PI;
-
-  // If the lines intersected inside one of them, the angle selected is less than 90 degrees
-  if ((aDist[0][0] >= tolerance && aDist[0][1] >= tolerance &&
-      aDist[0][0] + aDist[0][1] < aStartA->distance(aEndA) + 2.0 * tolerance) ||
-      (aDist[1][0] >= tolerance && aDist[1][1] >= tolerance &&
-      aDist[1][0] + aDist[1][1] < aStartB->distance(aEndB) + 2.0 * tolerance)) {
-    if (anAngle > 90.0)
-      anAngle = 180.0 - anAngle;
-  }
-
   return anAngle;
 }