Index: trunk/src/event.h =================================================================== --- trunk/src/event.h (revision 13238) +++ trunk/src/event.h (revision 13239) @@ -48,6 +48,7 @@ PCB_EVENT_RUBBER_MOVE, /* rubber band: object moved */ PCB_EVENT_RUBBER_MOVE_DRAW, /* rubber band: draw crosshair-attached rubber band objects after a move or copy */ PCB_EVENT_RUBBER_ROTATE90, /* rubber band: crosshair object rotated by 90 degrees */ + PCB_EVENT_RUBBER_ROTATE, /* rubber band: crosshair object rotated by arbitrary angle */ PCB_EVENT_RUBBER_RENAME, /* rubber band: element pin/pad got renamed */ PCB_EVENT_RUBBER_LOOKUP_LINES, /* rubber band: attach rubber banded line objects to crosshair */ PCB_EVENT_RUBBER_LOOKUP_RATS, /* rubber band: attach rubber banded rat lines objects to crosshair */ Index: trunk/src/rotate.c =================================================================== --- trunk/src/rotate.c (revision 13238) +++ trunk/src/rotate.c (revision 13239) @@ -97,10 +97,6 @@ PCB_COORD_ROTATE90(Point->X, Point->Y, X, Y, Number); } -/* ---------------------------------------------------------------------- - * rotates an objects at the cursor position as identified by its ID - * the center of rotation is determined by the current cursor location - */ void *pcb_obj_rotate90(int Type, void *Ptr1, void *Ptr2, void *Ptr3, pcb_coord_t X, pcb_coord_t Y, unsigned Steps) { void *ptr2; @@ -126,6 +122,32 @@ return (ptr2); } +void *pcb_obj_rotate(int Type, void *Ptr1, void *Ptr2, void *Ptr3, pcb_coord_t X, pcb_coord_t Y, double angle) +{ + void *ptr2; + int changed = 0; + pcb_opctx_t ctx; + + /* setup default global identifiers */ + ctx.rotate.pcb = PCB; + ctx.rotate.angle = angle; + ctx.rotate.center_x = X; + ctx.rotate.center_y = Y; + + pcb_event(PCB_EVENT_RUBBER_ROTATE, "ipppccip", Type, Ptr1, Ptr2, Ptr2, ctx.rotate.center_x, ctx.rotate.center_y, ctx.rotate.angle, &changed); + +#warning TODO: this should be a different rotation call for non90deg! + if (Type != PCB_TYPE_PSTK) /* padstack has its own way doing the rotation-undo */ + pcb_undo_add_obj_to_rotate(Type, Ptr1, Ptr2, Ptr3, ctx.rotate.center_x, ctx.rotate.center_y, ctx.rotate.angle); + ptr2 = pcb_object_operation(&RotateFunctions, &ctx, Type, Ptr1, Ptr2, Ptr3); + changed |= (ptr2 != NULL); + if (changed) { + pcb_draw(); + pcb_undo_inc_serial(); + } + return (ptr2); +} + void pcb_screen_obj_rotate90(pcb_coord_t X, pcb_coord_t Y, unsigned Steps) { int type; Index: trunk/src/rotate.h =================================================================== --- trunk/src/rotate.h (revision 13238) +++ trunk/src/rotate.h (revision 13239) @@ -54,7 +54,15 @@ #define PCB_ROTATE_TYPES (PCB_TYPE_PSTK | PCB_TYPE_ELEMENT | PCB_TYPE_SUBC | PCB_TYPE_TEXT | PCB_TYPE_ELEMENT_NAME | PCB_TYPE_ARC | PCB_TYPE_LINE_POINT | PCB_TYPE_LINE) +/* rotates an object passed; + * the center of rotation is determined by the current cursor location + */ void *pcb_obj_rotate90(int, void *, void *, void *, pcb_coord_t, pcb_coord_t, unsigned); + +/* rotates an objects passed; + * the center of rotation is determined by the current cursor location */ +void *pcb_obj_rotate(int Type, void *Ptr1, void *Ptr2, void *Ptr3, pcb_coord_t X, pcb_coord_t Y, double angle); + void pcb_screen_obj_rotate90(pcb_coord_t, pcb_coord_t, unsigned); void pcb_point_rotate90(pcb_point_t *Point, pcb_coord_t X, pcb_coord_t Y, unsigned Number);