Index: trunk/src/buffer.c =================================================================== --- trunk/src/buffer.c (revision 4855) +++ trunk/src/buffer.c (revision 4856) @@ -40,6 +40,8 @@ #include "remove.h" #include "select.h" #include "set.h" +#include "draw.h" +#include "undo.h" #include "funchash_core.h" #include "compat_misc.h" #include "compat_nls.h" @@ -610,6 +612,92 @@ return (ObjectOperation(&AddBufferFunctions, &ctx, Type, Ptr1, Ptr2, Ptr3)); } +/* --------------------------------------------------------------------------- + * pastes the contents of the buffer to the layout. Only visible objects + * are handled by the routine. + */ +pcb_bool pcb_buffer_copy_to_layout(pcb_coord_t X, pcb_coord_t Y) +{ + pcb_cardinal_t i; + pcb_bool changed = pcb_false; + pcb_opctx_t ctx; + +#ifdef DEBUG + printf("Entering CopyPastebufferToLayout.....\n"); +#endif + + /* set movement vector */ + ctx.copy.pcb = PCB; + ctx.copy.DeltaX = X - PCB_PASTEBUFFER->X; + ctx.copy.DeltaY = Y - PCB_PASTEBUFFER->Y; + + /* paste all layers */ + for (i = 0; i < max_copper_layer + 2; i++) { + pcb_layer_t *sourcelayer = &PCB_PASTEBUFFER->Data->Layer[i], *destlayer = LAYER_PTR(i); + + if (destlayer->On) { + changed = changed || (!LAYER_IS_EMPTY(sourcelayer)); + LINE_LOOP(sourcelayer); + { + CopyLine(&ctx, destlayer, line); + } + END_LOOP; + ARC_LOOP(sourcelayer); + { + CopyArc(&ctx, destlayer, arc); + } + END_LOOP; + TEXT_LOOP(sourcelayer); + { + CopyText(&ctx, destlayer, text); + } + END_LOOP; + POLYGON_LOOP(sourcelayer); + { + CopyPolygon(&ctx, destlayer, polygon); + } + END_LOOP; + } + } + + /* paste elements */ + if (PCB->PinOn && PCB->ElementOn) { + ELEMENT_LOOP(PCB_PASTEBUFFER->Data); + { +#ifdef DEBUG + printf("In CopyPastebufferToLayout, pasting element %s\n", element->Name[1].TextString); +#endif + if (FRONT(element) || PCB->InvisibleObjectsOn) { + CopyElement(&ctx, element); + changed = pcb_true; + } + } + END_LOOP; + } + + /* finally the vias */ + if (PCB->ViaOn) { + changed |= (pinlist_length(&(PCB_PASTEBUFFER->Data->Via)) != 0); + VIA_LOOP(PCB_PASTEBUFFER->Data); + { + CopyVia(&ctx, via); + } + END_LOOP; + } + + if (changed) { + Draw(); + IncrementUndoSerialNumber(); + } + +#ifdef DEBUG + printf(" .... Leaving CopyPastebufferToLayout.\n"); +#endif + + return (changed); +} + + /* ---------------------------------------------------------------------- */ static const char pastebuffer_syntax[] = Index: trunk/src/buffer.h =================================================================== --- trunk/src/buffer.h (revision 4855) +++ trunk/src/buffer.h (revision 4856) @@ -58,6 +58,11 @@ /* This action is called from ActionElementAddIf() */ int pcb_load_footprint(int argc, const char **argv, pcb_coord_t x, pcb_coord_t y); +/* pastes the contents of the buffer to the layout. Only visible objects + are handled by the routine. */ +pcb_bool pcb_buffer_copy_to_layout(pcb_coord_t X, pcb_coord_t Y); + + pcb_data_t *pcb_buffer_new(void); Index: trunk/src/copy.c =================================================================== --- trunk/src/copy.c (revision 4855) +++ trunk/src/copy.c (revision 4856) @@ -58,91 +58,6 @@ }; /* --------------------------------------------------------------------------- - * pastes the contents of the buffer to the layout. Only visible objects - * are handled by the routine. - */ -pcb_bool pcb_buffer_copy_to_layout(pcb_coord_t X, pcb_coord_t Y) -{ - pcb_cardinal_t i; - pcb_bool changed = pcb_false; - pcb_opctx_t ctx; - -#ifdef DEBUG - printf("Entering CopyPastebufferToLayout.....\n"); -#endif - - /* set movement vector */ - ctx.copy.pcb = PCB; - ctx.copy.DeltaX = X - PCB_PASTEBUFFER->X; - ctx.copy.DeltaY = Y - PCB_PASTEBUFFER->Y; - - /* paste all layers */ - for (i = 0; i < max_copper_layer + 2; i++) { - pcb_layer_t *sourcelayer = &PCB_PASTEBUFFER->Data->Layer[i], *destlayer = LAYER_PTR(i); - - if (destlayer->On) { - changed = changed || (!LAYER_IS_EMPTY(sourcelayer)); - LINE_LOOP(sourcelayer); - { - CopyLine(&ctx, destlayer, line); - } - END_LOOP; - ARC_LOOP(sourcelayer); - { - CopyArc(&ctx, destlayer, arc); - } - END_LOOP; - TEXT_LOOP(sourcelayer); - { - CopyText(&ctx, destlayer, text); - } - END_LOOP; - POLYGON_LOOP(sourcelayer); - { - CopyPolygon(&ctx, destlayer, polygon); - } - END_LOOP; - } - } - - /* paste elements */ - if (PCB->PinOn && PCB->ElementOn) { - ELEMENT_LOOP(PCB_PASTEBUFFER->Data); - { -#ifdef DEBUG - printf("In CopyPastebufferToLayout, pasting element %s\n", element->Name[1].TextString); -#endif - if (FRONT(element) || PCB->InvisibleObjectsOn) { - CopyElement(&ctx, element); - changed = pcb_true; - } - } - END_LOOP; - } - - /* finally the vias */ - if (PCB->ViaOn) { - changed |= (pinlist_length(&(PCB_PASTEBUFFER->Data->Via)) != 0); - VIA_LOOP(PCB_PASTEBUFFER->Data); - { - CopyVia(&ctx, via); - } - END_LOOP; - } - - if (changed) { - Draw(); - IncrementUndoSerialNumber(); - } - -#ifdef DEBUG - printf(" .... Leaving CopyPastebufferToLayout.\n"); -#endif - - return (changed); -} - -/* --------------------------------------------------------------------------- * copies the object identified by its data pointers and the type * the new objects is moved by DX,DY * I assume that the appropriate layer ... is switched on Index: trunk/src/copy.h =================================================================== --- trunk/src/copy.h (revision 4855) +++ trunk/src/copy.h (revision 4856) @@ -38,8 +38,6 @@ (PCB_TYPE_VIA | PCB_TYPE_LINE | PCB_TYPE_TEXT | \ PCB_TYPE_ELEMENT | PCB_TYPE_ELEMENT_NAME | PCB_TYPE_POLYGON | PCB_TYPE_ARC) - -pcb_bool pcb_buffer_copy_to_layout(pcb_coord_t, pcb_coord_t); void *CopyObject(int, void *, void *, void *, pcb_coord_t, pcb_coord_t); #endif