Index: undo_old.c =================================================================== --- undo_old.c (revision 13240) +++ 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";