Index: rubberband.c =================================================================== --- rubberband.c (revision 12713) +++ rubberband.c (revision 12714) @@ -113,6 +113,7 @@ static void CheckArcForRubberbandConnection(rubber_ctx_t *rbnd, pcb_layer_t *, pcb_arc_t *, pcb_bool); static void CheckPolygonForRubberbandConnection(rubber_ctx_t *rbnd, pcb_layer_t *, pcb_poly_t *); static void CheckLinePointForRat(rubber_ctx_t *rbnd, pcb_layer_t *, pcb_point_t *); +static void CheckLineForRubberbandConnection(rubber_ctx_t *rbnd, pcb_layer_t *, pcb_line_t *); static void calculate_route_rubber_arc_point_move(pcb_rubberband_arc_t * arcptr,pcb_coord_t group_dx,pcb_coord_t group_dy,pcb_route_t * route); @@ -719,6 +720,62 @@ } /* --------------------------------------------------------------------------- + * checks all visible lines which belong to the same group as the passed Line. + * If either of the endpoints of the line lays anywhere inside the passed line, + * the scanned line is added to the 'rubberband' list + */ +static void CheckLineForRubberbandConnection(rubber_ctx_t *rbnd, pcb_layer_t * Layer, pcb_line_t * Line) +{ + /* lookup layergroup and check all visible lines in this group */ + pcb_layergrp_id_t group = pcb_layer_get_group_(Layer); + + PCB_COPPER_GROUP_LOOP(PCB->Data, group); + { + if (layer->meta.real.vis) { + pcb_coord_t thick; + + /* the following code just stupidly compares the endpoints of the lines */ + PCB_LINE_LOOP(layer); + { + pcb_rubberband_t *have_line = NULL; + pcb_bool touches1 = pcb_false; + pcb_bool touches2 = pcb_false; + int l; + + if (PCB_FLAG_TEST(PCB_FLAG_LOCK, line)) + continue; + + /* Check whether the line is already in the rubberband list. */ + for(l = 0; (l < rbnd->RubberbandN) && (have_line == NULL); l++) + if (rbnd->Rubberband[l].Line == line) + have_line = &rbnd->Rubberband[l]; + + /* Check whether any of the scanned line points touch the passed line */ + thick = (line->Thickness + 1) / 2; + touches1 = pcb_is_point_on_line(line->Point1.X, line->Point1.Y, thick, Line); + touches2 = pcb_is_point_on_line(line->Point2.X, line->Point2.Y, thick, Line); + + if(touches1) { + if(have_line) + have_line->delta_index[0] = 0; + else + have_line = pcb_rubber_band_create(rbnd, layer, line, 0,0); + } + + if(touches2) { + if(have_line) + have_line->delta_index[1] = 0; + else + have_line = pcb_rubber_band_create(rbnd, layer, line, 1,0); + } + } + PCB_END_LOOP; + } + } + PCB_END_LOOP; +} + +/* --------------------------------------------------------------------------- * lookup all lines that are connected to an object and save the * data to 'pcb_crosshair.AttachedObject.Rubberband' * lookup is only done for visible layers @@ -752,7 +809,7 @@ switch((*o)->type) { - case PCB_OBJ_LINE : /* TODO: CheckEntireLineForRubberbandConnection */ break; + case PCB_OBJ_LINE : CheckLineForRubberbandConnection(rbnd, ly, (pcb_line_t *) (*o)); break; case PCB_OBJ_POLY : CheckPolygonForRubberbandConnection(rbnd, ly, (pcb_poly_t *) (*o)); break; case PCB_OBJ_ARC : /* TODO: CheckEntireArcForRubberbandConnection */ break; default : /* TODO: Check other object types */ break;