Index: trunk/src/move.c =================================================================== --- trunk/src/move.c (revision 12185) +++ trunk/src/move.c (revision 12186) @@ -82,6 +82,23 @@ NULL }; +pcb_opfunc_t ClipFunctions = { + pcb_lineop_clip, + pcb_textop_clip, + pcb_polyop_clip, + pcb_viaop_clip, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + pcb_arcop_clip, + NULL, + NULL, + NULL +}; + static pcb_opfunc_t MoveToLayerFunctions = { pcb_lineop_move_to_layer, pcb_textop_move_to_layer, Index: trunk/src/obj_arc.c =================================================================== --- trunk/src/obj_arc.c (revision 12185) +++ trunk/src/obj_arc.c (revision 12186) @@ -549,11 +549,20 @@ void *pcb_arcop_move(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_arc_t *Arc) { pcb_poly_restore_to_poly(PCB->Data, PCB_TYPE_ARC, Layer, Arc); - return pcb_arcop_move_noclip(ctx, Layer, Arc); + pcb_arcop_move_noclip(ctx, Layer, Arc); pcb_poly_clear_from_poly(PCB->Data, PCB_TYPE_ARC, Layer, Arc); return Arc; } +void *pcb_arcop_clip(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_arc_t *Arc) +{ + if (ctx->clip.restore) + pcb_poly_restore_to_poly(PCB->Data, PCB_TYPE_ARC, Layer, Arc); + if (ctx->clip.clear) + pcb_poly_clear_from_poly(PCB->Data, PCB_TYPE_ARC, Layer, Arc); + return Arc; +} + /* moves an arc between layers; lowlevel routines */ void *pcb_arcop_move_to_layer_low(pcb_opctx_t *ctx, pcb_layer_t * Source, pcb_arc_t * arc, pcb_layer_t * Destination) { Index: trunk/src/obj_arc_op.h =================================================================== --- trunk/src/obj_arc_op.h (revision 12185) +++ trunk/src/obj_arc_op.h (revision 12186) @@ -40,6 +40,7 @@ void *pcb_arcop_copy(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_arc_t *Arc); void *pcb_arcop_move(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_arc_t *Arc); void *pcb_arcop_move_noclip(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_arc_t *Arc); +void *pcb_arcop_clip(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_arc_t *Arc); void *pcb_arcop_move_to_layer_low(pcb_opctx_t *ctx, pcb_layer_t * Source, pcb_arc_t * arc, pcb_layer_t * Destination); void *pcb_arcop_move_to_layer(pcb_opctx_t *ctx, pcb_layer_t * Layer, pcb_arc_t * Arc); void *pcb_arcop_destroy(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_arc_t *Arc); Index: trunk/src/obj_line.c =================================================================== --- trunk/src/obj_line.c (revision 12185) +++ trunk/src/obj_line.c (revision 12186) @@ -510,6 +510,15 @@ return Line; } +void *pcb_lineop_clip(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_line_t *Line) +{ + if (ctx->clip.restore) + pcb_poly_restore_to_poly(PCB->Data, PCB_TYPE_LINE, Layer, Line); + if (ctx->clip.clear) + pcb_poly_clear_from_poly(PCB->Data, PCB_TYPE_LINE, Layer, Line); + return Line; +} + /* moves one end of a line */ void *pcb_lineop_move_point(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_line_t *Line, pcb_point_t *Point) { Index: trunk/src/obj_line_op.h =================================================================== --- trunk/src/obj_line_op.h (revision 12185) +++ trunk/src/obj_line_op.h (revision 12186) @@ -40,6 +40,7 @@ void *pcb_lineop_copy(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_line_t *Line); void *pcb_lineop_move(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_line_t *Line); void *pcb_lineop_move_noclip(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_line_t *Line); +void *pcb_lineop_clip(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_line_t *Line); void *pcb_lineop_move_point(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_line_t *Line, pcb_point_t *Point); void *pcb_lineop_move_point_with_route(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_line_t *Line, pcb_point_t *Point); void *pcb_lineop_move_to_layer_low(pcb_opctx_t *ctx, pcb_layer_t * Source, pcb_line_t * line, pcb_layer_t * Destination); Index: trunk/src/obj_pinvia.c =================================================================== --- trunk/src/obj_pinvia.c (revision 12185) +++ trunk/src/obj_pinvia.c (revision 12186) @@ -858,6 +858,16 @@ return Via; } +void *pcb_viaop_clip(pcb_opctx_t *ctx, pcb_pin_t *Via) +{ + if (ctx->clip.restore) + pcb_poly_restore_to_poly(PCB->Data, PCB_TYPE_VIA, Via, Via); + if (ctx->clip.clear) + pcb_poly_clear_from_poly(PCB->Data, PCB_TYPE_VIA, Via, Via); + return Via; +} + + /* destroys a via */ void *pcb_viaop_destroy(pcb_opctx_t *ctx, pcb_pin_t *Via) { Index: trunk/src/obj_pinvia_op.h =================================================================== --- trunk/src/obj_pinvia_op.h (revision 12185) +++ trunk/src/obj_pinvia_op.h (revision 12186) @@ -57,6 +57,7 @@ void *pcb_viaop_copy(pcb_opctx_t *ctx, pcb_pin_t *Via); void *pcb_viaop_move(pcb_opctx_t *ctx, pcb_pin_t *Via); void *pcb_viaop_move_noclip(pcb_opctx_t *ctx, pcb_pin_t *Via); +void *pcb_viaop_clip(pcb_opctx_t *ctx, pcb_pin_t *Via); void *pcb_viaop_destroy(pcb_opctx_t *ctx, pcb_pin_t *Via); void *pcb_viaop_remove(pcb_opctx_t *ctx, pcb_pin_t *Via); void *pcb_viaop_change_flag(pcb_opctx_t *ctx, pcb_pin_t *pin); Index: trunk/src/obj_poly.c =================================================================== --- trunk/src/obj_poly.c (revision 12185) +++ trunk/src/obj_poly.c (revision 12186) @@ -555,6 +555,14 @@ return Polygon; } +void *pcb_polyop_clip(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_polygon_t *Polygon) +{ + if (ctx->clip.restore) + pcb_poly_pprestore(Polygon); + if (ctx->clip.clear) + pcb_poly_ppclear(Polygon); + return Polygon; +} /* moves a polygon-point */ void *pcb_polyop_move_point(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_polygon_t *Polygon, pcb_point_t *Point) { Index: trunk/src/obj_poly_op.h =================================================================== --- trunk/src/obj_poly_op.h (revision 12185) +++ trunk/src/obj_poly_op.h (revision 12186) @@ -35,6 +35,7 @@ void *pcb_polyop_insert_point(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_polygon_t *Polygon); void *pcb_polyop_move(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_polygon_t *Polygon); void *pcb_polyop_move_noclip(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_polygon_t *Polygon); +void *pcb_polyop_clip(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_polygon_t *Polygon); void *pcb_polyop_move_point(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_polygon_t *Polygon, pcb_point_t *Point); void *pcb_polyop_move_to_layer_low(pcb_opctx_t *ctx, pcb_layer_t * Source, pcb_polygon_t * polygon, pcb_layer_t * Destination); void *pcb_polyop_move_to_layer(pcb_opctx_t *ctx, pcb_layer_t * Layer, pcb_polygon_t * Polygon); Index: trunk/src/obj_text.c =================================================================== --- trunk/src/obj_text.c (revision 12185) +++ trunk/src/obj_text.c (revision 12186) @@ -472,9 +472,19 @@ pcb_poly_restore_to_poly(PCB->Data, PCB_TYPE_TEXT, Layer, Text); pcb_textop_move_noclip(ctx, Layer, Text); pcb_poly_clear_from_poly(PCB->Data, PCB_TYPE_TEXT, Layer, Text); - return (Text); + return Text; } +void *pcb_textop_clip(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_text_t *Text) +{ + if (ctx->clip.restore) + pcb_poly_restore_to_poly(PCB->Data, PCB_TYPE_TEXT, Layer, Text); + if (ctx->clip.clear) + pcb_poly_clear_from_poly(PCB->Data, PCB_TYPE_TEXT, Layer, Text); + return Text; +} + + /* moves a text object between layers; lowlevel routines */ void *pcb_textop_move_to_layer_low(pcb_opctx_t *ctx, pcb_layer_t * Source, pcb_text_t * text, pcb_layer_t * Destination) { Index: trunk/src/obj_text_op.h =================================================================== --- trunk/src/obj_text_op.h (revision 12185) +++ trunk/src/obj_text_op.h (revision 12186) @@ -38,6 +38,7 @@ void *pcb_textop_copy(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_text_t *Text); void *pcb_textop_move(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_text_t *Text); void *pcb_textop_move_noclip(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_text_t *Text); +void *pcb_textop_clip(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_text_t *Text); void *pcb_textop_move_to_layer_low(pcb_opctx_t *ctx, pcb_layer_t * Source, pcb_text_t * text, pcb_layer_t * Destination); void *pcb_textop_move_to_layer(pcb_opctx_t *ctx, pcb_layer_t * layer, pcb_text_t * text); void *pcb_textop_destroy(pcb_opctx_t *ctx, pcb_layer_t *Layer, pcb_text_t *Text); Index: trunk/src/operation.h =================================================================== --- trunk/src/operation.h (revision 12185) +++ trunk/src/operation.h (revision 12186) @@ -106,6 +106,11 @@ pcb_board_t *pcb; } pcb_opctx_noarg_t; +typedef struct { + int restore; + int clear; +} pcb_opctx_clip_t; + typedef union { pcb_opctx_buffer_t buffer; pcb_opctx_chgname_t chgname; @@ -119,6 +124,7 @@ pcb_opctx_rotate_t rotate; pcb_opctx_chgflag_t chgflag; pcb_opctx_noarg_t noarg; + pcb_opctx_clip_t clip; } pcb_opctx_t; /* pointer to low-level operation (copy, move and rotate) functions */