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. r5634 - trunk/eda/fped (wer...@docs.openmoko.org)
   2. r5635 - trunk/eda/fped (wer...@docs.openmoko.org)
   3. r5636 - in trunk/eda/fped: . manual (wer...@docs.openmoko.org)
--- Begin Message ---
Author: werner
Date: 2009-09-13 11:58:30 +0200 (Sun, 13 Sep 2009)
New Revision: 5634

Added:
   trunk/eda/fped/layer.c
   trunk/eda/fped/layer.h
   trunk/eda/fped/overlap.c
   trunk/eda/fped/overlap.h
Modified:
   trunk/eda/fped/Makefile
   trunk/eda/fped/gui_inst.c
   trunk/eda/fped/inst.c
   trunk/eda/fped/inst.h
   trunk/eda/fped/kicad.c
   trunk/eda/fped/obj.h
   trunk/eda/fped/postscript.c
Log:
- the set of layers of a pad is now maintained in the instance, so that we can
  make adjustments when removing layers provided by specialized pads
- gui_inst.c: moved gc construction from gui_draw_pad and gui_draw_rpad to
  shared pad_gc
- layer.h: new home of all definitions related to pads and layers
- layer.c: 
- overlap.c: functions to test for overlaps of pad shapes (in progress)



Modified: trunk/eda/fped/Makefile
===================================================================
--- trunk/eda/fped/Makefile     2009-09-12 23:15:15 UTC (rev 5633)
+++ trunk/eda/fped/Makefile     2009-09-13 09:58:30 UTC (rev 5634)
@@ -16,6 +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 \
        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

Modified: trunk/eda/fped/gui_inst.c
===================================================================
--- trunk/eda/fped/gui_inst.c   2009-09-12 23:15:15 UTC (rev 5633)
+++ trunk/eda/fped/gui_inst.c   2009-09-13 09:58:30 UTC (rev 5634)
@@ -107,7 +107,7 @@
 }
 
 
-static enum mode get_mode(struct inst *self)
+static enum mode get_mode(const struct inst *self)
 {
        if (selected_inst == self)
                return mode_selected;
@@ -257,23 +257,26 @@
 }
 
 
+static GdkGC *pad_gc(const struct inst *inst)
+{
+       switch (layers_to_pad_type(inst->u.pad.layers)) {
+       case pt_bare:
+               return gc_pad_bare[get_mode(inst)];
+       case pt_mask:
+               return gc_pad_mask[get_mode(inst)];
+       default:
+               return gc_pad[get_mode(inst)];
+       }
+}
+
+
 void gui_draw_pad(struct inst *self)
 {
        struct coord min = translate(self->base);
        struct coord max = translate(self->u.pad.other);
        GdkGC *gc;
 
-       switch (self->obj->u.pad.type) {
-       case pt_bare:
-               gc = gc_pad_bare[get_mode(self)];
-               break;
-       case pt_mask:
-               gc = gc_pad_mask[get_mode(self)];
-               break;
-       default:
-               gc = gc_pad[get_mode(self)];
-               break;          
-       }
+       gc = pad_gc(self);
        sort_coord(&min, &max);
        gdk_draw_rectangle(DA, gc, TRUE,
            min.x, min.y, max.x-min.x, max.y-min.y);
@@ -289,17 +292,7 @@
        GdkGC *gc;
        unit_type h, w, r;
 
-       switch (self->obj->u.pad.type) {
-       case pt_bare:
-               gc = gc_pad_bare[get_mode(self)];
-               break;
-       case pt_mask:
-               gc = gc_pad_mask[get_mode(self)];
-               break;
-       default:
-               gc = gc_pad[get_mode(self)];
-               break;          
-       }
+       gc = pad_gc(self);
        sort_coord(&min, &max);
        h = max.y-min.y;
        w = max.x-min.x;

Modified: trunk/eda/fped/inst.c
===================================================================
--- trunk/eda/fped/inst.c       2009-09-12 23:15:15 UTC (rev 5633)
+++ trunk/eda/fped/inst.c       2009-09-13 09:58:30 UTC (rev 5634)
@@ -18,6 +18,7 @@
 #include "util.h"
 #include "coord.h"
 #include "expr.h"
+#include "layer.h"
 #include "obj.h"
 #include "delete.h"
 #include "gui_util.h"
@@ -802,6 +803,7 @@
        inst->obj = obj;
        inst->u.pad.name = stralloc(name);
        inst->u.pad.other = b;
+       inst->u.pad.layers = pad_type_to_layers(obj->u.pad.type);
        update_bbox(&inst->bbox, b);
        propagate_bbox(inst);
        return 1;

Modified: trunk/eda/fped/inst.h
===================================================================
--- trunk/eda/fped/inst.h       2009-09-12 23:15:15 UTC (rev 5633)
+++ trunk/eda/fped/inst.h       2009-09-13 09:58:30 UTC (rev 5634)
@@ -14,6 +14,7 @@
 #ifndef INST_H
 #define INST_H
 
+#include <stdint.h>
 #include <stdio.h>
 
 #include "coord.h"
@@ -95,6 +96,7 @@
                struct {
                        char *name;
                        struct coord other;
+                       layer_type layers; /* bit-set of layers */
                } pad;
                struct {
                        unit_type r;

Modified: trunk/eda/fped/kicad.c
===================================================================
--- trunk/eda/fped/kicad.c      2009-09-12 23:15:15 UTC (rev 5633)
+++ trunk/eda/fped/kicad.c      2009-09-13 09:58:30 UTC (rev 5634)
@@ -20,44 +20,10 @@
 #include "kicad.h"
 
 
-enum kicad_layer {
-       layer_bottom,           /* "copper" */
-       layer_l15,
-       layer_l14,
-       layer_l13,
-       layer_l12,
-       layer_l11,
-       layer_l10,
-       layer_l9,
-       layer_l8,
-       layer_l7,
-       layer_l6,
-       layer_l5,
-       layer_l4,
-       layer_l3,
-       layer_l2,
-       layer_top,              /* "component" */
-       layer_glue_bottom,      /* adhesive, copper side */
-       layer_glue_top,         /* adhesive, component side */
-       layer_paste_bottom,     /* solder paste */
-       layer_paste_top,
-       layer_silk_bottom,      /* silk screen */
-       layer_silk_top,
-       layer_mask_bottom,      /* solder mask */
-       layer_mask_top,
-       layer_draw,             /* general drawing */
-       layer_comment,
-       layer_eco1,
-       layer_eco2,
-       layer_edge,             /* edge */
-};
-
-
 static void kicad_pad(FILE *file, const struct inst *inst)
 {
        struct coord min, max;
        unit_type tmp;
-       int layers;
 
        min.x = units_to_kicad(inst->base.x);
        min.y = units_to_kicad(inst->base.y);
@@ -87,24 +53,7 @@
        /*
         * Attributes: pad type, N, layer mask
         */
-       layers = 0;
-       switch (inst->obj->u.pad.type) {
-       case pt_normal:
-               layers = 1 << layer_paste_top;
-               /* fall through */
-       case pt_bare:
-               layers |= (1 << layer_top) | (1 << layer_mask_top);
-               break;
-       case pt_paste:
-               layers = 1 << layer_paste_top;
-               break;
-       case pt_mask:
-               layers = 1 << layer_mask_top;
-               break;
-       default:
-               abort();
-       }
-       fprintf(file, "At SMD N %8.8X\n", layers);
+       fprintf(file, "At SMD N %8.8X\n", (unsigned) inst->u.pad.layers);
 
        /*
         * Position: Xpos, Ypos

Added: trunk/eda/fped/layer.c
===================================================================
--- trunk/eda/fped/layer.c                              (rev 0)
+++ trunk/eda/fped/layer.c      2009-09-13 09:58:30 UTC (rev 5634)
@@ -0,0 +1,56 @@
+/*
+ * layer.c - PCB layers on a pad
+ *
+ * Written 2009 by Werner Almesberger
+ * Copyright 2009 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 <stdlib.h>
+
+#include "layer.h"
+
+
+layer_type pad_type_to_layers(enum pad_type type)
+{
+       layer_type layers = 0;
+
+       switch (type) {
+       case pt_normal:
+               layers = LAYER_PASTE;
+               /* fall through */
+       case pt_bare:
+               layers |= LAYER_COPPER | LAYER_MASK;
+               break;
+       case pt_paste:
+               layers = LAYER_PASTE;
+               break;
+       case pt_mask:
+               layers = LAYER_MASK;
+               break;
+       default:
+               abort();
+       }
+       return layers;
+}
+
+
+enum pad_type layers_to_pad_type(layer_type layers)
+{
+       if (layers & LAYER_COPPER) {
+               if (layers & LAYER_PASTE)
+                       return pt_normal;
+               return pt_bare;
+       } else {
+               if (layers & LAYER_PASTE)
+                       return pt_paste;
+               if (layers & LAYER_MASK)
+                       return pt_mask;
+               abort();
+       }
+}

Added: trunk/eda/fped/layer.h
===================================================================
--- trunk/eda/fped/layer.h                              (rev 0)
+++ trunk/eda/fped/layer.h      2009-09-13 09:58:30 UTC (rev 5634)
@@ -0,0 +1,85 @@
+/*
+ * layer.h - PCB layers on a pad
+ *
+ * Written 2009 by Werner Almesberger
+ * Copyright 2009 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 LAYER_H
+#define LAYER_H
+
+#include <stdint.h>
+
+
+typedef uint32_t layer_type;
+
+
+enum kicad_layer {
+       layer_bottom,           /* "copper" */
+       layer_l15,
+       layer_l14,
+       layer_l13,
+       layer_l12,
+       layer_l11,
+       layer_l10,
+       layer_l9,
+       layer_l8,
+       layer_l7,
+       layer_l6,
+       layer_l5,
+       layer_l4,
+       layer_l3,
+       layer_l2,
+       layer_top,              /* "component" */
+       layer_glue_bottom,      /* adhesive, copper side */
+       layer_glue_top,         /* adhesive, component side */
+       layer_paste_bottom,     /* solder paste */
+       layer_paste_top,
+       layer_silk_bottom,      /* silk screen */
+       layer_silk_top,
+       layer_mask_bottom,      /* solder mask */
+       layer_mask_top,
+       layer_draw,             /* general drawing */
+       layer_comment,
+       layer_eco1,
+       layer_eco2,
+       layer_edge,             /* edge */
+};
+
+
+enum pad_type {
+       pt_normal,      /* copper and solder mask */
+       pt_bare,        /* only copper (and finish) */
+       pt_paste,       /* only solder paste */
+       pt_mask,        /* only solder mask */
+       pt_n
+};
+
+
+/*
+ * Shorthands for the layers we use in a general sense.
+ */
+
+#define        LAYER_COPPER    (1 << layer_top)
+#define        LAYER_PASTE     (1 << layer_paste_top)
+#define        LAYER_MASK      (1 << layer_mask_top)
+
+
+/*
+ * pad_type_to_layers returns the initial set of layers. This set can then be
+ * modified by overlaying other pads. For display purposes, we translate back
+ * to the effective pad type with layers_to_pad_type.
+ *
+ * What this basically means is that pt_normal becomes pt_bare if its solder
+ * paste mask has been removed.
+ */
+
+layer_type pad_type_to_layers(enum pad_type type);
+enum pad_type layers_to_pad_type(layer_type layers);
+
+#endif /* !LAYER_H */

Modified: trunk/eda/fped/obj.h
===================================================================
--- trunk/eda/fped/obj.h        2009-09-12 23:15:15 UTC (rev 5633)
+++ trunk/eda/fped/obj.h        2009-09-13 09:58:30 UTC (rev 5634)
@@ -20,6 +20,7 @@
 #include "expr.h"
 #include "coord.h"
 #include "meas.h"
+#include "layer.h"
 
 
 struct var {
@@ -139,14 +140,6 @@
        ot_meas,
 };
 
-enum pad_type {
-       pt_normal,      /* copper and solder mask */
-       pt_bare,        /* only copper (and finish) */
-       pt_paste,       /* only solder paste */
-       pt_mask,        /* only solder mask */
-       pt_n
-};
-
 struct frame_ref {
        struct frame *ref;
        int lineno;

Added: trunk/eda/fped/overlap.c
===================================================================
--- trunk/eda/fped/overlap.c                            (rev 0)
+++ trunk/eda/fped/overlap.c    2009-09-13 09:58:30 UTC (rev 5634)
@@ -0,0 +1,173 @@
+/*
+ * overlap.c - Test for overlaps
+ *
+ * Written 2009 by Werner Almesberger
+ * Copyright 2009 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 "coord.h"
+#include "obj.h"
+#include "inst.h"
+#include "overlap.h"
+
+
+/*
+ * @@@ result may be too optimistic if "b" is arounded pad.
+ */
+
+int inside(const struct inst *a, const struct inst *b)
+{
+       struct coord min_a, max_a;
+       struct coord min_b, max_b;
+
+       min_a = a->base;
+       max_a = a->u.pad.other;
+       sort_coord(&min_a, &max_a);
+       
+       min_b = b->base;
+       max_b = b->u.pad.other;
+       sort_coord(&min_b, &max_b);
+
+       return min_a.x >= min_b.x && max_a.x <= max_b.x &&
+           min_a.y >= min_b.y && max_a.y <= max_b.y;
+}
+
+
+/* ----- Overlap test for primitives --------------------------------------- */
+
+
+struct shape {
+       int circle;
+       struct coord center;
+       unit_type r;
+       struct coord min, max;
+};
+
+
+static int circle_circle_overlap(struct coord c1, unit_type r1,
+    struct coord c2, unit_type r2)
+{
+       return dist_point(c1, c2) <= r1+r2;
+}
+
+
+static int circle_rect_overlap(struct coord c, unit_type r,
+    struct coord min, struct coord max)
+{
+       if (c.x < min.x-r || c.x > max.x+r)
+               return 0;
+       if (c.y < min.y-r || c.y > max.y+r)
+               return 0;
+       return 1;
+}
+
+
+static int rect_rect_overlap(struct coord min1, struct coord max1,
+    struct coord min2, struct coord max2)
+{
+       if (max1.x < min2.x || max2.x < min1.x)
+               return 0;
+       if (max1.y < min2.y || max2.y < min1.y)
+               return 0;
+       return 1;
+}
+
+
+static int shapes_overlap(const struct shape *a, const struct shape *b)
+{
+       if (a->circle && !b->circle)
+               return shapes_overlap(b, a);
+       if (a->circle) /* b must be circle, too */
+               return circle_circle_overlap(a->center, a->r, b->center, b->r);
+       if (b->circle) /* a must be rect */
+               return circle_rect_overlap(b->center, b->r, a->min, a->max);
+       return rect_rect_overlap(a->min, a->max, b->min, b->max);
+}
+
+
+/* ----- Recursive overlap tester ------------------------------------------ */
+
+
+static int test_overlap(const struct inst *a, const struct inst *b,
+    const struct shape *other);
+
+
+static int do_circle(const struct inst *next, const struct shape *other,
+    unit_type x, unit_type y, unit_type r)
+{
+       struct shape shape = {
+               .circle = 1,
+               .center = {
+                       .x = x,
+                       .y = y,
+               },
+               .r = r,
+       };
+
+       if (next)
+               return test_overlap(next, NULL, &shape);
+       return shapes_overlap(other, &shape);
+}
+
+
+static int do_rect(const struct inst *next, const struct shape *other,
+    unit_type x, unit_type y, unit_type w, unit_type h)
+{
+       struct shape shape = {
+               .circle = 0,
+               .min = {
+                       .x = x,
+                       .y = y,
+               },
+               .max = {
+                       .x = x+w,
+                       .y = y+w,
+               },
+       };
+
+       if (next)
+               return test_overlap(next, NULL, &shape);
+       return shapes_overlap(other, &shape);
+}
+
+
+static int test_overlap(const struct inst *a, const struct inst *b,
+    const struct shape *other)
+{
+       struct coord min, max;
+       unit_type h, w, r;
+
+       min = a->base;
+       max = a->u.pad.other;
+       sort_coord(&min, &max);
+
+       h = max.y-min.y;
+       w = max.x-min.x;
+
+       if (!a->obj->u.pad.rounded)
+               return do_rect(b, other, min.x, min.y, w, h);
+
+       if (h > w) {
+               r = w/2;
+               return do_circle(b, other, min.x+r, max.y-r, r) ||
+                   do_rect(b, other, min.x, min.y+r, w, h-2*r) ||
+                   do_circle(b, other, min.x+r, min.y+r, r);
+       } else {
+               r = h/2;
+               return do_circle(b, other, min.x+r, max.y+r, r) ||
+                   do_rect(b, other, min.x+r, min.y, w-2*r, h) ||
+                   do_circle(b, other, min.x-r, min.y+r, r);
+       }
+}
+
+
+int overlap(const struct inst *a, const struct inst *b)
+{
+       return test_overlap(a, b, NULL);
+}

Added: trunk/eda/fped/overlap.h
===================================================================
--- trunk/eda/fped/overlap.h                            (rev 0)
+++ trunk/eda/fped/overlap.h    2009-09-13 09:58:30 UTC (rev 5634)
@@ -0,0 +1,32 @@
+/*
+ * overlap.h - Test for overlaps
+ *
+ * Written 2009 by Werner Almesberger
+ * Copyright 2009 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 OVERLAP_H
+#define OVERLAP_H
+
+#include "inst.h"
+
+
+/*
+ * "inside" returns 1 if "a" is completely enclosed by "b". If "a" == "b",
+ * that also counts as "a" being inside "b".
+ */
+
+int inside(const struct inst *a, const struct inst *b);
+
+/*
+ * "overlap" returns 1 if "a" and "b" have at least one point in common.
+ */
+
+int overlap(const struct inst *a, const struct inst *b);
+
+#endif /* !OVERLAP_H */

Modified: trunk/eda/fped/postscript.c
===================================================================
--- trunk/eda/fped/postscript.c 2009-09-12 23:15:15 UTC (rev 5633)
+++ trunk/eda/fped/postscript.c 2009-09-13 09:58:30 UTC (rev 5634)
@@ -16,6 +16,7 @@
 
 #include "util.h"
 #include "coord.h"
+#include "layer.h"
 #include "obj.h"
 #include "inst.h"
 #include "unparse.h"
@@ -189,9 +190,9 @@
 }
 
 
-static const char *hatch(enum pad_type type)
+static const char *hatch(layer_type layers)
 {
-       switch (type) {
+       switch (layers_to_pad_type(layers)) {
        case pt_normal:
                return "crosspath";
        case pt_bare:
@@ -217,7 +218,7 @@
        fprintf(file, "  %d %d lineto\n", b.x, b.y);
        fprintf(file, "  %d %d lineto\n", a.x, b.y);
        fprintf(file, "  closepath gsave %s grestore stroke\n",
-           hatch(inst->obj->u.pad.type));
+           hatch(inst->u.pad.layers));
 
        if (show_name)
                ps_pad_name(file, inst);
@@ -248,7 +249,7 @@
                fprintf(file, "  %d %d %d 90 270 arc\n", a.x+r, a.y+r, r);
        }
        fprintf(file, "  closepath gsave %s grestore stroke\n",
-           hatch(inst->obj->u.pad.type));
+           hatch(inst->u.pad.layers));
 
        if (show_name)
                ps_pad_name(file, inst);




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2009-09-13 13:11:03 +0200 (Sun, 13 Sep 2009)
New Revision: 5635

Modified:
   trunk/eda/fped/fpd.y
   trunk/eda/fped/gui_tool.c
   trunk/eda/fped/inst.c
   trunk/eda/fped/inst.h
   trunk/eda/fped/kicad.c
   trunk/eda/fped/layer.c
   trunk/eda/fped/layer.h
   trunk/eda/fped/obj.c
   trunk/eda/fped/overlap.c
   trunk/eda/fped/postscript.c
Log:
- inst.c: cleanup_inst leaked memory when using special pads
- changed pad classification in instances from bare/other to copper/special
- moved LAYER_* definitions from layer.h to layer.c
- after instantiation, we perform sanity checks on pads and remove layers from
  coppery pads that are handled by a special layer
- fped.y: the line number in objects was never set
- overlap.c: fixed overlap calculations
- gui_tool.c: end_new_pad didn't initialize the pad type



Modified: trunk/eda/fped/fpd.y
===================================================================
--- trunk/eda/fped/fpd.y        2009-09-13 09:58:30 UTC (rev 5634)
+++ trunk/eda/fped/fpd.y        2009-09-13 11:11:03 UTC (rev 5635)
@@ -128,6 +128,7 @@
        obj->type = type;
        obj->frame = curr_frame;
        obj->next = NULL;
+       obj->lineno = lineno;
        return obj;
 }
 

Modified: trunk/eda/fped/gui_tool.c
===================================================================
--- trunk/eda/fped/gui_tool.c   2009-09-13 09:58:30 UTC (rev 5634)
+++ trunk/eda/fped/gui_tool.c   2009-09-13 11:11:03 UTC (rev 5635)
@@ -413,6 +413,7 @@
        obj->u.pad.other = inst_get_vec(to);
        obj->u.pad.name = stralloc("?");
        obj->u.pad.rounded = 0;
+       obj->u.pad.type = pt_normal;
        return 1;
 }
 

Modified: trunk/eda/fped/inst.c
===================================================================
--- trunk/eda/fped/inst.c       2009-09-13 09:58:30 UTC (rev 5634)
+++ trunk/eda/fped/inst.c       2009-09-13 11:11:03 UTC (rev 5635)
@@ -799,7 +799,8 @@
        struct inst *inst;
 
        inst = add_inst(obj->u.pad.rounded ? &rpad_ops : &pad_ops,
-           obj->u.pad.type == pt_bare ? ip_pad_bare : ip_pad, a);
+           obj->u.pad.type == pt_normal || obj->u.pad.type == pt_bare ?
+           ip_pad_copper : ip_pad_special, a);
        inst->obj = obj;
        inst->u.pad.name = stralloc(name);
        inst->u.pad.other = b;
@@ -1105,7 +1106,8 @@
 static void cleanup_inst(enum inst_prio prio, const struct inst *inst)
 {
        switch (prio) {
-       case ip_pad:
+       case ip_pad_copper:
+       case ip_pad_special:
                free(inst->u.pad.name);
                break;
        default:

Modified: trunk/eda/fped/inst.h
===================================================================
--- trunk/eda/fped/inst.h       2009-09-13 09:58:30 UTC (rev 5634)
+++ trunk/eda/fped/inst.h       2009-09-13 11:11:03 UTC (rev 5635)
@@ -38,8 +38,8 @@
 
 enum inst_prio {
        ip_frame,       /* frames have their own selection */
-       ip_pad_bare,    /* pads also accept clicks inside */
-       ip_pad,         /* pads with solder mask on top of those without */
+       ip_pad_copper,  /* pads also accept clicks inside; pads with copper */
+       ip_pad_special, /* pads with only solder paste or mask, on top */
        ip_circ,        /* circles don't overlap easily */
        ip_arc,         /* arc are like circles, just shorter */
        ip_rect,        /* rectangles have plenty of sides */
@@ -132,7 +132,7 @@
  * frame being instantiated - we need to export this one for meas.c, so that
  * measurement scan update the root frame's bounding box.
  */
-extern struct inst *curr_frame;
+extern struct inst *curr_frame;
 
 /*
  * @@@ Note that we over-generalize a bit here: the only item that ever ends up

Modified: trunk/eda/fped/kicad.c
===================================================================
--- trunk/eda/fped/kicad.c      2009-09-13 09:58:30 UTC (rev 5634)
+++ trunk/eda/fped/kicad.c      2009-09-13 11:11:03 UTC (rev 5635)
@@ -148,8 +148,8 @@
 static void kicad_inst(FILE *file, enum inst_prio prio, const struct inst 
*inst)
 {
        switch (prio) {
-       case ip_pad:
-       case ip_pad_bare:
+       case ip_pad_copper:
+       case ip_pad_special:
                kicad_pad(file, inst);
                break;
        case ip_line:

Modified: trunk/eda/fped/layer.c
===================================================================
--- trunk/eda/fped/layer.c      2009-09-13 09:58:30 UTC (rev 5634)
+++ trunk/eda/fped/layer.c      2009-09-13 11:11:03 UTC (rev 5635)
@@ -10,12 +10,34 @@
  * (at your option) any later version.
  */
 
+/*
+ * We don't reject solder paste pads that don't cover anything yet.
+ * That way, things can be constructed step by step without getting blue
+ * screens all the time.
+ */
 
+
 #include <stdlib.h>
 
+#include "error.h"
+#include "overlap.h"
+#include "inst.h"
+#include "obj.h"
 #include "layer.h"
 
 
+/*
+ * Shorthands for the layers we use in a general sense.
+ */
+
+#define LAYER_COPPER   (1 << layer_top)
+#define LAYER_PASTE    (1 << layer_paste_top)
+#define LAYER_MASK     (1 << layer_mask_top)
+
+
+/* ----- Conversion between pad types and layer sets ----------------------- */
+
+
 layer_type pad_type_to_layers(enum pad_type type)
 {
        layer_type layers = 0;
@@ -54,3 +76,70 @@
                abort();
        }
 }
+
+
+/* ----- Refine layers after instantiation --------------------------------- */
+
+
+static int refine_overlapping(struct inst *copper, struct inst *other)
+{
+       if (other->u.pad.layers & LAYER_PASTE) {
+               copper->u.pad.layers &= ~LAYER_PASTE;
+               if (!inside(other, copper)) {
+                       fail("solder paste without copper underneath "
+                           "(\"%s\" line %d, \"%s\" line %d)",
+                           copper->u.pad.name, copper->obj->lineno,
+                           other->u.pad.name, other->obj->lineno);
+                       instantiation_error = other->obj;
+                       return 0;
+               }
+       }
+       if (other->u.pad.layers & LAYER_MASK)
+               copper->u.pad.layers &= ~LAYER_MASK;
+       return 1;
+}
+
+
+static int refine_copper(const struct pkg *pkg_copper, struct inst *copper)
+{
+       const struct pkg *pkg;
+       struct inst *other;
+
+       for (pkg = pkgs; pkg; pkg = pkg->next) {
+               /*
+                * Pads in distinct packages can happily coexist.
+                */
+               if (pkg != pkgs && pkg_copper != pkgs && pkg_copper != pkg)
+                       continue;
+               for (other = pkg->insts[ip_pad_copper]; other;
+                   other = other->next)
+                       if (copper != other && overlap(copper, other)) {
+                               fail("overlapping copper pads "
+                                   "(\"%s\" line %d, \"%s\" line %d)",
+                                   copper->u.pad.name, copper->obj->lineno,
+                                   other->u.pad.name, other->obj->lineno);
+                               instantiation_error = copper->obj;
+                               return 0;
+                       }
+               for (other = pkg->insts[ip_pad_special]; other;
+                   other = other->next)
+                       if (overlap(copper, other))
+                               if (!refine_overlapping(copper, other))
+                                       return 0;
+       }
+       return 1;
+}
+
+
+int refine_layers(void)
+{
+       const struct pkg *pkg;
+       struct inst *copper;
+
+       for (pkg = pkgs; pkg; pkg = pkg->next)
+               for (copper = pkg->insts[ip_pad_copper]; copper;
+                   copper = copper->next)
+                       if (!refine_copper(pkg, copper))
+                               return 0;
+       return 1;
+}

Modified: trunk/eda/fped/layer.h
===================================================================
--- trunk/eda/fped/layer.h      2009-09-13 09:58:30 UTC (rev 5634)
+++ trunk/eda/fped/layer.h      2009-09-13 11:11:03 UTC (rev 5635)
@@ -62,15 +62,6 @@
 
 
 /*
- * Shorthands for the layers we use in a general sense.
- */
-
-#define        LAYER_COPPER    (1 << layer_top)
-#define        LAYER_PASTE     (1 << layer_paste_top)
-#define        LAYER_MASK      (1 << layer_mask_top)
-
-
-/*
  * pad_type_to_layers returns the initial set of layers. This set can then be
  * modified by overlaying other pads. For display purposes, we translate back
  * to the effective pad type with layers_to_pad_type.
@@ -82,4 +73,6 @@
 layer_type pad_type_to_layers(enum pad_type type);
 enum pad_type layers_to_pad_type(layer_type layers);
 
+int refine_layers(void);
+
 #endif /* !LAYER_H */

Modified: trunk/eda/fped/obj.c
===================================================================
--- trunk/eda/fped/obj.c        2009-09-13 09:58:30 UTC (rev 5634)
+++ trunk/eda/fped/obj.c        2009-09-13 11:11:03 UTC (rev 5635)
@@ -20,6 +20,7 @@
 #include "expr.h"
 #include "meas.h"
 #include "inst.h"
+#include "layer.h"
 #include "delete.h"
 #include "obj.h"
 
@@ -304,6 +305,8 @@
        reset_all_loops();
        ok = generate_frame(root_frame, zero, NULL, NULL, 1);
        if (ok)
+               ok = refine_layers();
+       if (ok)
                ok = instantiate_meas();
        if (ok)
                inst_commit();

Modified: trunk/eda/fped/overlap.c
===================================================================
--- trunk/eda/fped/overlap.c    2009-09-13 09:58:30 UTC (rev 5634)
+++ trunk/eda/fped/overlap.c    2009-09-13 11:11:03 UTC (rev 5635)
@@ -127,7 +127,7 @@
                },
                .max = {
                        .x = x+w,
-                       .y = y+w,
+                       .y = y+h,
                },
        };
 
@@ -160,9 +160,9 @@
                    do_circle(b, other, min.x+r, min.y+r, r);
        } else {
                r = h/2;
-               return do_circle(b, other, min.x+r, max.y+r, r) ||
+               return do_circle(b, other, min.x+r, min.y+r, r) ||
                    do_rect(b, other, min.x+r, min.y, w-2*r, h) ||
-                   do_circle(b, other, min.x-r, min.y+r, r);
+                   do_circle(b, other, max.x-r, min.y+r, r);
        }
 }
 

Modified: trunk/eda/fped/postscript.c
===================================================================
--- trunk/eda/fped/postscript.c 2009-09-13 09:58:30 UTC (rev 5634)
+++ trunk/eda/fped/postscript.c 2009-09-13 11:11:03 UTC (rev 5635)
@@ -477,8 +477,8 @@
      const struct inst *inst, double zoom)
 {
        switch (prio) {
-       case ip_pad:
-       case ip_pad_bare:
+       case ip_pad_copper:
+       case ip_pad_special:
                if (inst->obj->u.pad.rounded)
                        ps_rpad(file, inst, active_params.show_pad_names);
                else




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2009-09-13 15:16:39 +0200 (Sun, 13 Sep 2009)
New Revision: 5636

Added:
   trunk/eda/fped/manual/concept-inst.fig
Modified:
   trunk/eda/fped/Makefile
   trunk/eda/fped/README
   trunk/eda/fped/gui.html
Log:
- README: added link to the GUI manual
- added a conceptual explanation of instantiation (with picture)



Modified: trunk/eda/fped/Makefile
===================================================================
--- trunk/eda/fped/Makefile     2009-09-13 11:11:03 UTC (rev 5635)
+++ trunk/eda/fped/Makefile     2009-09-13 13:16:39 UTC (rev 5636)
@@ -76,7 +76,8 @@
 
 # ----- Rules -----------------------------------------------------------------
 
-.PHONY:                all dep depend clean install uninstall upload-manual 
update
+.PHONY:                all dep depend clean install uninstall manual 
upload-manual
+.PHONY:                update
 
 .SUFFIXES:     .fig .xpm
 
@@ -109,10 +110,14 @@
 
 # ----- Upload the GUI manual -------------------------------------------------
 
-upload-manual: $(XPMS:%=icons/%)
-               scp gui.html README $(UPLOAD)/
+manual:                $(XPMS:%=icons/%)
                for n in $(XPMS:%.xpm=%); do \
                    convert icons/$$n.xpm manual/$$n.png || exit 1; done
+               fig2dev -L png -S 4 manual/concept-inst.fig \
+                   >manual/concept-inst.png
+
+upload-manual: manual
+               scp gui.html README $(UPLOAD)/
                scp $(XPMS:%.xpm=manual/%.png) $(PNGS:%=manual/%) \
                  $(UPLOAD)/manual/
 

Modified: trunk/eda/fped/README
===================================================================
--- trunk/eda/fped/README       2009-09-13 11:11:03 UTC (rev 5635)
+++ trunk/eda/fped/README       2009-09-13 13:16:39 UTC (rev 5636)
@@ -445,6 +445,10 @@
 GUI
 ---
 
+Part of the GUI is described in
+http://people.openmoko.org/werner/fped/gui.html
+
+
 Keyboard shortcuts
 - - - - - - - - -
 

Modified: trunk/eda/fped/gui.html
===================================================================
--- trunk/eda/fped/gui.html     2009-09-13 11:11:03 UTC (rev 5635)
+++ trunk/eda/fped/gui.html     2009-09-13 13:16:39 UTC (rev 5636)
@@ -17,8 +17,11 @@
 simple geometrical pattern. With fped, the user specifies the elements
 to repeat and the way they are repeated. Fped then generates the
 repetitions automatically.
+
+<H2>Hands-on example</H2>
 <P>
-Here is a simple example:
+Here is a simple example that illustrated the basic steps of constructing
+things with fled:
 <UL>
   <LI> Start fped without a command-line argument.
   <LI> Right-click on the yellow field that says "(root)" and select
@@ -64,7 +67,20 @@
 instances of the same objects by clicking on the numbers (1 2 3 4 5) shown
 next to the loop.
 
+<H2>Conceptual view</H2>
+The following picture illustrates the concept: the model is defined in
+terms of objects, in this case a vector from the origin to the circle's
+center, a vector for the radius, and the circle itself.
+<P>
+<IMG src="manual/concept-inst.png">
+<P>
+The vector to the center uses a variable that gets iterated through the
+values 0, 1, and 2. For each iteration, an instance is generated.
+<P>
+Only the instances of silk screen objects and pads are exported to KiCad.
+Elements used for construction, such as vectors, only appear in fped.
 
+
 <H1>Frames</H1>
 
 Frames serve various purposes:

Added: trunk/eda/fped/manual/concept-inst.fig
===================================================================
--- trunk/eda/fped/manual/concept-inst.fig                              (rev 0)
+++ trunk/eda/fped/manual/concept-inst.fig      2009-09-13 13:16:39 UTC (rev 
5636)
@@ -0,0 +1,35 @@
+#FIG 3.2  Produced by xfig version 3.2.5a
+Landscape
+Center
+Metric
+A4      
+100.00
+Single
+-2
+1200 2
+0 32 #c0c000
+1 1 0 5 3 7 40 -1 -1 0.000 1 0.0000 3600 4500 450 225 3600 4500 4050 4500
+1 1 0 5 3 7 40 -1 -1 0.000 1 0.0000 6300 4501 450 225 6300 4501 6750 4501
+1 1 0 5 3 7 40 -1 -1 0.000 1 0.0000 4950 4500 450 225 4950 4500 5400 4500
+1 1 0 1 12 12 50 -1 20 0.000 1 0.0000 3150 6075 90 45 3150 6075 3240 6075
+1 1 0 3 12 7 50 -1 -1 0.000 1 0.0000 3150 6075 180 90 3150 6075 3330 6075
+1 1 0 5 16 7 40 -1 -1 0.000 1 0.0000 4500 6075 450 225 4500 6075 4950 6075
+2 1 0 2 0 7 45 -1 -1 0.000 0 0 -1 0 0 3
+        2925 3600 1800 5175 6975 5175
+2 1 1 2 0 7 35 -1 -1 6.000 0 0 -1 0 0 2
+        3150 6075 3600 4500
+2 1 0 2 0 7 35 -1 -1 6.000 0 0 -1 0 0 2
+        3825 6165 4275 6750
+2 1 0 3 32 7 45 -1 -1 0.000 0 0 -1 1 0 2
+       0 0 3.00 135.00 120.00
+        4500 6075 4635 5850
+2 1 0 3 32 7 45 -1 -1 0.000 0 0 -1 1 0 2
+       0 0 3.00 135.00 135.00
+        3150 6075 4500 6075
+4 1 0 35 -1 18 12 0.0000 4 165 390 3600 4140 n=0\001
+4 1 0 35 -1 18 12 0.0000 4 165 390 4950 4140 n=1\001
+4 1 0 35 -1 18 12 0.0000 4 165 390 6300 4140 n=2\001
+4 1 0 35 -1 18 12 0.0000 4 210 660 3150 6435 Origin\001
+4 0 0 35 -1 18 12 0.0000 4 180 1305 4050 6975 n*4mm, 0mm\001
+4 0 0 35 -1 18 12 0.0000 4 210 1650 1800 7200 Objects (model)\001
+4 0 0 35 -1 18 12 0.0000 4 165 1005 4050 3600 Instances\001




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

Reply via email to