Index: trunk/src_plugins/lib_polyhelp/polyhelp.c =================================================================== --- trunk/src_plugins/lib_polyhelp/polyhelp.c (revision 31831) +++ trunk/src_plugins/lib_polyhelp/polyhelp.c (revision 31832) @@ -34,6 +34,8 @@ #include #include #include "obj_line.h" +#include "undo_old.h" +#include "undo.h" #include #include #include @@ -73,7 +75,7 @@ } #endif -rnd_cardinal_t pcb_pline_to_lines(pcb_layer_t *dst, const rnd_pline_t *src, rnd_coord_t thickness, rnd_coord_t clearance, pcb_flag_t flags) +rnd_cardinal_t pcb_pline_to_lines(pcb_layer_t *dst, const rnd_pline_t *src, rnd_coord_t thickness, rnd_coord_t clearance, pcb_flag_t flags, rnd_bool undoable) { rnd_cardinal_t cnt = 0; vtp0_t tracks; @@ -88,8 +90,13 @@ v = track->head; do { + pcb_line_t *l; + n = v->next; - pcb_line_new(dst, v->point[0], v->point[1], n->point[0], n->point[1], thickness, clearance, flags); + l = pcb_line_new(dst, v->point[0], v->point[1], n->point[0], n->point[1], thickness, clearance, flags); + if (undoable) + pcb_undo_add_obj_to_create(PCB_OBJ_LINE, dst, l, l); + cnt++; } while((v = v->next) != track->head); @@ -350,15 +357,18 @@ pcb_layer_t *dst; rnd_coord_t thickness, clearance; pcb_flag_t flags; + unsigned undoable:1; } hatch_ctx_t; static void hatch_cb(void *ctx_, rnd_coord_t x1, rnd_coord_t y1, rnd_coord_t x2, rnd_coord_t y2) { hatch_ctx_t *ctx = (hatch_ctx_t *)ctx_; - pcb_line_new(ctx->dst, x1, y1, x2, y2, ctx->thickness, ctx->clearance, ctx->flags); + pcb_line_t *l = pcb_line_new(ctx->dst, x1, y1, x2, y2, ctx->thickness, ctx->clearance, ctx->flags); + if (ctx->undoable) + pcb_undo_add_obj_to_create(PCB_OBJ_LINE, ctx->dst, l, l); } -void pcb_cpoly_hatch_lines(pcb_layer_t *dst, const pcb_poly_t *src, pcb_cpoly_hatchdir_t dir, rnd_coord_t period, rnd_coord_t thickness, rnd_coord_t clearance, pcb_flag_t flags) +void pcb_cpoly_hatch_lines(pcb_layer_t *dst, const pcb_poly_t *src, pcb_cpoly_hatchdir_t dir, rnd_coord_t period, rnd_coord_t thickness, rnd_coord_t clearance, pcb_flag_t flags, rnd_bool undoable) { hatch_ctx_t ctx; @@ -367,6 +377,7 @@ ctx.thickness = thickness; ctx.clearance = clearance; ctx.flags = flags; + ctx.undoable = undoable; pcb_cpoly_hatch(src, dir, (thickness/2)+1, period, &ctx, hatch_cb); } @@ -439,7 +450,7 @@ rnd_coord_t period = 0; pcb_cpoly_hatchdir_t dir = 0; pcb_flag_t flg; - int want_contour = 0, want_poly = 0, cont_specd = 0; + int want_contour = 0, want_poly = 0, cont_specd = 0, undoable = 1; RND_ACT_CONVARG(1, FGW_STR, PolyHatch, op = argv[1].val.str); RND_ACT_MAY_CONVARG(2, FGW_STR, PolyHatch, arg = argv[2].val.str); @@ -487,9 +498,9 @@ for(pa = pcb_poly_island_first(polygon, &it); pa != NULL; pa = pcb_poly_island_next(&it)) { rnd_pline_t *pl = pcb_poly_contour(&it); if (pl != NULL) { /* we have a contour */ - pcb_pline_to_lines(PCB_CURRLAYER(PCB), 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, undoable); for(pl = pcb_poly_hole_first(&it); pl != NULL; pl = pcb_poly_hole_next(&it)) - pcb_pline_to_lines(PCB_CURRLAYER(PCB), 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, undoable); } } } @@ -497,9 +508,12 @@ 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(PCB_CURRLAYER(PCB), 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, undoable); } PCB_ENDALL_LOOP; + if (undoable) + pcb_undo_inc_serial(); + RND_ACT_IRES(0); return 0; } Index: trunk/src_plugins/lib_polyhelp/polyhelp.h =================================================================== --- trunk/src_plugins/lib_polyhelp/polyhelp.h (revision 31831) +++ trunk/src_plugins/lib_polyhelp/polyhelp.h (revision 31832) @@ -32,7 +32,7 @@ /* Add lines on dst tracing pline from the inner side (no line will extend outside of the original pline, except when the original polygon has a hair narrower than thickness). Returns number of lines created */ -rnd_cardinal_t pcb_pline_to_lines(pcb_layer_t *dst, const rnd_pline_t *src, rnd_coord_t thickness, rnd_coord_t clearance, pcb_flag_t flags); +rnd_cardinal_t pcb_pline_to_lines(pcb_layer_t *dst, const rnd_pline_t *src, rnd_coord_t thickness, rnd_coord_t clearance, pcb_flag_t flags, rnd_bool undoable); /* Returns whether the clipped polygon is a simple rectangle (single island, no-hole rectangle). */ @@ -69,7 +69,7 @@ /* hatch a polygon with horizontal and/or vertical lines drawn on dst, one line per period */ -void pcb_cpoly_hatch_lines(pcb_layer_t *dst, const pcb_poly_t *src, pcb_cpoly_hatchdir_t dir, rnd_coord_t period, rnd_coord_t thickness, rnd_coord_t clearance, pcb_flag_t flags); +void pcb_cpoly_hatch_lines(pcb_layer_t *dst, const pcb_poly_t *src, pcb_cpoly_hatchdir_t dir, rnd_coord_t period, rnd_coord_t thickness, rnd_coord_t clearance, pcb_flag_t flags, rnd_bool undoable); /* Generic hor-ver hatch with a callback */ void pcb_cpoly_hatch(const pcb_poly_t *src, pcb_cpoly_hatchdir_t dir, rnd_coord_t offs, rnd_coord_t period, void *ctx, void (*cb)(void *ctx, rnd_coord_t x1, rnd_coord_t y1, rnd_coord_t x2, rnd_coord_t y2)); Index: trunk/src_plugins/millpath/toolpath.c =================================================================== --- trunk/src_plugins/millpath/toolpath.c (revision 31831) +++ trunk/src_plugins/millpath/toolpath.c (revision 31832) @@ -315,10 +315,10 @@ for(pa = pcb_poly_island_first(result->fill, &it); pa != NULL; pa = pcb_poly_island_next(&it)) { rnd_pline_t *pl = pcb_poly_contour(&it); if (pl != NULL) { /* we have a contour */ - pcb_pline_to_lines(result->res_path, pl, tool_dia + extra_offs, 0, pcb_no_flags()); + pcb_pline_to_lines(result->res_path, pl, tool_dia + extra_offs, 0, pcb_no_flags(), 0); cnt++; for(pl = pcb_poly_hole_first(&it); pl != NULL; pl = pcb_poly_hole_next(&it)) { - pcb_pline_to_lines(result->res_path, pl, tool_dia + extra_offs, 0, pcb_no_flags()); + pcb_pline_to_lines(result->res_path, pl, tool_dia + extra_offs, 0, pcb_no_flags(), 0); cnt++; } }