aPnt_A = aPoint_A->pnt();
aPnt_B = aPoint_B->pnt();
} else if (!aPoint_A && aPoint_B) {
- //std::shared_ptr<SketchPlugin_Line> aLine = SketcherPrs_Tools::getFeatureLine(
- // aData, SketchPlugin_Constraint::ENTITY_A());
- //if (aLine) {
- // aPnt_B = aPoint_B->pnt();
- // aPnt_A = SketcherPrs_Tools::getProjectionPoint(aLine, aPnt_B);
- //}
+ FeaturePtr aLine = SketcherPrs_Tools::getFeatureLine(
+ aData, SketchPlugin_Constraint::ENTITY_A());
+ if (aLine) {
+ aPnt_B = aPoint_B->pnt();
+ aPnt_A = SketcherPrs_Tools::getProjectionPoint(aLine, aPnt_B);
+ }
} else if (aPoint_A && !aPoint_B) {
- //std::shared_ptr<SketchPlugin_Line> aLine = SketcherPrs_Tools::getFeatureLine(
- // aData, SketchPlugin_Constraint::ENTITY_B());
- //if (aLine) {
- // aPnt_A = aPoint_A->pnt();
- // aPnt_B = SketcherPrs_Tools::getProjectionPoint(aLine, aPnt_A);
- //}
+ FeaturePtr aLine = SketcherPrs_Tools::getFeatureLine(
+ aData, SketchPlugin_Constraint::ENTITY_B());
+ if (aLine) {
+ aPnt_A = aPoint_A->pnt();
+ aPnt_B = SketcherPrs_Tools::getProjectionPoint(aLine, aPnt_A);
+ }
}
if (!aPnt_A || !aPnt_B)
return false;
if (aPointA && aPointB) { // both points
aDistance = aPointA->pnt()->distance(aPointB->pnt());
} else {
-// if (!aPointA && aPointB) { //Line and point
-// std::shared_ptr<SketchPlugin_Line> aLine =
-// SketcherPrs_Tools::getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_A());
-// if (aLine) {
-// aDistance = aLine->distanceToPoint(aPointB->pnt());
-// }
-// } else if (aPointA && !aPointB) { // Point and line
-// std::shared_ptr<SketchPlugin_Line> aLine =
-// SketcherPrs_Tools::getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_B());
-// if (aLine) {
-// aDistance = aLine->distanceToPoint(aPointA->pnt());
-// }
-// }
+ if (!aPointA && aPointB) { //Line and point
+ FeaturePtr aLineFeature =
+ SketcherPrs_Tools::getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_A());
+ std::shared_ptr<SketchPlugin_Line> aLine = std::dynamic_pointer_cast<SketchPlugin_Line>(aLineFeature);
+ if (aLine) {
+ aDistance = aLine->distanceToPoint(aPointB->pnt());
+ }
+ } else if (aPointA && !aPointB) { // Point and line
+ FeaturePtr aLineFeasture =
+ SketcherPrs_Tools::getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_B());
+ std::shared_ptr<SketchPlugin_Line> aLine = std::dynamic_pointer_cast<SketchPlugin_Line>(aLineFeasture);
+ if (aLine) {
+ aDistance = aLine->distanceToPoint(aPointA->pnt());
+ }
+ }
}
return aDistance;
}