Index: trunk/src/operation.h =================================================================== --- trunk/src/operation.h (revision 4559) +++ trunk/src/operation.h (revision 4560) @@ -31,6 +31,10 @@ #include "global_typedefs.h" #include "global_element.h" +/* Each object operation gets an operation-context with some operation-specific + configuration, and the board to operate on. Optionally this is the place to + hold temporary states of a multi-call operation too. */ + typedef struct { PCBType *pcb; int extraflg; @@ -86,6 +90,12 @@ pcb_bool bulk; /* don't draw if part of a bulk operation */ } pcb_opctx_remove_t; +typedef struct { + PCBType *pcb; + Coord center_x, center_y; /* center of rotation */ + unsigned number; /* number of rotations */ +} pcb_opctx_rotate_t; + typedef union { pcb_opctx_buffer_t buffer; pcb_opctx_chgname_t chgname; @@ -96,6 +106,7 @@ pcb_opctx_insert_t insert; pcb_opctx_move_t move; pcb_opctx_remove_t remove; + pcb_opctx_rotate_t rotate; } pcb_opctx_t; /* pointer to low-level operation (copy, move and rotate) functions */ Index: trunk/src/rotate.c =================================================================== --- trunk/src/rotate.c (revision 4559) +++ trunk/src/rotate.c (revision 4560) @@ -61,8 +61,6 @@ /* ---------------------------------------------------------------------- * some local identifiers */ -static Coord CenterX, CenterY; /* center of rotation */ -static unsigned Number; /* number of rotations */ static pcb_opfunc_t RotateFunctions = { NULL, RotateText, @@ -155,7 +153,7 @@ EraseText(Layer, Text); RestoreToPolygon(PCB->Data, PCB_TYPE_TEXT, Layer, Text); r_delete_entry(Layer->text_tree, (BoxTypePtr) Text); - RotateTextLowLevel(Text, CenterX, CenterY, Number); + RotateTextLowLevel(Text, ctx->rotate.center_x, ctx->rotate.center_y, ctx->rotate.number); r_insert_entry(Layer->text_tree, (BoxTypePtr) Text, 0); ClearFromPolygon(PCB->Data, PCB_TYPE_TEXT, Layer, Text); DrawText(Layer, Text); @@ -246,7 +244,7 @@ } else r_delete_entry(PCB->Data->rat_tree, (BoxTypePtr) Line); - RotatePointLowLevel(Point, CenterX, CenterY, Number); + RotatePointLowLevel(Point, ctx->rotate.center_x, ctx->rotate.center_y, ctx->rotate.number); SetLineBoundingBox(Line); if (Layer) { r_insert_entry(Layer->line_tree, (BoxTypePtr) Line, 0); @@ -268,7 +266,7 @@ { EraseArc(Arc); r_delete_entry(Layer->arc_tree, (BoxTypePtr) Arc); - RotateArcLowLevel(Arc, CenterX, CenterY, Number); + RotateArcLowLevel(Arc, ctx->rotate.center_x, ctx->rotate.center_y, ctx->rotate.number); r_insert_entry(Layer->arc_tree, (BoxTypePtr) Arc, 0); DrawArc(Layer, Arc); Draw(); @@ -281,7 +279,7 @@ static void *RotateElement(pcb_opctx_t *ctx, ElementTypePtr Element) { EraseElement(Element); - RotateElementLowLevel(PCB->Data, Element, CenterX, CenterY, Number); + RotateElementLowLevel(PCB->Data, Element, ctx->rotate.center_x, ctx->rotate.center_y, ctx->rotate.number); DrawElement(Element); Draw(); return (Element); @@ -296,7 +294,7 @@ ELEMENTTEXT_LOOP(Element); { r_delete_entry(PCB->Data->name_tree[n], (BoxType *) text); - RotateTextLowLevel(text, CenterX, CenterY, Number); + RotateTextLowLevel(text, ctx->rotate.center_x, ctx->rotate.center_y, ctx->rotate.number); r_insert_entry(PCB->Data->name_tree[n], (BoxType *) text, 0); } END_LOOP; @@ -332,9 +330,10 @@ pcb_opctx_t ctx; /* setup default global identifiers */ - Number = Steps; - CenterX = X; - CenterY = Y; + ctx.rotate.pcb = PCB; + ctx.rotate.number = Steps; + ctx.rotate.center_x = X; + ctx.rotate.center_y = Y; /* move all the rubberband lines... and reset the counter */ ptr = Crosshair.AttachedObject.Rubberband; @@ -341,7 +340,7 @@ while (Crosshair.AttachedObject.RubberbandN) { changed = pcb_true; CLEAR_FLAG(PCB_FLAG_RUBBEREND, ptr->Line); - AddObjectToRotateUndoList(PCB_TYPE_LINE_POINT, ptr->Layer, ptr->Line, ptr->MovedPoint, CenterX, CenterY, Steps); + AddObjectToRotateUndoList(PCB_TYPE_LINE_POINT, ptr->Layer, ptr->Line, ptr->MovedPoint, ctx.rotate.center_x, ctx.rotate.center_y, Steps); EraseLine(ptr->Line); if (ptr->Layer) { RestoreToPolygon(PCB->Data, PCB_TYPE_LINE, ptr->Layer, ptr->Line); @@ -349,7 +348,7 @@ } else r_delete_entry(PCB->Data->rat_tree, (BoxType *) ptr->Line); - RotatePointLowLevel(ptr->MovedPoint, CenterX, CenterY, Steps); + RotatePointLowLevel(ptr->MovedPoint, ctx.rotate.center_x, ctx.rotate.center_y, Steps); SetLineBoundingBox(ptr->Line); if (ptr->Layer) { r_insert_entry(ptr->Layer->line_tree, (BoxType *) ptr->Line, 0); @@ -363,7 +362,7 @@ Crosshair.AttachedObject.RubberbandN--; ptr++; } - AddObjectToRotateUndoList(Type, Ptr1, Ptr2, Ptr3, CenterX, CenterY, Number); + AddObjectToRotateUndoList(Type, Ptr1, Ptr2, Ptr3, ctx.rotate.center_x, ctx.rotate.center_y, ctx.rotate.number); ptr2 = ObjectOperation(&RotateFunctions, &ctx, Type, Ptr1, Ptr2, Ptr3); changed |= (ptr2 != NULL); if (changed) {