Index: trunk/src/select.c =================================================================== --- trunk/src/select.c (revision 33498) +++ trunk/src/select.c (revision 33499) @@ -214,9 +214,10 @@ * if len is non-NULL: * returns a list of object IDs matched the search and loads len with the * length of the list. Returns NULL on no match. + * Always limit layer search to layer types matching lyt (and never limit globals) */ TODO("cleanup: should be rewritten with generic ops and rtree") -static long int *ListBlock_(pcb_board_t *pcb, rnd_box_t *Box, rnd_bool Flag, int *len, void *(cb)(void *ctx, pcb_any_obj_t *obj), void *ctx) +static long int *ListBlock_(pcb_board_t *pcb, rnd_box_t *Box, rnd_bool Flag, pcb_layer_type_t lyt, int *len, void *(cb)(void *ctx, pcb_any_obj_t *obj), void *ctx) { int changed = 0; int used = 0, alloced = 0; @@ -275,6 +276,9 @@ { unsigned int lflg = pcb_layer_flags(pcb, n); + if ((lflg &lyt) == 0) + continue; + if ((lflg & PCB_LYT_SILK) && (PCB_LAYERFLG_ON_VISIBLE_SIDE(lflg))) { if (!(pcb_silk_on(pcb) || !Flag)) continue; @@ -476,16 +480,23 @@ */ long int *pcb_list_block(pcb_board_t *pcb, rnd_box_t *Box, int *len) { - return ListBlock_(pcb, Box, 1, len, NULL, NULL); + return ListBlock_(pcb, Box, 1, PCB_LYT_ANYWHERE|PCB_LYT_ANYTHING, len, NULL, NULL); } int pcb_list_block_cb(pcb_board_t *pcb, rnd_box_t *Box, void *(cb)(void *ctx, pcb_any_obj_t *obj), void *ctx) { int len = 0; - ListBlock_(pcb, Box, -1, &len, cb, ctx); + ListBlock_(pcb, Box, -1, PCB_LYT_ANYWHERE|PCB_LYT_ANYTHING, &len, cb, ctx); return len; } +int pcb_list_lyt_block_cb(pcb_board_t *pcb, pcb_layer_type_t lyt, rnd_box_t *Box, void *(cb)(void *ctx, pcb_any_obj_t *obj), void *ctx) +{ + int len = 0; + ListBlock_(pcb, Box, -1, lyt, &len, cb, ctx); + return len; +} + /* ---------------------------------------------------------------------- * selects/unselects all objects which were found during a connection scan * Flag determines if they are to be selected or unselected Index: trunk/src/select.h =================================================================== --- trunk/src/select.h (revision 33498) +++ trunk/src/select.h (revision 33499) @@ -43,8 +43,9 @@ long int *pcb_list_block(pcb_board_t *pcb, rnd_box_t *Box, int *len); /* List visible objects on screen within a box; return number of objects, call - a callback on each object found */ + a callback on each object found. Optionally limit the search to specific layer types plus globals */ int pcb_list_block_cb(pcb_board_t *pcb, rnd_box_t *Box, void *(cb)(void *ctx, pcb_any_obj_t *obj), void *ctx); +int pcb_list_lyt_block_cb(pcb_board_t *pcb, pcb_layer_type_t lyt, rnd_box_t *Box, void *(cb)(void *ctx, pcb_any_obj_t *obj), void *ctx); rnd_bool pcb_select_connection(pcb_board_t *pcb, rnd_bool);