r5412 - trunk/eda/fped
werner at docs.openmoko.org
werner at docs.openmoko.org
Sun Aug 9 02:06:54 CEST 2009
Author: werner
Date: 2009-08-09 02:06:54 +0200 (Sun, 09 Aug 2009)
New Revision: 5412
Modified:
trunk/eda/fped/README
trunk/eda/fped/TODO
trunk/eda/fped/delete.c
trunk/eda/fped/dump.c
trunk/eda/fped/fpd.l
trunk/eda/fped/fpd.y
trunk/eda/fped/gui_inst.c
trunk/eda/fped/gui_meas.c
trunk/eda/fped/gui_tool.c
trunk/eda/fped/gui_tool.h
trunk/eda/fped/inst.c
trunk/eda/fped/inst.h
trunk/eda/fped/meas.c
trunk/eda/fped/meas.fpd
trunk/eda/fped/meas.h
trunk/eda/fped/obj.c
trunk/eda/fped/obj.h
trunk/eda/fped/qfn.fpd
trunk/eda/fped/sc89.fpd
Log:
More work on measurements. Getting there ...
- removed support for old-style measurements
- new-style measurements are now embedded in "struct obj", so we can dump and
delete them
- "measxy" is now called "meas"
- updated examples to use new-style measurements
Modified: trunk/eda/fped/README
===================================================================
--- trunk/eda/fped/README 2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/README 2009-08-09 00:06:54 UTC (rev 5412)
@@ -202,6 +202,8 @@
Measurements
- - - - - -
+*** This is obsolete - see the section on new-style mesurements at the end. ***
+
Measurements show the distance between two points:
meas <point-a> <point-b> <offset>
@@ -439,16 +441,15 @@
items.
Known issues:
-- they are currently not dumped and they can't be entered or edited
- through the GUI
--
+- they currently can't be edited through the GUI
+- tie-breaking heuristics don't always do what one expects
Syntax:
<type> [<label>] <from> <op> <to> [<offset>]
Types:
-- measxy: measure diagonally
+- meas: measure diagonally
- measx: measure along the X axis
- measy: measure along the y axis
Modified: trunk/eda/fped/TODO
===================================================================
--- trunk/eda/fped/TODO 2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/TODO 2009-08-09 00:06:54 UTC (rev 5412)
@@ -1,4 +1,4 @@
-Missing features:
+Major missing features:
- populate input area (still needed: mm/mil, rezoom)
- add default unit (combine with grid unit selection ?)
- consider adding auto/mm/mil selection for each dimension
@@ -6,7 +6,10 @@
non-trivial endpoints, e.g., some vector in last iteration of loop)
- add KiCad output
- add postscript output
-- add option to include/omit helper vecs and frames (display and postscript)
+- add option to include/omit helper vecs and frames (done for display, still
+ need postscript)
+
+Minor missing features:
- reorder frames (can use text editor)
- reorder rows in a table (can use text editor)
- reorder columns in a table
@@ -17,6 +20,8 @@
Style:
- make column of entry field greedily consume all unallocated space
+- make menu bar consume all unallocated space instead of sharing it evenly with
+ upper toolbar
- status area looks awful
- add button with GTK_STOCK_UNDELETE for "undelete" to menu bar
- edit names/values/etc. in place if possible
Modified: trunk/eda/fped/delete.c
===================================================================
--- trunk/eda/fped/delete.c 2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/delete.c 2009-08-09 00:06:54 UTC (rev 5412)
@@ -124,6 +124,7 @@
case ot_arc:
return obj->u.arc.start == ref || obj->u.arc.end == ref;
case ot_meas:
+ return obj->u.meas.high == ref;
default:
abort();
}
@@ -203,7 +204,8 @@
free_expr(obj->u.arc.width);
break;
case ot_meas:
- free_expr(obj->u.meas.offset);
+ if (obj->u.meas.offset)
+ free_expr(obj->u.meas.offset);
break;
default:
abort();
Modified: trunk/eda/fped/dump.c
===================================================================
--- trunk/eda/fped/dump.c 2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/dump.c 2009-08-09 00:06:54 UTC (rev 5412)
@@ -201,9 +201,7 @@
l |= later(obj->u.arc.end, prev);
break;
case ot_meas:
- n |= need(obj->u.meas.other, prev);
- l |= later(obj->u.meas.other, prev);
- break;
+ return 0;
default:
abort();
}
@@ -212,6 +210,21 @@
}
+static const char *meas_type_name[mt_n] = {
+ "meas", "measx", "measy",
+ "meas", "measx", "measy",
+};
+
+
+
+static void print_meas_base(FILE *file, struct vec *base)
+{
+ if (base->frame != root_frame)
+ fprintf(file, "%s.", base->frame->name);
+ fprintf(file, "%s", base->name);
+}
+
+
static void dump_obj(FILE *file, struct obj *obj, const char *indent,
const struct vec *prev)
{
@@ -262,11 +275,22 @@
free(s3);
break;
case ot_meas:
- s1 = obj_base_name(obj->u.meas.other, prev);
- s2 = unparse(obj->u.meas.offset);
- fprintf(file, "%smeas %s %s %s\n", indent, base, s1, s2);
- free(s1);
- free(s2);
+ fprintf(file, "%s%s ", indent,
+ meas_type_name[obj->u.meas.type]);
+ if (obj->u.meas.label)
+ fprintf(file, "\"%s\" ", obj->u.meas.label);
+ print_meas_base(file, obj->base);
+ fprintf(file, " %s ",
+ obj->u.meas.type < 3 ? obj->u.meas.inverted ? "<-" : "->" :
+ obj->u.meas.inverted ? "<<" : ">>");
+ print_meas_base(file, obj->u.meas.high);
+ if (!obj->u.meas.offset)
+ fprintf(file, "\n");
+ else {
+ s1 = unparse(obj->u.meas.offset);
+ fprintf(file, " %s\n", s1);
+ free(s1);
+ }
break;
default:
abort();
@@ -340,7 +364,7 @@
obj->dumped = 0;
dump_vecs(file, frame->vecs, indent);
- /* duh. do we need this ? */
+ /* do we need this for anything but measurements ? */
for (obj = frame->objs; obj; obj = obj->next)
dump_obj(file, obj, indent, NULL);
}
Modified: trunk/eda/fped/fpd.l
===================================================================
--- trunk/eda/fped/fpd.l 2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/fpd.l 2009-08-09 00:06:54 UTC (rev 5412)
@@ -95,8 +95,6 @@
return TOK_ARC; }
<INITIAL>"meas" { BEGIN(NOKEYWORD);
return TOK_MEAS; }
-<INITIAL>"measxy" { BEGIN(NOKEYWORD);
- return TOK_MEASXY; }
<INITIAL>"measx" { BEGIN(NOKEYWORD);
return TOK_MEASX; }
<INITIAL>"measy" { BEGIN(NOKEYWORD);
Modified: trunk/eda/fped/fpd.y
===================================================================
--- trunk/eda/fped/fpd.y 2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/fpd.y 2009-08-09 00:06:54 UTC (rev 5412)
@@ -141,7 +141,6 @@
struct value *value;
struct vec *vec;
struct obj *obj;
- struct meas *meas;
enum meas_type mt;
struct {
int inverted;
@@ -153,7 +152,7 @@
%token START_FPD START_EXPR
%token TOK_SET TOK_LOOP TOK_PART TOK_FRAME TOK_TABLE TOK_VEC
%token TOK_PAD TOK_RECT TOK_LINE TOK_CIRC TOK_ARC
-%token TOK_MEAS TOK_MEASXY TOK_MEASX TOK_MEASY
+%token TOK_MEAS TOK_MEASX TOK_MEASY
%token TOK_NEXT TOK_NEXT_INVERTED TOK_MAX TOK_MAX_INVERTED
%token <num> NUMBER
@@ -165,9 +164,8 @@
%type <row> rows
%type <value> row value
%type <vec> vec base qbase
-%type <obj> obj
+%type <obj> obj meas
%type <expr> expr opt_expr add_expr mult_expr unary_expr primary_expr
-%type <meas> measurements meas
%type <str> opt_string
%type <mt> meas_type
%type <mo> meas_op
@@ -246,9 +244,6 @@
frame_items:
measurements
- {
- measurements = $1;
- }
| frame_item frame_items
;
@@ -455,13 +450,6 @@
$$->u.arc.end = $4;
$$->u.arc.width = $5;
}
- | TOK_MEAS base base expr
- {
- $$ = new_obj(ot_meas);
- $$->base = $2;
- $$->u.meas.other = $3;
- $$->u.meas.offset = $4;
- }
| TOK_FRAME ID
{
$<num>$.n = lineno;
@@ -482,26 +470,26 @@
;
measurements:
+ | measurements meas
{
- $$ = NULL;
+ *next_obj = $2;
+ next_obj = &$2->next;
}
- | meas measurements
- {
- $$ = $1;
- $$->next = $2;
- }
;
meas:
meas_type opt_string qbase meas_op qbase opt_expr
{
- $$ = alloc_type(struct meas);
- $$->type = $4.max ? $1+3 : $1;
- $$->label = $2;
- $$->low = $3;
- $$->inverted = $4.inverted;
- $$->high = $5;
- $$->offset = $6;
+ struct meas *meas;
+
+ $$ = new_obj(ot_meas);
+ meas = &$$->u.meas;
+ meas->type = $4.max ? $1+3 : $1;
+ meas->label = $2;
+ $$->base = $3;
+ meas->inverted = $4.inverted;
+ meas->high = $5;
+ meas->offset = $6;
$$->next = NULL;
}
;
@@ -529,7 +517,7 @@
;
meas_type:
- TOK_MEASXY
+ TOK_MEAS
{
$$ = mt_xy_next;
}
Modified: trunk/eda/fped/gui_inst.c
===================================================================
--- trunk/eda/fped/gui_inst.c 2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/gui_inst.c 2009-08-09 00:06:54 UTC (rev 5412)
@@ -358,15 +358,14 @@
struct coord a0, b0, a1, b1, off, c, d;
GdkGC *gc;
double len;
- const char *label = self->u.meas.meas ?
- self->u.meas.meas->label ? self->u.meas.meas->label : "" : "";
+ const struct meas *meas = &self->obj->u.meas;
char *s;
a0 = translate(self->base);
b0 = translate(self->u.meas.end);
a1 = self->base;
b1 = self->u.meas.end;
- switch (self->u.meas.meas ? self->u.meas.meas->type : mt_xy_next) {
+ switch (meas->type) {
case mt_xy_next:
case mt_xy_max:
break;
@@ -394,7 +393,7 @@
c = add_vec(a1, b1);
d = sub_vec(b1, a1);
- s = stralloc_printf("%s%lgmm", label, len);
+ s = stralloc_printf("%s%lgmm", meas->label ? meas->label : "", len);
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,
dist_point(a1, b1)-1.5*MEAS_ARROW_LEN, 0);
Modified: trunk/eda/fped/gui_meas.c
===================================================================
--- trunk/eda/fped/gui_meas.c 2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/gui_meas.c 2009-08-09 00:06:54 UTC (rev 5412)
@@ -256,12 +256,15 @@
static int end_new_meas(struct inst *from, struct inst *to)
{
+ struct obj *obj;
struct meas *meas;
meas_inst = NULL;
if (from == to)
return 0;
- meas = alloc_type(struct meas);
+ /* it's safe to pass "from" here, but we may change it later */
+ obj = new_obj(ot_meas, from);
+ meas = &obj->u.meas;
meas->label = NULL;
switch (mode) {
case min_to_next_or_max:
@@ -270,17 +273,17 @@
} else {
meas->type = meas_dsc->type+3;
}
- meas->low = from->vec;
+ obj->base = from->vec;
meas->high = to->vec;
break;
case next_to_min:
meas->type = meas_dsc->type;
- meas->low = to->vec;
+ obj->base = to->vec;
meas->high = from->vec;
break;
case max_to_min:
meas->type = meas_dsc->type+3;
- meas->low = to->vec;
+ obj->base = to->vec;
meas->high = from->vec;
break;
default:
@@ -296,9 +299,7 @@
fprintf(stderr, "mode %s type %s, inverted %d\n",
sm[mode], st[meas->type], meas->inverted);
}
- meas->offset = parse_expr("0mm");
- meas->next = measurements;
- measurements = meas;
+ meas->offset = NULL;
meas_dsc = NULL;
return 1;
}
Modified: trunk/eda/fped/gui_tool.c
===================================================================
--- trunk/eda/fped/gui_tool.c 2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/gui_tool.c 2009-08-09 00:06:54 UTC (rev 5412)
@@ -81,7 +81,7 @@
}
-static struct obj *new_obj(enum obj_type type, struct inst *base)
+struct obj *new_obj(enum obj_type type, struct inst *base)
{
struct obj *obj, **walk;
Modified: trunk/eda/fped/gui_tool.h
===================================================================
--- trunk/eda/fped/gui_tool.h 2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/gui_tool.h 2009-08-09 00:06:54 UTC (rev 5412)
@@ -59,6 +59,7 @@
* compilation unit.
*/
+struct obj *new_obj(enum obj_type type, struct inst *base);
struct pix_buf *draw_move_line_common(struct inst *inst,
struct coord end, struct coord pos, int i);
struct pix_buf *drag_new_line(struct inst *from, struct coord to);
Modified: trunk/eda/fped/inst.c
===================================================================
--- trunk/eda/fped/inst.c 2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/inst.c 2009-08-09 00:06:54 UTC (rev 5412)
@@ -677,10 +677,8 @@
{
struct obj *obj = inst->obj;
- if (!inst->obj)
- return 0; /* @@@ new-style measurements */
anchors[0] = &obj->base;
- anchors[1] = &obj->u.meas.other;
+ anchors[1] = &obj->u.meas.high;
return 2;
}
@@ -695,7 +693,7 @@
};
-int inst_meas(struct obj *obj, struct meas *meas,
+int inst_meas(struct obj *obj,
struct coord from, struct coord to, unit_type offset)
{
struct inst *inst;
@@ -704,9 +702,7 @@
inst->obj = obj;
inst->u.meas.end = to;
inst->u.meas.offset = offset;
- inst->u.meas.meas = meas;
- if (!obj)
- inst->active = 1; /* @@@ new-style measurements */
+ inst->active = 1; /* measurements are always active */
/* @@@ our bbox is actually a bit more complex than this */
update_bbox(&inst->bbox, to);
propagate_bbox(inst);
Modified: trunk/eda/fped/inst.h
===================================================================
--- trunk/eda/fped/inst.h 2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/inst.h 2009-08-09 00:06:54 UTC (rev 5412)
@@ -70,7 +70,6 @@
struct {
struct coord end;
double offset;
- struct meas *meas; /* new-style measurement */
} meas;
} u;
struct inst *next;
@@ -96,8 +95,8 @@
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, unit_type width);
-int inst_meas(struct obj *obj, struct meas *meas,
- struct coord from, struct coord to, unit_type offset);
+int inst_meas(struct obj *obj, struct coord from, struct coord to,
+ unit_type offset);
void inst_begin_active(int active);
void inst_end_active(void);
Modified: trunk/eda/fped/meas.c
===================================================================
--- trunk/eda/fped/meas.c 2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/meas.c 2009-08-09 00:06:54 UTC (rev 5412)
@@ -28,9 +28,7 @@
struct sample *next;
};
-struct meas *measurements = NULL;
-
static void reset_samples(struct sample **samples)
{
struct sample *next;
@@ -210,17 +208,21 @@
int instantiate_meas(void)
{
- struct meas *meas;
+ struct obj *obj;
+ const struct meas *meas;
struct coord a0, b0;
lt_op_type lt;
struct num offset;
- for (meas = measurements; meas; meas = meas->next) {
- if (!meas->low->samples || !meas->high->samples)
+ for (obj = root_frame->objs; obj; obj = obj->next) {
+ if (obj->type != ot_meas)
continue;
+ meas = &obj->u.meas;
+ if (!obj->base->samples || !meas->high->samples)
+ return 1;
lt = lt_op[meas->type];
- a0 = meas_find_min(lt, meas->low->samples);
+ a0 = meas_find_min(lt, obj->base->samples);
if (is_next[meas->type])
b0 = meas_find_next(lt, meas->high->samples, a0);
else
@@ -233,7 +235,7 @@
if (is_undef(offset))
return 0;
}
- inst_meas(NULL, meas,
+ inst_meas(obj,
meas->inverted ? b0 : a0, meas->inverted ? a0 : b0,
offset.n);
}
Modified: trunk/eda/fped/meas.fpd
===================================================================
--- trunk/eda/fped/meas.fpd 2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/meas.fpd 2009-08-09 00:06:54 UTC (rev 5412)
@@ -11,14 +11,14 @@
/*
* If we measure (x, y), y trumps x
*/
-measxy "A -> B = " A -> B 0.2mm
-measxy "A <- B = " A <- B 0.5mm
+meas "A -> B = " A -> B 0.2mm
+meas "A <- B = " A <- B 0.5mm
-measxy "A >> B = " A >> B 1.5mm
+meas "A >> B = " A >> B 1.5mm
measx "x(A -> B) = " A -> B -0.5mm
measx "x(A >> B) = " A >> B -1mm
measy "y(A -> B) = " A -> B -2mm
measy "y(A >> B) = " A >> B -4.5mm
-measxy "B -> C = " B -> C 0.5mm
+meas "B -> C = " B -> C 0.5mm
Modified: trunk/eda/fped/meas.h
===================================================================
--- trunk/eda/fped/meas.h 2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/meas.h 2009-08-09 00:06:54 UTC (rev 5412)
@@ -14,11 +14,15 @@
#ifndef MEAS_H
#define MEAS_H
-#include "obj.h"
+#include "coord.h"
+#include "expr.h"
+
typedef int (*lt_op_type)(struct coord a, struct coord b);
+struct vec;
+struct obj;
struct meas {
enum meas_type {
@@ -32,18 +36,14 @@
} type;
char *label; /* or NULL */
int inverted;
- struct vec *low;
+ /* low is obj->base */
struct vec *high;
struct expr *offset;
- struct meas *next;
};
struct sample;
-extern struct meas *measurements;
-
-
int lt_x(struct coord a, struct coord b);
int lt_y(struct coord a, struct coord b);
int lt_xy(struct coord a, struct coord b);
Modified: trunk/eda/fped/obj.c
===================================================================
--- trunk/eda/fped/obj.c 2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/obj.c 2009-08-09 00:06:54 UTC (rev 5412)
@@ -92,7 +92,7 @@
struct obj *obj;
char *name;
int ok;
- struct num width, offset;
+ struct num width;
for (obj = frame->objs; obj; obj = obj->next)
switch (obj->type) {
@@ -145,14 +145,6 @@
return 0;
break;
case ot_meas:
- offset = eval_unit(obj->u.meas.offset, frame);
- if (is_undef(offset))
- return 0;
- if (!inst_meas(obj, NULL,
- obj->base ? obj->base->pos : base,
- obj->u.meas.other ? obj->u.meas.other->pos : base,
- offset.n))
- return 0;
break;
default:
abort();
Modified: trunk/eda/fped/obj.h
===================================================================
--- trunk/eda/fped/obj.h 2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/obj.h 2009-08-09 00:06:54 UTC (rev 5412)
@@ -19,6 +19,7 @@
#include "expr.h"
#include "coord.h"
+#include "meas.h"
struct var {
@@ -152,11 +153,6 @@
struct expr *width;
};
-struct old_meas {
- struct vec *other; /* NULL if frame origin */
- struct expr *offset;
-};
-
struct obj {
enum obj_type type;
union {
@@ -165,7 +161,7 @@
struct rect line;
struct pad pad;
struct arc arc;
- struct old_meas meas;
+ struct meas meas;
} u;
struct frame *frame;
struct vec *base;
Modified: trunk/eda/fped/qfn.fpd
===================================================================
--- trunk/eda/fped/qfn.fpd 2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/qfn.fpd 2009-08-09 00:06:54 UTC (rev 5412)
@@ -9,9 +9,7 @@
frame pad_up {
c: vec @(-D/2, 0mm)
- vec .(0mm, C)
- meas c . 0.2mm
- vec c(D, C)
+ o: vec c(D, C)
set pad = n+1
pad "$pad" c .
}
@@ -71,3 +69,5 @@
x2 = (1+2)*3
x3 = 1-(2+3)
*/
+
+measy pad_up.c -> pad_up.o 0.2mm
Modified: trunk/eda/fped/sc89.fpd
===================================================================
--- trunk/eda/fped/sc89.fpd 2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/sc89.fpd 2009-08-09 00:06:54 UTC (rev 5412)
@@ -5,8 +5,6 @@
se: vec sw(Px, 0mm)
nw: vec sw(0mm, Py)
pad "$pad" se nw
-// meas sw se -0.1mm
-// meas sw nw 0.1mm
}
frame pad_ne {
More information about the commitlog
mailing list