mirror of
git://projects.qi-hardware.com/fped.git
synced 2024-11-25 12:33:09 +02:00
- bare pads are now drawn in orange, so that one can see if a pad has a special
solder mask pattern - postscript.c: don't scale fonts down to nothing to make measurement text fit (in progress) git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5626 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
parent
e04a8017b7
commit
5c37256c09
@ -263,7 +263,8 @@ void gui_draw_pad(struct inst *self)
|
||||
struct coord max = translate(self->u.pad.other);
|
||||
GdkGC *gc;
|
||||
|
||||
gc = gc_pad[get_mode(self)];
|
||||
gc = self->obj->u.pad.type == pt_bare ?
|
||||
gc_pad_bare[get_mode(self)] : gc_pad[get_mode(self)];
|
||||
sort_coord(&min, &max);
|
||||
gdk_draw_rectangle(DA, gc, TRUE,
|
||||
min.x, min.y, max.x-min.x, max.y-min.y);
|
||||
@ -279,7 +280,8 @@ void gui_draw_rpad(struct inst *self)
|
||||
GdkGC *gc;
|
||||
unit_type h, w, r;
|
||||
|
||||
gc = gc_pad[get_mode(self)];
|
||||
gc = self->obj->u.pad.type == pt_bare ?
|
||||
gc_pad_bare[get_mode(self)] : gc_pad[get_mode(self)];
|
||||
sort_coord(&min, &max);
|
||||
h = max.y-min.y;
|
||||
w = max.x-min.x;
|
||||
|
@ -25,6 +25,7 @@ GdkGC *gc_active_frame;
|
||||
GdkGC *gc_vec[mode_n];
|
||||
GdkGC *gc_obj[mode_n];
|
||||
GdkGC *gc_pad[mode_n];
|
||||
GdkGC *gc_pad_bare[mode_n];
|
||||
GdkGC *gc_ptext[mode_n];
|
||||
GdkGC *gc_meas[mode_n];
|
||||
GdkGC *gc_frame[mode_n];
|
||||
@ -63,6 +64,7 @@ void gui_setup_style(GdkDrawable *drawable)
|
||||
style(gc_vec, "#202000", "#b0b050", "#ffff80");
|
||||
style(gc_obj, "#006060", "#00ffff", "#ffff80");
|
||||
style(gc_pad, "#400000", "#ff0000", "#ffff80");
|
||||
style(gc_pad_bare, "#402000", "#ff6000", "#ffff80");
|
||||
style(gc_ptext, "#404040", "#ffffff", "#ffffff");
|
||||
style(gc_meas, "#280040", "#ff00ff", "#ffff80");
|
||||
style(gc_frame, "#005000", "#009000", "#ffff80");
|
||||
|
@ -109,6 +109,7 @@ extern GdkGC *gc_active_frame;
|
||||
extern GdkGC *gc_vec[mode_n];
|
||||
extern GdkGC *gc_obj[mode_n];
|
||||
extern GdkGC *gc_pad[mode_n];
|
||||
extern GdkGC *gc_pad_bare[mode_n];
|
||||
extern GdkGC *gc_ptext[mode_n];
|
||||
extern GdkGC *gc_meas[mode_n];
|
||||
extern GdkGC *gc_frame[mode_n];
|
||||
|
3
inst.c
3
inst.c
@ -796,7 +796,8 @@ int inst_pad(struct obj *obj, const char *name, struct coord a, struct coord b)
|
||||
{
|
||||
struct inst *inst;
|
||||
|
||||
inst = add_inst(obj->u.pad.rounded ? &rpad_ops : &pad_ops, ip_pad, a);
|
||||
inst = add_inst(obj->u.pad.rounded ? &rpad_ops : &pad_ops,
|
||||
obj->u.pad.type == pt_bare ? ip_pad_bare : ip_pad, a);
|
||||
inst->obj = obj;
|
||||
inst->u.pad.name = stralloc(name);
|
||||
inst->u.pad.other = b;
|
||||
|
3
inst.h
3
inst.h
@ -37,7 +37,8 @@ struct bbox {
|
||||
|
||||
enum inst_prio {
|
||||
ip_frame, /* frames have their own selection */
|
||||
ip_pad, /* pads also accept clicks inside */
|
||||
ip_pad_bare, /* pads also accept clicks inside */
|
||||
ip_pad, /* pads with solder mask on top of those without */
|
||||
ip_circ, /* circles don't overlap easily */
|
||||
ip_arc, /* arc are like circles, just shorter */
|
||||
ip_rect, /* rectangles have plenty of sides */
|
||||
|
1
kicad.c
1
kicad.c
@ -197,6 +197,7 @@ static void kicad_inst(FILE *file, enum inst_prio prio, const struct inst *inst)
|
||||
{
|
||||
switch (prio) {
|
||||
case ip_pad:
|
||||
case ip_pad_bare:
|
||||
kicad_pad(file, inst);
|
||||
break;
|
||||
case ip_line:
|
||||
|
72
postscript.c
72
postscript.c
@ -76,10 +76,13 @@
|
||||
#define PS_MEAS_ARROW_ANGLE 30
|
||||
#define PS_MEAS_TEXT_HEIGHT mm_to_units(3) /* ~8.5 pt, real mm */
|
||||
#define PS_MEAS_BASE_OFFSET mm_to_units(0.5) /* real mm */
|
||||
#define PS_MEAS_MIN_HEIGHT (PS_MEAS_TEXT_HEIGHT/2)
|
||||
|
||||
#define PS_CROSS_WIDTH mm_to_units(0.01)
|
||||
#define PS_CROSS_DASH mm_to_units(0.1)
|
||||
|
||||
#define TEXT_HEIGHT_FACTOR 1.5 /* height/width of typical text */
|
||||
|
||||
|
||||
struct postscript_params postscript_params = {
|
||||
.show_pad_names = 1,
|
||||
@ -359,12 +362,23 @@ static void ps_vec(FILE *file, const struct inst *inst)
|
||||
}
|
||||
|
||||
|
||||
/* ----- Measurements ------------------------------------------------------ */
|
||||
|
||||
|
||||
static unit_type guesstimate_text_height(const char *s, unit_type width,
|
||||
double zoom)
|
||||
{
|
||||
return width/strlen(s)*TEXT_HEIGHT_FACTOR*zoom;
|
||||
}
|
||||
|
||||
|
||||
static void ps_meas(FILE *file, const struct inst *inst,
|
||||
enum curr_unit unit)
|
||||
enum curr_unit unit, double zoom)
|
||||
{
|
||||
struct coord a0, b0, a1, b1;
|
||||
struct coord c, d;
|
||||
char *s;
|
||||
unit_type height, width, offset;
|
||||
|
||||
a0 = inst->base;
|
||||
b0 = inst->u.meas.end;
|
||||
@ -384,16 +398,51 @@ static void ps_meas(FILE *file, const struct inst *inst,
|
||||
|
||||
c = add_vec(a1, b1);
|
||||
d = sub_vec(b1, a1);
|
||||
|
||||
/*
|
||||
* First try: put text between the arrows
|
||||
*/
|
||||
width = dist_point(a1, b1)-1.5*PS_MEAS_ARROW_LEN;
|
||||
offset = PS_MEAS_BASE_OFFSET;
|
||||
height = 0;
|
||||
if (guesstimate_text_height(s, width, zoom) < PS_MEAS_MIN_HEIGHT) {
|
||||
#if 0
|
||||
fprintf(stderr, "%s -> width %d height %d vs. %d\n",
|
||||
s, width, guesstimate_text_height(s, width, zoom), PS_MEAS_MIN_HEIGHT);
|
||||
#endif
|
||||
/*
|
||||
* Second try: push it above the arrows
|
||||
*/
|
||||
width = dist_point(a1, b1);
|
||||
offset +=
|
||||
PS_MEAS_ARROW_LEN*sin(PS_MEAS_ARROW_ANGLE*M_PI/180)*zoom;
|
||||
|
||||
if (guesstimate_text_height(s, width, zoom) <
|
||||
PS_MEAS_MIN_HEIGHT) {
|
||||
height = PS_MEAS_MIN_HEIGHT;
|
||||
width = strlen(s)*height;
|
||||
}
|
||||
}
|
||||
|
||||
if (height) {
|
||||
fprintf(file, "gsave %d %d moveto\n", c.x/2, c.y/2);
|
||||
fprintf(file, " /Helvetica-Bold findfont dup\n");
|
||||
fprintf(file, " (%s) %d %d realsize\n", s,
|
||||
(int) (dist_point(a1, b1)-1.5*PS_MEAS_ARROW_LEN),
|
||||
fprintf(file, " (%s) %d realsize %d realsize\n",
|
||||
s, width, height);
|
||||
fprintf(file, " boxfont\n");
|
||||
fprintf(file, " %f rotate\n", atan2(d.y, d.x)/M_PI*180);
|
||||
fprintf(file, " (%s) %d realsize hcenter\n", s, offset);
|
||||
fprintf(file, " show grestore\n");
|
||||
} else {
|
||||
fprintf(file, "gsave %d %d moveto\n", c.x/2, c.y/2);
|
||||
fprintf(file, " /Helvetica-Bold findfont dup\n");
|
||||
fprintf(file, " (%s) %d %d realsize\n", s, width,
|
||||
PS_MEAS_TEXT_HEIGHT);
|
||||
fprintf(file, " boxfont\n");
|
||||
fprintf(file, " %f rotate\n", atan2(d.y, d.x)/M_PI*180);
|
||||
fprintf(file, " (%s) %d realsize hcenter\n",
|
||||
s, PS_MEAS_BASE_OFFSET);
|
||||
fprintf(file, " (%s) %d realsize hcenter\n", s, offset);
|
||||
fprintf(file, " show grestore\n");
|
||||
}
|
||||
free(s);
|
||||
}
|
||||
|
||||
@ -422,10 +471,11 @@ static void ps_background(FILE *file, enum inst_prio prio,
|
||||
|
||||
|
||||
static void ps_foreground(FILE *file, enum inst_prio prio,
|
||||
const struct inst *inst)
|
||||
const struct inst *inst, double zoom)
|
||||
{
|
||||
switch (prio) {
|
||||
case ip_pad:
|
||||
case ip_pad_bare:
|
||||
if (inst->obj->u.pad.rounded)
|
||||
ps_rpad(file, inst, active_params.show_pad_names);
|
||||
else
|
||||
@ -441,7 +491,7 @@ static void ps_foreground(FILE *file, enum inst_prio prio,
|
||||
break;
|
||||
case ip_meas:
|
||||
if (active_params.show_meas)
|
||||
ps_meas(file, inst, curr_unit);
|
||||
ps_meas(file, inst, curr_unit, zoom);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -479,9 +529,9 @@ static void ps_draw_package(FILE *file, const struct pkg *pkg, double zoom)
|
||||
}
|
||||
FOR_INST_PRIOS_UP(prio) {
|
||||
FOR_PKG_INSTS(pkgs, prio, inst)
|
||||
ps_foreground(file, prio, inst);
|
||||
ps_foreground(file, prio, inst, zoom);
|
||||
FOR_PKG_INSTS(pkg, prio, inst)
|
||||
ps_foreground(file, prio, inst);
|
||||
ps_foreground(file, prio, inst, zoom);
|
||||
}
|
||||
fprintf(file, "grestore\n");
|
||||
}
|
||||
@ -509,10 +559,10 @@ static void ps_draw_frame(FILE *file, const struct pkg *pkg,
|
||||
FOR_INST_PRIOS_UP(prio) {
|
||||
FOR_PKG_INSTS(pkgs, prio, inst)
|
||||
if (inst->outer == outer)
|
||||
ps_foreground(file, prio, inst);
|
||||
ps_foreground(file, prio, inst, zoom);
|
||||
FOR_PKG_INSTS(pkg, prio, inst)
|
||||
if (inst->outer == outer)
|
||||
ps_foreground(file, prio, inst);
|
||||
ps_foreground(file, prio, inst, zoom);
|
||||
}
|
||||
fprintf(file, "grestore\n");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user