Changeset 5515
- Timestamp:
- 08/21/09 21:19:33 (4 years ago)
- Location:
- trunk/eda/fped
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/eda/fped/TODO
r5514 r5515 34 34 - whenever we call parse_* for input parsing, we may leak lots of expressions 35 35 - can't edit measurement labels through the GUI 36 - r of rpads is misleading, particularly if we have a circle36 - unbalanced parentheses in text throw off Postscript syntax 37 37 38 38 Code cleanup: -
trunk/eda/fped/inst.c
r5514 r5515 365 365 366 366 367 static void rect_status(struct coord a, struct coord b, unit_type width) 367 static void rect_status(struct coord a, struct coord b, unit_type width, 368 int rounded) 368 369 { 369 370 struct coord d = sub_vec(b, a); 370 double angle; 371 double angle, r; 372 unit_type diag; 371 373 372 374 status_set_xy(d); … … 377 379 status_set_angle("a = %3.1f deg", angle); 378 380 } 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); 380 408 if (width != -1) { 381 409 status_set_type_entry("width ="); … … 468 496 status_set_type_entry("ref ="); 469 497 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); 471 499 vec_edit(self->vec); 472 500 } … … 539 567 static void line_op_select(struct inst *self) 540 568 { 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); 542 570 obj_line_edit(self->obj); 543 571 } … … 589 617 static void rect_op_select(struct inst *self) 590 618 { 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); 592 620 obj_rect_edit(self->obj); 593 621 } … … 643 671 status_set_type_entry("label ="); 644 672 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); 646 674 obj_pad_edit(self->obj); 647 675 } … … 667 695 668 696 697 static 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 669 706 static struct inst_ops rpad_ops = { 670 707 .draw = gui_draw_rpad, 671 708 .distance = gui_dist_pad, /* @@@ */ 672 .select = pad_op_select,709 .select = rpad_op_select, 673 710 .anchors = pad_op_anchors, 674 711 .draw_move = draw_move_rpad, … … 774 811 static void meas_op_select(struct inst *self) 775 812 { 776 rect_status(self->bbox.min, self->bbox.max, -1 );813 rect_status(self->bbox.min, self->bbox.max, -1, 0); 777 814 status_set_type_entry("offset ="); 778 815 set_with_units(status_set_name, "", self->u.meas.offset); … … 899 936 static void frame_op_select(struct inst *self) 900 937 { 901 rect_status(self->bbox.min, self->bbox.max, -1 );938 rect_status(self->bbox.min, self->bbox.max, -1, 0); 902 939 status_set_type_entry("name ="); 903 940 status_set_name("%s", self->u.frame.ref->name);
Note: See TracChangeset
for help on using the changeset viewer.
