Date:2010-04-27 12:57:09 (9 years 7 months ago)
Author:werner
Commit:dc1e644da144046ace91b5c1602ea0f2fa1231d3
Message: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



git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5946 99fdad57-331a-0410-800a-d7fa5415bdb3
Files: gui_inst.c (2 diffs)
test/frame_ref (7 diffs)

Change Details

gui_inst.c
234234}
235235
236236
237static void gui_draw_pad_text(struct inst *self)
237static void pad_text_in_rect(struct inst *self,
238    struct coord min, struct coord max)
238239{
239    struct coord min = translate(self->base);
240    struct coord max = translate(self->u.pad.other);
241240    GdkGC *gc;
242241    struct coord c;
243242    unit_type h, w;
244243    int rot;
245244
246    w = self->bbox.max.x-self->bbox.min.x;
247    h = self->bbox.max.y-self->bbox.min.y;
245    w = max.x-min.x;
246    h = max.y-min.y;
248247    rot = w/1.1 < h;
249248    gc = gc_ptext[get_mode(self)];
250    sort_coord(&min, &max);
251249    c = add_vec(min, max);
252250    h = max.y-min.y;
253251    w = max.x-min.x;
...... 
257255}
258256
259257
258static void maximize_box(struct coord *min_box, struct coord *max_box,
259    unit_type x_min, unit_type y_min, unit_type x_max, unit_type y_max)
260{
261    unit_type d_box, d_new, d;
262
263    d_box = max_box->x-min_box->x;
264    d = max_box->y-min_box->y;
265    if (d < d_box)
266        d_box = d;
267
268    d_new = x_max-x_min;
269    d = y_max-y_min;
270    if (d < d_new)
271        d_new = d;
272
273    if (d_new < d_box)
274        return;
275
276    min_box->x = x_min;
277    min_box->y = y_min;
278    max_box->x = x_max;
279    max_box->y = y_max;
280}
281
282
283static void gui_draw_pad_text(struct inst *self)
284{
285    struct coord pad_min = translate(self->base);
286    struct coord pad_max = translate(self->u.pad.other);
287    struct coord hole_min, hole_max;
288    struct coord box_min, box_max;
289
290    sort_coord(&pad_min, &pad_max);
291    if (!self->u.pad.hole) {
292        pad_text_in_rect(self, pad_min, pad_max);
293        return;
294    }
295
296    hole_min = translate(self->u.pad.hole->base);
297    hole_max = translate(self->u.pad.hole->u.hole.other);
298    sort_coord(&hole_min, &hole_max);
299
300    box_min.x = box_min.y = box_max.x = box_max.y;
301    maximize_box(&box_min, &box_max,
302        pad_min.x, pad_min.y, pad_max.x, hole_min.y); /* top */
303    maximize_box(&box_min, &box_max,
304        pad_min.x, hole_max.y, pad_max.x, pad_max.y); /* bottom */
305    maximize_box(&box_min, &box_max,
306        pad_min.x, pad_min.y, hole_min.x, pad_max.y); /* left */
307    maximize_box(&box_min, &box_max,
308        hole_max.x, pad_min.y, pad_max.x, pad_max.y); /* right */
309
310    pad_text_in_rect(self, box_min, box_max);
311}
312
313
260314static GdkGC *pad_gc(const struct inst *inst, int *fill)
261315{
262316    *fill = TRUE;
test/frame_ref
33
44###############################################################################
55
6fped_dump "frame reference: with \"frame\" (origin)" <<EOF
6fped_dump "frame reference: \"frame\" (origin)" <<EOF
77frame f {}
88frame f @
99EOF
...... 
2020
2121#------------------------------------------------------------------------------
2222
23fped_dump "frame reference: with \"%frame\" (current frame origin)" <<EOF
23fped_dump "frame reference: \"%frame\" (current frame origin)" <<EOF
2424frame f {}
2525%frame f @
2626EOF
...... 
3737
3838#------------------------------------------------------------------------------
3939
40fped_dump "frame reference: with \"%frame\" (current frame vector)" <<EOF
40fped_dump "frame reference: \"%frame\" (current frame vector)" <<EOF
4141frame f {}
4242v: vec @(0mm, 0mm)
4343%frame f v
...... 
5656
5757#------------------------------------------------------------------------------
5858
59fped_dump "frame reference: with \"%frame\" (other frame origin)" <<EOF
59fped_dump "frame reference: \"%frame\" (other frame origin)" <<EOF
6060frame f {}
6161frame g {}
6262%frame f g.@
...... 
7777
7878#------------------------------------------------------------------------------
7979
80fped_dump "frame reference: with \"%frame\" (other frame base)" <<EOF
80fped_dump "frame reference: \"%frame\" (other frame base)" <<EOF
8181frame f {}
8282frame g {
8383    v: vec @(0mm, 0mm)
...... 
101101
102102#------------------------------------------------------------------------------
103103
104fped_fail "frame reference: with \"%frame\" (cycle)" <<EOF
104fped_fail "frame reference: \"%frame\" (cycle)" <<EOF
105105frame f {
106106}
107107
...... 
117117
118118#------------------------------------------------------------------------------
119119
120fped_dump "frame reference: with \"%frame\" (out-of-order)" <<EOF
120fped_dump "frame reference: \"%frame\" (out-of-order)" <<EOF
121121frame f {
122122}
123123

Archive Download the corresponding diff file

Branches:
master



interactive