Index: trunk/src/draw_composite.c =================================================================== --- trunk/src/draw_composite.c (revision 12041) +++ trunk/src/draw_composite.c (revision 12042) @@ -115,12 +115,12 @@ static void comp_draw_layer_real(comp_ctx_t *ctx, void (*draw_auto)(comp_ctx_t *ctx, void *data), void *auto_data) { /* generic multi-layer rendering */ int n, adding = -1; - pcb_layer_t *l = pcb_get_layer(ctx->grp->lid[0]); + pcb_layer_t *l = pcb_get_layer(PCB->Data, ctx->grp->lid[0]); comp_init(ctx, (l->comb & PCB_LYC_SUB)); for(n = 0; n < ctx->grp->len; n++) { int want_add; - l = pcb_get_layer(ctx->grp->lid[n]); + l = pcb_get_layer(PCB->Data, ctx->grp->lid[n]); want_add = ctx->thin || !(l->comb & PCB_LYC_SUB); if (want_add != adding) { Index: trunk/src/gui_act.c =================================================================== --- trunk/src/gui_act.c (revision 12041) +++ trunk/src/gui_act.c (revision 12042) @@ -1483,7 +1483,7 @@ pcb_message(PCB_MSG_ERROR, "Can't find layer named %s\n", argv[n]+1); return 1; } - ly = pcb_get_layer(lid); + ly = pcb_get_layer(PCB->Data, lid); explicit = 1; } else if (strncmp(argv[n], "name=", 5) == 0) { Index: trunk/src/hid_helper.c =================================================================== --- trunk/src/hid_helper.c (revision 12041) +++ trunk/src/hid_helper.c (revision 12042) @@ -58,7 +58,7 @@ group = pcb_layer_get_group(PCB, lid); nlayers = PCB->LayerGroups.grp[group].len; - single_name = pcb_layer_name(PCB, lid); + single_name = pcb_layer_name(PCB->Data, lid); if (flags & PCB_LYT_TOP) { if (style == PCB_FNS_first || (style == PCB_FNS_single && nlayers == 2)) Index: trunk/src/layer.c =================================================================== --- trunk/src/layer.c (revision 12041) +++ trunk/src/layer.c (revision 12042) @@ -621,11 +621,10 @@ return NULL; } -#warning layer TODO: this should be the new pcb_get_layer() -pcb_layer_t *pcb_get_layer2(pcb_board_t *pcb, pcb_layer_id_t id) +pcb_layer_t *pcb_get_layer(pcb_data_t *data, pcb_layer_id_t id) { - if ((id >= 0) && (id < pcb->Data->LayerN)) - return &pcb->Data->Layer[id]; + if ((id >= 0) && (id < data->LayerN)) + return &data->Layer[id]; if (id & PCB_LYT_UI) { id &= ~(PCB_LYT_VIRTUAL | PCB_LYT_UI); if ((id >= 0) && (id < vtlayer_len(&pcb_uilayer))) @@ -634,11 +633,6 @@ return NULL; } -pcb_layer_t *pcb_get_layer(pcb_layer_id_t id) -{ - return pcb_get_layer2(PCB, id); -} - void pcb_layer_link_trees(pcb_layer_t *dst, pcb_layer_t *src) { /* we can't link non-existing trees - make sure src does have the trees initialized */ @@ -717,7 +711,7 @@ { pcb_layergrp_t *grp = pcb->LayerGroups.grp+gid; for(l = 0; l < grp->len; l++) { - pcb_layer_t *ly = pcb_get_layer2(pcb, grp->lid[l]); + pcb_layer_t *ly = pcb_get_layer(pcb->Data, grp->lid[l]); if ((ly->comb & PCB_LYC_SUB) == (src->comb & PCB_LYC_SUB)) { score = 1; if (ly->comb == src->comb) Index: trunk/src/layer.h =================================================================== --- trunk/src/layer.h (revision 12041) +++ trunk/src/layer.h (revision 12042) @@ -177,7 +177,7 @@ /************ NEW API - new code should use these **************/ /* Return the layer pointer (or NULL on invalid or virtual layers) for an id */ -pcb_layer_t *pcb_get_layer(pcb_layer_id_t id); +pcb_layer_t *pcb_get_layer(pcb_data_t *data, pcb_layer_id_t id); /* Return the name of a layer (real or virtual) or NULL on error NOTE: layer names may not be unique; returns the first case sensitive hit; Index: trunk/src/layer_grp.c =================================================================== --- trunk/src/layer_grp.c (revision 12041) +++ trunk/src/layer_grp.c (revision 12042) @@ -407,7 +407,7 @@ return -1; for(n = 0; n < stk->grp[gid].len; n++) { - pcb_layer_t *l = pcb_get_layer(stk->grp[gid].lid[n]); + pcb_layer_t *l = pcb_get_layer(pcb->Data, stk->grp[gid].lid[n]); if (l != NULL) { if (del_layers) { pcb_layer_move(pcb, stk->grp[gid].lid[n], -1, -1); @@ -455,8 +455,8 @@ /* fix up the group id for the layers of the group moved */ for(n = 0; n < stk->grp[to_before].len; n++) { -#warning TODO: use pcb_get_layer when it becomes pcb-safe -/* pcb_layer_t *l = pcb_get_layer(stk->grp[to_before].lid[n]);*/ +#warning layer TODO: use pcb_get_layer when it becomes pcb-safe - it is, DO IT NOW +/* pcb_layer_t *l = pcb_get_layer(pcb->data, stk->grp[to_before].lid[n]);*/ pcb_layer_t *l = &pcb->Data->Layer[stk->grp[to_before].lid[n]]; if ((l != NULL) && (l->meta.real.grp > 0)) l->meta.real.grp = to_before; @@ -790,7 +790,7 @@ grp = pcb_get_grp(&pcb->LayerGroups, ly->meta.bound.type & PCB_LYT_ANYWHERE, ly->meta.bound.type & PCB_LYT_ANYTHING); if (grp != NULL) { pcb_layer_id_t lid = pcb_layer_create(pcb, pcb_layergrp_id(pcb, grp), ly->name); - pcb_layer_t *nly = pcb_get_layer(lid); + pcb_layer_t *nly = pcb_get_layer(pcb->Data, lid); nly->comb = ly->comb; continue; } Index: trunk/src/layer_vis.c =================================================================== --- trunk/src/layer_vis.c (revision 12041) +++ trunk/src/layer_vis.c (revision 12042) @@ -250,7 +250,7 @@ /* the group is visible exactly if if any layer is visible */ g->vis = 0; for(n = 0; n < g->len; n++) { - pcb_layer_t *l = pcb_get_layer(g->lid[n]); + pcb_layer_t *l = pcb_get_layer(pcb->Data, g->lid[n]); if ((l != NULL) && (l->meta.real.vis)) { g->vis = 1; break; @@ -260,7 +260,7 @@ else { pcb_bool_op(g->vis, vis); for(n = 0; n < g->len; n++) { - pcb_layer_t *l = pcb_get_layer(g->lid[n]); + pcb_layer_t *l = pcb_get_layer(pcb->Data, g->lid[n]); pcb_bool_op(l->meta.real.vis, vis); } } @@ -281,7 +281,7 @@ int n; g->vis = pcb_false; for(n = 0; n < g->len; n++) { - pcb_layer_t *l = pcb_get_layer(g->lid[n]); + pcb_layer_t *l = pcb_get_layer(PCB->Data, g->lid[n]); l->meta.real.vis = 0; } } @@ -293,11 +293,12 @@ static void pcb_layer_confchg_color(conf_native_t *cfg, int arr_idx) { - pcb_layer_t *lp = pcb_get_layer(arr_idx); - - if (lp != NULL) { - lp->meta.real.color = conf_core.appearance.color.layer[arr_idx]; - lp->meta.real.selected_color = conf_core.appearance.color.layer_selected[arr_idx]; + if (PCB != NULL) { + pcb_layer_t *lp = pcb_get_layer(PCB->Data, arr_idx); + if (lp != NULL) { + lp->meta.real.color = conf_core.appearance.color.layer[arr_idx]; + lp->meta.real.selected_color = conf_core.appearance.color.layer_selected[arr_idx]; + } } } Index: trunk/src/object_act.c =================================================================== --- trunk/src/object_act.c (revision 12041) +++ trunk/src/object_act.c (revision 12042) @@ -1157,7 +1157,7 @@ if (new_index < 0) { if (pcb_layer_flags(PCB, old_index) & PCB_LYT_SILK) { - pcb_layer_t *l = pcb_get_layer(old_index); + pcb_layer_t *l = pcb_get_layer(PCB->Data, old_index); pcb_layergrp_t *g = pcb_get_layergrp(PCB, l->meta.real.grp); if (g->len == 1) { pcb_message(PCB_MSG_ERROR, "Removing this layer would result in an empty top or bottom silk group, which is not possible at the moment.\n"); @@ -1179,7 +1179,7 @@ if (*user_text == '#') { id = strtol(user_text+1, &end, 10); if (*end == '\0') - return pcb_get_layer(id); + return pcb_get_layer(PCB->Data, id); } return NULL; } Index: trunk/src/route.c =================================================================== --- trunk/src/route.c (revision 12041) +++ trunk/src/route.c (revision 12042) @@ -444,7 +444,7 @@ for( i=0;isize;i++) { pcb_route_object_t const * p_obj = &p_route->objects[i]; - pcb_layer_t * layer = pcb_get_layer(p_obj->layer); + pcb_layer_t * layer = pcb_get_layer(PCB->Data, p_obj->layer); switch(p_obj->type) { @@ -597,7 +597,7 @@ for(i=0;isize;++i) { const pcb_route_object_t * p_obj = &p_route->objects[i]; - pcb_layer_t * layer = pcb_get_layer(p_obj->layer); + pcb_layer_t * layer = pcb_get_layer(PCB->Data, p_obj->layer); if(layer) pcb_gui->set_color(GC,layer->meta.real.color); Index: trunk/src_plugins/diag/diag.c =================================================================== --- trunk/src_plugins/diag/diag.c (revision 12041) +++ trunk/src_plugins/diag/diag.c (revision 12042) @@ -164,7 +164,7 @@ for(n = 0; n < used; n++) { pcb_layer_id_t layer_id = arr[n]; pcb_layergrp_id_t grp = pcb_layer_get_group(PCB, layer_id); - printf(" [%lx] %04x group=%ld %s\n", layer_id, pcb_layer_flags(PCB, layer_id), grp, pcb_layer_name(PCB, layer_id)); + printf(" [%lx] %04x group=%ld %s\n", layer_id, pcb_layer_flags(PCB, layer_id), grp, pcb_layer_name(PCB->Data, layer_id)); } /* query by logical layer: any bottom copper */ Index: trunk/src_plugins/export_ps/ps.c =================================================================== --- trunk/src_plugins/export_ps/ps.c (revision 12041) +++ trunk/src_plugins/export_ps/ps.c (revision 12042) @@ -644,7 +644,7 @@ lid = -1; pcb_layer_list(PCB, PCB_LYT_OUTLINE, &lid, 1); if (lid >= 0) - global.outline_layer = pcb_get_layer(lid); + global.outline_layer = pcb_get_layer(PCB->Data, lid); else global.outline_layer = NULL; @@ -957,7 +957,7 @@ print the outline layer on this layer also. */ if (global.outline && global.outline_layer != NULL && - global.outline_layer != pcb_get_layer(layer) && + global.outline_layer != pcb_get_layer(PCB->Data, layer) && !(flags & PCB_LYT_OUTLINE)) { int save_drill = global.is_drill; global.is_drill = 0; Index: trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/gpmi_pkg/layout/create.c =================================================================== --- trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/gpmi_pkg/layout/create.c (revision 12041) +++ trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/gpmi_pkg/layout/create.c (revision 12042) @@ -81,7 +81,7 @@ layout_object_t *layout_create_line(const char *search_id, layer_id_t layer_id, int x1, int y1, int x2, int y2, int thickness, int clearance, multiple layout_flag_t flags) { - pcb_layer_t *layer = pcb_get_layer(layer_id); + pcb_layer_t *layer = pcb_get_layer(PCB->Data, layer_id); void *res; if (layer == NULL) return 0; @@ -123,7 +123,7 @@ { layout_search_t *s; void *res; - pcb_layer_t *layer = pcb_get_layer(layer_id); + pcb_layer_t *layer = pcb_get_layer(PCB->Data, layer_id); if (layer == NULL) return NULL; @@ -136,7 +136,7 @@ { layout_search_t *s; void *res; - pcb_layer_t *layer = pcb_get_layer(layer_id); + pcb_layer_t *layer = pcb_get_layer(PCB->Data, layer_id); if (layer == NULL) return NULL; Index: trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/gpmi_pkg/layout/object.c =================================================================== --- trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/gpmi_pkg/layout/object.c (revision 12041) +++ trunk/src_plugins/gpmi/pcb-gpmi/gpmi_plugin/gpmi_pkg/layout/object.c (revision 12042) @@ -89,7 +89,7 @@ if (obj == NULL) return -1; - ly = pcb_get_layer(obj->layer); + ly = pcb_get_layer(PCB->Data, obj->layer); if (ly == NULL) return -1; @@ -140,7 +140,7 @@ { pcb_layer_t *ly; - ly = pcb_get_layer(obj->layer); + ly = pcb_get_layer(PCB->Data, obj->layer); if (ly == NULL) return -1; Index: trunk/src_plugins/hid_remote/remote.c =================================================================== --- trunk/src_plugins/hid_remote/remote.c (revision 12041) +++ trunk/src_plugins/hid_remote/remote.c (revision 12042) @@ -79,7 +79,7 @@ const char *name; pcb_layer_id_t layer_id = arr[n]; pcb_layergrp_id_t gid = pcb_layer_get_group(PCB, layer_id); - name = pcb_layer_name(PCB, layer_id); + name = pcb_layer_name(PCB->Data, layer_id); if ((gid < 0) && (name != NULL)) { pcb_remote_new_layer_group(name, layer_id, pcb_layer_flags(PCB, layer_id)); pcb_remote_new_layer(name, layer_id, layer_id); @@ -91,7 +91,7 @@ pcb_layer_id_t lid = arr[n]; pcb_layergrp_id_t gid = pcb_layer_get_group(PCB, lid); if (gid >= 0) - pcb_remote_new_layer(pcb_layer_name(PCB, lid), lid, gid); + pcb_remote_new_layer(pcb_layer_name(PCB->Data, lid), lid, gid); } } Index: trunk/src_plugins/io_eagle/read.c =================================================================== --- trunk/src_plugins/io_eagle/read.c (revision 12041) +++ trunk/src_plugins/io_eagle/read.c (revision 12042) @@ -544,7 +544,7 @@ pcb_message(PCB_MSG_WARNING, "Ignoring circle on layer %s\n", ly->name); return 0; } - circ = pcb_arc_alloc(pcb_get_layer(ly->ly)); + circ = pcb_arc_alloc(pcb_get_layer(st->pcb->Data, ly->ly)); break; } circ->X = eagle_get_attrc(st, subtree, "x", -1); @@ -563,7 +563,7 @@ case IN_ELEM: break; case ON_BOARD: size_bump(st, circ->X + circ->Width + circ->Thickness, circ->Y + circ->Width + circ->Thickness); - pcb_add_arc_on_layer(pcb_get_layer(ly->ly), circ); + pcb_add_arc_on_layer(pcb_get_layer(st->pcb->Data, ly->ly), circ); break; } @@ -601,10 +601,10 @@ pcb_message(PCB_MSG_WARNING, "Ignoring rectangle on layer %s\n", ly->name); return 0; } - lin1 = pcb_line_alloc(pcb_get_layer(ly->ly)); - lin2 = pcb_line_alloc(pcb_get_layer(ly->ly)); - lin3 = pcb_line_alloc(pcb_get_layer(ly->ly)); - lin4 = pcb_line_alloc(pcb_get_layer(ly->ly)); + lin1 = pcb_line_alloc(pcb_get_layer(st->pcb->Data, ly->ly)); + lin2 = pcb_line_alloc(pcb_get_layer(st->pcb->Data, ly->ly)); + lin3 = pcb_line_alloc(pcb_get_layer(st->pcb->Data, ly->ly)); + lin4 = pcb_line_alloc(pcb_get_layer(st->pcb->Data, ly->ly)); break; } @@ -642,10 +642,10 @@ case ON_BOARD: size_bump(st, lin1->Point1.X + lin1->Thickness, lin1->Point1.Y + lin1->Thickness); size_bump(st, lin3->Point1.X + lin3->Thickness, lin3->Point1.Y + lin3->Thickness); - pcb_add_line_on_layer(pcb_get_layer(ly->ly), lin1); - pcb_add_line_on_layer(pcb_get_layer(ly->ly), lin2); - pcb_add_line_on_layer(pcb_get_layer(ly->ly), lin3); - pcb_add_line_on_layer(pcb_get_layer(ly->ly), lin4); + pcb_add_line_on_layer(pcb_get_layer(st->pcb->Data, ly->ly), lin1); + pcb_add_line_on_layer(pcb_get_layer(st->pcb->Data, ly->ly), lin2); + pcb_add_line_on_layer(pcb_get_layer(st->pcb->Data, ly->ly), lin3); + pcb_add_line_on_layer(pcb_get_layer(st->pcb->Data, ly->ly), lin4); break; } @@ -705,7 +705,7 @@ pcb_message(PCB_MSG_WARNING, "Ignoring wire on layer %s\n", ly->name); return 0; } - lin = pcb_line_alloc(pcb_get_layer(ly->ly)); + lin = pcb_line_alloc(pcb_get_layer(st->pcb->Data, ly->ly)); } lin->Point1.X = eagle_get_attrc(st, subtree, "x1", -1); lin->Point1.Y = eagle_get_attrc(st, subtree, "y1", -1); @@ -725,7 +725,7 @@ case ON_BOARD: size_bump(st, lin->Point1.X + lin->Thickness, lin->Point1.Y + lin->Thickness); size_bump(st, lin->Point2.X + lin->Thickness, lin->Point2.Y + lin->Thickness); - pcb_add_line_on_layer(pcb_get_layer(ly->ly), lin); + pcb_add_line_on_layer(pcb_get_layer(st->pcb->Data, ly->ly), lin); break; } Index: trunk/src_plugins/io_hyp/parser.c =================================================================== --- trunk/src_plugins/io_hyp/parser.c (revision 12041) +++ trunk/src_plugins/io_hyp/parser.c (revision 12042) @@ -491,7 +491,7 @@ pcb_message(PCB_MSG_ERROR, "no outline layer.\n"); return; } - outline_layer = pcb_get_layer(outline_id); + outline_layer = pcb_get_layer(PCB->Data, outline_id); if (outline_layer == NULL) { pcb_message(PCB_MSG_ERROR, "get outline layer failed.\n"); return; @@ -979,7 +979,7 @@ pcb_layer_t *hyp_get_layer(parse_param * h) { - return pcb_get_layer(hyp_create_layer(h->layer_name)); + return pcb_get_layer(PCB->Data, hyp_create_layer(h->layer_name)); } /* @@ -1148,7 +1148,7 @@ if (hyp_debug) pcb_message(PCB_MSG_DEBUG, "draw polyline: drawing poly id=%i.\n", polyline->hyp_poly_id); - layer = pcb_get_layer(hyp_create_layer(polyline->layer_name)); + layer = pcb_get_layer(PCB->Data, hyp_create_layer(polyline->layer_name)); xpos = polyline->vertex->x1; ypos = polyline->vertex->y1; @@ -1204,7 +1204,7 @@ if (hyp_debug) pcb_message(PCB_MSG_DEBUG, "draw polygon: drawing poly id=%i.\n", polygon->hyp_poly_id); - layer = pcb_get_layer(hyp_create_layer(polygon->layer_name)); + layer = pcb_get_layer(PCB->Data, hyp_create_layer(polygon->layer_name)); outer_contour = pcb_true; Index: trunk/src_plugins/io_hyp/write.c =================================================================== --- trunk/src_plugins/io_hyp/write.c (revision 12041) +++ trunk/src_plugins/io_hyp/write.c (revision 12042) @@ -234,7 +234,7 @@ } else { /* explicit outline */ - pcb_layer_t *l = pcb_get_layer(lid); + pcb_layer_t *l = pcb_get_layer(PCB->Data, lid); gdl_iterator_t it; pcb_line_t *line; pcb_arc_t *arc; Index: trunk/src_plugins/lib_gtk_common/wt_layersel.c =================================================================== --- trunk/src_plugins/lib_gtk_common/wt_layersel.c (revision 12041) +++ trunk/src_plugins/lib_gtk_common/wt_layersel.c (revision 12042) @@ -106,7 +106,7 @@ int is_on = 0; if (lsl->ev_vis == NULL) { - pcb_layer_t *l = pcb_get_layer(lsl->lid); + pcb_layer_t *l = pcb_get_layer(PCB->Data, lsl->lid); if (l != NULL) is_on = l->meta.real.vis; } @@ -299,7 +299,7 @@ } } else { - pcb_layer_t *l = pcb_get_layer(lsl->lid); + pcb_layer_t *l = pcb_get_layer(PCB->Data, lsl->lid); if (l != NULL) is_on = !l->meta.real.vis; else @@ -430,7 +430,7 @@ else color = *force_color; - ly = pcb_get_layer(lid); + ly = pcb_get_layer(PCB->Data, lid); /* sensitive layer visibility widgets */ vis_box = build_visbox(color, &lsl->vis_on, &lsl->vis_off, (((ly != NULL) && (ly->comb & PCB_LYC_SUB)) ? 2 : 1), (((ly != NULL) && (ly->comb & PCB_LYC_AUTO)) ? 1 : 0)); @@ -535,7 +535,7 @@ } else { for(n = 0; n < grp->len; n++) { - pcb_layer_t *l = pcb_get_layer(grp->lid[n]); + pcb_layer_t *l = pcb_get_layer(PCB->Data, grp->lid[n]); if (l != NULL) { GtkWidget *wl = build_layer(lsg, &lsg->layer[n], l->name, grp->lid[n], NULL); gtk_box_pack_start(GTK_BOX(lsg->layers), wl, TRUE, TRUE, 1); Index: trunk/src_plugins/lib_hid_common/layer_menu.c =================================================================== --- trunk/src_plugins/lib_hid_common/layer_menu.c (revision 12041) +++ trunk/src_plugins/lib_hid_common/layer_menu.c (revision 12042) @@ -55,7 +55,7 @@ pcb_gui->create_menu(path, "TODO: action", "", "accel", "Layer group", cookie); for(n = 0; n < g->len; n++) { - pcb_layer_t *l = pcb_get_layer(g->lid[n]); + pcb_layer_t *l = pcb_get_layer(PCB->Data, g->lid[n]); pcb_snprintf(bn, len_avail, " %s", l->name); pcb_gui->create_menu(path, "TODO: action", "", "accel", "Layer", cookie); Index: trunk/src_plugins/lib_polyhelp/topoly.c =================================================================== --- trunk/src_plugins/lib_polyhelp/topoly.c (revision 12041) +++ trunk/src_plugins/lib_polyhelp/topoly.c (revision 12042) @@ -287,7 +287,7 @@ if (pcb_layer_list(pcb, PCB_LYT_OUTLINE, &lid, 1) != 1) return NULL; - layer = pcb_get_layer(lid); + layer = pcb_get_layer(PCB->Data, lid); PCB_LINE_LOOP(layer) { check(line->Point1.X, line->Point1.Y, line); check(line->Point2.X, line->Point2.Y, line); Index: trunk/src_plugins/millpath/toolpath.c =================================================================== --- trunk/src_plugins/millpath/toolpath.c (revision 12041) +++ trunk/src_plugins/millpath/toolpath.c (revision 12042) @@ -89,7 +89,7 @@ { int n; for(n = 0; n < grp->len; n++) { - pcb_layer_t *l = pcb_get_layer(grp->lid[n]); + pcb_layer_t *l = pcb_get_layer(PCB->Data, grp->lid[n]); if (l != NULL) sub_layer_all(pcb, result, l, centerline); } @@ -171,7 +171,7 @@ otlbb.X2 = otlbb.Y2 = -PCB_MAX_COORD; for(n = 0; n < og->len; n++) { - pcb_layer_t *l = pcb_get_layer(og->lid[n]); + pcb_layer_t *l = pcb_get_layer(PCB->Data, og->lid[n]); if (l == NULL) continue;