r5367 - developers/werner/fped

werner at docs.openmoko.org werner at docs.openmoko.org
Sun Aug 2 18:35:10 CEST 2009


Author: werner
Date: 2009-08-02 18:35:09 +0200 (Sun, 02 Aug 2009)
New Revision: 5367

Modified:
   developers/werner/fped/README
   developers/werner/fped/TODO
   developers/werner/fped/expr.h
   developers/werner/fped/fpd.y
   developers/werner/fped/gui_inst.c
   developers/werner/fped/gui_style.c
   developers/werner/fped/gui_style.h
   developers/werner/fped/gui_util.c
   developers/werner/fped/gui_util.h
   developers/werner/fped/inst.c
   developers/werner/fped/inst.h
   developers/werner/fped/obj.c
   developers/werner/fped/obj.h
   developers/werner/fped/qfn.fpd
Log:
- the current frame is now drawn on top of the current items, to emphasize 
  access to the frame's origin
- measurement text is now scaled to the size of the arrow
- pad names are now shown on canvas
- added eval_unit for the various distance expressions in obj.c
- silk screen items now have an optional width
- qfn.fpd: commented out package outline because it would be printed over the
  pads



Modified: developers/werner/fped/README
===================================================================
--- developers/werner/fped/README	2009-08-02 05:36:21 UTC (rev 5366)
+++ developers/werner/fped/README	2009-08-02 16:35:09 UTC (rev 5367)
@@ -117,19 +117,20 @@
 
 A line connects two points:
 
-line <point-a> <point-b>
+line <point-a> <point-b> [<width>]
 
 The points can be specified with @, ., and an identifier, just like
-a vector base.
+a vector base. The option width specifies the thickness of the silk
+screen line. If omitted, a hard-coded default of 15 mil is used.
 
 A rectangle has sides parallel to the x and y axis and is defined
 by two diagonally opposite corners:
 
-rect <point-a> <point-b>
+rect <point-a> <point-b> [<width>]
 
 A circle is defined by its center and a point on the circle:
 
-circ <center> <point>
+circ <center> <point> [<width>]
 
 This example draws a unit circle:
 
@@ -141,7 +142,7 @@
 angle. The second point only determines the end angle but its distance
 from the center is ignored.
 
-arc <center> <radius> <end>
+arc <center> <radius> <end> [<width>]
 
 The arc is drawn in a counter-clockwise direction. The following example
 draws an arc of the unit circle in the x > 0, y > 0 quadrant:

Modified: developers/werner/fped/TODO
===================================================================
--- developers/werner/fped/TODO	2009-08-02 05:36:21 UTC (rev 5366)
+++ developers/werner/fped/TODO	2009-08-02 16:35:09 UTC (rev 5367)
@@ -19,6 +19,9 @@
 Style:
 - make column of entry field greedily consume all unallocated space
 
+Bugs:
+- default silk width has no business being hard-coded in obj.c
+
 Code cleanup:
 - merge edit_unique with edit_name
 - merge find_var_in_frame with similar mechanisms in expr.c and fpd.y

Modified: developers/werner/fped/expr.h
===================================================================
--- developers/werner/fped/expr.h	2009-08-02 05:36:21 UTC (rev 5366)
+++ developers/werner/fped/expr.h	2009-08-02 16:35:09 UTC (rev 5367)
@@ -69,6 +69,7 @@
 
 const char *str_unit(struct num n);
 
+
 static inline struct num make_num(double n)
 {
 	struct num res;
@@ -79,6 +80,18 @@
 	return res;
 }
 
+
+static inline struct num make_mil(double mil)
+{
+	struct num res;
+
+	res.type = nt_mil;
+	res.exponent = 1;
+	res.n = mil;
+	return res;
+}
+
+
 int to_unit(struct num *n);
 
 struct num op_num(const struct expr *self, const struct frame *frame);

Modified: developers/werner/fped/fpd.y
===================================================================
--- developers/werner/fped/fpd.y	2009-08-02 05:36:21 UTC (rev 5366)
+++ developers/werner/fped/fpd.y	2009-08-02 16:35:09 UTC (rev 5367)
@@ -151,7 +151,7 @@
 %type	<value>	row value
 %type	<vec>	vec base
 %type	<obj>	obj
-%type	<expr>	expr add_expr mult_expr unary_expr primary_expr
+%type	<expr>	expr opt_expr add_expr mult_expr unary_expr primary_expr
 
 %%
 
@@ -383,31 +383,35 @@
 			$$->u.pad.name = $2;
 			$$->u.pad.other = $4;
 		}
-	| TOK_RECT base base
+	| TOK_RECT base base opt_expr
 		{
 			$$ = new_obj(ot_rect);
 			$$->base = $2;
 			$$->u.rect.other = $3;
+			$$->width = $4;
 		}
-	| TOK_LINE base base
+	| TOK_LINE base base opt_expr
 		{
 			$$ = new_obj(ot_line);
 			$$->base = $2;
 			$$->u.line.other = $3;
+			$$->width = $4;
 		}
-	| TOK_CIRC base base
+	| TOK_CIRC base base opt_expr
 		{
 			$$ = new_obj(ot_arc);
 			$$->base = $2;
 			$$->u.arc.start = $3;
 			$$->u.arc.end = $3;
+			$$->width = $4;
 		}
-	| TOK_ARC base base base
+	| TOK_ARC base base base opt_expr
 		{
 			$$ = new_obj(ot_arc);
 			$$->base = $2;
 			$$->u.arc.start = $3;
 			$$->u.arc.end = $4;
+			$$->width = $5;
 		}
 	| TOK_MEAS base base expr
 		{
@@ -428,6 +432,16 @@
 		}
 	;
 
+opt_expr:
+		{
+			$$ = NULL;
+		}
+	| expr
+		{
+			$$ = $1;
+		}
+	;
+
 expr:
 	add_expr
 		{

Modified: developers/werner/fped/gui_inst.c
===================================================================
--- developers/werner/fped/gui_inst.c	2009-08-02 05:36:21 UTC (rev 5366)
+++ developers/werner/fped/gui_inst.c	2009-08-02 16:35:09 UTC (rev 5367)
@@ -138,7 +138,7 @@
 {
 	unit_type d;
 
-	d = dist_point(pos, self->u.end)/scale;
+	d = dist_point(pos, self->u.rect.end)/scale;
 	return d > VEC_EYE_R ? -1 : d;
 }
 
@@ -154,7 +154,7 @@
 {
 	unit_type d;
 
-	d = dist_line(pos, self->base, self->u.end)/scale;
+	d = dist_line(pos, self->base, self->u.rect.end)/scale;
 	return d > SELECT_R ? -1 : d;
 }
 
@@ -162,7 +162,7 @@
 void gui_draw_vec(struct inst *self, struct draw_ctx *ctx)
 {
 	struct coord from = translate(ctx, self->base);
-	struct coord to = translate(ctx, self->u.end);
+	struct coord to = translate(ctx, self->u.rect.end);
 	GdkGC *gc;
 
 	gc = gc_vec[get_mode(self)];
@@ -177,20 +177,24 @@
 
 unit_type gui_dist_line(struct inst *self, struct coord pos, unit_type scale)
 {
-	unit_type d;
+	unit_type r, d;
 
+	r = self->u.rect.width/scale/2;
+	if (r < SELECT_R)
+		r = SELECT_R;
 	d = dist_line(pos, self->bbox.min, self->bbox.max)/scale;
-	return d > SELECT_R ? -1 : d;
+	return d > r ? -1 : d;
 }
 
 
 void gui_draw_line(struct inst *self, struct draw_ctx *ctx)
 {
-	struct coord min = translate(ctx, self->bbox.min);
-	struct coord max = translate(ctx, self->bbox.max);
+	struct coord min = translate(ctx, self->base);
+	struct coord max = translate(ctx, self->u.rect.end);
 	GdkGC *gc;
 
 	gc = gc_obj[get_mode(self)];
+	set_width(gc, self->u.rect.width/ctx->scale);
 	gdk_draw_line(DA, gc, min.x, min.y, max.x, max.y);
 }
 
@@ -200,10 +204,13 @@
 
 unit_type gui_dist_rect(struct inst *self, struct coord pos, unit_type scale)
 {
-	unit_type d;
+	unit_type r, d;
 
+	r = self->u.rect.width/scale/2;
+	if (r < SELECT_R)
+		r = SELECT_R;
 	d = dist_rect(pos, self->bbox.min, self->bbox.max)/scale;
-	return d > SELECT_R ? -1 : d;
+	return d > r ? -1 : d;
 }
 
 
@@ -214,6 +221,7 @@
 	GdkGC *gc;
 
 	gc = gc_obj[get_mode(self)];
+	set_width(gc, self->u.rect.width/ctx->scale);
 	gdk_draw_rectangle(DA, gc, FALSE,
 	    min.x, max.y, max.x-min.x, min.y-max.y);
 }
@@ -238,11 +246,20 @@
 	struct coord min = translate(ctx, self->bbox.min);
 	struct coord max = translate(ctx, self->bbox.max);
 	GdkGC *gc;
+	struct coord c;
+	unit_type h, w;
 
 	gc = gc_pad[get_mode(self)];
-	/* @@@ name */
 	gdk_draw_rectangle(DA, gc, TRUE,
 	    min.x, max.y, max.x-min.x, min.y-max.y);
+
+	gc = gc_ptext[get_mode(self)];
+	c = add_vec(min, max);
+	h = min.y-max.y;
+	w = max.x-min.x;
+	render_text(DA, gc, c.x/2, c.y/2, w <= h ? 0 : 90, self->u.name,
+	    PAD_FONT, 0.5, 0.5,
+	    w-2*PAD_BORDER, h-2*PAD_BORDER);
 }
 
 
@@ -264,9 +281,13 @@
 {
 	struct coord c = self->base;
 	struct coord p;
-	unit_type d_min, d;
+	unit_type r, d_min, d;
 	double angle, a2;
 
+	r = self->u.arc.width/scale/2;
+	if (r < SELECT_R)
+		r = SELECT_R;
+
 	/* check endpoints */
 
 	p = rotate_r(c, self->u.arc.r, self->u.arc.a1);
@@ -277,13 +298,13 @@
         if (d < d_min)
                 d_min = d;
 
-	if (d_min/scale <= SELECT_R)
+	if (d_min/scale <= r)
 		return d;
 
 	/* distance from the circle containing the arc */
 
 	d = dist_circle(pos, c, self->u.arc.r)/scale;
-	if (d > SELECT_R)
+	if (d > r)
 		return -1;
 	if (self->u.arc.a1 == self->u.arc.a2)
 		return d;
@@ -306,6 +327,7 @@
 	GdkGC *gc;
 
 	gc = gc_obj[get_mode(self)];
+	set_width(gc, self->u.arc.width/ctx->scale);
 	draw_arc(ctx, gc, FALSE, center.x, center.y,
 	    self->u.arc.r/ctx->scale, self->u.arc.a1, self->u.arc.a2);
 }
@@ -368,7 +390,8 @@
 	s = stralloc_printf("%lgmm",
 	    units_to_mm(dist_point(self->base, self->u.meas.end)));
 	render_text(DA, gc, c.x/2, c.y/2, -atan2(d.y, d.x)/M_PI*180, s,
-	    MEAS_FONT, 0.5, -MEAS_BASELINE_OFFSET);
+	    MEAS_FONT, 0.5, -MEAS_BASELINE_OFFSET,
+	    dist_point(a1, b1)-1.5*MEAS_ARROW_LEN, 0);
 	free(s);
 }
 
@@ -394,5 +417,5 @@
 	gdk_draw_line(DA, gc, corner.x, corner.y,
 	    corner.x, corner.y+FRAME_SHORT_Y);
 	render_text(DA, gc, corner.x, corner.y, 0, self->u.frame.ref->name,
-	    FRAME_FONT, 0, -FRAME_BASELINE_OFFSET);
+	    FRAME_FONT, 0, -FRAME_BASELINE_OFFSET, 0, 0);
 }

Modified: developers/werner/fped/gui_style.c
===================================================================
--- developers/werner/fped/gui_style.c	2009-08-02 05:36:21 UTC (rev 5366)
+++ developers/werner/fped/gui_style.c	2009-08-02 16:35:09 UTC (rev 5367)
@@ -26,6 +26,7 @@
 GdkGC *gc_vec[mode_n];
 GdkGC *gc_obj[mode_n];
 GdkGC *gc_pad[mode_n];
+GdkGC *gc_ptext[mode_n];
 GdkGC *gc_meas[mode_n];
 GdkGC *gc_frame[mode_n];
 
@@ -62,6 +63,7 @@
 	style(gc_vec,	"#202000", "#404020", "#909040", "#c0c080", "#ffff80");
 	style(gc_obj,	"#006060", INVALID,   "#00ffff", INVALID,   "#ffff80");
 	style(gc_pad,	"#400000", INVALID,   "#ff0000", INVALID,   "#ffff80");
+	style(gc_ptext,	"#404040", INVALID,   "#ffffff", INVALID,   "#ffffff");
 	style(gc_meas,	"#280040", INVALID,   "#ff00ff", INVALID,   "#ffff80");
 	style(gc_frame,	"#004000", "#205020", "#00ff00", INVALID,   INVALID);
 }

Modified: developers/werner/fped/gui_style.h
===================================================================
--- developers/werner/fped/gui_style.h	2009-08-02 05:36:21 UTC (rev 5366)
+++ developers/werner/fped/gui_style.h	2009-08-02 16:35:09 UTC (rev 5367)
@@ -19,7 +19,7 @@
 #include "inst.h"
 
 
-/* ----- screen distances -------------------------------------------------- */
+/* ----- screen distances, etc. -------------------------------------------- */
 
 
 #define	CANVAS_CLEARANCE	10
@@ -28,6 +28,9 @@
 #define	VEC_ARROW_ANGLE		20
 #define	VEC_EYE_R		5
 
+#define	PAD_FONT		"Sans Bold 24"
+#define	PAD_BORDER		2
+
 #define	MEAS_FONT		"Sans 8"
 #define	MEAS_BASELINE_OFFSET	0.1
 #define	MEAS_ARROW_LEN		9
@@ -43,7 +46,9 @@
 
 #define	SELECT_R		6	/* pixels within which we select */
 
+#define	MIN_FONT_SCALE		0.20	/* don't scale fonts below this */
 
+
 /* ----- assorted colors --------------------------------------------------- */
 
 
@@ -76,6 +81,7 @@
 extern GdkGC *gc_vec[mode_n];
 extern GdkGC *gc_obj[mode_n];
 extern GdkGC *gc_pad[mode_n];
+extern GdkGC *gc_ptext[mode_n];
 extern GdkGC *gc_meas[mode_n];
 extern GdkGC *gc_frame[mode_n];
 

Modified: developers/werner/fped/gui_util.c
===================================================================
--- developers/werner/fped/gui_util.c	2009-08-02 05:36:21 UTC (rev 5366)
+++ developers/werner/fped/gui_util.c	2009-08-02 16:35:09 UTC (rev 5367)
@@ -15,6 +15,7 @@
 #include <math.h>
 #include <gtk/gtk.h>
 
+#include "gui_style.h"
 #include "gui.h"
 #include "gui_util.h"
 
@@ -36,6 +37,16 @@
 }
 
 
+/* ----- lines with a width ------------------------------------------------ */
+
+
+void set_width(GdkGC *gc, int width)
+{
+	gdk_gc_set_line_attributes(gc, width < 1 ? 1 : width,
+	    GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_ROUND);
+}
+
+
 /* ----- labels in a box --------------------------------------------------- */
 
 
@@ -71,7 +82,8 @@
 
 
 void render_text(GdkDrawable *da, GdkGC *gc, int x, int y, double angle,
-    const char *s, const char *font, double xalign, double yalign)
+    const char *s, const char *font, double xalign, double yalign,
+    int xmax, int ymax)
 {
 	GdkScreen *screen;
 	PangoRenderer *renderer;
@@ -80,6 +92,7 @@
 	PangoFontDescription *desc;
 	int width, height;
 	PangoMatrix m = PANGO_MATRIX_INIT;
+	double f_min, f;
 
 	/* set up the renderer */
 
@@ -103,10 +116,25 @@
 	/* align and position the text */
 
 	pango_layout_get_size(layout, &width, &height);
+	f_min = 1.0;
+	if (xmax) {
+		f = xmax/((double) width/PANGO_SCALE);
+		if (f < f_min)
+			f_min = f;
+	}
+	if (ymax) {
+		f = ymax/((double) height/PANGO_SCALE);
+		if (f < f_min)
+			f_min = f;
+	}
+	if (f_min < MIN_FONT_SCALE)
+		f_min = MIN_FONT_SCALE;
 	pango_matrix_translate(&m, x, y);
 	pango_matrix_rotate(&m, angle);
 	pango_matrix_translate(&m,
-	    -xalign*width/PANGO_SCALE, (yalign-1)*height/PANGO_SCALE);
+	    -xalign*f_min*width/PANGO_SCALE,
+	    (yalign-1)*f_min*height/PANGO_SCALE);
+	pango_matrix_scale(&m, f_min, f_min);
 
 	pango_context_set_matrix(context, &m);
 	pango_layout_context_changed(layout);

Modified: developers/werner/fped/gui_util.h
===================================================================
--- developers/werner/fped/gui_util.h	2009-08-02 05:36:21 UTC (rev 5366)
+++ developers/werner/fped/gui_util.h	2009-08-02 16:35:09 UTC (rev 5367)
@@ -19,12 +19,15 @@
 
 GdkColor get_color(const char *spec);
 
+void set_width(GdkGC *gc, int width);
+
 GtkWidget *label_in_box_new(const char *s);
 GtkWidget *box_of_label(GtkWidget *label);
 void label_in_box_bg(GtkWidget *box, const char *color);
 
 void render_text(GdkDrawable *da, GdkGC *gc, int x, int y, double angle,
-    const char *s, const char *font, double xalign, double yalign);
+    const char *s, const char *font, double xalign, double yalign,
+    int xmax, int ymax);
 
 void destroy_all_children(GtkContainer *container);
 

Modified: developers/werner/fped/inst.c
===================================================================
--- developers/werner/fped/inst.c	2009-08-02 05:36:21 UTC (rev 5366)
+++ developers/werner/fped/inst.c	2009-08-02 16:35:09 UTC (rev 5367)
@@ -247,7 +247,7 @@
 {
 	printf("vec %lg, %lg -> %lg, %lg\n",
 	    units_to_mm(self->base.x), units_to_mm(self->base.y),
-	    units_to_mm(self->u.end.x), units_to_mm(self->u.end.y));
+	    units_to_mm(self->u.rect.end.x), units_to_mm(self->u.rect.end.y));
 }
 
 
@@ -268,7 +268,7 @@
 static void vec_op_select(struct inst *self)
 {
 	status_set_name(self->vec->name ? self->vec->name : "");
-	rect_status(self->base, self->u.end);
+	rect_status(self->base, self->u.rect.end);
 	edit_unique_null(&self->vec->name, validate_vec_name, self->vec);
 }
 
@@ -287,7 +287,7 @@
 
 	inst = add_inst(&vec_ops, ip_vec, base);
 	inst->vec = vec;
-	inst->u.end = vec->pos;
+	inst->u.rect.end = vec->pos;
 	update_bbox(&inst->bbox, vec->pos);
 	propagate_bbox(inst);
 	return 1;
@@ -301,7 +301,7 @@
 {
 	printf("line %lg, %lg / %lg, %lg\n",
 	    units_to_mm(self->base.x), units_to_mm(self->base.y),
-	    units_to_mm(self->u.end.x), units_to_mm(self->u.end.y));
+	    units_to_mm(self->u.rect.end.x), units_to_mm(self->u.rect.end.y));
 }
 
 
@@ -319,13 +319,14 @@
 };
 
 
-int inst_line(struct obj *obj, struct coord a, struct coord b)
+int inst_line(struct obj *obj, struct coord a, struct coord b, unit_type width)
 {
 	struct inst *inst;
 
 	inst = add_inst(&line_ops, ip_line, a);
 	inst->obj = obj;
-	inst->u.end = b;
+	inst->u.rect.end = b;
+	inst->u.rect.width = width;
 	update_bbox(&inst->bbox, b);
 	propagate_bbox(inst);
 	return 1;
@@ -339,7 +340,7 @@
 {
 	printf("rect %lg, %lg / %lg, %lg\n",
 	    units_to_mm(self->base.x), units_to_mm(self->base.y),
-	    units_to_mm(self->u.end.x), units_to_mm(self->u.end.y));
+	    units_to_mm(self->u.rect.end.x), units_to_mm(self->u.rect.end.y));
 }
 
 
@@ -357,13 +358,14 @@
 };
 
 
-int inst_rect(struct obj *obj, struct coord a, struct coord b)
+int inst_rect(struct obj *obj, struct coord a, struct coord b, unit_type width)
 {
 	struct inst *inst;
 
 	inst = add_inst(&rect_ops, ip_rect, a);
 	inst->obj = obj;
-	inst->u.end = b;
+	inst->u.rect.end = b;
+	inst->u.rect.width = width;
 	update_bbox(&inst->bbox, b);
 	propagate_bbox(inst);
 	return 1;
@@ -452,7 +454,7 @@
 
 
 int inst_arc(struct obj *obj, struct coord center, struct coord start,
-    struct coord end)
+    struct coord end, unit_type width)
 {
 	struct inst *inst;
 	double r, a1, a2;
@@ -469,6 +471,7 @@
 	inst->u.arc.r = r;
 	inst->u.arc.a1 = a1;
 	inst->u.arc.a2 = a2;
+	inst->u.arc.width = width;
 	inst->bbox.min.x = center.x-r;
 	inst->bbox.max.x = center.x+r;
 	inst->bbox.min.y = center.x-r;
@@ -634,6 +637,10 @@
 		if (!inst->active && inst->ops->draw)
 			inst->ops->draw(inst, ctx);
 	FOR_INSTS_UP(prio, inst)
+		if (prio != ip_frame && inst->active &&
+		    inst != selected_inst && inst->ops->draw)
+			inst->ops->draw(inst, ctx);
+	for (inst = insts[ip_frame]; inst; inst = inst->next)
 		if (inst->active && inst != selected_inst && inst->ops->draw)
 			inst->ops->draw(inst, ctx);
 	if (selected_inst && selected_inst->ops->draw)

Modified: developers/werner/fped/inst.h
===================================================================
--- developers/werner/fped/inst.h	2009-08-02 05:36:21 UTC (rev 5366)
+++ developers/werner/fped/inst.h	2009-08-02 16:35:09 UTC (rev 5367)
@@ -52,10 +52,14 @@
 			const struct frame *ref;
 		} frame;
 		const char *name;
-		struct coord end;
 		struct {
+			struct coord end;
+			unit_type width;
+		} rect;
+		struct {
 			unit_type r;
 			double a1, a2;
+			unit_type width;
 		} arc;
 		struct {
 			struct coord end;
@@ -74,11 +78,11 @@
 void inst_deselect(void);
 
 int inst_vec(struct vec *vec, struct coord base);
-int inst_line(struct obj *obj, struct coord a, struct coord b);
-int inst_rect(struct obj *obj, struct coord a, struct coord b);
+int inst_line(struct obj *obj, struct coord a, struct coord b, unit_type width);
+int inst_rect(struct obj *obj, struct coord a, struct coord b, unit_type width);
 int inst_pad(struct obj *obj, const char *name, struct coord a, struct coord b);
 int inst_arc(struct obj *obj, struct coord center, struct coord start,
-    struct coord stop);
+    struct coord stop, unit_type width);
 int inst_meas(struct obj *obj, struct coord from, struct coord to,
     unit_type offset);
 

Modified: developers/werner/fped/obj.c
===================================================================
--- developers/werner/fped/obj.c	2009-08-02 05:36:21 UTC (rev 5366)
+++ developers/werner/fped/obj.c	2009-08-02 16:35:09 UTC (rev 5367)
@@ -21,6 +21,8 @@
 #include "obj.h"
 
 
+#define	DEFAULT_SILK_WIDTH	make_mil(15)	/* @@@ */
+
 #define	MAX_ITERATIONS	1000	/* abort "loop"s at this limit */
 
 
@@ -33,6 +35,28 @@
     const struct frame *parent, int active);
 
 
+static struct num eval_unit(const struct expr *expr, const struct frame *frame)
+{
+	struct num d;
+
+	d = eval_num(expr, frame);
+	if (!is_undef(d) && to_unit(&d))
+		return d;
+	fail_expr(expr);
+	return undef;
+}
+
+
+static struct num eval_unit_default(const struct expr *expr,
+    const struct frame *frame, struct num def)
+{
+	if (expr)
+		return eval_unit(expr, frame);
+	to_unit(&def);
+	return def;
+}
+
+
 static int generate_vecs(struct frame *frame, struct coord base)
 {
 	struct coord vec_base;
@@ -40,16 +64,12 @@
 	struct num x, y;
 
 	for (vec = frame->vecs; vec; vec = vec->next) {
-		x = eval_num(vec->x, frame);
-		if (is_undef(x) || !to_unit(&x)) {
-			fail_expr(vec->x);
+		x = eval_unit(vec->x, frame);
+		if (is_undef(x))
 			return 0;
-		}
-		y = eval_num(vec->y, frame);
-		if (is_undef(y) || !to_unit(&y)) {
-			fail_expr(vec->y);
+		y = eval_unit(vec->y, frame);
+		if (is_undef(y))
 			return 0;
-		}
 		vec_base = vec->base ? vec->base->pos : base;
 		vec->pos = vec_base;
 		vec->pos.x += x.n;
@@ -66,7 +86,7 @@
 	struct obj *obj;
 	char *name;
 	int ok;
-	struct num offset;
+	struct num width, offset;
 
 	for (obj = frame->objs; obj; obj = obj->next)
 		switch (obj->type) {
@@ -76,13 +96,23 @@
 				return 0;
 			break;
 		case ot_line:
+			width = eval_unit_default(obj->width, frame,
+			    DEFAULT_SILK_WIDTH);
+			if (is_undef(width))
+				return 0;
 			if (!inst_line(obj, obj->base ? obj->base->pos : base,
-			    obj->u.line.other ? obj->u.line.other->pos : base))
+			    obj->u.line.other ? obj->u.line.other->pos : base,
+			    width.n))
 				return 0;
 			break;
 		case ot_rect:
+			width = eval_unit_default(obj->width, frame,
+			    DEFAULT_SILK_WIDTH);
+			if (is_undef(width))
+				return 0;
 			if (!inst_rect(obj, obj->base ? obj->base->pos : base,
-			    obj->u.rect.other ? obj->u.rect.other->pos : base))
+			    obj->u.rect.other ? obj->u.rect.other->pos : base,
+			    width.n))
 				return 0;
 			break;
 		case ot_pad:
@@ -97,17 +127,20 @@
 				return 0;
 			break;
 		case ot_arc:
+			width = eval_unit_default(obj->width, frame,
+			    DEFAULT_SILK_WIDTH);
+			if (is_undef(width))
+				return 0;
 			if (!inst_arc(obj, obj->base ? obj->base->pos : base,
 			    obj->u.arc.start ? obj->u.arc.start->pos : base,
-			    obj->u.arc.end ? obj->u.arc.end->pos : base))
+			    obj->u.arc.end ? obj->u.arc.end->pos : base,
+			    width.n))
 				return 0;
 			break;
 		case ot_meas:
-			offset = eval_num(obj->u.meas.offset, frame);
-			if (is_undef(offset) || !to_unit(&offset)) {
-				fail_expr(obj->u.meas.offset);
+			offset = eval_unit(obj->u.meas.offset, frame);
+			if (is_undef(offset))
 				return 0;
-			}
 			if (!inst_meas(obj, obj->base ? obj->base->pos : base,
 			    obj->u.meas.other ? obj->u.meas.other->pos : base,
 			    offset.n))

Modified: developers/werner/fped/obj.h
===================================================================
--- developers/werner/fped/obj.h	2009-08-02 05:36:21 UTC (rev 5366)
+++ developers/werner/fped/obj.h	2009-08-02 16:35:09 UTC (rev 5367)
@@ -145,6 +145,7 @@
 		struct meas meas;
 	} u;
 	struct vec *base;
+	struct expr *width; /* may be NULL. not used in "meas" */
 	struct obj *next;
 };
 

Modified: developers/werner/fped/qfn.fpd
===================================================================
--- developers/werner/fped/qfn.fpd	2009-08-02 05:36:21 UTC (rev 5366)
+++ developers/werner/fped/qfn.fpd	2009-08-02 16:35:09 UTC (rev 5367)
@@ -40,11 +40,16 @@
 
 h_x0y0: vec @(-Hx/2, -Hy/2)
 h_x1y1: vec .(Hx, Hy)
-rect h_x0y0 h_x1y1
+rect h_x0y0 h_x1y1 8mil
 
+/*
+ * we can't draw the package outline on the silk screen for it would print
+ * over the pads.
+ */
+#if 0
 g_x0y0: vec @(-Gx/2, -Gy/2)
 g_x1y1: vec .(Gx, Gy)
-rect g_x0y0 g_x1y1
+#endif
 
 frame pads @
 
@@ -53,10 +58,10 @@
 c: vec @(-1mm, 1mm)
 r: vec c(0mm, 0.5mm)
 e: vec c(-0.5mm, 0mm)
-arc c r e
+arc c r e 2mil
 
 r2: vec c(0mm, 0.8mm)
-circ c r2
+circ c r2 5mil
 
 /*
 x1 = 1+2*3




More information about the commitlog mailing list