Draw extension lines from pt-line-distance to line ends.

Before this commit, if a pt-line-distance constraint is placed so
that the dimension line doesn't touch the line, no extension is
drawn. After this commit, an extension line will be drawn towards
the nearest end of the line.
This commit is contained in:
EvilSpirit 2016-01-08 11:20:37 +06:00 committed by whitequark
parent b3fa8dca37
commit a71d5894aa

View File

@ -490,6 +490,19 @@ void Constraint::DrawOrGetDistance(Vector *labelPos) {
if(!pt.Equals(closest)) { if(!pt.Equals(closest)) {
DoLineWithArrows(ref, pt, closest, true); DoLineWithArrows(ref, pt, closest, true);
// Extensions to line
double pixels = 1.0 / SS.GW.scale;
Vector refClosest = ref.ClosestPointOnLine(lA, dl);
double ddl = dl.Dot(dl);
if(fabs(ddl) > LENGTH_EPS * LENGTH_EPS) {
double t = refClosest.Minus(lA).Dot(dl) / ddl;
if(t < 0.0) {
LineDrawOrGetDistance(refClosest.Minus(dl.WithMagnitude(10.0 * pixels)), lA);
} else if(t > 1.0) {
LineDrawOrGetDistance(refClosest.Plus(dl.WithMagnitude(10.0 * pixels)), lB);
}
}
} }
if(workplane.v != Entity::FREE_IN_3D.v) { if(workplane.v != Entity::FREE_IN_3D.v) {