Index: trunk/src/draw.c =================================================================== --- trunk/src/draw.c (revision 28107) +++ trunk/src/draw.c (revision 28108) @@ -426,7 +426,7 @@ if (pcb_layer_gui_set_glayer(PCB, group, 0, &info->xform_exporter)) { int is_current = 0; - pcb_layergrp_id_t cgrp = CURRENT->meta.real.grp; + pcb_layergrp_id_t cgrp = PCB_CURRLAYER(PCB)->meta.real.grp; if ((cgrp == solder) || (cgrp == component)) { /* current group is top or bottom: visibility depends on side we are looking at */ @@ -677,7 +677,7 @@ xform_setup(info, &xform, Layer); - current_grp = (Layer_->meta.real.grp == CURRENT->meta.real.grp); + current_grp = (Layer_->meta.real.grp == PCB_CURRLAYER(PCB)->meta.real.grp); if ((info->xform != NULL) && (info->xform->layer_faded)) { orig_color = Layer->meta.real.color; @@ -905,7 +905,7 @@ ly1 = info->pcb->Data->Layer + layers[0]; xform_setup(info, &tmp, ly1); - pcb_draw_pstks(info, group, (CURRENT->meta.real.grp == group), 0); + pcb_draw_pstks(info, group, (PCB_CURRLAYER(PCB)->meta.real.grp == group), 0); info->xform = NULL; info->layer = NULL; } Index: trunk/src/layer.h =================================================================== --- trunk/src/layer.h (revision 28107) +++ trunk/src/layer.h (revision 28108) @@ -186,8 +186,6 @@ /************ OLD API - new code should not use these **************/ -#define CURRENT (&PCB->Data->Layer[pcb_layer_stack[0]]) - #define LAYER_LOOP(data, ml) \ do { \ pcb_cardinal_t n; \ Index: trunk/src/obj_line_drcenf.c =================================================================== --- trunk/src/obj_line_drcenf.c (revision 28107) +++ trunk/src/obj_line_drcenf.c (revision 28108) @@ -45,7 +45,7 @@ pcb_attached_line_t *line = &pcb_crosshair.AttachedLine; int flags = conf_core.editor.clear_line ? PCB_FLAG_CLEARLINE : 0; - if (conf_core.editor.auto_drc && (pcb_layer_flags_(CURRENT) & PCB_LYT_COPPER)) + if (conf_core.editor.auto_drc && (pcb_layer_flags_(PCB_CURRLAYER(PCB)) & PCB_LYT_COPPER)) flags |= PCB_FLAG_FOUND; /* I need at least one point */ @@ -57,7 +57,7 @@ pcb_route_calculate(PCB, &pcb_crosshair.Route, &line->Point1, &line->Point2, - pcb_layer_id(PCB->Data, CURRENT), + pcb_layer_id(PCB->Data, PCB_CURRLAYER(PCB)), conf_core.design.line_thickness, conf_core.design.clearance * 2, pcb_flag_make(flags), pcb_gui->shift_is_pressed(pcb_gui), pcb_gui->control_is_pressed(pcb_gui)); @@ -243,7 +243,7 @@ line1.type = line2.type = PCB_OBJ_LINE; line1.Flags = line2.Flags = pcb_no_flags(); line1.parent_type = line2.parent_type = PCB_PARENT_LAYER; - line1.parent.layer = line2.parent.layer = CURRENT; + line1.parent.layer = line2.parent.layer = PCB_CURRLAYER(PCB); line1.Thickness = conf_core.design.line_thickness + 2 * (conf_core.design.bloat + 1); line2.Thickness = line1.Thickness; line1.Clearance = line2.Clearance = 0; @@ -420,7 +420,7 @@ aline.Point1.Y = pcb_crosshair.AttachedLine.Point1.Y; pcb_line_45(&aline); line.parent_type = PCB_PARENT_LAYER; - line.parent.layer = CURRENT; + line.parent.layer = PCB_CURRLAYER(PCB); line.type = PCB_OBJ_LINE; line.Point1 = aline.Point1; line.Point2 = aline.Point2; Index: trunk/src/obj_pstk.c =================================================================== --- trunk/src/obj_pstk.c (revision 28107) +++ trunk/src/obj_pstk.c (revision 28108) @@ -740,7 +740,7 @@ { pcb_pstk_shape_t *shape = NULL; pcb_board_t *pcb; - pcb_layergrp_id_t gid = CURRENT->meta.real.grp; + pcb_layergrp_id_t gid = PCB_CURRLAYER(PCB)->meta.real.grp; pcb = pcb_data_get_top(ps->parent.data); if (pcb != NULL) { Index: trunk/src/obj_rat.c =================================================================== --- trunk/src/obj_rat.c (revision 28107) +++ trunk/src/obj_rat.c (revision 28108) @@ -383,18 +383,18 @@ { pcb_line_t *newone; - newone = pcb_line_new_merge(CURRENT, Rat->Point1.X, Rat->Point1.Y, + newone = pcb_line_new_merge(PCB_CURRLAYER(PCB), Rat->Point1.X, Rat->Point1.Y, ctx->insert.x, ctx->insert.y, conf_core.design.line_thickness, 2 * conf_core.design.clearance, Rat->Flags); if (!newone) return newone; - pcb_undo_add_obj_to_create(PCB_OBJ_LINE, CURRENT, newone, newone); + pcb_undo_add_obj_to_create(PCB_OBJ_LINE, PCB_CURRLAYER(PCB), newone, newone); pcb_rat_invalidate_erase(Rat); - pcb_line_invalidate_draw(CURRENT, newone); - newone = pcb_line_new_merge(CURRENT, Rat->Point2.X, Rat->Point2.Y, + pcb_line_invalidate_draw(PCB_CURRLAYER(PCB), newone); + newone = pcb_line_new_merge(PCB_CURRLAYER(PCB), Rat->Point2.X, Rat->Point2.Y, ctx->insert.x, ctx->insert.y, conf_core.design.line_thickness, 2 * conf_core.design.clearance, Rat->Flags); if (newone) { - pcb_undo_add_obj_to_create(PCB_OBJ_LINE, CURRENT, newone, newone); - pcb_line_invalidate_draw(CURRENT, newone); + pcb_undo_add_obj_to_create(PCB_OBJ_LINE, PCB_CURRLAYER(PCB), newone, newone); + pcb_line_invalidate_draw(PCB_CURRLAYER(PCB), newone); } pcb_undo_move_obj_to_remove(PCB_OBJ_RAT, Rat, Rat, Rat); return newone; Index: trunk/src/polygon.c =================================================================== --- trunk/src/polygon.c (revision 28107) +++ trunk/src/polygon.c (revision 28108) @@ -1188,7 +1188,7 @@ */ void pcb_polygon_copy_attached_to_layer(void) { - pcb_layer_t *layer = pcb_loose_subc_layer(PCB, CURRENT, pcb_true); + pcb_layer_t *layer = pcb_loose_subc_layer(PCB, PCB_CURRLAYER(PCB), pcb_true); pcb_poly_t *polygon; int saveID; Index: trunk/src/search.c =================================================================== --- trunk/src/search.c (revision 28107) +++ trunk/src/search.c (revision 28108) @@ -103,7 +103,7 @@ if (!pcb_is_point_in_pstk(PosX, PosY, SearchRadius, ps, NULL)) return PCB_R_DIR_NOT_FOUND; - if ((i->on_current) && (pcb_pstk_shape_at(PCB, ps, CURRENT) == NULL) && (!pcb_pstk_bb_drills(PCB, ps, CURRENT->meta.real.grp, NULL))) + if ((i->on_current) && (pcb_pstk_shape_at(PCB, ps, PCB_CURRLAYER(PCB)) == NULL) && (!pcb_pstk_bb_drills(PCB, ps, PCB_CURRLAYER(PCB)->meta.real.grp, NULL))) return PCB_R_DIR_NOT_FOUND; if ((i->on_lyt != 0) && (pcb_pstk_shape(ps, i->on_lyt, 0) == NULL)) return PCB_R_DIR_NOT_FOUND; Index: trunk/src_plugins/acompnet/acompnet.c =================================================================== --- trunk/src_plugins/acompnet/acompnet.c (revision 28107) +++ trunk/src_plugins/acompnet/acompnet.c (revision 28108) @@ -133,7 +133,7 @@ double sep = conf_core.design.line_thickness + conf_core.design.bloat; int n; - PCB_LINE_LOOP(CURRENT) { + PCB_LINE_LOOP(PCB_CURRLAYER(PCB)) { double i, len, vx, vy, x1, y1, x2, y2, nx, ny; x1 = line->Point1.X; x2 = line->Point2.X; @@ -178,7 +178,7 @@ long int is, ie; pcb_msgr_init(&gr); - acompnet_mesh(&gr, CURRENT); + acompnet_mesh(&gr, PCB_CURRLAYER(PCB)); { /* temporary hack for testing: fixed, off-mesh start/end */ pcb_box_t bbox; Index: trunk/src_plugins/ddraft/cli_line.c =================================================================== --- trunk/src_plugins/ddraft/cli_line.c (revision 28107) +++ trunk/src_plugins/ddraft/cli_line.c (revision 28108) @@ -47,7 +47,7 @@ res = line_parse(line, argc, argv, &box, 1, 0); if (res == 0) { pcb_trace("line_exec: %mm;%mm -> %mm;%mm\n", box.X1, box.Y1, box.X2, box.Y2); - pcb_line_new(CURRENT, box.X1, box.Y1, box.X2, box.Y2, + pcb_line_new(PCB_CURRLAYER(PCB), box.X1, box.Y1, box.X2, box.Y2, conf_core.design.line_thickness, 2 * conf_core.design.clearance, pcb_flag_make(conf_core.editor.clear_line ? PCB_FLAG_CLEARLINE : 0)); } Index: trunk/src_plugins/ddraft/ddraft.c =================================================================== --- trunk/src_plugins/ddraft/ddraft.c (revision 28107) +++ trunk/src_plugins/ddraft/ddraft.c (revision 28108) @@ -453,7 +453,7 @@ } if (pcb_ddraft_attached.line_valid) { - pcb_render->set_color(pcb_crosshair.GC, &CURRENT->meta.real.color); + pcb_render->set_color(pcb_crosshair.GC, &PCB_CURRLAYER(PCB)->meta.real.color); pcb_draw_wireframe_line(pcb_crosshair.GC, pcb_ddraft_attached.line.Point1.X, pcb_ddraft_attached.line.Point1.Y, pcb_ddraft_attached.line.Point2.X, pcb_ddraft_attached.line.Point2.Y, conf_core.design.line_thickness, 0); Index: trunk/src_plugins/export_openems/mesh.c =================================================================== --- trunk/src_plugins/export_openems/mesh.c (revision 28107) +++ trunk/src_plugins/export_openems/mesh.c (revision 28108) @@ -1015,7 +1015,7 @@ static void ia_gen_cb(void *hid_ctx, void *caller_data, pcb_hid_attribute_t *attr) { mesh_layer_reset(); - mesh.layer = CURRENT; + mesh.layer = PCB_CURRLAYER(PCB); dlg2mesh(); Index: trunk/src_plugins/import_mucs/mucs.c =================================================================== --- trunk/src_plugins/import_mucs/mucs.c (revision 28107) +++ trunk/src_plugins/import_mucs/mucs.c (revision 28108) @@ -114,7 +114,7 @@ y2 = (getc(fi) + (getc(fi) * 256)); pcb_trace("Line(%d %d %d %d 20 \" \")\n", x1, y1, x2, y2); /* consider a bounds checking function to censor absurd coord sizes */ - pcb_line_new(CURRENT, PCB_MIL_TO_COORD(x1), PCB_MIL_TO_COORD(y1), PCB_MIL_TO_COORD(x2), PCB_MIL_TO_COORD(y2), PCB_MIL_TO_COORD(10), PCB_MIL_TO_COORD(10), pcb_flag_make(PCB_FLAG_AUTO)); + pcb_line_new(PCB_CURRLAYER(PCB), PCB_MIL_TO_COORD(x1), PCB_MIL_TO_COORD(y1), PCB_MIL_TO_COORD(x2), PCB_MIL_TO_COORD(y2), PCB_MIL_TO_COORD(10), PCB_MIL_TO_COORD(10), pcb_flag_make(PCB_FLAG_AUTO)); break; case 'c': x1 = (getc(fi) + (getc(fi) * 256)); @@ -128,7 +128,7 @@ x1 = (getc(fi) + (getc(fi) * 256)); y1 = (getc(fi) + (getc(fi) * 256)); pcb_trace("Line(%d %d %d %d 20 \" \")\n", x1, y1, x2, y2); - pcb_line_new(CURRENT, PCB_MIL_TO_COORD(x1), PCB_MIL_TO_COORD(y1), PCB_MIL_TO_COORD(x2), PCB_MIL_TO_COORD(y2), PCB_MIL_TO_COORD(10), PCB_MIL_TO_COORD(10), pcb_flag_make(PCB_FLAG_AUTO)); + pcb_line_new(PCB_CURRLAYER(PCB), PCB_MIL_TO_COORD(x1), PCB_MIL_TO_COORD(y1), PCB_MIL_TO_COORD(x2), PCB_MIL_TO_COORD(y2), PCB_MIL_TO_COORD(10), PCB_MIL_TO_COORD(10), pcb_flag_make(PCB_FLAG_AUTO)); x2 = x1; y2 = y1; break; Index: trunk/src_plugins/io_tedax/io_tedax.c =================================================================== --- trunk/src_plugins/io_tedax/io_tedax.c (revision 28107) +++ trunk/src_plugins/io_tedax/io_tedax.c (revision 28108) @@ -90,7 +90,7 @@ } if (pcb_strcasecmp(type, "layer") == 0) { - PCB_ACT_IRES(tedax_layer_save(PCB, pcb_layer_get_group_(CURRENT), NULL, fname)); + PCB_ACT_IRES(tedax_layer_save(PCB, pcb_layer_get_group_(PCB_CURRLAYER(PCB)), NULL, fname)); return 0; } Index: trunk/src_plugins/jostle/jostle.c =================================================================== --- trunk/src_plugins/jostle/jostle.c (revision 28107) +++ trunk/src_plugins/jostle/jostle.c (revision 28108) @@ -482,7 +482,7 @@ y = pcb_crosshair.Y; fprintf(stderr, "%d, %d, %f\n", (int) x, (int) y, value); info.brush = pcb_poly_from_circle(x, y, value / 2); - info.layer = CURRENT; + info.layer = PCB_CURRLAYER(PCB); PCB_LINE_LOOP(info.layer); { PCB_FLAG_CLEAR(PCB_FLAG_DRC, line); Index: trunk/src_plugins/lib_hid_pcbui/act.c =================================================================== --- trunk/src_plugins/lib_hid_pcbui/act.c (revision 28107) +++ trunk/src_plugins/lib_hid_pcbui/act.c (revision 28108) @@ -283,7 +283,7 @@ switch (b[0]) { case 'S': case 's': - lyt = (pcb_layer_flags_(CURRENT) & PCB_LYT_ANYTHING) | (!conf_core.editor.show_solder_side ? PCB_LYT_BOTTOM : PCB_LYT_TOP); + lyt = (pcb_layer_flags_(PCB_CURRLAYER(PCB)) & PCB_LYT_ANYTHING) | (!conf_core.editor.show_solder_side ? PCB_LYT_BOTTOM : PCB_LYT_TOP); lid = pcb_layer_vis_last_lyt(lyt); if (lid >= 0) pcb_layervis_change_group_vis(&PCB->hidlib, lid, 1, 1); Index: trunk/src_plugins/lib_hid_pcbui/layersel.c =================================================================== --- trunk/src_plugins/lib_hid_pcbui/layersel.c (revision 28107) +++ trunk/src_plugins/lib_hid_pcbui/layersel.c (revision 28108) @@ -341,7 +341,7 @@ } /* Select the first visible layer (physically) below the one turned off or - reenable the original if all are off; this how we ensure the CURRENT layer + reenable the original if all are off; this how we ensure the current layer is visible and avoid drawing on inivisible layers */ static void ensure_visible_current(layersel_ctx_t *ls) { @@ -359,10 +359,10 @@ /* currently selected layer lost visible state - choose another */ /* At the moment the layer selector displays only board layers which are always real */ - assert(!CURRENT->is_bound); + assert(!PCB_CURRLAYER(PCB)->is_bound); /* look for the next one to enable, group-vise */ - for(gid = CURRENT->meta.real.grp + 1; gid != CURRENT->meta.real.grp; gid++) { + for(gid = PCB_CURRLAYER(PCB)->meta.real.grp + 1; gid != PCB_CURRLAYER(PCB)->meta.real.grp; gid++) { pcb_layergrp_t *g; if (gid >= pcb_max_group(PCB)) { gid = 0; @@ -379,7 +379,7 @@ } /* fallback: all off; turn the current one back on */ - l = CURRENT; + l = PCB_CURRLAYER(PCB); change_selection:; lid = pcb_layer_id(PCB->Data, l); @@ -624,7 +624,7 @@ if (is_open) layersel_create_layer_open(ls, lys, ly->name, clr, brd, hatch, 1); else - layersel_create_layer_closed(ls, lys, ly->name, clr, brd, hatch, (ly == CURRENT), 1); + layersel_create_layer_closed(ls, lys, ly->name, clr, brd, hatch, (ly ==PCB_CURRLAYER(PCB)), 1); } } if (is_open) @@ -820,8 +820,8 @@ pcb_gui->attr_dlg_widget_hide(ls->sub.dlg_hid_ctx, (*lgs)->wclosed, (*lgs)->is_open); } - { /* if CURRENT is not selected, select it */ - ls_layer_t *lys = lys_get(ls, &ls->real_layer, pcb_layer_id(PCB->Data, CURRENT), 0); + { /* ifPCB_CURRLAYER(PCB) is not selected, select it */ + ls_layer_t *lys = lys_get(ls, &ls->real_layer, pcb_layer_id(PCB->Data,PCB_CURRLAYER(PCB)), 0); if ((lys != NULL) && (lys->wlab != ls->w_last_sel)) locked_layersel(ls, lys->wlab, lys->wunsel_closed, lys->wsel_closed); } Index: trunk/src_plugins/lib_polyhelp/polyhelp.c =================================================================== --- trunk/src_plugins/lib_polyhelp/polyhelp.c (revision 28107) +++ trunk/src_plugins/lib_polyhelp/polyhelp.c (revision 28108) @@ -477,17 +477,17 @@ for(pa = pcb_poly_island_first(polygon, &it); pa != NULL; pa = pcb_poly_island_next(&it)) { pcb_pline_t *pl = pcb_poly_contour(&it); if (pl != NULL) { /* we have a contour */ - pcb_pline_to_lines(CURRENT, pl, conf_core.design.line_thickness, conf_core.design.line_thickness * 2, flg); + pcb_pline_to_lines(PCB_CURRLAYER(PCB), pl, conf_core.design.line_thickness, conf_core.design.line_thickness * 2, flg); for(pl = pcb_poly_hole_first(&it); pl != NULL; pl = pcb_poly_hole_next(&it)) - pcb_pline_to_lines(CURRENT, pl, conf_core.design.line_thickness, conf_core.design.line_thickness * 2, flg); + pcb_pline_to_lines(PCB_CURRLAYER(PCB), pl, conf_core.design.line_thickness, conf_core.design.line_thickness * 2, flg); } } } if (want_poly) { - pcb_poly_t *p = pcb_poly_new_from_poly(CURRENT, polygon, period, polygon->Clearance, polygon->Flags); + pcb_poly_t *p = pcb_poly_new_from_poly(PCB_CURRLAYER(PCB), polygon, period, polygon->Clearance, polygon->Flags); PCB_FLAG_CLEAR(PCB_FLAG_SELECTED, p); } - pcb_cpoly_hatch_lines(CURRENT, polygon, dir, period, conf_core.design.line_thickness, conf_core.design.line_thickness * 2, flg); + pcb_cpoly_hatch_lines(PCB_CURRLAYER(PCB), polygon, dir, period, conf_core.design.line_thickness, conf_core.design.line_thickness * 2, flg); } PCB_ENDALL_LOOP; PCB_ACT_IRES(0); @@ -507,7 +507,7 @@ if (!PCB_FLAG_TEST(PCB_FLAG_SELECTED, polygon)) continue; - p = pcb_poly_new_from_poly(CURRENT, polygon, offs, polygon->Clearance, polygon->Flags); + p = pcb_poly_new_from_poly(PCB_CURRLAYER(PCB), polygon, offs, polygon->Clearance, polygon->Flags); PCB_FLAG_CLEAR(PCB_FLAG_SELECTED, p); } PCB_ENDALL_LOOP; Index: trunk/src_plugins/millpath/millpath.c =================================================================== --- trunk/src_plugins/millpath/millpath.c (revision 28107) +++ trunk/src_plugins/millpath/millpath.c (revision 28108) @@ -48,7 +48,7 @@ { ctx.edge_clearance = PCB_MM_TO_COORD(0.05); ctx.tools = &tools; - PCB_ACT_IRES(pcb_tlp_mill_copper_layer(&ctx, CURRENT)); + PCB_ACT_IRES(pcb_tlp_mill_copper_layer(&ctx, PCB_CURRLAYER(PCB))); return 0; } Index: trunk/src_plugins/propedit/propedit.c =================================================================== --- trunk/src_plugins/propedit/propedit.c (revision 28107) +++ trunk/src_plugins/propedit/propedit.c (revision 28108) @@ -89,7 +89,7 @@ vtl0_append(&pe->layergrps, id); } else { - vtl0_append(&pe->layergrps, CURRENT->meta.real.grp); + vtl0_append(&pe->layergrps, PCB_CURRLAYER(PCB)->meta.real.grp); } } else if (strncmp(cmd, "layer", 5) == 0) { Index: trunk/src_plugins/puller/puller.c =================================================================== --- trunk/src_plugins/puller/puller.c (revision 28107) +++ trunk/src_plugins/puller/puller.c (revision 28108) @@ -326,8 +326,8 @@ spot.Y1 = y - 1; spot.X2 = x + 1; spot.Y2 = y + 1; - pcb_r_search(CURRENT->line_tree, &spot, NULL, line_callback, CURRENT, NULL); - pcb_r_search(CURRENT->arc_tree, &spot, NULL, arc_callback, CURRENT, NULL); + pcb_r_search(PCB_CURRLAYER(PCB)->line_tree, &spot, NULL, line_callback, PCB_CURRLAYER(PCB), NULL); + pcb_r_search(PCB_CURRLAYER(PCB)->arc_tree, &spot, NULL, arc_callback, PCB_CURRLAYER(PCB), NULL); if (the_line && the_arc && !multi) return 1; x = Px; @@ -379,7 +379,7 @@ cx = the_arc->X; cy = the_arc->Y; if (arc_endpoint_is(the_arc, the_arc->StartAngle, x, y)) { - pcb_arc_set_angles(CURRENT, the_arc, the_arc->StartAngle + the_arc->Delta, -the_arc->Delta); + pcb_arc_set_angles(PCB_CURRLAYER(PCB), the_arc, the_arc->StartAngle + the_arc->Delta, -the_arc->Delta); } else if (!arc_endpoint_is(the_arc, the_arc->StartAngle + the_arc->Delta, x, y)) { #if TRACE1 @@ -427,7 +427,7 @@ new_delta_angle -= 360; if (new_delta_angle < -180) new_delta_angle += 360; - pcb_arc_set_angles(CURRENT, the_arc, the_arc->StartAngle, new_delta_angle); + pcb_arc_set_angles(PCB_CURRLAYER(PCB), the_arc, the_arc->StartAngle, new_delta_angle); #if TRACE1 printf("arc now start %ld end %ld\n", the_arc->StartAngle, the_arc->StartAngle + new_delta_angle); @@ -437,7 +437,7 @@ x = the_arc->X - the_arc->Width * cos(d2r(arc_angle)) + 0.5; y = the_arc->Y + the_arc->Height * sin(d2r(arc_angle)) + 0.5; - pcb_move_obj(PCB_OBJ_LINE_POINT, CURRENT, the_line, &(the_line->Point2), x - the_line->Point2.X, y - the_line->Point2.Y); + pcb_move_obj(PCB_OBJ_LINE_POINT, PCB_CURRLAYER(PCB), the_line, &(the_line->Point2), x - the_line->Point2.X, y - the_line->Point2.Y); pcb_gui->invalidate_all(pcb_gui); pcb_undo_inc_serial(); @@ -688,8 +688,8 @@ b.X2 = x + 10; b.Y1 = y - 10; b.Y2 = y + 10; - pcb_r_search(CURRENT->line_tree, &b, NULL, find_pair_line_callback, &fpcs, NULL); - pcb_r_search(CURRENT->arc_tree, &b, NULL, find_pair_arc_callback, &fpcs, NULL); + pcb_r_search(PCB_CURRLAYER(PCB)->line_tree, &b, NULL, find_pair_line_callback, &fpcs, NULL); + pcb_r_search(PCB_CURRLAYER(PCB)->arc_tree, &b, NULL, find_pair_arc_callback, &fpcs, NULL); } static int check_point_in_pstk(pcb_pstk_t *ps, pcb_layer_t *layer, int x, int y, End *e) @@ -803,8 +803,8 @@ PCB_PADSTACK_LOOP(PCB->Data); { pcb_box_t box; box = padstack->BoundingBox; - pcb_r_search(CURRENT->line_tree, &box, NULL, find_pair_pstkline_callback, padstack, NULL); - pcb_r_search(CURRENT->arc_tree, &box, NULL, find_pair_pstkarc_callback, padstack, NULL); + pcb_r_search(PCB_CURRLAYER(PCB)->line_tree, &box, NULL, find_pair_pstkline_callback, padstack, NULL); + pcb_r_search(PCB_CURRLAYER(PCB)->arc_tree, &box, NULL, find_pair_pstkarc_callback, padstack, NULL); } PCB_END_LOOP; } @@ -820,16 +820,16 @@ static void find_pairs() { - PCB_ARC_LOOP(CURRENT); { + PCB_ARC_LOOP(PCB_CURRLAYER(PCB)); { Extra *e = new_arc_extra(arc); fix_arc_extra(arc, e); } PCB_END_LOOP; - PCB_LINE_LOOP(CURRENT); { + PCB_LINE_LOOP(PCB_CURRLAYER(PCB)); { new_line_extra(line); } PCB_END_LOOP; - PCB_LINE_LOOP(CURRENT); { + PCB_LINE_LOOP(PCB_CURRLAYER(PCB)); { Extra *e = LINE2EXTRA(line); if (line->Point1.X >= 0) { find_pairs_1(line, &e->start.next, line->Point1.X, line->Point1.Y); @@ -838,7 +838,7 @@ } PCB_END_LOOP; - PCB_ARC_LOOP(CURRENT); { + PCB_ARC_LOOP(PCB_CURRLAYER(PCB)); { Extra *e = ARC2EXTRA(arc); if (!e->deleted) { find_pairs_1(arc, &e->start.next, e->start.x, e->start.y); @@ -1014,11 +1014,11 @@ Extra *e; clear_found(); - PCB_LINE_LOOP(CURRENT); { + PCB_LINE_LOOP(PCB_CURRLAYER(PCB)); { e = LINE2EXTRA(line); trace_path(e); } PCB_END_LOOP; - PCB_ARC_LOOP(CURRENT); { + PCB_ARC_LOOP(PCB_CURRLAYER(PCB)); { e = ARC2EXTRA(arc); trace_path(e); } PCB_END_LOOP; @@ -1034,8 +1034,8 @@ x = line->Point1.X; y = line->Point1.Y; #if 1 - pcb_move_obj(PCB_OBJ_LINE_POINT, CURRENT, line, &(line->Point1), line->Point2.X - line->Point1.X, line->Point2.Y - line->Point1.Y); - pcb_move_obj(PCB_OBJ_LINE_POINT, CURRENT, line, &(line->Point2), x - line->Point2.X, y - line->Point2.Y); + pcb_move_obj(PCB_OBJ_LINE_POINT, PCB_CURRLAYER(PCB), line, &(line->Point1), line->Point2.X - line->Point1.X, line->Point2.Y - line->Point1.Y); + pcb_move_obj(PCB_OBJ_LINE_POINT, PCB_CURRLAYER(PCB), line, &(line->Point2), x - line->Point2.X, y - line->Point2.Y); #else /* In theory, we should be using the above so that undo works. */ line->Point1.X = line->Point2.X; @@ -1054,7 +1054,7 @@ End etmp; #if 1 - pcb_arc_set_angles(CURRENT, arc, arc->StartAngle + arc->Delta, -arc->Delta); + pcb_arc_set_angles(PCB_CURRLAYER(PCB), arc, arc->StartAngle + arc->Delta, -arc->Delta); #else /* Likewise, see above. */ arc->StartAngle += arc->Delta; @@ -1398,7 +1398,7 @@ static pcb_r_dir_t gp_pstk_cb(const pcb_box_t *b, void *cb) { pcb_pstk_t *ps = (pcb_pstk_t *)b; /* have to drop const because we may update the cache in ps */ - pcb_layer_t *layer = CURRENT; + pcb_layer_t *layer = PCB_CURRLAYER(PCB); pcb_pstk_shape_t *shape = pcb_pstk_shape_at(PCB, ps, layer), tmpshp; if (ps == start_pinpad || ps == end_pinpad) @@ -1433,9 +1433,9 @@ Extra *e; pcb_printf("create_line from %#mD to %#mD\n", x1, y1, x2, y2); #endif - pcb_line_t *line = pcb_line_new(CURRENT, x1, y1, x2, y2, + pcb_line_t *line = pcb_line_new(PCB_CURRLAYER(PCB), x1, y1, x2, y2, sample->Thickness, sample->Clearance, sample->Flags); - pcb_undo_add_obj_to_create(PCB_OBJ_LINE, CURRENT, line, line); + pcb_undo_add_obj_to_create(PCB_OBJ_LINE, PCB_CURRLAYER(PCB), line, line); #if TRACE1 e = @@ -1459,11 +1459,11 @@ #if TRACE1 pcb_printf("create_arc at %#mD r %#mS sa %d delta %d\n", x, y, r, sa, da); #endif - arc = pcb_arc_new(CURRENT, x, y, r, r, sa, da, sample->Thickness, sample->Clearance, sample->Flags, pcb_true); + arc = pcb_arc_new(PCB_CURRLAYER(PCB), x, y, r, r, sa, da, sample->Thickness, sample->Clearance, sample->Flags, pcb_true); if (arc == 0) { - arc = pcb_arc_new(CURRENT, x, y, r, r, sa, da * 2, sample->Thickness, sample->Clearance, sample->Flags, pcb_true); + arc = pcb_arc_new(PCB_CURRLAYER(PCB), x, y, r, r, sa, da * 2, sample->Thickness, sample->Clearance, sample->Flags, pcb_true); } - pcb_undo_add_obj_to_create(PCB_OBJ_ARC, CURRENT, arc, arc); + pcb_undo_add_obj_to_create(PCB_OBJ_ARC, PCB_CURRLAYER(PCB), arc, arc); if (!arc) longjmp(abort_buf, 1); @@ -1544,8 +1544,8 @@ fprintf(stderr, "double neg move?\n"); abort(); } - pcb_move_obj(PCB_OBJ_LINE_POINT, CURRENT, l, &(l->Point1), -1 - l->Point1.X, -1 - l->Point1.Y); - pcb_move_obj(PCB_OBJ_LINE_POINT, CURRENT, l, &(l->Point2), -1 - l->Point2.X, -1 - l->Point2.Y); + pcb_move_obj(PCB_OBJ_LINE_POINT, PCB_CURRLAYER(PCB), l, &(l->Point1), -1 - l->Point1.X, -1 - l->Point1.Y); + pcb_move_obj(PCB_OBJ_LINE_POINT, PCB_CURRLAYER(PCB), l, &(l->Point2), -1 - l->Point2.X, -1 - l->Point2.Y); #endif } @@ -1735,10 +1735,10 @@ end_pinpad = start_extra->end.pin; fp = 0; - pcb_r_search(CURRENT->line_tree, &box, NULL, gp_line_cb, 0, NULL); - pcb_r_search(CURRENT->arc_tree, &box, NULL, gp_arc_cb, 0, NULL); - pcb_r_search(CURRENT->text_tree, &box, NULL, gp_text_cb, 0, NULL); - pcb_r_search(CURRENT->polygon_tree, &box, NULL, gp_poly_cb, 0, NULL); + pcb_r_search(PCB_CURRLAYER(PCB)->line_tree, &box, NULL, gp_line_cb, 0, NULL); + pcb_r_search(PCB_CURRLAYER(PCB)->arc_tree, &box, NULL, gp_arc_cb, 0, NULL); + pcb_r_search(PCB_CURRLAYER(PCB)->text_tree, &box, NULL, gp_text_cb, 0, NULL); + pcb_r_search(PCB_CURRLAYER(PCB)->polygon_tree, &box, NULL, gp_poly_cb, 0, NULL); pcb_r_search(PCB->Data->padstack_tree, &box, NULL, gp_pstk_cb, 0, NULL); /* radians, absolute angle of (at the moment) the start_line */ @@ -1788,7 +1788,7 @@ mark_arc_for_deletion(end_arc); mark_line_for_deletion(start_line); mark_line_for_deletion(end_line); - pcb_arc_set_angles(CURRENT, start_arc, start_arc->StartAngle, new_delta); + pcb_arc_set_angles(PCB_CURRLAYER(PCB), start_arc, start_arc->StartAngle, new_delta); fix_arc_extra(start_arc, sarc_extra); did_something++; return; @@ -1823,13 +1823,13 @@ if (new_delta * start_arc->Delta <= 0) del_arc = 1; - pcb_arc_set_angles(CURRENT, start_arc, start_arc->StartAngle, new_delta); + pcb_arc_set_angles(PCB_CURRLAYER(PCB), start_arc, start_arc->StartAngle, new_delta); fix_arc_extra(start_arc, sarc_extra); - pcb_move_obj(PCB_OBJ_LINE_POINT, CURRENT, start_line, &(start_line->Point1), + pcb_move_obj(PCB_OBJ_LINE_POINT, PCB_CURRLAYER(PCB), start_line, &(start_line->Point1), sarc_extra->end.x - start_line->Point1.X, sarc_extra->end.y - start_line->Point1.Y); if (del_arc) { - pcb_move_obj(PCB_OBJ_LINE_POINT, CURRENT, start_line, &(start_line->Point1), + pcb_move_obj(PCB_OBJ_LINE_POINT, PCB_CURRLAYER(PCB), start_line, &(start_line->Point1), sarc_extra->start.x - start_line->Point1.X, sarc_extra->start.y - start_line->Point1.Y); mark_arc_for_deletion(start_arc); } @@ -1889,19 +1889,19 @@ if (new_delta * end_arc->Delta <= 0) del_arc = 1; - pcb_arc_set_angles(CURRENT, end_arc, end_arc->StartAngle, new_delta); + pcb_arc_set_angles(PCB_CURRLAYER(PCB), end_arc, end_arc->StartAngle, new_delta); fix_arc_extra(end_arc, earc_extra); - pcb_move_obj(PCB_OBJ_LINE_POINT, CURRENT, start_line, &(start_line->Point2), + pcb_move_obj(PCB_OBJ_LINE_POINT, PCB_CURRLAYER(PCB), start_line, &(start_line->Point2), earc_extra->end.x - start_line->Point2.X, earc_extra->end.y - start_line->Point2.Y); if (del_arc) { - pcb_move_obj(PCB_OBJ_LINE_POINT, CURRENT, start_line, &(start_line->Point2), + pcb_move_obj(PCB_OBJ_LINE_POINT, PCB_CURRLAYER(PCB), start_line, &(start_line->Point2), earc_extra->start.x - start_line->Point2.X, earc_extra->start.y - start_line->Point2.Y); mark_arc_for_deletion(end_arc); } } else { - pcb_move_obj(PCB_OBJ_LINE_POINT, CURRENT, start_line, &(start_line->Point2), + pcb_move_obj(PCB_OBJ_LINE_POINT, PCB_CURRLAYER(PCB), start_line, &(start_line->Point2), end_line->Point2.X - start_line->Point2.X, end_line->Point2.Y - start_line->Point2.Y); } mark_line_for_deletion(end_line); @@ -1935,7 +1935,7 @@ #if TRACE1 pcb_printf("new point %#mS\n", ex, ey); #endif - pcb_move_obj(PCB_OBJ_LINE_POINT, CURRENT, end_line, &(end_line->Point1), ex - end_line->Point1.X, ey - end_line->Point1.Y); + pcb_move_obj(PCB_OBJ_LINE_POINT, PCB_CURRLAYER(PCB), end_line, &(end_line->Point1), ex - end_line->Point1.X, ey - end_line->Point1.Y); /* Step 4: Split start_line at the obstacle and insert a zero-delta arc at it. */ @@ -1948,7 +1948,7 @@ if (end_arc) earc_extra = ARC2EXTRA(end_arc); - pcb_move_obj(PCB_OBJ_LINE_POINT, CURRENT, start_line, &(start_line->Point2), + pcb_move_obj(PCB_OBJ_LINE_POINT, PCB_CURRLAYER(PCB), start_line, &(start_line->Point2), new_aextra->start.x - start_line->Point2.X, new_aextra->start.y - start_line->Point2.Y); new_line = create_line(start_line, new_aextra->end.x, new_aextra->end.y, ex, ey); @@ -2092,7 +2092,7 @@ /* This canonicalizes all the lines, and cleans up near-misses. */ /* pcb_actionva(&PCB->hidlib, "djopt", "puller", 0); */ - cflg = pcb_layergrp_flags(PCB, pcb_layer_get_group_(CURRENT)); + cflg = pcb_layergrp_flags(PCB, pcb_layer_get_group_(PCB_CURRLAYER(PCB))); current_is_solder = (cflg & PCB_LYT_BOTTOM); current_is_component = (cflg & PCB_LYT_TOP); @@ -2126,7 +2126,7 @@ nloops++; status(); did_something = 0; - PCB_LINE_LOOP(CURRENT); { + PCB_LINE_LOOP(PCB_CURRLAYER(PCB)); { Extra *e = LINE2EXTRA(line); if (e->deleted) continue; @@ -2161,17 +2161,17 @@ printf("\nlines\n"); #endif - PCB_LINE_LOOP(CURRENT); + PCB_LINE_LOOP(PCB_CURRLAYER(PCB)); { if (LINE2EXTRA(line)->deleted) - pcb_line_destroy(CURRENT, line); + pcb_line_destroy(PCB_CURRLAYER(PCB), line); } PCB_END_LOOP; - PCB_ARC_LOOP(CURRENT); + PCB_ARC_LOOP(PCB_CURRLAYER(PCB)); { if (ARC2EXTRA(arc)->deleted) - pcb_arc_destroy(CURRENT, arc); + pcb_arc_destroy(PCB_CURRLAYER(PCB), arc); } PCB_END_LOOP; Index: trunk/src_plugins/shape/shape.c =================================================================== --- trunk/src_plugins/shape/shape.c (revision 28107) +++ trunk/src_plugins/shape/shape.c (revision 28108) @@ -209,13 +209,13 @@ if (p == NULL) return NULL; - pcb_poly_init_clip(PCB->Data, CURRENT, p); - pcb_poly_invalidate_draw(CURRENT, p); + pcb_poly_init_clip(PCB->Data, PCB_CURRLAYER(PCB), p); + pcb_poly_invalidate_draw(PCB_CURRLAYER(PCB), p); if (data != PCB->Data) { pcb_buffer_clear(PCB, PCB_PASTEBUFFER); - pcb_copy_obj_to_buffer(PCB, data, PCB->Data, PCB_OBJ_POLY, CURRENT, p, p); - pcb_r_delete_entry(CURRENT->polygon_tree, (pcb_box_t *)p); + pcb_copy_obj_to_buffer(PCB, data, PCB->Data, PCB_OBJ_POLY, PCB_CURRLAYER(PCB), p, p); + pcb_r_delete_entry(PCB_CURRLAYER(PCB)->polygon_tree, (pcb_box_t *)p); pcb_poly_free_fields(p); pcb_poly_free(p); pcb_tool_select_by_id(&PCB->hidlib, PCB_MODE_PASTE_BUFFER); @@ -228,7 +228,7 @@ pcb_poly_t *p; if (layer == pcb_shape_current_layer) - layer = CURRENT; + layer = PCB_CURRLAYER(PCB); p = regpoly(layer, corners, rx, ry, rot_deg, cx, cy); return any_poly_place(data, layer, p); @@ -239,7 +239,7 @@ pcb_poly_t *p; if (layer == pcb_shape_current_layer) - layer = CURRENT; + layer = PCB_CURRLAYER(PCB); p = pcb_genpoly_roundrect(layer, w, h, rx, ry, rot_deg, cx, cy, corner, roundres); return any_poly_place(data, layer, p); @@ -251,7 +251,7 @@ pcb_line_t *l; if (layer == pcb_shape_current_layer) - layer = CURRENT; + layer = PCB_CURRLAYER(PCB); if (conf_core.editor.clear_line) flags |= PCB_FLAG_CLEARLINE; @@ -263,8 +263,8 @@ if (data != PCB->Data) { pcb_buffer_clear(PCB, PCB_PASTEBUFFER); - pcb_copy_obj_to_buffer(PCB, data, PCB->Data, PCB_OBJ_LINE, CURRENT, l, l); - pcb_r_delete_entry(CURRENT->line_tree, (pcb_box_t *)l); + pcb_copy_obj_to_buffer(PCB, data, PCB->Data, PCB_OBJ_LINE, PCB_CURRLAYER(PCB), l, l); + pcb_r_delete_entry(PCB_CURRLAYER(PCB)->line_tree, (pcb_box_t *)l); pcb_line_free(l); pcb_tool_select_by_id(&PCB->hidlib, PCB_MODE_PASTE_BUFFER); } @@ -400,7 +400,7 @@ if ((data == PCB->Data) && (!have_coords)) pcb_hid_get_coords("Click on the center of the polygon", &x, &y, 0); - if (regpoly_place(data, CURRENT, corners, rx, ry, rot, x, y) == NULL) + if (regpoly_place(data, PCB_CURRLAYER(PCB), corners, rx, ry, rot, x, y) == NULL) pcb_message(PCB_MSG_ERROR, "regpoly(): failed to create the polygon\n"); PCB_ACT_IRES(0); @@ -516,7 +516,7 @@ if ((data == PCB->Data) && (!have_coords)) pcb_hid_get_coords("Click on the center of the polygon", &x, &y, 0); - if (roundrect_place(data, CURRENT, w, h, rx, ry, rot, x, y, corner, roundres) == NULL) + if (roundrect_place(data, PCB_CURRLAYER(PCB), w, h, rx, ry, rot, x, y, corner, roundres) == NULL) pcb_message(PCB_MSG_ERROR, "roundrect(): failed to create the polygon\n"); PCB_ACT_IRES(0); @@ -570,7 +570,7 @@ if ((data == PCB->Data) && (!have_coords)) pcb_hid_get_coords("Click on the center of the circle", &x, &y, 0); - if (circle_place(PCB->Data, CURRENT, dia, x, y) == NULL) + if (circle_place(PCB->Data, PCB_CURRLAYER(PCB), dia, x, y) == NULL) pcb_message(PCB_MSG_ERROR, "circle(): failed to create the polygon\n"); PCB_ACT_IRES(0); Index: trunk/src_plugins/shape/shape.h =================================================================== --- trunk/src_plugins/shape/shape.h (revision 28107) +++ trunk/src_plugins/shape/shape.h (revision 28108) @@ -31,7 +31,7 @@ #include "layer.h" #include "pcb_bool.h" -/* special layer: when used, the shape is always placed on the CURRENT layer */ +/* special layer: when used, the shape is always placed on the current layer */ extern pcb_layer_t *pcb_shape_current_layer; void pcb_shape_dialog(pcb_board_t *pcb, pcb_data_t *data, pcb_layer_t *layer, pcb_bool modal); Index: trunk/src_plugins/sketch_route/sketch_route.c =================================================================== --- trunk/src_plugins/sketch_route/sketch_route.c (revision 28107) +++ trunk/src_plugins/sketch_route/sketch_route.c (revision 28108) @@ -1030,9 +1030,9 @@ if (type != PCB_OBJ_VOID) { term_obj = ptr2; if (term_obj->term != NULL - && ((type == PCB_OBJ_PSTK && pcb_pstk_shape_at(PCB, (pcb_pstk_t *) term_obj, CURRENT) != NULL) + && ((type == PCB_OBJ_PSTK && pcb_pstk_shape_at(PCB, (pcb_pstk_t *) term_obj, PCB_CURRLAYER(PCB)) != NULL) || type != PCB_OBJ_PSTK) - && attached_path_init(CURRENT, term_obj)) { + && attached_path_init(PCB_CURRLAYER(PCB), term_obj)) { pcb_crosshair.AttachedObject.Type = PCB_OBJ_LINE; pcb_crosshair.AttachedObject.State = PCB_CH_STATE_SECOND; } @@ -1047,7 +1047,7 @@ if (type != PCB_OBJ_VOID) { term_obj = ptr2; if (term_obj->term != NULL - && ((type == PCB_OBJ_PSTK && pcb_pstk_shape_at(PCB, (pcb_pstk_t *) term_obj, CURRENT) != NULL) + && ((type == PCB_OBJ_PSTK && pcb_pstk_shape_at(PCB, (pcb_pstk_t *) term_obj, PCB_CURRLAYER(PCB)) != NULL) || type != PCB_OBJ_PSTK)) { if (attached_path_finish(term_obj) == pcb_true) { attached_path_uninit();