Date:2012-07-19 03:31:36 (7 years 4 months ago)
Author:Werner Almesberger
Commit:ed69b7b0e085382c2c2c8cdbb331325c60112b4f
Message:postscript.c: cleaned up geometry calculation for pad type key

Files: postscript.c (4 diffs)

Change Details

postscript.c
8989#define PS_CROSS_WIDTH mm_to_units(0.01)
9090#define PS_CROSS_DASH mm_to_units(0.1)
9191
92#define PS_KEY_GAP mm_to_units(8)
92#define PS_KEY_X_GAP mm_to_units(8)
93#define PS_KEY_Y_GAP mm_to_units(4)
9394#define PS_KEY_HEIGTH mm_to_units(8)
9495
9596#define TEXT_HEIGHT_FACTOR 1.5 /* height/width of typical text */
...... 
818819    struct coord a, b;
819820    unit_type key_w;
820821
821    key_w = (w-2*PS_KEY_GAP-PS_KEY_GAP*(pt_n-1))/pt_n;
822    a.x = b.x = (key_w+PS_KEY_GAP)*type-w/2+PS_KEY_GAP;
823    a.y = b.y = -h/2-PS_KEY_GAP;
822    key_w = (w-2*PS_KEY_X_GAP-PS_KEY_X_GAP*(pt_n-1))/pt_n;
823    a.x = b.x = (key_w+PS_KEY_X_GAP)*type-w/2+PS_KEY_X_GAP;
824    a.y = b.y = -h/2-PS_KEY_Y_GAP;
824825    b.x += key_w;
825826    b.y -= PS_KEY_HEIGTH;
826827
...... 
11841185    double fx, fy, f;
11851186    double w = 2.0*PAGE_HALF_WIDTH;
11861187    double h = 2.0*PAGE_HALF_HEIGHT;
1188    int yoff = 0;
11871189
11881190    ps_page(file, page, pkg);
11891191    active_params = postscript_params;
...... 
11981200        fx = w/(bbox.max.x-bbox.min.x);
11991201        if (active_params.max_height)
12001202            h = active_params.max_height;
1201        if (active_params.show_key)
1202            h -= 2*PS_KEY_HEIGTH;
1203        if (active_params.show_key) {
1204            yoff = PS_KEY_HEIGTH+PS_KEY_Y_GAP;
1205            h -= yoff;
1206        }
12031207        fy = h/(bbox.max.y-bbox.min.y);
12041208        f = fx < fy ? fx : fy;
12051209    }
12061210    fprintf(file, "gsave\n");
1207    fprintf(file, "%d %d translate\n", (int) (-cx*f), (int) (-cy*f));
1211    fprintf(file, "%d %d translate\n", (int) (-cx*f), (int) (-cy*f)+yoff);
12081212    ps_draw_package(file, pkg, f, 0);
12091213    fprintf(file, "grestore\n");
1210    if (active_params.show_key)
1214    if (active_params.show_key) {
1215        fprintf(file, "gsave 0 %d translate\n", yoff);
12111216        ps_keys(file, w, h);
1217        fprintf(file, "grestore\n");
1218    }
12121219    fprintf(file, "showpage\n");
12131220}
12141221

Archive Download the corresponding diff file

Branches:
master



interactive