Index: trunk/src/search.c =================================================================== --- trunk/src/search.c (revision 14219) +++ trunk/src/search.c (revision 14220) @@ -1153,6 +1153,28 @@ #undef angle_in_range } +pcb_line_t *pcb_line_center_cross_point(pcb_layer_t *layer, pcb_coord_t x, pcb_coord_t y, pcb_angle_t *ang, pcb_bool no_subc_part, pcb_bool no_term) +{ + pcb_rtree_it_t it; + pcb_rtree_box_t pt; + pcb_line_t *l; + +/* TODO: set pt coords to x and y */ + + for(l = pcb_rtree_first(&it, &layer->line_tree, &pt); l != NULL; l = pcb_rtree_next(&it)) { + /* check if line needs to be ignored and "continue;" if so: + l->term is non-NULL if it's a terminal, + pcb_lobj_parent_subc(pcb_parenttype_t pt, pcb_parent_t *p) returns non-NULL if it's in a subc + */ + /* if the line shouldn't be ignored, check if x;y is on the centerline and + "continue;" if bad */ + /* check if angle is required and is correct; "continue;" on mismatch */ + return l; + } + return NULL; /* found nothing */ +} + + /* --------------------------------------------------------------------------- * searches for any kind of object or for a set of object types * the calling routine passes two pointers to allocated memory for storing Index: trunk/src/search.h =================================================================== --- trunk/src/search.h (revision 14219) +++ trunk/src/search.h (revision 14220) @@ -34,6 +34,7 @@ #include "global_typedefs.h" #include "rats.h" #include "misc_util.h" +#include "layer.h" int pcb_lines_intersect(pcb_coord_t ax1, pcb_coord_t ay1, pcb_coord_t ax2, pcb_coord_t ay2, pcb_coord_t bx1, pcb_coord_t by1, pcb_coord_t bx2, pcb_coord_t by2); pcb_bool pcb_arc_in_box(pcb_arc_t *arc, pcb_box_t *b); @@ -175,6 +176,13 @@ /* Return the distance^2 between a line-center and a point */ double pcb_point_line_dist2(pcb_coord_t X, pcb_coord_t Y, pcb_line_t *Line); +/* Return the first line object that has its centerline crossing the point; + if ang is not NULL, only return lines that are pointing in the right + angle (also accept 180 degree rotation) + if no_subc_part is true, ignore lines that are part of subcircuits; + if no_term is true, ignore lines that are terminals */ +pcb_line_t *pcb_line_center_cross_point(pcb_layer_t *layer, pcb_coord_t x, pcb_coord_t y, pcb_angle_t *ang, pcb_bool no_subc_part, pcb_bool no_term); + int pcb_search_screen(pcb_coord_t X, pcb_coord_t Y, int Type, void **Result1, void **Result2, void **Result3); int pcb_search_grid_slop(pcb_coord_t X, pcb_coord_t Y, int Type, void **Result1, void **Result2, void **Result3); int pcb_search_obj_by_location(unsigned long Type, void **Result1, void **Result2, void **Result3, pcb_coord_t X, pcb_coord_t Y, pcb_coord_t Radius);