Changeset 5525
- Timestamp:
- 08/22/09 17:58:58 (4 years ago)
- Location:
- trunk/eda/fped
- Files:
-
- 10 edited
-
Makefile (modified) (1 diff)
-
README (modified) (2 diffs)
-
dump.c (modified) (3 diffs)
-
fpd.l (modified) (1 diff)
-
fpd.y (modified) (4 diffs)
-
gui_inst.c (modified) (2 diffs)
-
gui_status.c (modified) (3 diffs)
-
gui_tool.c (modified) (3 diffs)
-
inst.c (modified) (2 diffs)
-
postscript.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/eda/fped/Makefile
r5487 r5525 119 119 # ----- Install / uninstall --------------------------------------------------- 120 120 121 install: 121 install: all 122 122 install -m 755 fped $(PREFIX)/bin/ 123 123 -
trunk/eda/fped/README
r5519 r5525 91 91 ... 92 92 package name 93 unit 93 94 objects 94 95 ... … … 125 126 126 127 All values used as dimensions must be either mm or mil. 128 129 The default unit can be set with one of the following directives: 130 131 unit mm 132 unit mil 133 unit auto 134 135 When saving a footprint definition, the default unit is set to the 136 unit set in the GUI. 127 137 128 138 -
trunk/eda/fped/dump.c
r5490 r5525 18 18 #include "unparse.h" 19 19 #include "obj.h" 20 #include "gui_status.h" 20 21 #include "dump.h" 21 22 … … 492 493 493 494 495 static void dump_unit(FILE *file) 496 { 497 switch (curr_unit) { 498 case curr_unit_mm: 499 fprintf(file, "unit mm\n"); 500 break; 501 case curr_unit_mil: 502 fprintf(file, "unit mil\n"); 503 break; 504 case curr_unit_auto: 505 fprintf(file, "unit auto\n"); 506 break; 507 default: 508 abort(); 509 } 510 } 511 512 494 513 int dump(FILE *file) 495 514 { … … 502 521 if (!frame->name) { 503 522 fprintf(file, "package \"%s\"\n", pkg_name); 523 dump_unit(file); 504 524 dump_frame(file, frame, ""); 505 525 } else { -
trunk/eda/fped/fpd.l
r5478 r5525 119 119 <INITIAL>"measy" { BEGIN(NOKEYWORD); 120 120 return TOK_MEASY; } 121 <INITIAL>"unit" { BEGIN(NOKEYWORD); 122 return TOK_UNIT; } 121 123 122 124 <INITIAL>[a-zA-Z_][a-zA-Z_0-9]*: { *strchr(yytext, ':') = 0; -
trunk/eda/fped/fpd.y
r5478 r5525 20 20 #include "obj.h" 21 21 #include "meas.h" 22 #include "gui_status.h" 22 23 #include "fpd.h" 23 24 … … 157 158 %token TOK_SET TOK_LOOP TOK_PACKAGE TOK_FRAME TOK_TABLE TOK_VEC 158 159 %token TOK_PAD TOK_RPAD TOK_RECT TOK_LINE TOK_CIRC TOK_ARC 159 %token TOK_MEAS TOK_MEASX TOK_MEASY 160 %token TOK_MEAS TOK_MEASX TOK_MEASY TOK_UNIT 160 161 %token TOK_NEXT TOK_NEXT_INVERTED TOK_MAX TOK_MAX_INVERTED 161 162 … … 207 208 208 209 fpd: 209 | frame_defs part_name frame_items210 | frame_defs part_name opt_unit frame_items 210 211 ; 211 212 … … 225 226 } 226 227 pkg_name = $2; 228 } 229 ; 230 231 opt_unit: 232 | TOK_UNIT ID 233 { 234 if (!strcmp($2, "mm")) 235 curr_unit = curr_unit_mm; 236 else if (!strcmp($2, "mil")) 237 curr_unit = curr_unit_mil; 238 else if (!strcmp($2, "auto")) 239 curr_unit = curr_unit_auto; 240 else { 241 yyerrorf("unrecognized unit \"%s\"", $2); 242 YYABORT; 243 } 227 244 } 228 245 ; -
trunk/eda/fped/gui_inst.c
r5484 r5525 242 242 struct coord c; 243 243 unit_type h, w; 244 244 int rot; 245 246 w = self->bbox.max.x-self->bbox.min.x; 247 h = self->bbox.max.y-self->bbox.min.y; 248 rot = w/1.1 < h; 245 249 gc = gc_ptext[get_mode(self)]; 246 250 sort_coord(&min, &max); … … 248 252 h = max.y-min.y; 249 253 w = max.x-min.x; 250 render_text(DA, gc, c.x/2, c.y/2, w <= h*1.1? 0 : 90,254 render_text(DA, gc, c.x/2, c.y/2, rot ? 0 : 90, 251 255 self->u.pad.name, PAD_FONT, 0.5, 0.5, 252 256 w-2*PAD_BORDER, h-2*PAD_BORDER); -
trunk/eda/fped/gui_status.c
r5461 r5525 737 737 738 738 739 static void show_curr_unit(void) 740 { 741 switch (curr_unit) { 742 case curr_unit_mm: 743 status_set_unit("mm"); 744 break; 745 case curr_unit_mil: 746 status_set_unit("mil"); 747 break; 748 case curr_unit_auto: 749 status_set_unit("auto"); 750 break; 751 default: 752 abort(); 753 } 754 } 755 756 739 757 static gboolean unit_button_press_event(GtkWidget *widget, 740 758 GdkEventButton *event, gpointer data) … … 743 761 case 1: 744 762 curr_unit = (curr_unit+1) % curr_unit_n; 745 switch (curr_unit) { 746 case curr_unit_mm: 747 status_set_unit("mm"); 748 break; 749 case curr_unit_mil: 750 status_set_unit("mil"); 751 break; 752 case curr_unit_auto: 753 status_set_unit("auto"); 754 break; 755 default: 756 abort(); 757 } 763 show_curr_unit(); 758 764 break; 759 765 } … … 860 866 861 867 label_in_box_bg(status_unit, COLOR_UNIT_SELECTOR); 862 s tatus_set_unit("mm");868 show_curr_unit(); 863 869 g_signal_connect(G_OBJECT(box_of_label(status_unit)), 864 870 "button_press_event", G_CALLBACK(unit_button_press_event), NULL); -
trunk/eda/fped/gui_tool.c
r5524 r5525 216 216 { 217 217 struct coord new; 218 unit_type unit = mm_to_units(0.1); 219 218 unit_type unit; 219 220 switch (curr_unit) { 221 case curr_unit_mm: 222 case curr_unit_auto: 223 unit = mm_to_units(0.1); 224 break; 225 case curr_unit_mil: 226 unit = mil_to_units(10); 227 break; 228 default: 229 abort(); 230 } 220 231 new.x = pos.x-((pos.x-base.x) % unit); 221 232 new.y = pos.y-((pos.y-base.y) % unit); … … 239 250 status_set_type_x("dX ="); 240 251 status_set_type_y("dX ="); 241 status_set_x("%lg mm", units_to_mm(to.x-pos.x)); 242 status_set_y("%lg mm", units_to_mm(to.y-pos.y)); 252 /* @@@ use status_set_xy */ 253 switch (curr_unit) { 254 case curr_unit_mm: 255 case curr_unit_auto: 256 status_set_x("%lg mm", units_to_mm(to.x-pos.x)); 257 status_set_y("%lg mm", units_to_mm(to.y-pos.y)); 258 break; 259 case curr_unit_mil: 260 status_set_x("%lg mil", units_to_mil(to.x-pos.x)); 261 status_set_y("%lg mil", units_to_mil(to.y-pos.y)); 262 break; 263 default: 264 abort(); 265 } 243 266 pos = translate(pos); 244 267 to = translate(to); … … 271 294 pos = inst_get_point(from); 272 295 to = gridify(pos, to); 273 vec->x = new_num(make_mm(units_to_mm(to.x-pos.x))); 274 vec->y = new_num(make_mm(units_to_mm(to.y-pos.y))); 296 switch (curr_unit) { 297 case curr_unit_mm: 298 case curr_unit_auto: 299 vec->x = new_num(make_mm(units_to_mm(to.x-pos.x))); 300 vec->y = new_num(make_mm(units_to_mm(to.y-pos.y))); 301 break; 302 case curr_unit_mil: 303 vec->x = new_num(make_mil(units_to_mil(to.x-pos.x))); 304 vec->y = new_num(make_mil(units_to_mil(to.y-pos.y))); 305 break; 306 default: 307 abort(); 308 } 275 309 return 1; 276 310 } -
trunk/eda/fped/inst.c
r5523 r5525 209 209 goto selected; 210 210 } 211 212 /* give vectors a second chance */ 213 214 if (show_stuff) { 215 FOR_ALL_INSTS(i, ip_vec, inst) { 216 if (!inst->active) 217 continue; 218 if (!inst_connected(inst)) 219 continue; 220 dist = gui_dist_vec_fallback(inst, pos, draw_ctx.scale); 221 if (dist >= 0 && (!selected_inst || best_dist > dist)) { 222 selected_inst = inst; 223 best_dist = dist; 224 } 225 } 226 227 if (selected_inst) 228 goto selected; 229 } 230 211 231 if (any_same_frame) { 212 232 if (activate_item(any_same_frame)) … … 221 241 } 222 242 223 if (!show_stuff) 224 return 0; 225 226 /* give vectors a second chance */ 227 228 FOR_ALL_INSTS(i, ip_vec, inst) { 229 if (!inst->active) 230 continue; 231 if (!inst_connected(inst)) 232 continue; 233 dist = gui_dist_vec_fallback(inst, pos, draw_ctx.scale); 234 if (dist >= 0 && (!selected_inst || best_dist > dist)) { 235 selected_inst = inst; 236 best_dist = dist; 237 } 238 } 239 240 if (!selected_inst) 241 return 0; 243 return 0; 242 244 243 245 selected: -
trunk/eda/fped/postscript.c
r5522 r5525 53 53 #define PS_DIVIDER_BORDER mm_to_units(2) 54 54 #define PS_DIVIDER_WIDTH mm_to_units(0.5) 55 56 #define PS_MISC_TEXT_HEIGHT mm_to_units(3) 55 57 56 58 #define PS_DOT_DIST mm_to_units(0.03) … … 455 457 fprintf(file, "gsave %d setlinewidth\n", PS_DIVIDER_WIDTH); 456 458 fprintf(file, " %d %d moveto\n", -PAGE_HALF_WIDTH, y); 457 fprintf(file, " %d 0 rlineto stroke g save\n", PAGE_HALF_WIDTH*2);459 fprintf(file, " %d 0 rlineto stroke grestore\n", PAGE_HALF_WIDTH*2); 458 460 } 459 461 … … 489 491 490 492 493 static void ps_unit(FILE *file, 494 unit_type x, unit_type y, unit_type w, unit_type h) 495 { 496 const char *s; 497 498 switch (curr_unit) { 499 case curr_unit_mm: 500 s = "Dimensions in mm"; 501 break; 502 case curr_unit_mil: 503 s = "Dimensions in mil"; 504 break; 505 case curr_unit_auto: 506 return; 507 default: 508 abort(); 509 } 510 511 fprintf(file, "gsave %d %d moveto\n", x, y); 512 fprintf(file, " /Helvetica findfont dup\n"); 513 fprintf(file, " (%s) %d %d\n", s, w, h); 514 fprintf(file, " 4 copy 1000 maxfont maxfont scalefont setfont\n"); 515 fprintf(file, " (%s) show grestore\n", s); 516 } 517 518 491 519 static void ps_package(FILE *file, const struct pkg *pkg, int page) 492 520 { … … 505 533 506 534 bbox = inst_get_bbox(); 507 w = 2*(-bbox.min. y > bbox.max.y ? -bbox.min.y : bbox.max.y);508 h = 2*(-bbox.min. x > bbox.max.x ? -bbox.min.x : bbox.max.x);535 w = 2*(-bbox.min.x > bbox.max.x ? -bbox.min.x : bbox.max.x); 536 h = 2*(-bbox.min.y > bbox.max.y ? -bbox.min.y : bbox.max.y); 509 537 510 538 /* … … 575 603 fprintf(file, "grestore\n"); 576 604 605 ps_unit(file, -PAGE_HALF_WIDTH, PS_DIVIDER_BORDER, PAGE_HALF_WIDTH, 606 PS_MISC_TEXT_HEIGHT); 577 607 ps_hline(file, 0); 578 608
Note: See TracChangeset
for help on using the changeset viewer.
