r5635 - trunk/eda/fped

werner at docs.openmoko.org werner at docs.openmoko.org
Sun Sep 13 13:11:03 CEST 2009


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




More information about the commitlog mailing list