pcb 4.1.1
An interactive printed circuit board layout editor.

mirror.c

Go to the documentation of this file.
00001 
00038 #ifdef HAVE_CONFIG_H
00039 #include "config.h"
00040 #endif
00041 
00042 #include <stdlib.h>
00043 
00044 #include "global.h"
00045 
00046 #include "data.h"
00047 #include "draw.h"
00048 #include "mirror.h"
00049 #include "misc.h"
00050 #include "polygon.h"
00051 #include "search.h"
00052 #include "select.h"
00053 #include "set.h"
00054 
00055 #ifdef HAVE_LIBDMALLOC
00056 #include <dmalloc.h>
00057 #endif
00058 
00064 void
00065 MirrorElementCoordinates (DataType *Data, ElementType *Element,
00066                           Coord yoff)
00067 {
00068   r_delete_element (Data, Element);
00069   ELEMENTLINE_LOOP (Element);
00070   {
00071     line->Point1.X = SWAP_X (line->Point1.X);
00072     line->Point1.Y = SWAP_Y (line->Point1.Y) + yoff;
00073     line->Point2.X = SWAP_X (line->Point2.X);
00074     line->Point2.Y = SWAP_Y (line->Point2.Y) + yoff;
00075   }
00076   END_LOOP;
00077   PIN_LOOP (Element);
00078   {
00079     RestoreToPolygon (Data, PIN_TYPE, Element, pin);
00080     pin->X = SWAP_X (pin->X);
00081     pin->Y = SWAP_Y (pin->Y) + yoff;
00082   }
00083   END_LOOP;
00084   PAD_LOOP (Element);
00085   {
00086     Coord X1,X2,Y1,Y2;
00087     RestoreToPolygon (Data, PAD_TYPE, Element, pad);
00088     X1 = SWAP_X (pad->Point1.X);
00089     Y1 = SWAP_Y (pad->Point1.Y) + yoff;
00090     X2 = SWAP_X (pad->Point2.X);
00091     Y2 = SWAP_Y (pad->Point2.Y) + yoff;
00092     /* copy values */
00093     if (X1 > X2 || (X1 == X2 && Y1 > Y2))
00094     {
00095       pad->Point1.X = X2;
00096       pad->Point1.Y = Y2;
00097       pad->Point2.X = X1;
00098       pad->Point2.Y = Y1;
00099     }
00100     else
00101     {
00102       pad->Point1.X = X1;
00103       pad->Point1.Y = Y1;
00104       pad->Point2.X = X2;
00105       pad->Point2.Y = Y2;
00106     }
00107     TOGGLE_FLAG (ONSOLDERFLAG, pad);
00108   }
00109   END_LOOP;
00110   ARC_LOOP (Element);
00111   {
00112     arc->X = SWAP_X (arc->X);
00113     arc->Y = SWAP_Y (arc->Y) + yoff;
00114     arc->StartAngle = SWAP_ANGLE (arc->StartAngle);
00115     arc->Delta = SWAP_DELTA (arc->Delta);
00116   }
00117   END_LOOP;
00118   ELEMENTTEXT_LOOP (Element);
00119   {
00120     text->X = SWAP_X (text->X);
00121     text->Y = SWAP_Y (text->Y) + yoff;
00122     TOGGLE_FLAG (ONSOLDERFLAG, text);
00123   }
00124   END_LOOP;
00125   Element->MarkX = SWAP_X (Element->MarkX);
00126   Element->MarkY = SWAP_Y (Element->MarkY) + yoff;
00127 
00128   /* now toggle the solder-side flag */
00129   TOGGLE_FLAG (ONSOLDERFLAG, Element);
00130   /* this inserts all of the rtree data too */
00131   SetElementBoundingBox (Data, Element, &PCB->Font);
00132   ClearFromPolygon (Data, ELEMENT_TYPE, Element, Element);
00133 }