Index: trunk/src/rotate.c =================================================================== --- trunk/src/rotate.c (revision 13240) +++ trunk/src/rotate.c (revision 13241) @@ -136,9 +136,8 @@ 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_rotate90(Type, Ptr1, Ptr2, Ptr3, ctx.rotate.center_x, ctx.rotate.center_y, ctx.rotate.angle); + 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) { Index: trunk/src/undo_old.c =================================================================== --- trunk/src/undo_old.c (revision 13240) +++ trunk/src/undo_old.c (revision 13241) @@ -75,6 +75,7 @@ /* --------------------------------------------------------------------------- * some local prototypes */ +static pcb_bool UndoRotate90(UndoListTypePtr); static pcb_bool UndoRotate(UndoListTypePtr); static pcb_bool UndoChangeName(UndoListTypePtr); static pcb_bool UndoCopyOrCreate(UndoListTypePtr); @@ -141,10 +142,10 @@ } /* --------------------------------------------------------------------------- - * recovers an object from a 'rotate' operation + * recovers an object from a 90 deg 'rotate' operation * returns pcb_true if anything has been recovered */ -static pcb_bool UndoRotate(UndoListTypePtr Entry) +static pcb_bool UndoRotate90(UndoListTypePtr Entry) { void *ptr1, *ptr2, *ptr3; int type; @@ -161,6 +162,25 @@ } /* --------------------------------------------------------------------------- + * recovers an object from an arbitrary angle 'rotate' operation + * returns pcb_true if anything has been recovered + */ +static pcb_bool UndoRotate(UndoListTypePtr Entry) +{ + void *ptr1, *ptr2, *ptr3; + int type; + + /* lookup entry by it's ID */ + type = pcb_search_obj_by_id(PCB->Data, &ptr1, &ptr2, &ptr3, Entry->ID, Entry->Kind); + if (type != PCB_TYPE_NONE) { + pcb_obj_rotate(type, ptr1, ptr2, ptr3, Entry->Data.Rotate.CenterX, Entry->Data.Rotate.CenterY, -(Entry->Data.Angle)); + Entry->Data.Angle = -(Entry->Data.Angle); + return pcb_true; + } + return pcb_false; +} + +/* --------------------------------------------------------------------------- * recovers an object from a clear/restore poly operation * returns pcb_true if anything has been recovered */ @@ -827,6 +847,11 @@ return 0; break; + case PCB_UNDO_ROTATE90: + if (UndoRotate90(ptr)) + return 0; + break; + case PCB_UNDO_CLEAR: if (UndoClearPoly(ptr)) return 0; @@ -936,7 +961,7 @@ } /* --------------------------------------------------------------------------- - * adds an object to the list of rotated objects + * adds an object to the list of 90-deg rotated objects */ void pcb_undo_add_obj_to_rotate90(int Type, void *Ptr1, void *Ptr2, void *Ptr3, pcb_coord_t CenterX, pcb_coord_t CenterY, pcb_uint8_t Steps) { @@ -943,7 +968,7 @@ UndoListTypePtr undo; if (!Locked) { - undo = GetUndoSlot(PCB_UNDO_ROTATE, PCB_OBJECT_ID(Ptr3), Type); + undo = GetUndoSlot(PCB_UNDO_ROTATE90, PCB_OBJECT_ID(Ptr3), Type); undo->Data.Rotate.CenterX = CenterX; undo->Data.Rotate.CenterY = CenterY; undo->Data.Rotate.Steps = Steps; @@ -951,6 +976,21 @@ } /* --------------------------------------------------------------------------- + * adds an object to the list of rotated objects + */ +void pcb_undo_add_obj_to_rotate(int Type, void *Ptr1, void *Ptr2, void *Ptr3, pcb_coord_t CenterX, pcb_coord_t CenterY, pcb_angle_t angle) +{ + UndoListTypePtr undo; + + if (!Locked) { + undo = GetUndoSlot(PCB_UNDO_ROTATE, PCB_OBJECT_ID(Ptr3), Type); + undo->Data.Rotate.CenterX = CenterX; + undo->Data.Rotate.CenterY = CenterY; + undo->Data.Angle = angle; + } +} + +/* --------------------------------------------------------------------------- * adds an object to the list of removed objects and removes it from * the current PCB */ @@ -1342,6 +1382,7 @@ case PCB_UNDO_INSERT_POINT: return "insert_point"; case PCB_UNDO_REMOVE_CONTOUR: return "remove_contour"; case PCB_UNDO_INSERT_CONTOUR: return "insert_contour"; + case PCB_UNDO_ROTATE90: return "rotate90"; case PCB_UNDO_ROTATE: return "rotate"; case PCB_UNDO_CREATE: return "create"; case PCB_UNDO_MOVETOLAYER: return "movetolayer"; Index: trunk/src/undo_old.h =================================================================== --- trunk/src/undo_old.h (revision 13240) +++ trunk/src/undo_old.h (revision 13241) @@ -72,7 +72,7 @@ PCB_UNDO_INSERT_POINT = 0x000010, /* inserting polygon/... points */ PCB_UNDO_REMOVE_CONTOUR = 0x000020, /* removing a contour from a polygon */ PCB_UNDO_INSERT_CONTOUR = 0x000040, /* inserting a contour from a polygon */ - PCB_UNDO_ROTATE = 0x000080, /* rotations */ + PCB_UNDO_ROTATE90 = 0x000080, /* rotations by 90 deg steps */ PCB_UNDO_CREATE = 0x000100, /* creation of objects */ PCB_UNDO_MOVETOLAYER = 0x000200, /* moving objects to */ PCB_UNDO_FLAG = 0x000400, /* toggling SELECTED flag */ @@ -87,7 +87,8 @@ PCB_UNDO_NETLISTCHANGE = 0x080000, /* netlist change */ PCB_UNDO_CHANGEPINNUM = 0x100000, /* change of pin number */ PCB_UNDO_CHANGERADII = 0x200000, /* change arc radii */ - PCB_UNDO_OTHERSIDE = 0x400000 /* change side of board (subcircuit) */ + PCB_UNDO_OTHERSIDE = 0x400000, /* change side of board (subcircuit) */ + PCB_UNDO_ROTATE = 0x800000 /* rotations at arbitrary angle */ } pcb_undo_op_t; const char *undo_type2str(int type); Index: trunk/src/undo_old_str.h =================================================================== --- trunk/src/undo_old_str.h (revision 13240) +++ trunk/src/undo_old_str.h (revision 13241) @@ -61,5 +61,6 @@ NetlistChangeType NetlistChange; long int CopyID; AngleChangeType AngleChange; + pcb_angle_t Angle; } Data; } UndoListType, *UndoListTypePtr;