Index: src/crosshair.c =================================================================== --- src/crosshair.c (revision 2305) +++ src/crosshair.c (revision 2306) @@ -79,6 +79,26 @@ gui->thindraw_pcb_pv(Crosshair.GC, Crosshair.GC, &moved_pv, true, false); } +static void draw_dashed_line(hidGC GC, Coord x1, Coord y1, Coord x2, Coord y2) +{ +/* TODO: we need a real geo lib... using double here is plain wrong */ + double dx = x2-x1, dy = y2-y1; + double len_squared = dx*dx + dy*dy; + int n; + const int segs = 10; + + if (len_squared < 1000000) { + /* line too short, just draw it - TODO: magic value; with a proper geo lib this would be gone anyway */ + gui->draw_line(Crosshair.GC, x1, y1, x2, y2); + return; + } + + for(n = 1; n < segs; n+=2) + gui->draw_line(Crosshair.GC, + x1 + (dx * (double)(n-1) / (double)segs), y1 + (dy * (double)(n-1) / (double)segs), + x1 + (dx * (double)n / (double)segs), y1 + (dy * (double)n / (double)segs)); +} + /* --------------------------------------------------------------------------- * creates a tmp polygon with coordinates converted to screen system */ @@ -87,9 +107,19 @@ Cardinal i; for (i = 0; i < polygon->PointN; i++) { Cardinal next = next_contour_point(polygon, i); - gui->draw_line(Crosshair.GC, + if (next == 0) { + /* the implicit closing line */ + if (i != 1) /* corner case: don't draw two lines on top of eachother - with XOR it looks bad */ + draw_dashed_line(Crosshair.GC, polygon->Points[i].X + dx, polygon->Points[i].Y + dy, polygon->Points[next].X + dx, polygon->Points[next].Y + dy); + } + else { + /* any other line */ + gui->draw_line(Crosshair.GC, + polygon->Points[i].X + dx, + polygon->Points[i].Y + dy, polygon->Points[next].X + dx, polygon->Points[next].Y + dy); + } } }