Index: trunk/src/draw.c =================================================================== --- trunk/src/draw.c (revision 31582) +++ trunk/src/draw.c (revision 31583) @@ -739,6 +739,16 @@ else pcb_draw_out.active_padGC = pcb_draw_out.backpadGC; + /* first draw all gfx that's under other layer objects */ + if (lflg & PCB_LYT_COPPER) { + delayed_terms_enabled = rnd_true; + rnd_r_search(Layer->gfx_tree, info->drawn_area, NULL, pcb_gfx_draw_under_callback, info, NULL); + delayed_terms_enabled = rnd_false; + may_have_delayed = 1; + } + else + rnd_r_search(Layer->gfx_tree, info->drawn_area, NULL, pcb_gfx_draw_under_callback, info, NULL); + /* print the non-clearing polys */ if (lflg & PCB_LYT_COPPER) { delayed_terms_enabled = rnd_true; @@ -761,7 +771,7 @@ rnd_r_search(Layer->line_tree, info->drawn_area, NULL, pcb_line_draw_term_callback, info, NULL); rnd_r_search(Layer->arc_tree, info->drawn_area, NULL, pcb_arc_draw_term_callback, info, NULL); rnd_r_search(Layer->text_tree, info->drawn_area, NULL, pcb_text_draw_term_callback, info, NULL); - rnd_r_search(Layer->gfx_tree, info->drawn_area, NULL, pcb_gfx_draw_callback, info, NULL); + rnd_r_search(Layer->gfx_tree, info->drawn_area, NULL, pcb_gfx_draw_above_callback, info, NULL); delayed_terms_enabled = rnd_false; may_have_delayed = 1; } @@ -769,7 +779,7 @@ rnd_r_search(Layer->line_tree, info->drawn_area, NULL, pcb_line_draw_callback, info, NULL); rnd_r_search(Layer->arc_tree, info->drawn_area, NULL, pcb_arc_draw_callback, info, NULL); rnd_r_search(Layer->text_tree, info->drawn_area, NULL, pcb_text_draw_callback, info, NULL); - rnd_r_search(Layer->gfx_tree, info->drawn_area, NULL, pcb_gfx_draw_callback, info, NULL); + rnd_r_search(Layer->gfx_tree, info->drawn_area, NULL, pcb_gfx_draw_above_callback, info, NULL); } if (may_have_delayed) @@ -854,7 +864,21 @@ else pcb_draw_out.active_padGC = pcb_draw_out.backpadGC; - /* print the non-clearing polys */ + /* first draw gfx that are under other layer objects */ + if (lflg & PCB_LYT_COPPER) { + if (Layer->gfx_tree != NULL) + for(o = rnd_rtree_first(&it, Layer->gfx_tree, (rnd_rtree_box_t *)screen); o != NULL; o = rnd_rtree_next(&it)) + if ((pcb_obj_is_under(o, data)) && (((pcb_gfx_t *)o)->render_under)) + pcb_gfx_draw(&info, (pcb_gfx_t *)o, 0); + } + else { + if (Layer->gfx_tree != NULL) + for(o = rnd_rtree_first(&it, Layer->gfx_tree, (rnd_rtree_box_t *)screen); o != NULL; o = rnd_rtree_next(&it)) + if (pcb_obj_is_under(o, data)) + pcb_gfx_draw_under_callback((rnd_rnd_box_t *)o, &info); + } + + /* print the non-clearing polys */ if (Layer->polygon_tree != NULL) { if (lflg & PCB_LYT_COPPER) { for(o = rnd_rtree_first(&it, Layer->polygon_tree, (rnd_rtree_box_t *)screen); o != NULL; o = rnd_rtree_next(&it)) @@ -887,7 +911,7 @@ pcb_text_draw_term_callback((rnd_rnd_box_t *)o, &info); if (Layer->gfx_tree != NULL) for(o = rnd_rtree_first(&it, Layer->gfx_tree, (rnd_rtree_box_t *)screen); o != NULL; o = rnd_rtree_next(&it)) - if (pcb_obj_is_under(o, data)) + if ((pcb_obj_is_under(o, data)) && !(((pcb_gfx_t *)o)->render_under)) pcb_gfx_draw(&info, (pcb_gfx_t *)o, 0); } else { @@ -906,7 +930,7 @@ if (Layer->gfx_tree != NULL) for(o = rnd_rtree_first(&it, Layer->gfx_tree, (rnd_rtree_box_t *)screen); o != NULL; o = rnd_rtree_next(&it)) if (pcb_obj_is_under(o, data)) - pcb_gfx_draw_callback((rnd_rnd_box_t *)o, &info); + pcb_gfx_draw_above_callback((rnd_rnd_box_t *)o, &info); } out:; Index: trunk/src/obj_common.c =================================================================== --- trunk/src/obj_common.c (revision 31582) +++ trunk/src/obj_common.c (revision 31583) @@ -217,6 +217,12 @@ pcb_text_t *t = (pcb_text_t *)obj; t->mirror_x = rnd_istrue(value); } + else if ((obj->type == PCB_OBJ_GFX) && (strcmp(name, "render_level") == 0)) { + pcb_gfx_t *g = (pcb_gfx_t *)obj; + if ((value != NULL) && ((*value == 'u') || (*value == 'U'))) g->render_under = 1; + else g->render_under = 0; +rnd_trace("renderlevel: %s -> %d\n", value, g->render_under); + } } const char *pcb_obj_id_invalid(const char *id) Index: trunk/src/obj_gfx.c =================================================================== --- trunk/src/obj_gfx.c (revision 31582) +++ trunk/src/obj_gfx.c (revision 31583) @@ -718,12 +718,11 @@ pcb_gfx_draw_(info, gfx, allow_term_gfx); } -rnd_r_dir_t pcb_gfx_draw_callback(const rnd_rnd_box_t *b, void *cl) +RND_INLINE rnd_r_dir_t pcb_gfx_draw_callback_(pcb_gfx_t *gfx, void *cl) { - pcb_gfx_t *gfx = (pcb_gfx_t *)b; pcb_draw_info_t *info = cl; - if (pcb_hidden_floater((pcb_any_obj_t*)b, info) || pcb_partial_export((pcb_any_obj_t*)b, info)) + if (pcb_hidden_floater((pcb_any_obj_t*)gfx, info) || pcb_partial_export((pcb_any_obj_t*)gfx, info)) return RND_R_DIR_FOUND_CONTINUE; if (!PCB->SubcPartsOn && pcb_lobj_parent_subc(gfx->parent_type, &gfx->parent)) @@ -733,6 +732,22 @@ return RND_R_DIR_FOUND_CONTINUE; } +rnd_r_dir_t pcb_gfx_draw_under_callback(const rnd_rnd_box_t *b, void *cl) +{ + pcb_gfx_t *gfx = (pcb_gfx_t *)b; + if (!gfx->render_under) + return RND_R_DIR_FOUND_CONTINUE; + return pcb_gfx_draw_callback_(gfx, cl); +} + +rnd_r_dir_t pcb_gfx_draw_above_callback(const rnd_rnd_box_t *b, void *cl) +{ + pcb_gfx_t *gfx = (pcb_gfx_t *)b; + if (gfx->render_under) + return RND_R_DIR_FOUND_CONTINUE; + return pcb_gfx_draw_callback_(gfx, cl); +} + /* erases a gfx on a layer */ void pcb_gfx_invalidate_erase(pcb_gfx_t *gfx) { Index: trunk/src/obj_gfx.h =================================================================== --- trunk/src/obj_gfx.h (revision 31582) +++ trunk/src/obj_gfx.h (revision 31583) @@ -47,6 +47,7 @@ rnd_pixmap_t *pxm_xformed; /* transformed version from the cache */ /* calculated/cached fields */ + unsigned int render_under:1; /* render under layer objects (default is 0=above) */ rnd_point_t corner[4]; /* the 4 corners - has to be point so search.c can return it for the crosshair to edit */ gdl_elem_t link; /* an gfx is in a list on a layer */ }; Index: trunk/src/obj_gfx_draw.h =================================================================== --- trunk/src/obj_gfx_draw.h (revision 31582) +++ trunk/src/obj_gfx_draw.h (revision 31583) @@ -31,7 +31,8 @@ /* Include rtree.h for this */ #ifdef RND_RTREE_H -rnd_r_dir_t pcb_gfx_draw_callback(const rnd_rnd_box_t * b, void *cl); +rnd_r_dir_t pcb_gfx_draw_under_callback(const rnd_rnd_box_t * b, void *cl); +rnd_r_dir_t pcb_gfx_draw_above_callback(const rnd_rnd_box_t * b, void *cl); #endif void pcb_gfx_draw_(pcb_draw_info_t *info, pcb_gfx_t *gfx, int allow_term_gfx);