Date:2010-05-03 15:41:24 (9 years 3 months ago)
Author:werner
Commit:8e60952ba1e7c4814940c4fe97869b80541348db
Message: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



git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5954 99fdad57-331a-0410-800a-d7fa5415bdb3
Files: fped.c (6 diffs)
postscript.c (2 diffs)
postscript.h (2 diffs)

Change Details

fped.c
1414#include <stdlib.h>
1515#include <stdio.h>
1616#include <unistd.h>
17#include <string.h>
1718#include <errno.h>
1819
1920#include "cpp.h"
...... 
2223#include "obj.h"
2324#include "inst.h"
2425#include "file.h"
26#include "postscript.h"
2527#include "dump.h"
2628#include "gui.h"
2729#include "delete.h"
...... 
6567static void usage(const char *name)
6668{
6769    fprintf(stderr,
68"usage: %s [-k] [-p|-P] [-T [-T]] [cpp_option ...] [in_file [out_file]]\n\n"
70"usage: %s [-k] [-p|-P [-s scale]] [-T [-T]] [cpp_option ...]\n"
71" %*s [in_file [out_file]]\n\n"
6972" -k write KiCad output, then exit\n"
7073" -p write Postscript output, then exit\n"
7174" -P write Postscript output (full page), then exit\n"
75" -s scale scale factor for -P (default: auto-scale)\n"
7276" -T test mode. Load file, then exit\n"
7377" -T -T test mode. Load file, dump to stdout, then exit\n"
7478" cpp_option -Idir, -Dname[=value], or -Uname\n"
75    , name);
79    , name, (int) strlen(name), "");
7680    exit(1);
7781}
7882
...... 
8488    char *args[2];
8589    int fake_argc;
8690    char opt[] = "-?";
91    char *end;
8792    int error;
8893    int batch = 0;
8994    int test_mode = 0;
...... 
9196    int batch_write_ps = 0, batch_write_ps_fullpage = 0;
9297    int c;
9398
94    while ((c = getopt(argc, argv, "kpD:I:PTU:")) != EOF)
99    while ((c = getopt(argc, argv, "kps:D:I:PTU:")) != EOF)
95100        switch (c) {
96101        case 'k':
97102            batch_write_kicad = 1;
...... 
102107        case 'P':
103108            batch_write_ps_fullpage = 1;
104109            break;
110        case 's':
111            if (!batch_write_ps_fullpage)
112                usage(*argv);
113            postscript_params.zoom = strtod(optarg, &end);
114            if (*end)
115                usage(*argv);
116            break;
105117        case 'T':
106118            batch = 1;
107119            test_mode++;
postscript.c
8888
8989
9090struct postscript_params postscript_params = {
91    .zoom = 0,
9192    .show_pad_names = 1,
9293    .show_stuff = 0,
9394    .label_vecs = 0,
...... 
11061107    bbox = inst_get_bbox();
11071108    cx = (bbox.min.x+bbox.max.x)/2;
11081109    cy = (bbox.min.y+bbox.max.y)/2;
1109    fx = 2.0*PAGE_HALF_WIDTH/(bbox.max.x-bbox.min.x);
1110    fy = 2.0*PAGE_HALF_HEIGHT/(bbox.max.y-bbox.min.y);
1111    f = fx < fy ? fx : fy;
1110    if (active_params.zoom)
1111        f = active_params.zoom;
1112    else {
1113        fx = 2.0*PAGE_HALF_WIDTH/(bbox.max.x-bbox.min.x);
1114        fy = 2.0*PAGE_HALF_HEIGHT/(bbox.max.y-bbox.min.y);
1115        f = fx < fy ? fx : fy;
1116    }
11121117    fprintf(file, "%d %d translate\n", (int) (-cx*f), (int) (-cy*f));
11131118    ps_draw_package(file, pkg, f);
11141119    fprintf(file, "showpage\n");
postscript.h
11/*
2 * ps.h - Dump objects in Postscript
2 * postscript.h - Dump objects in Postscript
33 *
44 * Written 2009, 2010 by Werner Almesberger
55 * Copyright 2009, 2010 by Werner Almesberger
...... 
2323        int show_stuff; /* vecs and frames */
2424        int label_vecs;
2525        int show_meas;
26};
26} postscript_params;
2727
2828
2929int postscript(FILE *file);

Archive Download the corresponding diff file

Branches:
master



interactive