r5849 - trunk/eda/fped

werner at docs.openmoko.org werner at docs.openmoko.org
Fri Feb 19 23:27:25 CET 2010


Author: werner
Date: 2010-02-19 23:27:25 +0100 (Fri, 19 Feb 2010)
New Revision: 5849

Modified:
   trunk/eda/fped/file.c
   trunk/eda/fped/file.h
   trunk/eda/fped/fped.c
   trunk/eda/fped/postscript.c
   trunk/eda/fped/postscript.h
Log:
New option -P for batch output for full-page postscript.

- fped.c (main, usage): new option -P to output full-page Postscript
- postscript.c (postscript): renamed full-page output to postscript_page,
  uncommented it, and added auto-zoom
- file.c, file.h (write_ps_fullpage): handler for full-page postscript
- fped.c (usage): clarified that -k and -p/-P don/t exclude each other



Modified: trunk/eda/fped/file.c
===================================================================
--- trunk/eda/fped/file.c	2010-02-19 14:00:55 UTC (rev 5848)
+++ trunk/eda/fped/file.c	2010-02-19 22:27:25 UTC (rev 5849)
@@ -1,8 +1,8 @@
 /*
  * file.c - File handling
  *
- * Written 2009 by Werner Almesberger
- * Copyright 2009 by Werner Almesberger
+ * Written 2009, 2010 by Werner Almesberger
+ * Copyright 2009, 2010 by Werner Almesberger
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -172,16 +172,28 @@
 }
 
 
-void write_ps(void)
+static void do_write_ps(int (*fn)(FILE *file))
 {
 	char *name;
 
 	if (save_file_name) {
 		name = set_extension(save_file_name, "ps");
-		save_to(name, postscript);
+		save_to(name, fn);
 		free(name);
 	} else {
-		if (!postscript(stdout))
+		if (!fn(stdout))
 			perror("stdout");
 	}
 }
+
+
+void write_ps(void)
+{
+	do_write_ps(postscript);
+}
+
+
+void write_ps_fullpage(void)
+{
+	do_write_ps(postscript_fullpage);
+}

Modified: trunk/eda/fped/file.h
===================================================================
--- trunk/eda/fped/file.h	2010-02-19 14:00:55 UTC (rev 5848)
+++ trunk/eda/fped/file.h	2010-02-19 22:27:25 UTC (rev 5849)
@@ -1,8 +1,8 @@
 /*
  * file.h - File handling
  *
- * Written 2009 by Werner Almesberger
- * Copyright 2009 by Werner Almesberger
+ * Written 2009, 2010 by Werner Almesberger
+ * Copyright 2009, 2010 by Werner Almesberger
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -29,5 +29,6 @@
 void save_fpd(void);
 void write_kicad(void);
 void write_ps(void);
+void write_ps_fullpage(void);
 
 #endif /* !FILE_H */

Modified: trunk/eda/fped/fped.c
===================================================================
--- trunk/eda/fped/fped.c	2010-02-19 14:00:55 UTC (rev 5848)
+++ trunk/eda/fped/fped.c	2010-02-19 22:27:25 UTC (rev 5849)
@@ -1,8 +1,8 @@
 /*
  * fped.c - Footprint editor, main function
  *
- * Written 2009 by Werner Almesberger
- * Copyright 2009 by Werner Almesberger
+ * Written 2009, 2010 by Werner Almesberger
+ * Copyright 2009, 2010 by Werner Almesberger
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -44,9 +44,10 @@
 static void usage(const char *name)
 {
 	fprintf(stderr,
-"usage: %s [-k|-p] [cpp_option ...] [in_file [out_file]]\n\n"
+"usage: %s [-k] [-p|-P] [cpp_option ...] [in_file [out_file]]\n\n"
 "  -k          write KiCad output, then exit\n"
 "  -p          write Postscript output, then exit\n"
+"  -P          write Postscript output (full page), then exit\n"
 "  cpp_option  -Idir, -Dname[=value], or -Uname\n"
     , name);
 	exit(1);
@@ -61,10 +62,11 @@
 	int fake_argc;
 	char opt[] = "-?";
 	int error, batch;
-	int batch_write_kicad = 0, batch_write_ps = 0;
+	int batch_write_kicad = 0;
+	int batch_write_ps = 0, batch_write_ps_fullpage = 0;
 	int c;
 
-	while ((c = getopt(argc, argv, "kpD:U:I:")) != EOF)
+	while ((c = getopt(argc, argv, "kpD:I:U:P")) != EOF)
 		switch (c) {
 		case 'k':
 			batch_write_kicad = 1;
@@ -72,6 +74,9 @@
 		case 'p':
 			batch_write_ps = 1;
 			break;
+		case 'P':
+			batch_write_ps_fullpage = 1;
+			break;
 		case 'D':
 		case 'U':
 		case 'I':
@@ -83,8 +88,11 @@
 			usage(name);
 		}
 
-	batch = batch_write_kicad || batch_write_ps;
+	if (batch_write_ps && batch_write_ps_fullpage)
+		usage(name);
 
+	batch = batch_write_kicad || batch_write_ps || batch_write_ps_fullpage;
+
 	if (!batch) {
 		args[0] = name;
 		args[1] = NULL;
@@ -125,6 +133,8 @@
 		write_kicad();
 	if (batch_write_ps)
 		write_ps();
+	if (batch_write_ps_fullpage)
+		write_ps_fullpage();
 	if (!batch) {
 		error = gui_main();
 		if (error)

Modified: trunk/eda/fped/postscript.c
===================================================================
--- trunk/eda/fped/postscript.c	2010-02-19 14:00:55 UTC (rev 5848)
+++ trunk/eda/fped/postscript.c	2010-02-19 22:27:25 UTC (rev 5849)
@@ -1,8 +1,8 @@
 /*
  * postscript.c - Dump objects in Postscript
  *
- * Written 2009 by Werner Almesberger
- * Copyright 2009 by Werner Almesberger
+ * Written 2009, 2010 by Werner Almesberger
+ * Copyright 2009, 2010 by Werner Almesberger
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -1004,7 +1004,6 @@
 }
 
 
-#if 1
 int postscript(FILE *file)
 {
 	struct pkg *pkg;
@@ -1023,16 +1022,17 @@
 	fflush(file);
 	return !ferror(file);
 }
-#else
 
+
 /*
  * Experimental. Doesn't work properly.
  */
-int postscript(FILE *file)
+
+int postscript_fullpage(FILE *file)
 {
 	unit_type cx, cy;
 	struct bbox bbox;
-	double f = 0.2;
+	double fx, fy, f;
 
 	prologue(file, 1);
 	ps_page(file, 1, pkgs);
@@ -1040,6 +1040,9 @@
 	bbox = inst_get_bbox();
 	cx = (bbox.min.x+bbox.max.x)/2;
 	cy = (bbox.min.y+bbox.max.y)/2;
+	fx = 2.0*PAGE_HALF_WIDTH/(bbox.max.x-bbox.min.x);
+	fy = 2.0*PAGE_HALF_HEIGHT/(bbox.max.y-bbox.min.y);
+	f = fx < fy ? fx : fy;
 	fprintf(file, "%d %d translate\n", (int) (-cx*f), (int) (-cy*f));
 	ps_draw_package(file, pkgs->next, f);
 	fprintf(file, "showpage\n");
@@ -1047,4 +1050,3 @@
 	fflush(file);
 	return !ferror(file);
 }
-#endif

Modified: trunk/eda/fped/postscript.h
===================================================================
--- trunk/eda/fped/postscript.h	2010-02-19 14:00:55 UTC (rev 5848)
+++ trunk/eda/fped/postscript.h	2010-02-19 22:27:25 UTC (rev 5849)
@@ -1,8 +1,8 @@
 /*
  * ps.h - Dump objects in Postscript
  *
- * Written 2009 by Werner Almesberger
- * Copyright 2009 by Werner Almesberger
+ * Written 2009, 2010 by Werner Almesberger
+ * Copyright 2009, 2010 by Werner Almesberger
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -27,5 +27,6 @@
 
 
 int postscript(FILE *file);
+int postscript_fullpage(FILE *file);
 
 #endif /* !POSTSCRIPT_H */




More information about the commitlog mailing list