Changeset 5515


Ignore:
Timestamp:
08/21/09 21:19:33 (4 years ago)
Author:
werner
Message:
  • calculation of a rounded pad's diagonal is now more sensible. We use the length of the part of the diagonal that's on the pad. In the case of a circle (BGA), this is just the diameter.
  • changed label for diagonals from "r" to "d"
Location:
trunk/eda/fped
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/eda/fped/TODO

    r5514 r5515  
    3434- whenever we call parse_* for input parsing, we may leak lots of expressions 
    3535- can't edit measurement labels through the GUI 
    36 - r of rpads is misleading, particularly if we have a circle 
     36- unbalanced parentheses in text throw off Postscript syntax 
    3737 
    3838Code cleanup: 
  • trunk/eda/fped/inst.c

    r5514 r5515  
    365365 
    366366 
    367 static void rect_status(struct coord a, struct coord b, unit_type width) 
     367static void rect_status(struct coord a, struct coord b, unit_type width, 
     368    int rounded) 
    368369{ 
    369370        struct coord d = sub_vec(b, a); 
    370         double angle; 
     371        double angle, r; 
     372        unit_type diag; 
    371373         
    372374        status_set_xy(d); 
     
    377379                status_set_angle("a = %3.1f deg", angle); 
    378380        } 
    379         set_with_units(status_set_r, "r = ", hypot(d.x, d.y)); 
     381        if (d.x < 0) 
     382                d.x = -d.x; 
     383        if (d.y < 0) 
     384                d.y = -d.y; 
     385        diag = hypot(d.x, d.y); 
     386        if (rounded) { 
     387                /* 
     388                 * Only consider the part of the diagonal that is on the pad 
     389                 * surface. 
     390                 * 
     391                 * The circle: (x-r)^2+(y-r)^2 = r^2 
     392                 * The diagonal: x = t*cos(theta), y = t*sin(theta) 
     393                 * 
     394                 * t is the distance from the corner of the surrounding 
     395                 * rectangle to the half-circle: 
     396                 * 
     397                 * t = 2*r*(s+c-sqrt(2*s*c)) 
     398                 * 
     399                 * With s = sin(theta) and c = cos(theta). 
     400                 * 
     401                 * Since d.x = diag*cos(theta), we don't need to calculate the 
     402                 * sinus and cosinus but can use d.x and d.y directly. 
     403                 */ 
     404                r = (d.x > d.y ? d.y : d.x)/2; 
     405                diag -= 2*r*(d.x+d.y-sqrt(2*d.x*d.y))/diag; 
     406        } 
     407        set_with_units(status_set_r, "d = ", diag); 
    380408        if (width != -1) { 
    381409                status_set_type_entry("width ="); 
     
    468496        status_set_type_entry("ref ="); 
    469497        status_set_name("%s", self->vec->name ? self->vec->name : ""); 
    470         rect_status(self->base, self->u.rect.end, -1); 
     498        rect_status(self->base, self->u.rect.end, -1, 0); 
    471499        vec_edit(self->vec); 
    472500} 
     
    539567static void line_op_select(struct inst *self) 
    540568{ 
    541         rect_status(self->bbox.min, self->bbox.max, self->u.rect.width); 
     569        rect_status(self->bbox.min, self->bbox.max, self->u.rect.width, 0); 
    542570        obj_line_edit(self->obj); 
    543571} 
     
    589617static void rect_op_select(struct inst *self) 
    590618{ 
    591         rect_status(self->bbox.min, self->bbox.max, self->u.rect.width); 
     619        rect_status(self->bbox.min, self->bbox.max, self->u.rect.width, 0); 
    592620        obj_rect_edit(self->obj); 
    593621} 
     
    643671        status_set_type_entry("label ="); 
    644672        status_set_name("%s", self->u.pad.name); 
    645         rect_status(self->base, self->u.pad.other, -1); 
     673        rect_status(self->base, self->u.pad.other, -1, 0); 
    646674        obj_pad_edit(self->obj); 
    647675} 
     
    667695 
    668696 
     697static void rpad_op_select(struct inst *self) 
     698{ 
     699        status_set_type_entry("label ="); 
     700        status_set_name("%s", self->u.pad.name); 
     701        rect_status(self->base, self->u.pad.other, -1, 1); 
     702        obj_pad_edit(self->obj); 
     703} 
     704 
     705 
    669706static struct inst_ops rpad_ops = { 
    670707        .draw           = gui_draw_rpad, 
    671708        .distance       = gui_dist_pad, /* @@@ */ 
    672         .select         = pad_op_select, 
     709        .select         = rpad_op_select, 
    673710        .anchors        = pad_op_anchors, 
    674711        .draw_move      = draw_move_rpad, 
     
    774811static void meas_op_select(struct inst *self) 
    775812{ 
    776         rect_status(self->bbox.min, self->bbox.max, -1); 
     813        rect_status(self->bbox.min, self->bbox.max, -1, 0); 
    777814        status_set_type_entry("offset ="); 
    778815        set_with_units(status_set_name, "", self->u.meas.offset); 
     
    899936static void frame_op_select(struct inst *self) 
    900937{ 
    901         rect_status(self->bbox.min, self->bbox.max, -1); 
     938        rect_status(self->bbox.min, self->bbox.max, -1, 0); 
    902939        status_set_type_entry("name ="); 
    903940        status_set_name("%s", self->u.frame.ref->name); 
Note: See TracChangeset for help on using the changeset viewer.