(no commit message)
[geda-pcb/pcjc2.git] / src / mirror.c
blob1adeda916cba6f2459dd380330a97d242e9b14d6
1 /*
2 * COPYRIGHT
4 * PCB, interactive printed circuit board design
5 * Copyright (C) 1994,1995,1996 Thomas Nau
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * Contact addresses for paper mail and Email:
22 * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany
23 * Thomas.Nau@rz.uni-ulm.de
28 /* functions used to change the mirror flag of an object
30 * an undo operation is not implemented because it's easy to
31 * recover an object
34 #ifdef HAVE_CONFIG_H
35 #include "config.h"
36 #endif
38 #include <stdlib.h>
40 #include "global.h"
42 #include "data.h"
43 #include "draw.h"
44 #include "mirror.h"
45 #include "misc.h"
46 #include "polygon.h"
47 #include "search.h"
48 #include "select.h"
49 #include "set.h"
51 #ifdef HAVE_LIBDMALLOC
52 #include <dmalloc.h>
53 #endif
55 /* ---------------------------------------------------------------------------
56 * mirrors the coordinates of an element
57 * an additional offset is passed
59 void
60 MirrorElementCoordinates (DataType *Data, ElementType *Element,
61 Coord yoff)
63 r_delete_element (Data, Element);
64 ELEMENTLINE_LOOP (Element);
66 line->Point1.X = SWAP_X (line->Point1.X);
67 line->Point1.Y = SWAP_Y (line->Point1.Y) + yoff;
68 line->Point2.X = SWAP_X (line->Point2.X);
69 line->Point2.Y = SWAP_Y (line->Point2.Y) + yoff;
71 END_LOOP;
72 PIN_LOOP (Element);
74 RestoreToPolygon (Data, PIN_TYPE, Element, pin);
75 pin->X = SWAP_X (pin->X);
76 pin->Y = SWAP_Y (pin->Y) + yoff;
78 END_LOOP;
79 PAD_LOOP (Element);
81 RestoreToPolygon (Data, PAD_TYPE, Element, pad);
82 pad->Point1.X = SWAP_X (pad->Point1.X);
83 pad->Point1.Y = SWAP_Y (pad->Point1.Y) + yoff;
84 pad->Point2.X = SWAP_X (pad->Point2.X);
85 pad->Point2.Y = SWAP_Y (pad->Point2.Y) + yoff;
86 TOGGLE_FLAG (ONSOLDERFLAG, pad);
88 END_LOOP;
89 ARC_LOOP (Element);
91 arc->X = SWAP_X (arc->X);
92 arc->Y = SWAP_Y (arc->Y) + yoff;
93 arc->StartAngle = SWAP_ANGLE (arc->StartAngle);
94 arc->Delta = SWAP_DELTA (arc->Delta);
96 END_LOOP;
97 ELEMENTTEXT_LOOP (Element);
99 text->X = SWAP_X (text->X);
100 text->Y = SWAP_Y (text->Y) + yoff;
101 TOGGLE_FLAG (ONSOLDERFLAG, text);
103 END_LOOP;
104 Element->MarkX = SWAP_X (Element->MarkX);
105 Element->MarkY = SWAP_Y (Element->MarkY) + yoff;
107 /* now toggle the solder-side flag */
108 TOGGLE_FLAG (ONSOLDERFLAG, Element);
109 /* this inserts all of the rtree data too */
110 SetElementBoundingBox (Data, Element, &PCB->Font);
111 ClearFromPolygon (Data, ELEMENT_TYPE, Element, Element);