r5490 - trunk/eda/fped

werner at docs.openmoko.org werner at docs.openmoko.org
Thu Aug 20 00:13:48 CEST 2009


Author: werner
Date: 2009-08-20 00:13:47 +0200 (Thu, 20 Aug 2009)
New Revision: 5490

Modified:
   trunk/eda/fped/dump.c
   trunk/eda/fped/fbga.fpd
   trunk/eda/fped/inst.h
   trunk/eda/fped/obj.h
   trunk/eda/fped/postscript.c
   trunk/eda/fped/sc89.fpd
Log:
- postscript.c: always run flattenpath before pathbbox
- postscript.c: fixed algorithm in "center"
- dump.c: reorder frames if we would end up with forward-references
- sc89.fpd, fbga.fpd: changed "part" to new "package"



Modified: trunk/eda/fped/dump.c
===================================================================
--- trunk/eda/fped/dump.c	2009-08-19 14:53:19 UTC (rev 5489)
+++ trunk/eda/fped/dump.c	2009-08-19 22:13:47 UTC (rev 5490)
@@ -436,8 +436,7 @@
 /* ----- frames ------------------------------------------------------------ */
 
 
-static void dump_frame(FILE *file, const struct frame *frame,
-    const char *indent)
+static void dump_frame(FILE *file, struct frame *frame, const char *indent)
 {
 	const struct table *table;
 	const struct loop *loop;
@@ -446,6 +445,17 @@
 	const struct order *item;
 	char *s, *s1;
 
+	if (frame->dumped)
+		return;
+	frame->dumped = 1;
+
+	for (obj = frame->objs; obj; obj = obj->next)
+		if (obj->type == ot_frame)
+			dump_frame(file, obj->u.frame.ref, "\t");
+
+	if (frame->name)
+		fprintf(file, "frame %s {\n", frame->name);
+
 	for (table = frame->tables; table; table = table->next)
 		dump_table(file, table, indent);
 	for (loop = frame->loops; loop; loop = loop->next)
@@ -472,6 +482,9 @@
 		fprintf(file, "%s%s\n", indent, s);
 		free(s);
 	}
+
+	if (frame->name)
+		fprintf(file, "}\n\n");
 }
 
 
@@ -480,17 +493,17 @@
 
 int dump(FILE *file)
 {
-	const struct frame *frame;
+	struct frame *frame;
 
 	fprintf(file, "/* MACHINE-GENERATED ! */\n\n");
+	for (frame = frames; frame; frame = frame->next)
+		frame->dumped = 0;
 	for (frame = frames; frame; frame = frame->next) {
 		if (!frame->name) {
 			fprintf(file, "package \"%s\"\n", pkg_name);
 			dump_frame(file, frame, "");
 		} else {
-			fprintf(file, "frame %s {\n", frame->name);
 			dump_frame(file, frame, "\t");
-			fprintf(file, "}\n\n");
 		}
 	}
 	fflush(file);

Modified: trunk/eda/fped/fbga.fpd
===================================================================
--- trunk/eda/fped/fbga.fpd	2009-08-19 14:53:19 UTC (rev 5489)
+++ trunk/eda/fped/fbga.fpd	2009-08-19 22:13:47 UTC (rev 5490)
@@ -35,7 +35,7 @@
 	frame pad @
 }
 
-part "Fake_BGA"
+package "Fake_BGA"
 table
     { row, rname, inner }
     { 0, "A", 1 }

Modified: trunk/eda/fped/inst.h
===================================================================
--- trunk/eda/fped/inst.h	2009-08-19 14:53:19 UTC (rev 5489)
+++ trunk/eda/fped/inst.h	2009-08-19 22:13:47 UTC (rev 5490)
@@ -72,7 +72,6 @@
 struct inst {
 	const struct inst_ops *ops;
 	struct coord base;
-//	struct inst *base_inst; /* frame or vector leading to this item */
 	struct bbox bbox;
 	struct vec *vec; /* NULL if not vector */
 	struct obj *obj; /* NULL if not object */

Modified: trunk/eda/fped/obj.h
===================================================================
--- trunk/eda/fped/obj.h	2009-08-19 14:53:19 UTC (rev 5489)
+++ trunk/eda/fped/obj.h	2009-08-19 22:13:47 UTC (rev 5490)
@@ -122,6 +122,9 @@
 	/* generating and editing */
 	struct obj *active_ref;
 
+	/* for dumping */
+	int dumped;
+
 	/* for the GUI */
 	GtkWidget *label;
 };

Modified: trunk/eda/fped/postscript.c
===================================================================
--- trunk/eda/fped/postscript.c	2009-08-19 14:53:19 UTC (rev 5489)
+++ trunk/eda/fped/postscript.c	2009-08-19 22:13:47 UTC (rev 5490)
@@ -31,6 +31,8 @@
 #define	PS_MEAS_ARROW_ANGLE	30
 #define	PS_MEAS_TEXT_HEIGHT	mm_to_units(0.2)
 #define	PS_MEAS_BASE_OFFSET	mm_to_units(0.05)
+#define	PS_CROSS_WIDTH		mm_to_units(0.01)
+#define	PS_CROSS_DASH		mm_to_units(0.1)
 
 
 struct postscript_params postscript_params = {
@@ -274,6 +276,18 @@
 }
 
 
+static void ps_cross(FILE *file, const struct inst *inst)
+{
+	fprintf(file, "gsave 0 setgray %d setlinewidth\n", PS_CROSS_WIDTH);
+	fprintf(file, "    [%d] 0 setdash\n", PS_CROSS_DASH);
+	fprintf(file, "    %d 0 moveto %d 0 lineto\n",
+	    inst->bbox.min.x, inst->bbox.max.x);
+	fprintf(file, "    0 %d moveto 0 %d lineto\n",
+	    inst->bbox.min.y, inst->bbox.max.y);
+	fprintf(file, "    stroke grestore \n");
+}
+
+
 int postscript(FILE *file)
 {
 	enum inst_prio prio;
@@ -292,7 +306,7 @@
 
 	fprintf(file,
 "/dotpath {\n"
-"    gsave pathbbox clip newpath\n"
+"    gsave flattenpath pathbbox clip newpath\n"
 "    1 setlinecap %d setlinewidth\n"
 "    /ury exch def /urx exch def /lly exch def /llx exch def\n"
 "    llx %d urx {\n"
@@ -304,7 +318,7 @@
 
 	fprintf(file,
 "/hatchpath {\n"
-"     gsave pathbbox clip newpath\n"
+"     gsave flattenpath pathbbox clip newpath\n"
 "    /ury exch def /urx exch def /lly exch def /llx exch def\n"
 "    lly ury sub %d urx llx sub {\n"	/* for -(ury-lly) to urx-llx */
 "	llx add dup lly moveto\n"
@@ -314,7 +328,7 @@
 
 	fprintf(file,
 "/backhatchpath {\n"
-"     gsave pathbbox clip newpath\n"
+"     gsave flattenpath pathbbox clip newpath\n"
 "    /ury exch def /urx exch def /lly exch def /llx exch def\n"
 "    0 %d ury lly sub urx llx sub add {\n"	/* for 0 to urx-llx_ury-lly */
 "	llx add dup lly moveto\n"
@@ -335,7 +349,7 @@
 "    gsave 0 0 moveto\n"
 "    /f exch def /h exch def /w exch def\n"
 "    exch f scalefont setfont\n"
-"    false charpath pathbbox\n"
+"    false charpath flattenpath pathbbox\n"
 "    /ury exch def /urx exch def /lly exch def /llx exch def\n"
 "    w urx llx sub div h ury lly sub div 2 copy gt { exch } if pop\n"
 "    f mul grestore } def\n");
@@ -346,10 +360,12 @@
 
 	fprintf(file,
 "/center {\n"
-"    gsave dup false charpath pathbbox\n"
-"    /ury exch def /urx exch def /lly exch def /llx exch def\n"
+"    currentpoint /y exch def /x exch def\n"
+"    gsave dup false charpath flattenpath pathbbox\n"
+"    /ury exch def /urx exch def\n"
+"    /lly exch def /llx exch def\n"
 "    grestore\n"
-"    llx urx sub 2 div lly ury sub 2 div rmoveto } def\n");
+"    x llx urx add 2 div sub y lly ury add 2 div sub rmoveto } def\n");
 
 	/*
 	 * Stack: string dist -> string
@@ -358,7 +374,7 @@
 	fprintf(file,
 "/hcenter {\n"
 "    /off exch def\n"
-"    gsave dup false charpath pathbbox\n"
+"    gsave dup false charpath flattenpath pathbbox\n"
 "    /ury exch def /urx exch def /lly exch def /llx exch def\n"
 "    grestore\n"
 "    llx urx sub 2 div\n"
@@ -371,9 +387,20 @@
 	fprintf(file,
 "/showoutlined {\n"
 "    gsave 2 mul setlinewidth 1 setgray\n"
-"    dup false charpath stroke grestore\n"
+"    dup false charpath flattenpath stroke grestore\n"
 "    show } def\n");
 
+	/*
+	 * Stack: string -> string
+	 */
+
+fprintf(file,
+"/debugbox { gsave dup false charpath flattenpath pathbbox\n"
+"    /ury exch def /urx exch def /lly exch def /llx exch def\n"
+"    0 setgray 100 setlinewidth\n"
+"    llx lly urx llx sub ury lly sub rectstroke grestore } def\n");
+
+	ps_cross(file, pkgs->insts[ip_frame]);
 	FOR_INST_PRIOS_UP(prio)
 		FOR_ALL_INSTS(i, prio, inst)
 			ps_background(file, prio, inst);

Modified: trunk/eda/fped/sc89.fpd
===================================================================
--- trunk/eda/fped/sc89.fpd	2009-08-19 14:53:19 UTC (rev 5489)
+++ trunk/eda/fped/sc89.fpd	2009-08-19 22:13:47 UTC (rev 5490)
@@ -50,7 +50,7 @@
 	line top_left . 5mil
 }
 
-part "SC89"
+package "SC89"
 table
     { Px, Py, Gy, Wx }
     { 0.5mm, 0.6mm, 0.7mm, 1.5mm }




More information about the commitlog mailing list