- boost::shared_ptr<GeomAPI_Pln> aPlane = sketch()->plane();
-
- DataPtr aData = data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint_A = getFeaturePoint(aData, SketchPlugin_Constraint::ENTITY_A());
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint_B = getFeaturePoint(aData, SketchPlugin_Constraint::ENTITY_B());
-
- boost::shared_ptr<GeomAPI_Pnt2d> aPnt_A;
- boost::shared_ptr<GeomAPI_Pnt2d> aPnt_B;
-
- if (aPoint_A && aPoint_B) {
- aPnt_A = aPoint_A->pnt();
- aPnt_B = aPoint_B->pnt();
- } else if (!aPoint_A && aPoint_B) {
- boost::shared_ptr<SketchPlugin_Line> aLine =
- getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_A());
- if (aLine) {
- aPnt_B = aPoint_B->pnt();
- aPnt_A = getProjectionPoint(aLine, aPnt_B);
- }
- } else if (aPoint_A && !aPoint_B) {
- boost::shared_ptr<SketchPlugin_Line> aLine =
- getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_B());
- if (aLine) {
- aPnt_A = aPoint_A->pnt();
- aPnt_B = getProjectionPoint(aLine, aPnt_A);
- }
- }
- if (!aPnt_A || !aPnt_B)
- return thePrevious;
-
- boost::shared_ptr<GeomDataAPI_Point2D> aFlyOutAttr =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
-
- boost::shared_ptr<GeomAPI_Pnt> aPoint1 = sketch()->to3D(aPnt_A->x(), aPnt_A->y());
- boost::shared_ptr<GeomAPI_Pnt> aPoint2 = sketch()->to3D(aPnt_B->x(), aPnt_B->y());
- boost::shared_ptr<GeomAPI_Pnt> aFlyoutPnt = aFlyOutAttr->isInitialized() ?
- sketch()->to3D(aFlyOutAttr->x(), aFlyOutAttr->y()) :
- boost::shared_ptr<GeomAPI_Pnt>();
-
- // value calculation
- boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr =
- boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(SketchPlugin_Constraint::VALUE()));
- double aValue = aValueAttr->value();
-
- boost::shared_ptr<GeomAPI_AISObject> anAIS = thePrevious;
- if (!anAIS)
- anAIS = boost::shared_ptr<GeomAPI_AISObject>(new GeomAPI_AISObject);
- anAIS->createDistance(aPoint1, aPoint2, aFlyoutPnt, aPlane, aValue);
-
- // Set color from preferences
- std::string aColor = Config_PropManager::value("Sketcher", "Visualization",
- "distance_color", DISTANCE_COLOR);
- std::vector<int> aRGB = stringToRGB(aColor);
- anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);