r5946 - in trunk/eda/fped: . test
werner at docs.openmoko.org
werner at docs.openmoko.org
Tue Apr 27 12:57:09 CEST 2010
Author: werner
Date: 2010-04-27 12:57:09 +0200 (Tue, 27 Apr 2010)
New Revision: 5946
Modified:
trunk/eda/fped/gui_inst.c
trunk/eda/fped/test/frame_ref
Log:
In the GUI, pad names were always centered on the pad. In the case of
through-hole pads, this could easily make them disappear into the hole. We now
draw them outside the hole.
- gui_inst.c: when showing through-hole pads, gui_draw_pad_text now places the
pad name into the largest area of the pad outside the hole
- test/frame_ref: removed redundant "with" in all titles
Modified: trunk/eda/fped/gui_inst.c
===================================================================
--- trunk/eda/fped/gui_inst.c 2010-04-27 01:02:24 UTC (rev 5945)
+++ trunk/eda/fped/gui_inst.c 2010-04-27 10:57:09 UTC (rev 5946)
@@ -234,20 +234,18 @@
}
-static void gui_draw_pad_text(struct inst *self)
+static void pad_text_in_rect(struct inst *self,
+ struct coord min, struct coord max)
{
- struct coord min = translate(self->base);
- struct coord max = translate(self->u.pad.other);
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;
+ w = max.x-min.x;
+ h = max.y-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;
@@ -257,6 +255,62 @@
}
+static void maximize_box(struct coord *min_box, struct coord *max_box,
+ unit_type x_min, unit_type y_min, unit_type x_max, unit_type y_max)
+{
+ unit_type d_box, d_new, d;
+
+ d_box = max_box->x-min_box->x;
+ d = max_box->y-min_box->y;
+ if (d < d_box)
+ d_box = d;
+
+ d_new = x_max-x_min;
+ d = y_max-y_min;
+ if (d < d_new)
+ d_new = d;
+
+ if (d_new < d_box)
+ return;
+
+ min_box->x = x_min;
+ min_box->y = y_min;
+ max_box->x = x_max;
+ max_box->y = y_max;
+}
+
+
+static void gui_draw_pad_text(struct inst *self)
+{
+ struct coord pad_min = translate(self->base);
+ struct coord pad_max = translate(self->u.pad.other);
+ struct coord hole_min, hole_max;
+ struct coord box_min, box_max;
+
+ sort_coord(&pad_min, &pad_max);
+ if (!self->u.pad.hole) {
+ pad_text_in_rect(self, pad_min, pad_max);
+ return;
+ }
+
+ hole_min = translate(self->u.pad.hole->base);
+ hole_max = translate(self->u.pad.hole->u.hole.other);
+ sort_coord(&hole_min, &hole_max);
+
+ box_min.x = box_min.y = box_max.x = box_max.y;
+ maximize_box(&box_min, &box_max,
+ pad_min.x, pad_min.y, pad_max.x, hole_min.y); /* top */
+ maximize_box(&box_min, &box_max,
+ pad_min.x, hole_max.y, pad_max.x, pad_max.y); /* bottom */
+ maximize_box(&box_min, &box_max,
+ pad_min.x, pad_min.y, hole_min.x, pad_max.y); /* left */
+ maximize_box(&box_min, &box_max,
+ hole_max.x, pad_min.y, pad_max.x, pad_max.y); /* right */
+
+ pad_text_in_rect(self, box_min, box_max);
+}
+
+
static GdkGC *pad_gc(const struct inst *inst, int *fill)
{
*fill = TRUE;
Modified: trunk/eda/fped/test/frame_ref
===================================================================
--- trunk/eda/fped/test/frame_ref 2010-04-27 01:02:24 UTC (rev 5945)
+++ trunk/eda/fped/test/frame_ref 2010-04-27 10:57:09 UTC (rev 5946)
@@ -3,7 +3,7 @@
###############################################################################
-fped_dump "frame reference: with \"frame\" (origin)" <<EOF
+fped_dump "frame reference: \"frame\" (origin)" <<EOF
frame f {}
frame f @
EOF
@@ -20,7 +20,7 @@
#------------------------------------------------------------------------------
-fped_dump "frame reference: with \"%frame\" (current frame origin)" <<EOF
+fped_dump "frame reference: \"%frame\" (current frame origin)" <<EOF
frame f {}
%frame f @
EOF
@@ -37,7 +37,7 @@
#------------------------------------------------------------------------------
-fped_dump "frame reference: with \"%frame\" (current frame vector)" <<EOF
+fped_dump "frame reference: \"%frame\" (current frame vector)" <<EOF
frame f {}
v: vec @(0mm, 0mm)
%frame f v
@@ -56,7 +56,7 @@
#------------------------------------------------------------------------------
-fped_dump "frame reference: with \"%frame\" (other frame origin)" <<EOF
+fped_dump "frame reference: \"%frame\" (other frame origin)" <<EOF
frame f {}
frame g {}
%frame f g.@
@@ -77,7 +77,7 @@
#------------------------------------------------------------------------------
-fped_dump "frame reference: with \"%frame\" (other frame base)" <<EOF
+fped_dump "frame reference: \"%frame\" (other frame base)" <<EOF
frame f {}
frame g {
v: vec @(0mm, 0mm)
@@ -101,7 +101,7 @@
#------------------------------------------------------------------------------
-fped_fail "frame reference: with \"%frame\" (cycle)" <<EOF
+fped_fail "frame reference: \"%frame\" (cycle)" <<EOF
frame f {
}
@@ -117,7 +117,7 @@
#------------------------------------------------------------------------------
-fped_dump "frame reference: with \"%frame\" (out-of-order)" <<EOF
+fped_dump "frame reference: \"%frame\" (out-of-order)" <<EOF
frame f {
}
More information about the commitlog
mailing list