r5954 - trunk/eda/fped

werner at docs.openmoko.org werner at docs.openmoko.org
Mon May 3 15:41:24 CEST 2010


Author: werner
Date: 2010-05-03 15:41:24 +0200 (Mon, 03 May 2010)
New Revision: 5954

Modified:
   trunk/eda/fped/fped.c
   trunk/eda/fped/postscript.c
   trunk/eda/fped/postscript.h
Log:
New option "-s scale" to set the exact scale factor for full-page Postscript 
output.

- postscript.h (postscript_params): didn't declare this global variable
- postscript.c (ps_package_fullpage): if postscript_params.zoom is non-zero,
  scale to this value (instead of auto-scaling) 
- fped.c (usage, main): added option "-s scale" to set the scale factor for -P



Modified: trunk/eda/fped/fped.c
===================================================================
--- trunk/eda/fped/fped.c	2010-05-03 13:22:25 UTC (rev 5953)
+++ trunk/eda/fped/fped.c	2010-05-03 13:41:24 UTC (rev 5954)
@@ -14,6 +14,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
+#include <string.h>
 #include <errno.h>
 
 #include "cpp.h"
@@ -22,6 +23,7 @@
 #include "obj.h"
 #include "inst.h"
 #include "file.h"
+#include "postscript.h"
 #include "dump.h"
 #include "gui.h"
 #include "delete.h"
@@ -65,14 +67,16 @@
 static void usage(const char *name)
 {
 	fprintf(stderr,
-"usage: %s [-k] [-p|-P] [-T [-T]] [cpp_option ...] [in_file [out_file]]\n\n"
+"usage: %s [-k] [-p|-P [-s scale]] [-T [-T]] [cpp_option ...]\n"
+"       %*s [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"
+"  -s scale    scale factor for -P (default: auto-scale)\n"
 "  -T          test mode. Load file, then exit\n"
 "  -T -T       test mode. Load file, dump to stdout, then exit\n"
 "  cpp_option  -Idir, -Dname[=value], or -Uname\n"
-    , name);
+    , name, (int) strlen(name), "");
 	exit(1);
 }
 
@@ -84,6 +88,7 @@
 	char *args[2];
 	int fake_argc;
 	char opt[] = "-?";
+	char *end;
 	int error;
 	int batch = 0;
 	int test_mode = 0;
@@ -91,7 +96,7 @@
 	int batch_write_ps = 0, batch_write_ps_fullpage = 0;
 	int c;
 
-	while ((c = getopt(argc, argv, "kpD:I:PTU:")) != EOF)
+	while ((c = getopt(argc, argv, "kps:D:I:PTU:")) != EOF)
 		switch (c) {
 		case 'k':
 			batch_write_kicad = 1;
@@ -102,6 +107,13 @@
 		case 'P':
 			batch_write_ps_fullpage = 1;
 			break;
+		case 's':
+			if (!batch_write_ps_fullpage)
+				usage(*argv);
+			postscript_params.zoom = strtod(optarg, &end);
+			if (*end)
+				usage(*argv);
+			break;
 		case 'T':
 			batch = 1;
 			test_mode++;

Modified: trunk/eda/fped/postscript.c
===================================================================
--- trunk/eda/fped/postscript.c	2010-05-03 13:22:25 UTC (rev 5953)
+++ trunk/eda/fped/postscript.c	2010-05-03 13:41:24 UTC (rev 5954)
@@ -88,6 +88,7 @@
 
 
 struct postscript_params postscript_params = {
+	.zoom		= 0,
 	.show_pad_names	= 1,
 	.show_stuff	= 0,
 	.label_vecs	= 0,
@@ -1106,9 +1107,13 @@
 	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;
+	if (active_params.zoom)
+		f = active_params.zoom;
+	else {
+		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, pkg, f);
 	fprintf(file, "showpage\n");

Modified: trunk/eda/fped/postscript.h
===================================================================
--- trunk/eda/fped/postscript.h	2010-05-03 13:22:25 UTC (rev 5953)
+++ trunk/eda/fped/postscript.h	2010-05-03 13:41:24 UTC (rev 5954)
@@ -1,5 +1,5 @@
 /*
- * ps.h - Dump objects in Postscript
+ * postscript.h - Dump objects in Postscript
  *
  * Written 2009, 2010 by Werner Almesberger
  * Copyright 2009, 2010 by Werner Almesberger
@@ -23,7 +23,7 @@
         int show_stuff;         /* vecs and frames */
         int label_vecs;
         int show_meas;
-};
+} postscript_params;
 
 
 int postscript(FILE *file);




More information about the commitlog mailing list