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. r5939 - in trunk/eda/fped: . icons (wer...@docs.openmoko.org)
   2. r5940 - in trunk/eda/fped: . icons (wer...@docs.openmoko.org)
--- Begin Message ---
Author: werner
Date: 2010-04-25 12:58:07 +0200 (Sun, 25 Apr 2010)
New Revision: 5939

Added:
   trunk/eda/fped/icons/hole.fig
Modified:
   trunk/eda/fped/Makefile
   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_inst.h
   trunk/eda/fped/gui_style.c
   trunk/eda/fped/gui_style.h
   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/obj.c
   trunk/eda/fped/obj.h
Log:
When creating an object in the GUI, its label wasn't initialized. Added 
infrastructure for hole objects. (Postscript and KiCad output are still 
missing, and so does sanity checking.)

- gui_tool.c (new_obj_unconnected): set obj->name to NULL
- added hole objects to tool bar, all the various GUI routines, the .fpd
  parser, and the .fpd dumper



Modified: trunk/eda/fped/Makefile
===================================================================
--- trunk/eda/fped/Makefile     2010-04-25 00:37:04 UTC (rev 5938)
+++ trunk/eda/fped/Makefile     2010-04-25 10:58:07 UTC (rev 5939)
@@ -23,7 +23,7 @@
 
 XPMS = point.xpm delete.xpm delete_off.xpm \
        vec.xpm frame.xpm \
-       line.xpm rect.xpm pad.xpm rpad.xpm arc.xpm circ.xpm \
+       line.xpm rect.xpm pad.xpm rpad.xpm hole.xpm arc.xpm circ.xpm \
        meas.xpm meas_x.xpm meas_y.xpm \
        stuff.xpm stuff_off.xpm meas_off.xpm \
        bright.xpm bright_off.xpm all.xpm all_off.xpm

Modified: trunk/eda/fped/delete.c
===================================================================
--- trunk/eda/fped/delete.c     2010-04-25 00:37:04 UTC (rev 5938)
+++ trunk/eda/fped/delete.c     2010-04-25 10:58:07 UTC (rev 5939)
@@ -1,8 +1,8 @@
 /*
  * delete.c - Object deletion
  *
- * Written 2009 by Werner Almesberger
- * Copyright 2009 by Werner Almesberger
+ * Written 2009, 2010 by Werner Almesberger
+ * Copyright 2009, 2010 by Werner Almesberger
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -137,6 +137,8 @@
                return obj->u.rect.other == ref;
        case ot_pad:
                return obj->u.pad.other == ref;
+       case ot_hole:
+               return obj->u.hole.other == ref;
        case ot_arc:
                return obj->u.arc.start == ref || obj->u.arc.end == ref;
        case ot_meas:
@@ -210,6 +212,8 @@
        case ot_pad:
                free(obj->u.pad.name);
                break;
+       case ot_hole:
+               break;
        case ot_line:
                if (obj->u.line.width)
                        free_expr(obj->u.line.width);

Modified: trunk/eda/fped/dump.c
===================================================================
--- trunk/eda/fped/dump.c       2010-04-25 00:37:04 UTC (rev 5938)
+++ trunk/eda/fped/dump.c       2010-04-25 10:58:07 UTC (rev 5939)
@@ -111,6 +111,10 @@
                n |= need(obj->u.pad.other, prev);
                l |= later(obj->u.pad.other, prev);
                break;
+       case ot_hole:
+               n |= need(obj->u.hole.other, prev);
+               l |= later(obj->u.hole.other, prev);
+               break;
        case ot_arc:
                n |= need(obj->u.arc.start, prev);
                n |= need(obj->u.arc.end, prev);
@@ -352,6 +356,10 @@
                    obj->u.pad.rounded ? "r" : "",
                    obj->u.pad.name, base, s1, s2);
                break;
+       case ot_hole:
+               s1 = obj_base_name(obj->u.hole.other, prev);
+               s = stralloc_printf("hole %s %s", base, s1);
+               break;
        case ot_arc:
                s1 = obj_base_name(obj->u.arc.start, prev);
                s2 = unparse(obj->u.arc.width);

Modified: trunk/eda/fped/fpd.l
===================================================================
--- trunk/eda/fped/fpd.l        2010-04-25 00:37:04 UTC (rev 5938)
+++ trunk/eda/fped/fpd.l        2010-04-25 10:58:07 UTC (rev 5939)
@@ -104,6 +104,8 @@
                                  return TOK_PAD; }
 <INITIAL>"rpad"                        { BEGIN(NOKEYWORD);
                                  return TOK_RPAD; }
+<INITIAL>"hole"                        { BEGIN(NOKEYWORD);
+                                 return TOK_HOLE; }
 <INITIAL>"rect"                        { BEGIN(NOKEYWORD);
                                  return TOK_RECT; }
 <INITIAL>"line"                        { BEGIN(NOKEYWORD);

Modified: trunk/eda/fped/fpd.y
===================================================================
--- trunk/eda/fped/fpd.y        2010-04-25 00:37:04 UTC (rev 5938)
+++ trunk/eda/fped/fpd.y        2010-04-25 10:58:07 UTC (rev 5939)
@@ -285,7 +285,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_PAD TOK_RPAD TOK_HOLE TOK_RECT TOK_LINE TOK_CIRC TOK_ARC
 %token         TOK_MEAS TOK_MEASX TOK_MEASY TOK_UNIT
 %token         TOK_NEXT TOK_NEXT_INVERTED TOK_MAX TOK_MAX_INVERTED
 %token         TOK_DBG_DEL TOK_DBG_MOVE TOK_DBG_PRINT TOK_DBG_DUMP
@@ -653,6 +653,12 @@
                        $$->u.pad.rounded = 1;
                        $$->u.pad.type = $5;
                }
+       | TOK_HOLE base base
+               {
+                       $$ = new_obj(ot_hole);
+                       $$->base = $2;
+                       $$->u.hole.other = $3;
+               }
        | TOK_RECT base base opt_expr
                {
                        $$ = new_obj(ot_rect);

Modified: trunk/eda/fped/gui_inst.c
===================================================================
--- trunk/eda/fped/gui_inst.c   2010-04-25 00:37:04 UTC (rev 5938)
+++ trunk/eda/fped/gui_inst.c   2010-04-25 10:58:07 UTC (rev 5939)
@@ -1,8 +1,8 @@
 /*
  * gui_inst.c - GUI, instance functions
  *
- * Written 2009 by Werner Almesberger
- * Copyright 2009 by Werner Almesberger
+ * Written 2009, 2010 by Werner Almesberger
+ * Copyright 2009, 2010 by Werner Almesberger
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -288,15 +288,13 @@
 }
 
 
-void gui_draw_rpad(struct inst *self)
+static void draw_rounded_rect(GdkGC *gc, struct coord a, struct coord b,
+     int fill)
 {
-       struct coord min = translate(self->base);
-       struct coord max = translate(self->u.pad.other);
-       GdkGC *gc;
-       int fill;
+       struct coord min = translate(a);
+       struct coord max = translate(b);
        unit_type h, w, r;
 
-       gc = pad_gc(self, &fill);
        sort_coord(&min, &max);
        h = max.y-min.y;
        w = max.x-min.x;
@@ -323,11 +321,44 @@
                }
                draw_arc(DA, gc, fill, max.x-r, min.y+r, r, 270, 90);
        }
+}
 
+
+void gui_draw_rpad(struct inst *self)
+{
+       GdkGC *gc;
+       int fill;
+
+       gc = pad_gc(self, &fill);
+       draw_rounded_rect(gc, self->base, self->u.pad.other, fill);
        gui_draw_pad_text(self);
 }
 
 
+/* ----- hole -------------------------------------------------------------- */
+
+
+unit_type gui_dist_hole(struct inst *self, struct coord pos, unit_type scale)
+{
+       unit_type d;
+
+       /* @@@ not quite right ... */
+       if (inside_rect(pos, self->base, self->u.hole.other))
+               return SELECT_R;
+       d = dist_rect(pos, self->base, self->u.hole.other)/scale;
+       return d > SELECT_R ? -1 : d;
+}
+
+
+void gui_draw_hole(struct inst *self)
+{
+       draw_rounded_rect(gc_hole[get_mode(self)],
+           self->base, self->u.hole.other, 1);
+       draw_rounded_rect(gc_rim[get_mode(self)],
+           self->base, self->u.hole.other, 0);
+}
+
+
 /* ----- arc --------------------------------------------------------------- */
 
 

Modified: trunk/eda/fped/gui_inst.h
===================================================================
--- trunk/eda/fped/gui_inst.h   2010-04-25 00:37:04 UTC (rev 5938)
+++ trunk/eda/fped/gui_inst.h   2010-04-25 10:58:07 UTC (rev 5939)
@@ -1,8 +1,8 @@
 /*
  * gui_inst.h - GUI, instance functions
  *
- * Written 2009 by Werner Almesberger
- * Copyright 2009 by Werner Almesberger
+ * Written 2009, 2010 by Werner Almesberger
+ * Copyright 2009, 2010 by Werner Almesberger
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -30,6 +30,7 @@
 unit_type gui_dist_line(struct inst *self, struct coord pos, unit_type scale);
 unit_type gui_dist_rect(struct inst *self, struct coord pos, unit_type scale);
 unit_type gui_dist_pad(struct inst *self, struct coord pos, unit_type scale);
+unit_type gui_dist_hole(struct inst *self, struct coord pos, unit_type scale);
 unit_type gui_dist_arc(struct inst *self, struct coord pos, unit_type scale);
 unit_type gui_dist_meas(struct inst *self, struct coord pos, unit_type scale);
 unit_type gui_dist_frame(struct inst *self, struct coord pos, unit_type scale);
@@ -44,6 +45,7 @@
 void gui_draw_rect(struct inst *self);
 void gui_draw_pad(struct inst *self);
 void gui_draw_rpad(struct inst *self);
+void gui_draw_hole(struct inst *self);
 void gui_draw_arc(struct inst *self);
 void gui_draw_meas(struct inst *self);
 void gui_draw_frame(struct inst *self);

Modified: trunk/eda/fped/gui_style.c
===================================================================
--- trunk/eda/fped/gui_style.c  2010-04-25 00:37:04 UTC (rev 5938)
+++ trunk/eda/fped/gui_style.c  2010-04-25 10:58:07 UTC (rev 5939)
@@ -1,7 +1,7 @@
 /* * gui_style.c - GUI, style definitions
  *
- * Written 2009 by Werner Almesberger
- * Copyright 2009 by Werner Almesberger
+ * Written 2009, 2010 by Werner Almesberger
+ * Copyright 2009, 2010 by Werner Almesberger
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -28,6 +28,8 @@
 GdkGC *gc_pad_bare[mode_n];
 GdkGC *gc_pad_mask[mode_n];
 GdkGC *gc_ptext[mode_n];
+GdkGC *gc_rim[mode_n];
+GdkGC *gc_hole[mode_n];
 GdkGC *gc_meas[mode_n];
 GdkGC *gc_frame[mode_n];
 
@@ -61,13 +63,15 @@
        gc_bg = gc("#000000", 0);
        gc_bg_error = gc("#000040", 0);
        gc_drag = gc("#ffffff", 2);
-       /*                      inactive   active     selected */
+       /*                      inactive   active     selected  width */
        style(gc_vec,           "#202000", "#b0b050", "#ffff80", 1);
        style(gc_obj,           "#006060", "#00ffff", "#ffff80", 1);
        style(gc_pad,           "#400000", "#ff0000", "#ffff80", 1);
        style(gc_pad_bare,      "#402000", "#ff6000", "#ffff80", 1);
        style(gc_pad_mask,      "#000040", "#0000ff", "#ffff80", 2);
        style(gc_ptext,         "#404040", "#ffffff", "#ffffff", 1);
+       style(gc_hole,          "#000000", "#000000", "#000000", 0);
+       style(gc_rim,           "#202020", "#606060", "#ffff80", 3);
        style(gc_meas,          "#280040", "#ff00ff", "#ffff80", 1);
        style(gc_frame,         "#005000", "#009000", "#ffff80", 1);
 

Modified: trunk/eda/fped/gui_style.h
===================================================================
--- trunk/eda/fped/gui_style.h  2010-04-25 00:37:04 UTC (rev 5938)
+++ trunk/eda/fped/gui_style.h  2010-04-25 10:58:07 UTC (rev 5939)
@@ -116,6 +116,8 @@
 extern GdkGC *gc_pad_bare[mode_n];
 extern GdkGC *gc_pad_mask[mode_n];
 extern GdkGC *gc_ptext[mode_n];
+extern GdkGC *gc_rim[mode_n];
+extern GdkGC *gc_hole[mode_n];
 extern GdkGC *gc_meas[mode_n];
 extern GdkGC *gc_frame[mode_n];
 

Modified: trunk/eda/fped/gui_tool.c
===================================================================
--- trunk/eda/fped/gui_tool.c   2010-04-25 00:37:04 UTC (rev 5938)
+++ trunk/eda/fped/gui_tool.c   2010-04-25 10:58:07 UTC (rev 5939)
@@ -40,6 +40,7 @@
 #include "icons/meas_y.xpm"
 #include "icons/pad.xpm"
 #include "icons/rpad.xpm"
+#include "icons/hole.xpm"
 #include "icons/point.xpm"
 #include "icons/delete.xpm"
 #include "icons/delete_off.xpm"
@@ -88,6 +89,7 @@
 
        obj = alloc_type(struct obj);
        obj->type = type;
+       obj->name = NULL;
        obj->frame = active_frame;
        obj->base = inst_get_vec(base);
        obj->next = NULL;
@@ -459,6 +461,33 @@
 };
 
 
+/* ----- hole -------------------------------------------------------------- */
+
+
+static int end_new_hole(struct inst *from, struct inst *to)
+{
+       struct obj *obj;
+
+       if (from == to)
+               return 0;
+       obj = new_obj(ot_hole, from);
+       obj->u.hole.other = inst_get_vec(to);
+       return 1;
+}
+
+
+struct pix_buf *draw_move_hole(struct inst *inst, struct coord pos, int i)
+{
+       return draw_move_rect_common(inst, inst->u.hole.other, pos, i);
+}
+
+
+static struct tool_ops hole_ops = {
+       .drag_new       = drag_new_rect,
+       .end_new        = end_new_hole,
+};
+
+
 /* ----- circ -------------------------------------------------------------- */
 
 
@@ -1049,6 +1078,9 @@
        case ip_pad_special:
                image = inst->obj->u.pad.rounded ? xpm_rpad : xpm_pad;
                break;
+       case ip_hole:
+               image = xpm_hole;
+               break;
        case ip_circ:
                image = xpm_circ;
                break;
@@ -1166,6 +1198,9 @@
        tool_button(bar, drawable, xpm_rpad,
            "Add a rounded pad",
            tool_button_press_event, &rpad_ops);
+       tool_button(bar, drawable, xpm_hole,
+           "Add a hole",
+           tool_button_press_event, &hole_ops);
        tool_button(bar, drawable, xpm_line,
            "Add a silk screen line",
            tool_button_press_event, &line_ops);

Modified: trunk/eda/fped/gui_tool.h
===================================================================
--- trunk/eda/fped/gui_tool.h   2010-04-25 00:37:04 UTC (rev 5938)
+++ trunk/eda/fped/gui_tool.h   2010-04-25 10:58:07 UTC (rev 5939)
@@ -36,6 +36,7 @@
 struct pix_buf *draw_move_rect(struct inst *inst, struct coord pos, int i);
 struct pix_buf *draw_move_pad(struct inst *inst, struct coord pos, int i);
 struct pix_buf *draw_move_rpad(struct inst *inst, struct coord pos, int i);
+struct pix_buf *draw_move_hole(struct inst *inst, struct coord pos, int i);
 struct pix_buf *draw_move_arc(struct inst *inst, struct coord pos, int i);
 struct pix_buf *draw_move_meas(struct inst *inst, struct coord pos, int i);
 struct pix_buf *draw_move_frame(struct inst *inst, struct coord pos, int i);

Added: trunk/eda/fped/icons/hole.fig
===================================================================
--- trunk/eda/fped/icons/hole.fig                               (rev 0)
+++ trunk/eda/fped/icons/hole.fig       2010-04-25 10:58:07 UTC (rev 5939)
@@ -0,0 +1,24 @@
+#FIG 3.2  Produced by xfig version 3.2.5a
+Landscape
+Center
+Inches
+A4      
+100.00
+Single
+-2
+1200 2
+6 3600 2400 6000 4800
+1 3 0 8 0 7 45 -1 20 0.000 1 0.0000 4800 3600 600 600 4800 3600 5400 3600
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+        3600 2400 6000 2400 6000 4800 3600 4800 3600 2400
+2 1 0 5 0 7 50 -1 20 0.000 0 1 -1 0 0 2
+        3900 4500 5700 2700
+2 1 0 5 0 7 50 -1 20 0.000 0 1 -1 0 0 2
+        3900 3900 5100 2700
+2 1 0 5 0 7 50 -1 20 0.000 0 1 -1 0 0 2
+        3900 3300 4500 2700
+2 1 0 5 0 7 50 -1 20 0.000 0 1 -1 0 0 2
+        4500 4500 5700 3300
+2 1 0 5 0 7 50 -1 20 0.000 0 1 -1 0 0 2
+        5100 4500 5700 3900
+-6

Modified: trunk/eda/fped/inst.c
===================================================================
--- trunk/eda/fped/inst.c       2010-04-25 00:37:04 UTC (rev 5938)
+++ trunk/eda/fped/inst.c       2010-04-25 10:58:07 UTC (rev 5939)
@@ -909,6 +909,37 @@
 }
 
 
+/* ----- hole -------------------------------------------------------------- */
+
+
+static void hole_op_select(struct inst *self)
+{
+       rect_status_sort(self->base, self->u.hole.other, -1, 1);
+}
+
+
+static struct inst_ops hole_ops = {
+       .draw           = gui_draw_hole,
+       .distance       = gui_dist_hole,
+       .select         = hole_op_select,
+       .draw_move      = draw_move_hole,
+};
+
+
+int inst_hole(struct obj *obj, struct coord a, struct coord b)
+{
+       struct inst *inst;
+
+       inst = add_inst(&hole_ops, ip_hole, a);
+       inst->obj = obj;
+       inst->u.hole.other = b;
+       find_inst(inst);
+       update_bbox(&inst->bbox, b);
+       propagate_bbox(inst);
+       return 1;
+}
+
+
 /* ----- arc --------------------------------------------------------------- */
 
 

Modified: trunk/eda/fped/inst.h
===================================================================
--- trunk/eda/fped/inst.h       2010-04-25 00:37:04 UTC (rev 5938)
+++ trunk/eda/fped/inst.h       2010-04-25 10:58:07 UTC (rev 5939)
@@ -40,6 +40,7 @@
        ip_frame,       /* frames have their own selection */
        ip_pad_copper,  /* pads also accept clicks inside; pads with copper */
        ip_pad_special, /* pads with only solder paste or mask, on top */
+       ip_hole,        /* holes in pads must be on top to be seen */
        ip_circ,        /* circles don't overlap easily */
        ip_arc,         /* arcs are like circles, just shorter */
        ip_rect,        /* rectangles have plenty of sides */
@@ -99,6 +100,9 @@
                        layer_type layers; /* bit-set of layers */
                } pad;
                struct {
+                       struct coord other;
+               } hole;
+               struct {
                        unit_type r;
                        double a1, a2;
                        unit_type width;
@@ -173,6 +177,7 @@
 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_hole(struct obj *obj, 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 coord from, struct coord to);

Modified: trunk/eda/fped/obj.c
===================================================================
--- trunk/eda/fped/obj.c        2010-04-25 00:37:04 UTC (rev 5938)
+++ trunk/eda/fped/obj.c        2010-04-25 10:58:07 UTC (rev 5939)
@@ -112,6 +112,9 @@
        case ot_pad:
                anchors[1] = &obj->u.pad.other;
                return 2;
+       case ot_hole:
+               anchors[1] = &obj->u.hole.other;
+               return 2;
        case ot_meas:
                anchors[1] = &obj->u.meas.high;
                return 2;
@@ -234,6 +237,11 @@
                        if (!ok)
                                goto error;
                        break;
+               case ot_hole:
+                       if (!inst_hole(obj, obj->base ? obj->base->pos : base,
+                           obj->u.hole.other ? obj->u.hole.other->pos : base))
+                               goto error;
+                       break;
                case ot_arc:
                        width = eval_unit_default(obj->u.arc.width, frame,
                            DEFAULT_SILK_WIDTH);

Modified: trunk/eda/fped/obj.h
===================================================================
--- trunk/eda/fped/obj.h        2010-04-25 00:37:04 UTC (rev 5938)
+++ trunk/eda/fped/obj.h        2010-04-25 10:58:07 UTC (rev 5939)
@@ -178,6 +178,7 @@
        ot_frame,
        ot_rect,
        ot_pad,
+       ot_hole,
        ot_line,
        ot_arc,
        ot_meas,
@@ -200,6 +201,10 @@
        enum pad_type type;
 };
 
+struct hole {
+       struct vec *other; /* NULL if frame origin */
+};
+
 struct arc {
        struct vec *start; /* NULL if frame origin */
        struct vec *end; /* NULL if this is a circle */
@@ -214,6 +219,7 @@
                struct rect rect;
                struct rect line;
                struct pad pad;
+               struct hole hole;
                struct arc arc;
                struct meas meas;
        } u;




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2010-04-25 15:09:36 +0200 (Sun, 25 Apr 2010)
New Revision: 5940

Added:
   trunk/eda/fped/hole.c
   trunk/eda/fped/hole.h
Modified:
   trunk/eda/fped/Makefile
   trunk/eda/fped/README
   trunk/eda/fped/gui.html
   trunk/eda/fped/icons/hole.fig
   trunk/eda/fped/inst.h
   trunk/eda/fped/obj.c
   trunk/eda/fped/overlap.c
   trunk/eda/fped/postscript.c
Log:
More work on holes: added documentation and Postscript output.

- overlap.c (inside, test_overlap): check for instance type 
- overlap.c (inside, test_overlap): support hole instances
- README: put a pointer to the GUI description at the beginning
- README, gui.html: documented role and creation of holes
- inst.h: holes can now link to pads and vice versa
- hole.c, obj.c (instantiate): connect holes with pads and apply consistency 
  checks
- postscript.c: added output for holes
- icons/hole.fig: make hatched surroundings of hole look more round



Modified: trunk/eda/fped/Makefile
===================================================================
--- trunk/eda/fped/Makefile     2010-04-25 10:58:07 UTC (rev 5939)
+++ trunk/eda/fped/Makefile     2010-04-25 13:09:36 UTC (rev 5940)
@@ -16,7 +16,7 @@
 
 OBJS = fped.o expr.o coord.o obj.o delete.o inst.o util.o error.o \
        unparse.o file.o dump.o kicad.o postscript.o meas.o \
-       layer.o overlap.o \
+       layer.o overlap.o hole.o \
        cpp.o lex.yy.o y.tab.o \
        gui.o gui_util.o gui_style.o gui_inst.o gui_status.o gui_canvas.o \
        gui_tool.o gui_over.o gui_meas.o gui_frame.o gui_frame_drag.o

Modified: trunk/eda/fped/README
===================================================================
--- trunk/eda/fped/README       2010-04-25 10:58:07 UTC (rev 5939)
+++ trunk/eda/fped/README       2010-04-25 13:09:36 UTC (rev 5940)
@@ -9,6 +9,11 @@
 the textual definition also has a straightforward equivalent operation
 that can be performed through the GUI.
 
+This README describes only the footprint definition language. A
+description of the GUI can be found here:
+
+http://people.openmoko.org/werner/fped/gui.html
+
 This work is distributed under the terms of the GNU GENERAL PUBLIC
 LICENSE, Version 2:
 
@@ -251,6 +256,23 @@
 rpad "<name>" <point-a> <point-b> [<type>]
 
 
+Holes
+- - -
+
+Holes can be used for through-hole pins or for mechanical support.
+In the former case, the hole must be placed inside a pad. Only one
+hole per pad is allowed. Mechanical holes must be outside any pads.
+
+Through-hole pads are always present on both sides of the board, i.e.,
+when fped generates a KiCad module, the surface layers of a pad
+containing a hole are propagated to the opposite side of the board.
+
+Holes have the same shape as a rounded pad and their geometry is
+defined in the same way:
+
+hole <point-a> <point-b>
+
+
 Measurements
 - - - - - -
 

Modified: trunk/eda/fped/gui.html
===================================================================
--- trunk/eda/fped/gui.html     2010-04-25 10:58:07 UTC (rev 5939)
+++ trunk/eda/fped/gui.html     2010-04-25 13:09:36 UTC (rev 5940)
@@ -222,6 +222,15 @@
     containing the pad. Move the mouse cursor to the first point, then
     drag to the second point. The pad's name can be edited after selecting
     the pad.
+  <DT><IMG src="manual/hole.png">
+  <DD> Add a hole. There are two purposes for holes:
+    <UL>
+      <LI> Pins of through-hole components. In this case, the hole has to be
+       inside a pad.
+      <LI> Mechanical support. In this case, the hole has to be outside any
+       pads.
+    </UL>
+    The construction of holes is the same as for pads.
   <DT><IMG src="manual/line.png">&nbsp;<IMG src="manual/rect.png">
   <DD> Add a line or a rectangle. Similar to pads, lines and rectangles
     are defined by two points. The width of the line can be edited after

Added: trunk/eda/fped/hole.c
===================================================================
--- trunk/eda/fped/hole.c                               (rev 0)
+++ trunk/eda/fped/hole.c       2010-04-25 13:09:36 UTC (rev 5940)
@@ -0,0 +1,86 @@
+/*
+ * hole.c - Classify holes and connect them with pads
+ *
+ * Written 2010 by Werner Almesberger
+ * Copyright 2010 by Werner Almesberger
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+
+#include "error.h"
+#include "inst.h"
+#include "overlap.h"
+#include "hole.h"
+
+
+static int check_through_hole(struct inst *pad, struct inst *hole)
+{
+       if (!overlap(pad, hole))
+               return 1;
+       if (!inside(hole, pad)) {
+               fail("hole (line %d) not completely inside "
+                   "pad \"%s\" (line %d)", hole->obj->lineno,
+                   pad->u.pad.name, pad->obj->lineno);
+               instantiation_error = pad->obj;
+               return 0;
+       }
+       if (hole->u.hole.pad) {
+               /*
+                * A hole can only be on several pads if the pads themselves
+                * overlap. We'll catch this error in refine_copper.
+                */
+               return 1;
+       }
+       if (pad->u.pad.hole) {
+               fail("pad \"%s\" (line %d) has multiple holes (lines %d, %d)",
+                   pad->u.pad.name, pad->obj->lineno,
+                   hole->obj->lineno, pad->u.pad.hole->obj->lineno);
+               instantiation_error = pad->obj;
+               return 0;
+       }
+       pad->u.pad.hole = hole;
+       hole->u.hole.pad = pad;
+       return 1;
+}
+
+
+static int connect_holes(const struct pkg *pkg)
+{
+       struct inst *pad, *hole;
+
+       for (pad = pkg->insts[ip_pad_copper]; pad; pad = pad->next)
+               for (hole = pkg->insts[ip_hole]; hole; hole = hole->next)
+                       if (!check_through_hole(pad, hole))
+                               return 0;
+       return 1;
+}
+
+
+static void clear_links(const struct pkg *pkg)
+{
+       struct inst *pad, *hole;
+
+       for (pad = pkg->insts[ip_pad_copper]; pad; pad = pad->next)
+               pad->u.pad.hole = NULL;
+       for (pad = pkg->insts[ip_pad_special]; pad; pad = pad->next)
+               pad->u.pad.hole = NULL;
+       for (hole = pkg->insts[ip_hole]; hole; hole = hole->next)
+               hole->u.hole.pad = NULL;
+}
+
+
+int link_holes(void)
+{
+       const struct pkg *pkg;
+
+       for (pkg = pkgs; pkg; pkg = pkg->next) {
+               clear_links(pkg);
+               if (!connect_holes(pkg))
+                       return 0;
+       }
+        return 1;
+}

Added: trunk/eda/fped/hole.h
===================================================================
--- trunk/eda/fped/hole.h                               (rev 0)
+++ trunk/eda/fped/hole.h       2010-04-25 13:09:36 UTC (rev 5940)
@@ -0,0 +1,18 @@
+/*
+ * hole.h - Classify holes and connect them with pads
+ *
+ * Written 2010 by Werner Almesberger
+ * Copyright 2010 by Werner Almesberger
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef HOLE_H
+#define HOLE_H
+
+int link_holes(void);
+
+#endif /* !HOLE_H */

Modified: trunk/eda/fped/icons/hole.fig
===================================================================
--- trunk/eda/fped/icons/hole.fig       2010-04-25 10:58:07 UTC (rev 5939)
+++ trunk/eda/fped/icons/hole.fig       2010-04-25 13:09:36 UTC (rev 5940)
@@ -7,12 +7,11 @@
 Single
 -2
 1200 2
-6 3600 2400 6000 4800
 1 3 0 8 0 7 45 -1 20 0.000 1 0.0000 4800 3600 600 600 4800 3600 5400 3600
 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
         3600 2400 6000 2400 6000 4800 3600 4800 3600 2400
 2 1 0 5 0 7 50 -1 20 0.000 0 1 -1 0 0 2
-        3900 4500 5700 2700
+        4050 4350 5550 2850
 2 1 0 5 0 7 50 -1 20 0.000 0 1 -1 0 0 2
         3900 3900 5100 2700
 2 1 0 5 0 7 50 -1 20 0.000 0 1 -1 0 0 2
@@ -21,4 +20,3 @@
         4500 4500 5700 3300
 2 1 0 5 0 7 50 -1 20 0.000 0 1 -1 0 0 2
         5100 4500 5700 3900
--6

Modified: trunk/eda/fped/inst.h
===================================================================
--- trunk/eda/fped/inst.h       2010-04-25 10:58:07 UTC (rev 5939)
+++ trunk/eda/fped/inst.h       2010-04-25 13:09:36 UTC (rev 5940)
@@ -98,9 +98,11 @@
                        char *name;
                        struct coord other;
                        layer_type layers; /* bit-set of layers */
+                       struct inst *hole; /* through-hole or NULL */
                } pad;
                struct {
                        struct coord other;
+                       struct inst *pad; /* through-hole pad of NULL */
                } hole;
                struct {
                        unit_type r;

Modified: trunk/eda/fped/obj.c
===================================================================
--- trunk/eda/fped/obj.c        2010-04-25 10:58:07 UTC (rev 5939)
+++ trunk/eda/fped/obj.c        2010-04-25 13:09:36 UTC (rev 5940)
@@ -20,6 +20,7 @@
 #include "expr.h"
 #include "meas.h"
 #include "inst.h"
+#include "hole.h"
 #include "layer.h"
 #include "delete.h"
 #include "obj.h"
@@ -476,6 +477,8 @@
        find_vec = NULL;
        find_obj = NULL;
        if (ok)
+               ok = link_holes();
+       if (ok)
                ok = refine_layers();
        if (ok)
                ok = instantiate_meas();

Modified: trunk/eda/fped/overlap.c
===================================================================
--- trunk/eda/fped/overlap.c    2010-04-25 10:58:07 UTC (rev 5939)
+++ trunk/eda/fped/overlap.c    2010-04-25 13:09:36 UTC (rev 5940)
@@ -1,8 +1,8 @@
 /*
  * overlap.c - Test for overlaps
  *
- * Written 2009 by Werner Almesberger
- * Copyright 2009 by Werner Almesberger
+ * Written 2009, 2010 by Werner Almesberger
+ * Copyright 2009, 2010 by Werner Almesberger
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -11,6 +11,8 @@
  */
 
 
+#include <stdlib.h>
+
 #include "coord.h"
 #include "obj.h"
 #include "inst.h"
@@ -18,7 +20,7 @@
 
 
 /*
- * @@@ result may be too optimistic if "b" is arounded pad.
+ * @@@ result may be too optimistic if "b" is a rounded pad
  */
 
 int inside(const struct inst *a, const struct inst *b)
@@ -27,11 +29,29 @@
        struct coord min_b, max_b;
 
        min_a = a->base;
-       max_a = a->u.pad.other;
+       switch (a->obj->type) {
+       case ot_pad:
+               max_a = a->u.pad.other;
+               break;
+       case ot_hole:
+               max_a = a->u.hole.other;
+               break;
+       default:
+               abort();
+       }
        sort_coord(&min_a, &max_a);
        
        min_b = b->base;
-       max_b = b->u.pad.other;
+       switch (b->obj->type) {
+       case ot_pad:
+               max_b = b->u.pad.other;
+               break;
+       case ot_hole:
+               max_b = b->u.hole.other;
+               break;
+       default:
+               abort();
+       }
        sort_coord(&min_b, &max_b);
 
        return min_a.x >= min_b.x && max_a.x <= max_b.x &&
@@ -142,15 +162,27 @@
 {
        struct coord min, max;
        unit_type h, w, r;
+       int rounded;
 
        min = a->base;
-       max = a->u.pad.other;
+       switch (a->obj->type) {
+       case ot_pad:
+               max = a->u.pad.other;
+               rounded = a->obj->u.pad.rounded;
+               break;
+       case ot_hole:
+               max = a->u.hole.other;
+               rounded = 1;
+               break;
+       default:
+               abort();
+       }
        sort_coord(&min, &max);
 
        h = max.y-min.y;
        w = max.x-min.x;
 
-       if (!a->obj->u.pad.rounded)
+       if (!rounded)
                return do_rect(b, other, min.x, min.y, w, h);
 
        if (h > w) {

Modified: trunk/eda/fped/postscript.c
===================================================================
--- trunk/eda/fped/postscript.c 2010-04-25 10:58:07 UTC (rev 5939)
+++ trunk/eda/fped/postscript.c 2010-04-25 13:09:36 UTC (rev 5940)
@@ -64,6 +64,8 @@
 #define        PS_HATCH                mm_to_units(0.1)
 #define        PS_HATCH_LINE           mm_to_units(0.015)
 
+#define        PS_RIM_LINE             mm_to_units(0.02)
+
 #define        PS_FONT_OUTLINE         mm_to_units(0.025)
 
 #define        PS_VEC_LINE             mm_to_units(0.02)
@@ -220,21 +222,19 @@
        fprintf(file, "  closepath gsave %s grestore stroke\n",
            hatch(inst->u.pad.layers));
 
-       if (show_name)
+       if (show_name && !inst->u.pad.hole)
                ps_pad_name(file, inst);
 }
 
 
-static void ps_rpad(FILE *file, const struct inst *inst, int show_name)
+static void ps_rounded_rect(FILE *file, struct coord a, struct coord b)
 {
-       struct coord a = inst->base;
-       struct coord b = inst->u.pad.other;
        unit_type h, w, r;
 
        sort_coord(&a, &b);
        h = b.y-a.y;
        w = b.x-a.x;
-       fprintf(file, "0 setgray %d setlinewidth\n", PS_HATCH_LINE);
+
        if (h > w) {
                r = w/2;
                fprintf(file, "  %d %d moveto\n", b.x, b.y-r);
@@ -248,14 +248,33 @@
                fprintf(file, "  %d %d lineto\n", a.x+r, b.y);
                fprintf(file, "  %d %d %d 90 270 arc\n", a.x+r, a.y+r, r);
        }
+}
+
+
+static void ps_rpad(FILE *file, const struct inst *inst, int show_name)
+{
+       fprintf(file, "0 setgray %d setlinewidth\n", PS_HATCH_LINE);
+       ps_rounded_rect(file, inst->base, inst->u.pad.other);
        fprintf(file, "  closepath gsave %s grestore stroke\n",
            hatch(inst->u.pad.layers));
 
-       if (show_name)
+       if (show_name && !inst->u.pad.hole)
                ps_pad_name(file, inst);
 }
 
 
+static void ps_hole(FILE *file, const struct inst *inst, int show_name)
+{
+       fprintf(file, "1 setgray %d setlinewidth\n", PS_RIM_LINE);
+       ps_rounded_rect(file, inst->base, inst->u.hole.other);
+       fprintf(file, "  closepath gsave fill grestore\n");
+       fprintf(file, "  0 setgray stroke\n");
+
+       if (show_name && inst->u.hole.pad)
+               ps_pad_name(file, inst->u.hole.pad);
+}
+
+
 static void ps_line(FILE *file, const struct inst *inst)
 {
        struct coord a = inst->base;
@@ -485,6 +504,9 @@
                else
                        ps_pad(file, inst, active_params.show_pad_names);
                break;
+       case ip_hole:
+               ps_hole(file, inst, active_params.show_pad_names);
+               break;
        case ip_vec:
                if (active_params.show_stuff)
                        ps_vec(file, inst);




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

Reply via email to