Index: trunk/src/crosshair.c =================================================================== --- trunk/src/crosshair.c (revision 17245) +++ trunk/src/crosshair.c (revision 17246) @@ -91,7 +91,7 @@ if (dash_last) { pcb_draw_dashed_line(pcb_crosshair.GC, polygon->Points[i].X + dx, - polygon->Points[i].Y + dy, polygon->Points[next].X + dx, polygon->Points[next].Y + dy, 5); + polygon->Points[i].Y + dy, polygon->Points[next].X + dx, polygon->Points[next].Y + dy, 5, pcb_false); break; /* skip normal line draw below */ } } Index: trunk/src/draw.c =================================================================== --- trunk/src/draw.c (revision 17245) +++ trunk/src/draw.c (revision 17246) @@ -110,21 +110,29 @@ pcb_snprintf(buf, sizeof("#XXXXXX"), "#%02x%02x%02x", r, g, b); } -void pcb_draw_dashed_line(pcb_hid_gc_t GC, pcb_coord_t x1, pcb_coord_t y1, pcb_coord_t x2, pcb_coord_t y2, unsigned int segs) +void pcb_draw_dashed_line(pcb_hid_gc_t GC, pcb_coord_t x1, pcb_coord_t y1, pcb_coord_t x2, pcb_coord_t y2, unsigned int segs, pcb_bool_t cheap) { /* 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; + double len_mnt = PCB_ABS(dx) + PCB_ABS(dy); int n; + pcb_coord_t minlen = pcb_gui->coord_per_pix * 8; - segs = (segs << 1) + 1; /* must be odd */ - - if (len_squared < 1000000) { - /* line too short, just draw it - TODO: magic value; with a proper geo lib this would be gone anyway */ + if (len_mnt < minlen*2) { + /* line too short, just draw it */ pcb_gui->draw_line(GC, x1, y1, x2, y2); return; } + segs = (segs << 1) + 1; /* must be odd */ + + if (cheap) { + if ((segs > 3) && (len_mnt < minlen * segs)) + segs = 3; + else if ((segs > 5) && (len_mnt < minlen * 2 * segs)) + segs = 5; + } + /* first seg is drawn from x1, y1 with no rounding error due to n-1 == 0 */ for(n = 1; n < segs; n+=2) pcb_gui->draw_line(GC, Index: trunk/src/draw.h =================================================================== --- trunk/src/draw.h (revision 17245) +++ trunk/src/draw.h (revision 17246) @@ -76,8 +76,9 @@ /* Draw a series of short line segments emulating a dashed line. segs is the number of on/off segment pairs. It is guaranteed that the line starts - and ends with an "on" line segment */ -void pcb_draw_dashed_line(pcb_hid_gc_t GC, pcb_coord_t x1, pcb_coord_t y1, pcb_coord_t x2, pcb_coord_t y2, unsigned int segs); + and ends with an "on" line segment. If cheap is true, allow drawing less + segments if the line is short */ +void pcb_draw_dashed_line(pcb_hid_gc_t GC, pcb_coord_t x1, pcb_coord_t y1, pcb_coord_t x2, pcb_coord_t y2, unsigned int segs, pcb_bool_t cheap); void pcb_draw(void); Index: trunk/src/obj_subc.c =================================================================== --- trunk/src/obj_subc.c (revision 17245) +++ trunk/src/obj_subc.c (revision 17246) @@ -1535,10 +1535,10 @@ pcb_subc_draw_origin(pcb_draw_out.fgGC, subc, 0, 0); if (freq >= 0) { - pcb_draw_dashed_line(pcb_draw_out.fgGC, bb->X1, bb->Y1, bb->X2, bb->Y1, freq); - pcb_draw_dashed_line(pcb_draw_out.fgGC, bb->X1, bb->Y1, bb->X1, bb->Y2, freq); - pcb_draw_dashed_line(pcb_draw_out.fgGC, bb->X2, bb->Y2, bb->X2, bb->Y1, freq); - pcb_draw_dashed_line(pcb_draw_out.fgGC, bb->X2, bb->Y2, bb->X1, bb->Y2, freq); + pcb_draw_dashed_line(pcb_draw_out.fgGC, bb->X1, bb->Y1, bb->X2, bb->Y1, freq, pcb_true); + pcb_draw_dashed_line(pcb_draw_out.fgGC, bb->X1, bb->Y1, bb->X1, bb->Y2, freq, pcb_true); + pcb_draw_dashed_line(pcb_draw_out.fgGC, bb->X2, bb->Y2, bb->X2, bb->Y1, freq, pcb_true); + pcb_draw_dashed_line(pcb_draw_out.fgGC, bb->X2, bb->Y2, bb->X1, bb->Y2, freq, pcb_true); } return PCB_R_DIR_FOUND_CONTINUE;