changeset 70:a9a20c85140e

pads2gpcb: foundation laid for mirroring and rotation
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Mon, 01 Feb 2016 00:06:43 +0000
parents a7f0e9bb3fb7
children a3d47129ebdc
files pads2gpcb/Makefile pads2gpcb/fpmanip.c
diffstat 2 files changed, 80 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/pads2gpcb/Makefile	Sun Jan 31 23:41:00 2016 +0000
+++ b/pads2gpcb/Makefile	Mon Feb 01 00:06:43 2016 +0000
@@ -1,7 +1,7 @@
 CC=	gcc
 CFLAGS=	-O2
-OBJS=	decals.o globals.o gpcbout.o main.o partinst.o parttype.o rdunits.o \
-	readpads.o silkselect.o util.o writeelem.o
+OBJS=	decals.o fpmanip.o globals.o gpcbout.o main.o partinst.o parttype.o \
+	rdunits.o readpads.o silkselect.o util.o writeelem.o
 HDRS=	globals.h gpcbout.h struct.h
 PROG=	pads2gpcb
 BINDIR=	/usr/local/bin
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pads2gpcb/fpmanip.c	Mon Feb 01 00:06:43 2016 +0000
@@ -0,0 +1,78 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "struct.h"
+
+static void
+do_footprint_pad(obj, func)
+	struct footprint_pad *obj;
+	void (*func)();
+{
+	func(&obj->end1);
+	func(&obj->end2);
+}
+
+static void
+do_element_line(obj, func)
+	struct element_line *obj;
+	void (*func)();
+{
+	func(&obj->end1);
+	func(&obj->end2);
+}
+
+static void
+do_element_arc(obj, func)
+	struct element_arc *obj;
+	void (*func)();
+{
+	func(&obj->centre);
+}
+
+manipulate_footprint_coord_pairs(fpbody, func)
+	struct footprint_body *fpbody;
+	void (*func)();
+{
+	int i;
+
+	for (i = 0; i < fpbody->npins; i++)
+		do_footprint_pad(fpbody->pins + i, func);
+	for (i = 0; i < fpbody->num_silk_lines; i++)
+		do_element_line(fpbody->silk_lines + i, func);
+	for (i = 0; i < fpbody->num_silk_arcs; i++)
+		do_element_arc(fpbody->silk_arcs + i, func);
+}
+
+coordpair_mirror_x(cp)
+	struct coord_pair *cp;
+{
+	cp->x = -cp->x;
+}
+
+coordpair_rot_90(cp)
+	struct coord_pair *cp;
+{
+	long newx, newy;
+
+	newx = -cp->y;
+	newy = cp->x;
+	cp->x = newx;
+	cp->y = newy;
+}
+
+coordpair_rot_180(cp)
+	struct coord_pair *cp;
+{
+	cp->x = -cp->x;
+	cp->y = -cp->y;
+}
+
+coordpair_rot_270(cp)
+	struct coord_pair *cp;
+{
+	long newx, newy;
+
+	newx = cp->y;
+	newy = -cp->x;
+	cp->x = newx;
+	cp->y = newy;
+}