1
0
mirror of git://projects.qi-hardware.com/fped.git synced 2024-06-30 22:11:40 +03: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:
werner 2009-09-10 23:40:03 +00:00
parent e04a8017b7
commit 5c37256c09
7 changed files with 86 additions and 28 deletions

View File

@ -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;

View File

@ -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];
@ -59,13 +60,14 @@ void gui_setup_style(GdkDrawable *drawable)
gc_bg = gc("#000000", 0);
gc_bg_error = gc("#000040", 0);
gc_drag = gc("#ffffff", 2);
/* inactive active selected */
style(gc_vec, "#202000", "#b0b050", "#ffff80");
style(gc_obj, "#006060", "#00ffff", "#ffff80");
style(gc_pad, "#400000", "#ff0000", "#ffff80");
style(gc_ptext, "#404040", "#ffffff", "#ffffff");
style(gc_meas, "#280040", "#ff00ff", "#ffff80");
style(gc_frame, "#005000", "#009000", "#ffff80");
/* inactive active selected */
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");
gc_active_frame = gc("#00ff00", 2);
// gc_highlight = gc("#ff8020", 2);

View File

@ -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
View File

@ -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
View File

@ -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 */

View File

@ -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:

View File

@ -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);
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),
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, " show grestore\n");
/*
* 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 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, 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");
}