Send commitlog mailing list submissions to
        commitlog@lists.openmoko.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.openmoko.org/mailman/listinfo/commitlog
or, via email, send a message with subject or body 'help' to
        commitlog-requ...@lists.openmoko.org

You can reach the person managing the list at
        commitlog-ow...@lists.openmoko.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of commitlog digest..."
Today's Topics:

   1. r5521 - trunk/gta02-core/docs/ecn (alvie...@docs.openmoko.org)
   2. r5522 - trunk/eda/fped (wer...@docs.openmoko.org)
   3. r5523 - trunk/eda/fped (wer...@docs.openmoko.org)
   4. r5524 - trunk/eda/fped (wer...@docs.openmoko.org)
   5. r5525 - trunk/eda/fped (wer...@docs.openmoko.org)
--- Begin Message ---
Author: alvieboy
Date: 2009-08-22 13:02:30 +0200 (Sat, 22 Aug 2009)
New Revision: 5521

Modified:
   trunk/gta02-core/docs/ecn/STATUS
Log:
Update ECN0029 status

Modified: trunk/gta02-core/docs/ecn/STATUS
===================================================================
--- trunk/gta02-core/docs/ecn/STATUS    2009-08-22 09:09:14 UTC (rev 5520)
+++ trunk/gta02-core/docs/ecn/STATUS    2009-08-22 11:02:30 UTC (rev 5521)
@@ -28,7 +28,7 @@
 0026   Discuss Improve bus termination at sd-card
 0027   Edit    Renamed some nets for clarity
 0028   Cancel  Remove USB "charge path" power switch U4905
-0029   Execute Move 0R resistors next to PMU after caps
+0029   Done    Move 0R resistors next to PMU after caps
 0030   Edit    Replace Calypso with Telit GE865
 0031   Discuss Use codec to detect jack insertion and HOLD button
 0032   Discuss Add EMI and ESD protection to headset jack




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2009-08-22 14:27:47 +0200 (Sat, 22 Aug 2009)
New Revision: 5522

Modified:
   trunk/eda/fped/TODO
   trunk/eda/fped/gui_canvas.c
   trunk/eda/fped/gui_tool.c
   trunk/eda/fped/inst.c
   trunk/eda/fped/inst.h
   trunk/eda/fped/postscript.c
Log:
Selection now tries to help us not to get lost.

- postscript.c: started adding generation of object-level frames (on-going)
- gui_canvas.c: moved call to inst_deselect into inst_select, so that 
  inst_select can keep track of the previous selection (if any)
- inst_select: if clicking on the location of the previous selection, try to 
  select the next matching item
- inst_select: if we can't find an active item, try to see if we can get
  something by changing active references or - if all else fails - by 
  activating a different frame
- end_new_frame: reset the tool after placing the frame



Modified: trunk/eda/fped/TODO
===================================================================
--- trunk/eda/fped/TODO 2009-08-22 11:02:30 UTC (rev 5521)
+++ trunk/eda/fped/TODO 2009-08-22 12:27:47 UTC (rev 5522)
@@ -36,6 +36,7 @@
 - whenever we call parse_* for input parsing, we may leak lots of expressions
 - can't edit measurement labels through the GUI
 - unbalanced parentheses in text throw off Postscript syntax
+- we can't drag points that are at a frame base
 
 Code cleanup:
 - merge edit_unique with edit_name

Modified: trunk/eda/fped/gui_canvas.c
===================================================================
--- trunk/eda/fped/gui_canvas.c 2009-08-22 11:02:30 UTC (rev 5521)
+++ trunk/eda/fped/gui_canvas.c 2009-08-22 12:27:47 UTC (rev 5522)
@@ -200,7 +200,6 @@
                        break;
                }
                prev = selected_inst;
-               inst_deselect();
                inst_select(pos);
                if (prev != selected_inst)
                        redraw();

Modified: trunk/eda/fped/gui_tool.c
===================================================================
--- trunk/eda/fped/gui_tool.c   2009-08-22 11:02:30 UTC (rev 5521)
+++ trunk/eda/fped/gui_tool.c   2009-08-22 12:27:47 UTC (rev 5522)
@@ -625,6 +625,7 @@
                locked_frame->active_ref = obj;
        locked_frame = NULL;
        tool_frame_update();
+       tool_reset();
        return 1;
 }
 

Modified: trunk/eda/fped/inst.c
===================================================================
--- trunk/eda/fped/inst.c       2009-08-22 11:02:30 UTC (rev 5521)
+++ trunk/eda/fped/inst.c       2009-08-22 12:27:47 UTC (rev 5522)
@@ -137,37 +137,88 @@
 }
 
 
+static int activate_item(struct inst *inst)
+{
+       if (!inst->outer)
+               return 0;
+       if (inst->outer->u.frame.ref->active_ref == inst->outer->obj)
+               return activate_item(inst->outer);
+       inst->outer->u.frame.ref->active_ref = inst->outer->obj;
+       activate_item(inst->outer);
+       return 1;
+}
+
+
 int inst_select(struct coord pos)
 {
        enum inst_prio prio;
+       const struct inst *prev;
        struct inst *inst;
+       struct inst *first = NULL;      /* first active item */
+       struct inst *next = NULL;       /* active item after currently sel. */
+       struct inst *any_first = NULL;  /* first item, active or inactive */
+       struct inst *any_same_frame = NULL; /* first item on active frame */
+       struct frame *frame;
        int best_dist = 0; /* keep gcc happy */
+       int select_next;
        int dist, i;
 
+       prev = selected_inst;
        deselect_outside();
        edit_nothing();
        if (selected_inst) {
                gui_frame_deselect_inst(selected_inst);
                tool_selected_inst(NULL);
        }
-       selected_inst = NULL;
+       inst_deselect();
+       select_next = 0;
        FOR_INST_PRIOS_DOWN(prio) {
                if (!show(prio))
                        continue;
                FOR_ALL_INSTS(i, prio, inst) {
-                       if (!inst->active || !inst->ops->distance)
+                       if (!inst->ops->distance)
                                continue;
                        if (!inst_connected(inst))
                                continue;
                        dist = inst->ops->distance(inst, pos, draw_ctx.scale);
-                       if (dist >= 0 && (!selected_inst || best_dist > dist)) {
-                               selected_inst = inst;
-                               best_dist = dist;
+                       if (dist >= 0) {
+                               if (!any_first)
+                                       any_first = inst;
+                               if (!any_same_frame && inst->outer &&
+                                   inst->outer->u.frame.ref == active_frame)
+                                       any_same_frame = inst;
+                               if (!inst->active)
+                                       continue;
+                               if (!first)
+                                       first = inst;
+                               if (!next && select_next)
+                                       next = inst;
+                               if (inst == prev)
+                                       select_next = 1;
+                               if (!selected_inst || best_dist > dist) {
+                                       selected_inst = inst;
+                                       best_dist = dist;
+                               }
                        }
                }
+               if (select_next) {
+                       selected_inst = next ? next : first;
+                       goto selected;
+               }
                if (selected_inst)
                        goto selected;
        }
+       if (any_same_frame) {
+               if (activate_item(any_same_frame))
+                       return inst_select(pos);
+       }
+       if (any_first) {
+               frame = any_first->outer ? any_first->outer->u.frame.ref : NULL;
+               if (frame != active_frame) {
+                       select_frame(frame);
+                       return inst_select(pos);
+               }
+       }
 
        if (!show_stuff)
                return 0;
@@ -958,7 +1009,7 @@
 };
 
 
-void inst_begin_frame(struct obj *obj, const struct frame *frame,
+void inst_begin_frame(struct obj *obj, struct frame *frame,
     struct coord base, int active, int is_active_frame)
 {
        struct inst *inst;
@@ -1061,6 +1112,7 @@
        pkgs = NULL;
        inst_select_pkg(NULL);
        curr_pkg = pkgs;
+       curr_frame = NULL;
 }
 
 

Modified: trunk/eda/fped/inst.h
===================================================================
--- trunk/eda/fped/inst.h       2009-08-22 11:02:30 UTC (rev 5521)
+++ trunk/eda/fped/inst.h       2009-08-22 12:27:47 UTC (rev 5522)
@@ -79,7 +79,7 @@
        int active;
        union {
                struct {
-                       const struct frame *ref;
+                       struct frame *ref;
                        int active;
                } frame;
                const char *name;
@@ -172,7 +172,7 @@
 void inst_begin_active(int active);
 void inst_end_active(void);
 
-void inst_begin_frame(struct obj *obj, const struct frame *frame,
+void inst_begin_frame(struct obj *obj, struct frame *frame,
     struct coord base, int active, int is_active_frame);
 void inst_end_frame(const struct frame *frame);
 

Modified: trunk/eda/fped/postscript.c
===================================================================
--- trunk/eda/fped/postscript.c 2009-08-22 11:02:30 UTC (rev 5521)
+++ trunk/eda/fped/postscript.c 2009-08-22 12:27:47 UTC (rev 5522)
@@ -14,6 +14,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 
+#include "util.h"
 #include "coord.h"
 #include "inst.h"
 #include "gui_status.h"
@@ -77,6 +78,77 @@
 static struct postscript_params active_params;
 
 
+/* ----- Boxes ------------------------------------------------------------- */
+
+
+static struct box {
+       unit_type x, y;         /* width and height */
+       unit_type x0, y0;       /* lower left corner */
+       struct box *next;
+} *boxes = NULL;
+
+
+static void add_box(unit_type xa, unit_type ya, unit_type xb, unit_type yb)
+{
+       struct box *box;
+
+       box = alloc_type(struct box);
+       box->x = xb-xa;
+       box->y = yb-ya;
+       box->x0 = xa;
+       box->y0 = ya;
+       box->next = boxes;
+       boxes = box;
+}
+
+
+static void free_boxes(void)
+{
+       struct box *next;
+
+       while (boxes) {
+               next = boxes->next;
+               free(boxes);
+               boxes = next;
+       }
+}
+
+
+static int get_box(unit_type x, unit_type y, unit_type *xa, unit_type *ya)
+{
+       struct box **box, **best = NULL;
+       struct box *b;
+       double size, best_size;
+
+       for (box = &boxes; *box; box = &(*box)->next) {
+               if ((*box)->x < x || (*box)->y < y)
+                       continue;
+               size = (double) (*box)->x*(*box)->y;
+               if (!best || size < best_size) {
+                       best = box;
+                       best_size = size;
+               }
+       }
+       if (!best)
+               return 0;
+       b = *best;
+       if (xa)
+               *xa = b->x0;
+       if (ya)
+               *ya = b->y0;
+
+       *best = b->next;
+       add_box(b->x0+x, b->y0, b->x0+b->x, b->y0+y);
+       add_box(b->x0, b->y0+y, b->x0+b->x, b->y0+b->y);
+       free(b);
+
+       return 1;
+}
+
+
+/* ----- Items ------------------------------------------------------------- */
+
+
 static void ps_pad_name(FILE *file, const struct inst *inst)
 {
        struct coord a = inst->base;
@@ -261,6 +333,9 @@
 }
 
 
+/* ----- Print layers ------------------------------------------------------ */
+
+
 static void ps_background(FILE *file, enum inst_prio prio,
      const struct inst *inst)
 {
@@ -347,6 +422,31 @@
 }
 
 
+/* ----- Object frames ----------------------------------------------------- */
+
+
+static int generate_frames(FILE *file, const struct pkg *pkg,
+    const struct frame *frame, double zoom)
+{
+       const struct inst *inst;
+
+       while (frame) {
+               if (frame->name)
+                       for (inst = pkg->insts[ip_frame]; inst;
+                           inst = inst->next)
+                               if (inst->u.frame.ref == frame)
+                                       goto found_frame;
+               frame = frame->next;
+       }
+       if (!frame)
+               return 1;
+
+found_frame:
+       /* @@@ */
+       return 0;
+}
+
+
 /* ----- Page level -------------------------------------------------------- */
 
 
@@ -372,7 +472,6 @@
 }
 
 
-
 static void ps_page(FILE *file, int page)
 {
        fprintf(file, "%%%%Page: %d %d\n", page, page);
@@ -396,6 +495,7 @@
        unit_type w, h;
        double f;
        unit_type c, d;
+       int done;
 
        ps_page(file, page);
        ps_header(file, pkg);
@@ -480,6 +580,15 @@
         * Put the frames
         */
 
+       for (f = 20; f >= 0.1; f = f > 1 ? f-1 : f-0.1) {
+               add_box(-PAGE_HALF_WIDTH, -PAGE_HALF_HEIGHT, PAGE_HALF_WIDTH,
+                   -PS_DIVIDER_BORDER);
+               done = generate_frames(file, pkg, frames, f);
+               free_boxes();
+               if (done)
+                       break;
+       }
+
        fprintf(file, "showpage\n");
 }
 
@@ -589,7 +698,7 @@
         * Stack: string -> string
         */
 
-fprintf(file,
+       fprintf(file,
 "/debugbox { gsave dup false charpath flattenpath pathbbox\n"
 "    /ury exch def /urx exch def /lly exch def /llx exch def\n"
 "    0 setgray 100 setlinewidth\n"
@@ -599,7 +708,7 @@
         * Stack: int -> int
         */
 
-fprintf(file,
+       fprintf(file,
 "/realsize {\n"
 "    254 div 72 mul 1000 div 0 matrix currentmatrix idtransform pop\n"
 "    } def\n");




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2009-08-22 15:18:15 +0200 (Sat, 22 Aug 2009)
New Revision: 5523

Modified:
   trunk/eda/fped/TODO
   trunk/eda/fped/inst.c
Log:
- inst.c: we can drag points at a frame base again



Modified: trunk/eda/fped/TODO
===================================================================
--- trunk/eda/fped/TODO 2009-08-22 12:27:47 UTC (rev 5522)
+++ trunk/eda/fped/TODO 2009-08-22 13:18:15 UTC (rev 5523)
@@ -36,7 +36,6 @@
 - whenever we call parse_* for input parsing, we may leak lots of expressions
 - can't edit measurement labels through the GUI
 - unbalanced parentheses in text throw off Postscript syntax
-- we can't drag points that are at a frame base
 
 Code cleanup:
 - merge edit_unique with edit_name

Modified: trunk/eda/fped/inst.c
===================================================================
--- trunk/eda/fped/inst.c       2009-08-22 12:27:47 UTC (rev 5522)
+++ trunk/eda/fped/inst.c       2009-08-22 13:18:15 UTC (rev 5523)
@@ -301,7 +301,7 @@
                                }
                        }
                } else {
-                       FOR_ALL_INSTS(j, ip_vec, inst) {
+                       FOR_ALL_INSTS(j, ip_frame, inst) {
                                if (inst != selected_inst->outer)
                                        continue;
                                d = gui_dist_frame(inst, pos, draw_ctx.scale);




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2009-08-22 16:29:48 +0200 (Sat, 22 Aug 2009)
New Revision: 5524

Modified:
   trunk/eda/fped/gui_tool.c
   trunk/eda/fped/obj.c
Log:
Bug-fixing ...

- obj.c: embarrasingly, the default offset wasn't a distance
- connect_obj: didn't update the object's frame pointer, deeply confusing
  deletion



Modified: trunk/eda/fped/gui_tool.c
===================================================================
--- trunk/eda/fped/gui_tool.c   2009-08-22 13:18:15 UTC (rev 5523)
+++ trunk/eda/fped/gui_tool.c   2009-08-22 14:29:48 UTC (rev 5524)
@@ -101,6 +101,7 @@
 {
        struct obj **walk;
 
+       obj->frame = frame;
        for (walk = &frame->objs; *walk; walk = &(*walk)->next);
        *walk = obj;
 }

Modified: trunk/eda/fped/obj.c
===================================================================
--- trunk/eda/fped/obj.c        2009-08-22 13:18:15 UTC (rev 5523)
+++ trunk/eda/fped/obj.c        2009-08-22 14:29:48 UTC (rev 5524)
@@ -25,6 +25,7 @@
 
 
 #define        DEFAULT_SILK_WIDTH      make_mil(15)    /* @@@ */
+#define        DEFAULT_OFFSET          make_mil(0)     /* @@@ */
 
 #define        MAX_ITERATIONS  1000    /* abort "loop"s at this limit */
 
@@ -94,11 +95,6 @@
 
 static int generate_objs(struct frame *frame, struct coord base, int active)
 {
-       static const struct num zero_offset = {
-               .type = nt_mm,
-               .exponent = 0,
-               .n = 0,
-       };
        struct obj *obj;
        char *name;
        int ok;
@@ -157,7 +153,7 @@
                case ot_meas:
                        assert(frame == root_frame);
                        offset = eval_unit_default(obj->u.meas.offset, frame,
-                           zero_offset);
+                           DEFAULT_OFFSET);
                        if (is_undef(offset))
                                goto error;
                        inst_meas_hint(obj, offset.n);




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2009-08-22 17:58:58 +0200 (Sat, 22 Aug 2009)
New Revision: 5525

Modified:
   trunk/eda/fped/Makefile
   trunk/eda/fped/README
   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_status.c
   trunk/eda/fped/gui_tool.c
   trunk/eda/fped/inst.c
   trunk/eda/fped/postscript.c
Log:
Made life in mil-land a little less painful.

- .fpd file format: new directive "unit" to set the default unit
- new selection was too aggressive - make it only rearrange settings if we also
  fail the second vector search
- gui_draw_pad_text: calculation of height vs. width lost too much precision,
  causing pad text to be rotated arbitrarily
- drag_new_vec: display distance in mil if unit is mil
- end_new_raw_vec: store distance in mil if unit is mil
- gridify: use a 10 mil grid if unit is mil
- ps_hline: corrected gsave/grestore mismatch
- Makefile: made "all" a prerequisite of "install"
- Postscript output now mentions the default unit (if set)
- ps_package: height and width were swapped, oopsie !



Modified: trunk/eda/fped/Makefile
===================================================================
--- trunk/eda/fped/Makefile     2009-08-22 14:29:48 UTC (rev 5524)
+++ trunk/eda/fped/Makefile     2009-08-22 15:58:58 UTC (rev 5525)
@@ -118,7 +118,7 @@
 
 # ----- Install / uninstall ---------------------------------------------------
 
-install:
+install:       all
                install -m 755 fped $(PREFIX)/bin/
 
 uninstall:

Modified: trunk/eda/fped/README
===================================================================
--- trunk/eda/fped/README       2009-08-22 14:29:48 UTC (rev 5524)
+++ trunk/eda/fped/README       2009-08-22 15:58:58 UTC (rev 5525)
@@ -90,6 +90,7 @@
 frame definitions
 ...
 package name
+unit
 objects
 ...
 
@@ -125,7 +126,16 @@
 
 All values used as dimensions must be either mm or mil.
 
+The default unit can be set with one of the following directives:
 
+unit mm
+unit mil
+unit auto
+
+When saving a footprint definition, the default unit is set to the
+unit set in the GUI.
+
+
 Vectors
 - - - -
 

Modified: trunk/eda/fped/dump.c
===================================================================
--- trunk/eda/fped/dump.c       2009-08-22 14:29:48 UTC (rev 5524)
+++ trunk/eda/fped/dump.c       2009-08-22 15:58:58 UTC (rev 5525)
@@ -17,6 +17,7 @@
 #include "util.h"
 #include "unparse.h"
 #include "obj.h"
+#include "gui_status.h"
 #include "dump.h"
 
 
@@ -491,6 +492,24 @@
 /* ----- file -------------------------------------------------------------- */
 
 
+static void dump_unit(FILE *file)
+{
+       switch (curr_unit) {
+       case curr_unit_mm:
+               fprintf(file, "unit mm\n");
+               break;
+       case curr_unit_mil:
+               fprintf(file, "unit mil\n");
+               break;
+       case curr_unit_auto:
+               fprintf(file, "unit auto\n");
+               break;
+       default:
+               abort();
+       }
+}
+
+
 int dump(FILE *file)
 {
        struct frame *frame;
@@ -501,6 +520,7 @@
        for (frame = frames; frame; frame = frame->next) {
                if (!frame->name) {
                        fprintf(file, "package \"%s\"\n", pkg_name);
+                       dump_unit(file);
                        dump_frame(file, frame, "");
                } else {
                        dump_frame(file, frame, "\t");

Modified: trunk/eda/fped/fpd.l
===================================================================
--- trunk/eda/fped/fpd.l        2009-08-22 14:29:48 UTC (rev 5524)
+++ trunk/eda/fped/fpd.l        2009-08-22 15:58:58 UTC (rev 5525)
@@ -118,6 +118,8 @@
                                  return TOK_MEASX; }
 <INITIAL>"measy"               { BEGIN(NOKEYWORD);
                                  return TOK_MEASY; }
+<INITIAL>"unit"                        { BEGIN(NOKEYWORD);
+                                 return TOK_UNIT; }
 
 <INITIAL>[a-zA-Z_][a-zA-Z_0-9]*: { *strchr(yytext, ':') = 0;
                                  yylval.id = unique(yytext);

Modified: trunk/eda/fped/fpd.y
===================================================================
--- trunk/eda/fped/fpd.y        2009-08-22 14:29:48 UTC (rev 5524)
+++ trunk/eda/fped/fpd.y        2009-08-22 15:58:58 UTC (rev 5525)
@@ -19,6 +19,7 @@
 #include "expr.h"
 #include "obj.h"
 #include "meas.h"
+#include "gui_status.h"
 #include "fpd.h"
 
 
@@ -156,7 +157,7 @@
 %token         START_FPD START_EXPR START_VAR START_VALUES
 %token         TOK_SET TOK_LOOP TOK_PACKAGE TOK_FRAME TOK_TABLE TOK_VEC
 %token         TOK_PAD TOK_RPAD TOK_RECT TOK_LINE TOK_CIRC TOK_ARC
-%token         TOK_MEAS TOK_MEASX TOK_MEASY
+%token         TOK_MEAS TOK_MEASX TOK_MEASY TOK_UNIT
 %token         TOK_NEXT TOK_NEXT_INVERTED TOK_MAX TOK_MAX_INVERTED
 
 %token <num>   NUMBER
@@ -206,7 +207,7 @@
        ;
 
 fpd:
-       | frame_defs part_name frame_items
+       | frame_defs part_name opt_unit frame_items
        ;
 
 part_name:
@@ -227,6 +228,22 @@
                }
        ;
 
+opt_unit:
+       | TOK_UNIT ID
+               {
+                       if (!strcmp($2, "mm"))
+                               curr_unit = curr_unit_mm;
+                       else if (!strcmp($2, "mil"))
+                               curr_unit = curr_unit_mil;
+                       else if (!strcmp($2, "auto"))
+                               curr_unit = curr_unit_auto;
+                       else {
+                               yyerrorf("unrecognized unit \"%s\"", $2);
+                               YYABORT;
+                       }
+               }
+       ;
+
 frame_defs:
        | frame_defs frame_def
        ;

Modified: trunk/eda/fped/gui_inst.c
===================================================================
--- trunk/eda/fped/gui_inst.c   2009-08-22 14:29:48 UTC (rev 5524)
+++ trunk/eda/fped/gui_inst.c   2009-08-22 15:58:58 UTC (rev 5525)
@@ -241,13 +241,17 @@
        GdkGC *gc;
        struct coord c;
        unit_type h, w;
+       int rot;
 
+       w = self->bbox.max.x-self->bbox.min.x;
+       h = self->bbox.max.y-self->bbox.min.y;
+       rot = w/1.1 < h;
        gc = gc_ptext[get_mode(self)];
        sort_coord(&min, &max);
        c = add_vec(min, max);
        h = max.y-min.y;
        w = max.x-min.x;
-       render_text(DA, gc, c.x/2, c.y/2, w <= h*1.1 ? 0 : 90,
+       render_text(DA, gc, c.x/2, c.y/2, rot ? 0 : 90,
            self->u.pad.name, PAD_FONT, 0.5, 0.5,
            w-2*PAD_BORDER, h-2*PAD_BORDER);
 }

Modified: trunk/eda/fped/gui_status.c
===================================================================
--- trunk/eda/fped/gui_status.c 2009-08-22 14:29:48 UTC (rev 5524)
+++ trunk/eda/fped/gui_status.c 2009-08-22 15:58:58 UTC (rev 5525)
@@ -736,25 +736,31 @@
 /* ----- unit selection ---------------------------------------------------- */
 
 
+static void show_curr_unit(void)
+{
+       switch (curr_unit) {
+       case curr_unit_mm:
+               status_set_unit("mm");
+               break;
+       case curr_unit_mil:
+               status_set_unit("mil");
+               break;
+       case curr_unit_auto:
+               status_set_unit("auto");
+               break;
+       default:
+               abort();
+       }
+}
+
+
 static gboolean unit_button_press_event(GtkWidget *widget,
     GdkEventButton *event, gpointer data)
 {
        switch (event->button) {
        case 1:
                curr_unit = (curr_unit+1) % curr_unit_n;
-               switch (curr_unit) {
-               case curr_unit_mm:
-                       status_set_unit("mm");
-                       break;
-               case curr_unit_mil:
-                       status_set_unit("mil");
-                       break;
-               case curr_unit_auto:
-                       status_set_unit("auto");
-                       break;
-               default:
-                       abort();
-               }
+               show_curr_unit();
                break;
        }
        refresh_pos();
@@ -859,7 +865,7 @@
        /* unit selection */
 
        label_in_box_bg(status_unit, COLOR_UNIT_SELECTOR);
-       status_set_unit("mm");
+       show_curr_unit();
        g_signal_connect(G_OBJECT(box_of_label(status_unit)),
            "button_press_event", G_CALLBACK(unit_button_press_event), NULL);
 

Modified: trunk/eda/fped/gui_tool.c
===================================================================
--- trunk/eda/fped/gui_tool.c   2009-08-22 14:29:48 UTC (rev 5524)
+++ trunk/eda/fped/gui_tool.c   2009-08-22 15:58:58 UTC (rev 5525)
@@ -215,8 +215,19 @@
 static struct coord gridify(struct coord base, struct coord pos)
 {
        struct coord new;
-       unit_type unit = mm_to_units(0.1);
+       unit_type unit;
 
+       switch (curr_unit) {
+       case curr_unit_mm:
+       case curr_unit_auto:
+               unit = mm_to_units(0.1);
+               break;
+       case curr_unit_mil:
+               unit = mil_to_units(10);
+               break;
+       default:
+               abort();
+       }
        new.x = pos.x-((pos.x-base.x) % unit);
        new.y = pos.y-((pos.y-base.y) % unit);
        if (new.x != base.x || new.y != base.y)
@@ -238,8 +249,20 @@
        to = gridify(pos, to);
        status_set_type_x("dX =");
        status_set_type_y("dX =");
-       status_set_x("%lg mm", units_to_mm(to.x-pos.x));
-       status_set_y("%lg mm", units_to_mm(to.y-pos.y));
+       /* @@@ use status_set_xy */
+       switch (curr_unit) {
+       case curr_unit_mm:
+       case curr_unit_auto:
+               status_set_x("%lg mm", units_to_mm(to.x-pos.x));
+               status_set_y("%lg mm", units_to_mm(to.y-pos.y));
+               break;
+       case curr_unit_mil:
+               status_set_x("%lg mil", units_to_mil(to.x-pos.x));
+               status_set_y("%lg mil", units_to_mil(to.y-pos.y));
+               break;
+       default:
+               abort();
+       }
        pos = translate(pos);
        to = translate(to);
        buf = save_pix_buf(DA, pos.x, pos.y, to.x, to.y, 1);
@@ -270,8 +293,19 @@
        vec = new_vec(from);
        pos = inst_get_point(from);
        to = gridify(pos, to);
-       vec->x = new_num(make_mm(units_to_mm(to.x-pos.x)));
-       vec->y = new_num(make_mm(units_to_mm(to.y-pos.y)));
+       switch (curr_unit) {
+       case curr_unit_mm:
+       case curr_unit_auto:
+               vec->x = new_num(make_mm(units_to_mm(to.x-pos.x)));
+               vec->y = new_num(make_mm(units_to_mm(to.y-pos.y)));
+               break;
+       case curr_unit_mil:
+               vec->x = new_num(make_mil(units_to_mil(to.x-pos.x)));
+               vec->y = new_num(make_mil(units_to_mil(to.y-pos.y)));
+               break;
+       default:
+               abort();
+       }
        return 1;
 }
 

Modified: trunk/eda/fped/inst.c
===================================================================
--- trunk/eda/fped/inst.c       2009-08-22 14:29:48 UTC (rev 5524)
+++ trunk/eda/fped/inst.c       2009-08-22 15:58:58 UTC (rev 5525)
@@ -208,6 +208,26 @@
                if (selected_inst)
                        goto selected;
        }
+
+       /* give vectors a second chance */
+
+       if (show_stuff) {
+               FOR_ALL_INSTS(i, ip_vec, inst) {
+                       if (!inst->active)
+                               continue;
+                       if (!inst_connected(inst))
+                               continue;
+                       dist = gui_dist_vec_fallback(inst, pos, draw_ctx.scale);
+                       if (dist >= 0 && (!selected_inst || best_dist > dist)) {
+                               selected_inst = inst;
+                               best_dist = dist;
+                       }
+               }
+       
+               if (selected_inst)
+                       goto selected;
+       }
+
        if (any_same_frame) {
                if (activate_item(any_same_frame))
                        return inst_select(pos);
@@ -220,26 +240,8 @@
                }
        }
 
-       if (!show_stuff)
-               return 0;
+       return 0;
 
-       /* give vectors a second chance */
-
-       FOR_ALL_INSTS(i, ip_vec, inst) {
-               if (!inst->active)
-                       continue;
-               if (!inst_connected(inst))
-                       continue;
-               dist = gui_dist_vec_fallback(inst, pos, draw_ctx.scale);
-               if (dist >= 0 && (!selected_inst || best_dist > dist)) {
-                       selected_inst = inst;
-                       best_dist = dist;
-               }
-       }
-       
-       if (!selected_inst)
-               return 0;
-
 selected:
        inst_select_inst(selected_inst);
        return 1;

Modified: trunk/eda/fped/postscript.c
===================================================================
--- trunk/eda/fped/postscript.c 2009-08-22 14:29:48 UTC (rev 5524)
+++ trunk/eda/fped/postscript.c 2009-08-22 15:58:58 UTC (rev 5525)
@@ -53,6 +53,8 @@
 #define        PS_DIVIDER_BORDER       mm_to_units(2)
 #define        PS_DIVIDER_WIDTH        mm_to_units(0.5)
 
+#define        PS_MISC_TEXT_HEIGHT     mm_to_units(3)
+
 #define        PS_DOT_DIST             mm_to_units(0.03)
 #define        PS_DOT_DIAM             mm_to_units(0.01)
 #define        PS_HATCH                mm_to_units(0.1)
@@ -454,7 +456,7 @@
 {
        fprintf(file, "gsave %d setlinewidth\n", PS_DIVIDER_WIDTH);
        fprintf(file, "    %d %d moveto\n", -PAGE_HALF_WIDTH, y);
-       fprintf(file, "    %d 0 rlineto stroke gsave\n", PAGE_HALF_WIDTH*2);
+       fprintf(file, "    %d 0 rlineto stroke grestore\n", PAGE_HALF_WIDTH*2);
 }
 
 
@@ -488,6 +490,32 @@
 }
 
 
+static void ps_unit(FILE *file,
+    unit_type x, unit_type y, unit_type w, unit_type h)
+{
+       const char *s;
+
+       switch (curr_unit) {
+       case curr_unit_mm:
+               s = "Dimensions in mm";
+               break;
+       case curr_unit_mil:
+               s = "Dimensions in mil";
+               break;
+       case curr_unit_auto:
+               return;
+       default:
+               abort();
+       }
+
+       fprintf(file, "gsave %d %d moveto\n", x, y);
+       fprintf(file, "    /Helvetica findfont dup\n");
+       fprintf(file, "    (%s) %d %d\n", s, w, h);
+       fprintf(file, "    4 copy 1000 maxfont maxfont scalefont setfont\n");
+       fprintf(file, "    (%s) show grestore\n", s);
+}
+
+
 static void ps_package(FILE *file, const struct pkg *pkg, int page)
 {
        struct bbox bbox;
@@ -504,8 +532,8 @@
        y = PAGE_HALF_HEIGHT-PS_HEADER_HEIGHT-3*PS_DIVIDER_BORDER;
 
        bbox = inst_get_bbox();
-       w = 2*(-bbox.min.y > bbox.max.y ? -bbox.min.y : bbox.max.y);
-       h = 2*(-bbox.min.x > bbox.max.x ? -bbox.min.x : bbox.max.x);
+       w = 2*(-bbox.min.x > bbox.max.x ? -bbox.min.x : bbox.max.x);
+       h = 2*(-bbox.min.y > bbox.max.y ? -bbox.min.y : bbox.max.y);
 
        /*
         * Zoom such that we can fit at least one drawing
@@ -574,6 +602,8 @@
        }
        fprintf(file, "grestore\n");
 
+       ps_unit(file, -PAGE_HALF_WIDTH, PS_DIVIDER_BORDER, PAGE_HALF_WIDTH,
+           PS_MISC_TEXT_HEIGHT);
        ps_hline(file, 0);
 
        /*




--- End Message ---
_______________________________________________
commitlog mailing list
commitlog@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/commitlog

Reply via email to