mirror of
git://projects.qi-hardware.com/fped.git
synced 2024-11-25 21:38:26 +02:00
- added KiCad export of arcs
- added pad names to Postscript export git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5458 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
parent
230de72552
commit
233fc4b683
29
kicad.c
29
kicad.c
@ -153,7 +153,30 @@ static void kicad_circ(FILE *file, const struct inst *inst)
|
|||||||
|
|
||||||
static void kicad_arc(FILE *file, const struct inst *inst)
|
static void kicad_arc(FILE *file, const struct inst *inst)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "NOT YET IMPLEMENTED\n");
|
struct coord p;
|
||||||
|
double a;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The documentation says:
|
||||||
|
* Xstart, Ystart, Xend, Yend, Angle, Width, Layer
|
||||||
|
*
|
||||||
|
* But it's really:
|
||||||
|
* Xcenter, Ycenter, Xend, Yend, ...
|
||||||
|
*/
|
||||||
|
p = rotate_r(inst->base, inst->u.arc.r, inst->u.arc.a2);
|
||||||
|
a = inst->u.arc.a2-inst->u.arc.a1;
|
||||||
|
while (a <= 0)
|
||||||
|
a += 360;
|
||||||
|
while (a > 360)
|
||||||
|
a -= 360;
|
||||||
|
fprintf(file, "DA %d %d %d %d %d %d %d\n",
|
||||||
|
units_to_kicad(inst->base.x),
|
||||||
|
-units_to_kicad(inst->base.y),
|
||||||
|
units_to_kicad(p.x),
|
||||||
|
-units_to_kicad(p.y),
|
||||||
|
(int) (a*10.0),
|
||||||
|
units_to_kicad(inst->u.arc.width),
|
||||||
|
layer_silk_top);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -176,6 +199,10 @@ static void kicad_inst(FILE *file, enum inst_prio prio, const struct inst *inst)
|
|||||||
kicad_arc(file, inst);
|
kicad_arc(file, inst);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
/*
|
||||||
|
* Don't try to export vectors, frame references, or
|
||||||
|
* measurements.
|
||||||
|
*/
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
74
postscript.c
74
postscript.c
@ -23,18 +23,41 @@
|
|||||||
#define DOT_DIAM mm_to_units(0.01)
|
#define DOT_DIAM mm_to_units(0.01)
|
||||||
#define HATCH mm_to_units(0.1)
|
#define HATCH mm_to_units(0.1)
|
||||||
#define HATCH_LINE mm_to_units(0.02)
|
#define HATCH_LINE mm_to_units(0.02)
|
||||||
|
#define FONT_OUTLINE mm_to_units(0.025)
|
||||||
|
|
||||||
|
|
||||||
struct postscript_params postscript_params = {
|
struct postscript_params postscript_params = {
|
||||||
.zoom = 10.0,
|
.zoom = 10.0,
|
||||||
.show_pad_names = 0,
|
.show_pad_names = 1,
|
||||||
.show_stuff = 0,
|
.show_stuff = 0,
|
||||||
.label_vecs = 0,
|
.label_vecs = 0,
|
||||||
.show_meas = 0,
|
.show_meas = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static void ps_pad(FILE *file, const struct inst *inst)
|
static void ps_pad_name(FILE *file, const struct inst *inst)
|
||||||
|
{
|
||||||
|
struct coord a = inst->base;
|
||||||
|
struct coord b = inst->u.pad.other;
|
||||||
|
unit_type h, w;
|
||||||
|
|
||||||
|
h = a.y-b.y;
|
||||||
|
w = a.x-b.x;
|
||||||
|
if (h < 0)
|
||||||
|
h = -h;
|
||||||
|
if (w < 0)
|
||||||
|
w = -w;
|
||||||
|
fprintf(file, "0 setgray /Helvetica-Bold findfont dup\n");
|
||||||
|
fprintf(file, " (%s) %d %d\n", inst->u.pad.name, w/2, h/2);
|
||||||
|
fprintf(file, " 4 copy 100 maxfont\n");
|
||||||
|
fprintf(file, " maxfont scalefont setfont\n");
|
||||||
|
fprintf(file, " %d %d moveto\n", (a.x+b.x)/2, (a.y+b.y)/2);
|
||||||
|
fprintf(file, " (%s) center %d showoutlined newpath\n",
|
||||||
|
inst->u.pad.name, FONT_OUTLINE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void ps_pad(FILE *file, const struct inst *inst, int show_name)
|
||||||
{
|
{
|
||||||
struct coord a = inst->base;
|
struct coord a = inst->base;
|
||||||
struct coord b = inst->u.pad.other;
|
struct coord b = inst->u.pad.other;
|
||||||
@ -45,10 +68,13 @@ static void ps_pad(FILE *file, const struct inst *inst)
|
|||||||
fprintf(file, " %d %d lineto\n", b.x, b.y);
|
fprintf(file, " %d %d lineto\n", b.x, b.y);
|
||||||
fprintf(file, " %d %d lineto\n", a.x, b.y);
|
fprintf(file, " %d %d lineto\n", a.x, b.y);
|
||||||
fprintf(file, " closepath gsave hatchpath grestore stroke\n");
|
fprintf(file, " closepath gsave hatchpath grestore stroke\n");
|
||||||
|
|
||||||
|
if (show_name)
|
||||||
|
ps_pad_name(file, inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ps_rpad(FILE *file, const struct inst *inst)
|
static void ps_rpad(FILE *file, const struct inst *inst, int show_name)
|
||||||
{
|
{
|
||||||
struct coord a = inst->base;
|
struct coord a = inst->base;
|
||||||
struct coord b = inst->u.pad.other;
|
struct coord b = inst->u.pad.other;
|
||||||
@ -72,6 +98,9 @@ static void ps_rpad(FILE *file, const struct inst *inst)
|
|||||||
fprintf(file, " %d %d %d 90 270 arc\n", a.x+r, a.y+r, r);
|
fprintf(file, " %d %d %d 90 270 arc\n", a.x+r, a.y+r, r);
|
||||||
}
|
}
|
||||||
fprintf(file, " closepath gsave hatchpath grestore stroke\n");
|
fprintf(file, " closepath gsave hatchpath grestore stroke\n");
|
||||||
|
|
||||||
|
if (show_name)
|
||||||
|
ps_pad_name(file, inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -159,9 +188,9 @@ static void ps_foreground(FILE *file, enum inst_prio prio,
|
|||||||
switch (prio) {
|
switch (prio) {
|
||||||
case ip_pad:
|
case ip_pad:
|
||||||
if (inst->obj->u.pad.rounded)
|
if (inst->obj->u.pad.rounded)
|
||||||
ps_rpad(file, inst);
|
ps_rpad(file, inst, postscript_params.show_pad_names);
|
||||||
else
|
else
|
||||||
ps_pad(file, inst);
|
ps_pad(file, inst, postscript_params.show_pad_names);
|
||||||
break;
|
break;
|
||||||
case ip_vec:
|
case ip_vec:
|
||||||
if (postscript_params.show_stuff)
|
if (postscript_params.show_stuff)
|
||||||
@ -218,6 +247,41 @@ int postscript(FILE *file)
|
|||||||
" } for\n"
|
" } for\n"
|
||||||
" grestore newpath } def\n", HATCH);
|
" grestore newpath } def\n", HATCH);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Stack: font string width height factor -> factor
|
||||||
|
*/
|
||||||
|
|
||||||
|
fprintf(file,
|
||||||
|
"/maxfont {\n"
|
||||||
|
" gsave 0 0 moveto\n"
|
||||||
|
" /f exch def /h exch def /w exch def\n"
|
||||||
|
" exch f scalefont setfont\n"
|
||||||
|
" false charpath 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");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Stack: string -> string
|
||||||
|
*/
|
||||||
|
|
||||||
|
fprintf(file,
|
||||||
|
"/center {\n"
|
||||||
|
" gsave dup false charpath pathbbox\n"
|
||||||
|
" /ury exch def /urx exch def /lly exch def /llx exch def\n"
|
||||||
|
" grestore\n"
|
||||||
|
" llx urx sub 2 div lly ury sub 2 div rmoveto } def\n");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Stack: string outline_width -> -
|
||||||
|
*/
|
||||||
|
|
||||||
|
fprintf(file,
|
||||||
|
"/showoutlined {\n"
|
||||||
|
" gsave 2 mul setlinewidth 1 setgray\n"
|
||||||
|
" dup false charpath stroke grestore\n"
|
||||||
|
" show } def\n");
|
||||||
|
|
||||||
FOR_INSTS_UP(prio, inst)
|
FOR_INSTS_UP(prio, inst)
|
||||||
ps_background(file, prio, inst);
|
ps_background(file, prio, inst);
|
||||||
FOR_INSTS_UP(prio, inst)
|
FOR_INSTS_UP(prio, inst)
|
||||||
|
Loading…
Reference in New Issue
Block a user