Date: | 2010-04-25 12:58:07 (13 years 11 months ago) |
---|---|
Author: | werner |
Commit: | 1dda2ac2aee9a4177e49ebd3deb32a9d4e7e754d |
Message: | When creating an object in the GUI, its label wasn't initialized.
Added infrastructure for hole objects. (Postscript and KiCad output
are still missing, and so does sanity checking.) - gui_tool.c (new_obj_unconnected): set obj->name to NULL - added hole objects to tool bar, all the various GUI routines, the .fpd parser, and the .fpd dumper git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5939 99fdad57-331a-0410-800a-d7fa5415bdb3 |
Files: |
Makefile (1 diff) delete.c (3 diffs) dump.c (2 diffs) fpd.l (1 diff) fpd.y (2 diffs) gui_inst.c (3 diffs) gui_inst.h (3 diffs) gui_style.c (3 diffs) gui_style.h (1 diff) gui_tool.c (5 diffs) gui_tool.h (1 diff) icons/hole.fig (1 diff) inst.c (1 diff) inst.h (3 diffs) obj.c (2 diffs) obj.h (3 diffs) |
Change Details
Makefile | ||
---|---|---|
23 | 23 | |
24 | 24 | XPMS = point.xpm delete.xpm delete_off.xpm \ |
25 | 25 | vec.xpm frame.xpm \ |
26 | line.xpm rect.xpm pad.xpm rpad.xpm arc.xpm circ.xpm \ | |
26 | line.xpm rect.xpm pad.xpm rpad.xpm hole.xpm arc.xpm circ.xpm \ | |
27 | 27 | meas.xpm meas_x.xpm meas_y.xpm \ |
28 | 28 | stuff.xpm stuff_off.xpm meas_off.xpm \ |
29 | 29 | bright.xpm bright_off.xpm all.xpm all_off.xpm |
delete.c | ||
---|---|---|
1 | 1 | /* |
2 | 2 | * delete.c - Object deletion |
3 | 3 | * |
4 | * Written 2009 by Werner Almesberger | |
5 | * Copyright 2009 by Werner Almesberger | |
4 | * Written 2009, 2010 by Werner Almesberger | |
5 | * Copyright 2009, 2010 by Werner Almesberger | |
6 | 6 | * |
7 | 7 | * This program is free software; you can redistribute it and/or modify |
8 | 8 | * it under the terms of the GNU General Public License as published by |
... | ... | |
137 | 137 | return obj->u.rect.other == ref; |
138 | 138 | case ot_pad: |
139 | 139 | return obj->u.pad.other == ref; |
140 | case ot_hole: | |
141 | return obj->u.hole.other == ref; | |
140 | 142 | case ot_arc: |
141 | 143 | return obj->u.arc.start == ref || obj->u.arc.end == ref; |
142 | 144 | case ot_meas: |
... | ... | |
210 | 212 | case ot_pad: |
211 | 213 | free(obj->u.pad.name); |
212 | 214 | break; |
215 | case ot_hole: | |
216 | break; | |
213 | 217 | case ot_line: |
214 | 218 | if (obj->u.line.width) |
215 | 219 | free_expr(obj->u.line.width); |
dump.c | ||
---|---|---|
111 | 111 | n |= need(obj->u.pad.other, prev); |
112 | 112 | l |= later(obj->u.pad.other, prev); |
113 | 113 | break; |
114 | case ot_hole: | |
115 | n |= need(obj->u.hole.other, prev); | |
116 | l |= later(obj->u.hole.other, prev); | |
117 | break; | |
114 | 118 | case ot_arc: |
115 | 119 | n |= need(obj->u.arc.start, prev); |
116 | 120 | n |= need(obj->u.arc.end, prev); |
... | ... | |
352 | 356 | obj->u.pad.rounded ? "r" : "", |
353 | 357 | obj->u.pad.name, base, s1, s2); |
354 | 358 | break; |
359 | case ot_hole: | |
360 | s1 = obj_base_name(obj->u.hole.other, prev); | |
361 | s = stralloc_printf("hole %s %s", base, s1); | |
362 | break; | |
355 | 363 | case ot_arc: |
356 | 364 | s1 = obj_base_name(obj->u.arc.start, prev); |
357 | 365 | s2 = unparse(obj->u.arc.width); |
fpd.l | ||
---|---|---|
104 | 104 | return TOK_PAD; } |
105 | 105 | <INITIAL>"rpad" { BEGIN(NOKEYWORD); |
106 | 106 | return TOK_RPAD; } |
107 | <INITIAL>"hole" { BEGIN(NOKEYWORD); | |
108 | return TOK_HOLE; } | |
107 | 109 | <INITIAL>"rect" { BEGIN(NOKEYWORD); |
108 | 110 | return TOK_RECT; } |
109 | 111 | <INITIAL>"line" { BEGIN(NOKEYWORD); |
fpd.y | ||
---|---|---|
285 | 285 | |
286 | 286 | %token START_FPD START_EXPR START_VAR START_VALUES |
287 | 287 | %token TOK_SET TOK_LOOP TOK_PACKAGE TOK_FRAME TOK_TABLE TOK_VEC |
288 | %token TOK_PAD TOK_RPAD TOK_RECT TOK_LINE TOK_CIRC TOK_ARC | |
288 | %token TOK_PAD TOK_RPAD TOK_HOLE TOK_RECT TOK_LINE TOK_CIRC TOK_ARC | |
289 | 289 | %token TOK_MEAS TOK_MEASX TOK_MEASY TOK_UNIT |
290 | 290 | %token TOK_NEXT TOK_NEXT_INVERTED TOK_MAX TOK_MAX_INVERTED |
291 | 291 | %token TOK_DBG_DEL TOK_DBG_MOVE TOK_DBG_PRINT TOK_DBG_DUMP |
... | ... | |
653 | 653 | $$->u.pad.rounded = 1; |
654 | 654 | $$->u.pad.type = $5; |
655 | 655 | } |
656 | | TOK_HOLE base base | |
657 | { | |
658 | $$ = new_obj(ot_hole); | |
659 | $$->base = $2; | |
660 | $$->u.hole.other = $3; | |
661 | } | |
656 | 662 | | TOK_RECT base base opt_expr |
657 | 663 | { |
658 | 664 | $$ = new_obj(ot_rect); |
gui_inst.c | ||
---|---|---|
1 | 1 | /* |
2 | 2 | * gui_inst.c - GUI, instance functions |
3 | 3 | * |
4 | * Written 2009 by Werner Almesberger | |
5 | * Copyright 2009 by Werner Almesberger | |
4 | * Written 2009, 2010 by Werner Almesberger | |
5 | * Copyright 2009, 2010 by Werner Almesberger | |
6 | 6 | * |
7 | 7 | * This program is free software; you can redistribute it and/or modify |
8 | 8 | * it under the terms of the GNU General Public License as published by |
... | ... | |
288 | 288 | } |
289 | 289 | |
290 | 290 | |
291 | void gui_draw_rpad(struct inst *self) | |
291 | static void draw_rounded_rect(GdkGC *gc, struct coord a, struct coord b, | |
292 | int fill) | |
292 | 293 | { |
293 | struct coord min = translate(self->base); | |
294 | struct coord max = translate(self->u.pad.other); | |
295 | GdkGC *gc; | |
296 | int fill; | |
294 | struct coord min = translate(a); | |
295 | struct coord max = translate(b); | |
297 | 296 | unit_type h, w, r; |
298 | 297 | |
299 | gc = pad_gc(self, &fill); | |
300 | 298 | sort_coord(&min, &max); |
301 | 299 | h = max.y-min.y; |
302 | 300 | w = max.x-min.x; |
... | ... | |
323 | 321 | } |
324 | 322 | draw_arc(DA, gc, fill, max.x-r, min.y+r, r, 270, 90); |
325 | 323 | } |
324 | } | |
326 | 325 | |
326 | ||
327 | void gui_draw_rpad(struct inst *self) | |
328 | { | |
329 | GdkGC *gc; | |
330 | int fill; | |
331 | ||
332 | gc = pad_gc(self, &fill); | |
333 | draw_rounded_rect(gc, self->base, self->u.pad.other, fill); | |
327 | 334 | gui_draw_pad_text(self); |
328 | 335 | } |
329 | 336 | |
330 | 337 | |
338 | /* ----- hole -------------------------------------------------------------- */ | |
339 | ||
340 | ||
341 | unit_type gui_dist_hole(struct inst *self, struct coord pos, unit_type scale) | |
342 | { | |
343 | unit_type d; | |
344 | ||
345 | /* @@@ not quite right ... */ | |
346 | if (inside_rect(pos, self->base, self->u.hole.other)) | |
347 | return SELECT_R; | |
348 | d = dist_rect(pos, self->base, self->u.hole.other)/scale; | |
349 | return d > SELECT_R ? -1 : d; | |
350 | } | |
351 | ||
352 | ||
353 | void gui_draw_hole(struct inst *self) | |
354 | { | |
355 | draw_rounded_rect(gc_hole[get_mode(self)], | |
356 | self->base, self->u.hole.other, 1); | |
357 | draw_rounded_rect(gc_rim[get_mode(self)], | |
358 | self->base, self->u.hole.other, 0); | |
359 | } | |
360 | ||
361 | ||
331 | 362 | /* ----- arc --------------------------------------------------------------- */ |
332 | 363 | |
333 | 364 |
gui_inst.h | ||
---|---|---|
1 | 1 | /* |
2 | 2 | * gui_inst.h - GUI, instance functions |
3 | 3 | * |
4 | * Written 2009 by Werner Almesberger | |
5 | * Copyright 2009 by Werner Almesberger | |
4 | * Written 2009, 2010 by Werner Almesberger | |
5 | * Copyright 2009, 2010 by Werner Almesberger | |
6 | 6 | * |
7 | 7 | * This program is free software; you can redistribute it and/or modify |
8 | 8 | * it under the terms of the GNU General Public License as published by |
... | ... | |
30 | 30 | unit_type gui_dist_line(struct inst *self, struct coord pos, unit_type scale); |
31 | 31 | unit_type gui_dist_rect(struct inst *self, struct coord pos, unit_type scale); |
32 | 32 | unit_type gui_dist_pad(struct inst *self, struct coord pos, unit_type scale); |
33 | unit_type gui_dist_hole(struct inst *self, struct coord pos, unit_type scale); | |
33 | 34 | unit_type gui_dist_arc(struct inst *self, struct coord pos, unit_type scale); |
34 | 35 | unit_type gui_dist_meas(struct inst *self, struct coord pos, unit_type scale); |
35 | 36 | unit_type gui_dist_frame(struct inst *self, struct coord pos, unit_type scale); |
... | ... | |
44 | 45 | void gui_draw_rect(struct inst *self); |
45 | 46 | void gui_draw_pad(struct inst *self); |
46 | 47 | void gui_draw_rpad(struct inst *self); |
48 | void gui_draw_hole(struct inst *self); | |
47 | 49 | void gui_draw_arc(struct inst *self); |
48 | 50 | void gui_draw_meas(struct inst *self); |
49 | 51 | void gui_draw_frame(struct inst *self); |
gui_style.c | ||
---|---|---|
1 | 1 | /* * gui_style.c - GUI, style definitions |
2 | 2 | * |
3 | * Written 2009 by Werner Almesberger | |
4 | * Copyright 2009 by Werner Almesberger | |
3 | * Written 2009, 2010 by Werner Almesberger | |
4 | * Copyright 2009, 2010 by Werner Almesberger | |
5 | 5 | * |
6 | 6 | * This program is free software; you can redistribute it and/or modify |
7 | 7 | * it under the terms of the GNU General Public License as published by |
... | ... | |
28 | 28 | GdkGC *gc_pad_bare[mode_n]; |
29 | 29 | GdkGC *gc_pad_mask[mode_n]; |
30 | 30 | GdkGC *gc_ptext[mode_n]; |
31 | GdkGC *gc_rim[mode_n]; | |
32 | GdkGC *gc_hole[mode_n]; | |
31 | 33 | GdkGC *gc_meas[mode_n]; |
32 | 34 | GdkGC *gc_frame[mode_n]; |
33 | 35 | |
... | ... | |
61 | 63 | gc_bg = gc("#000000", 0); |
62 | 64 | gc_bg_error = gc("#000040", 0); |
63 | 65 | gc_drag = gc("#ffffff", 2); |
64 | /* inactive active selected */ | |
66 | /* inactive active selected width */ | |
65 | 67 | style(gc_vec, "#202000", "#b0b050", "#ffff80", 1); |
66 | 68 | style(gc_obj, "#006060", "#00ffff", "#ffff80", 1); |
67 | 69 | style(gc_pad, "#400000", "#ff0000", "#ffff80", 1); |
68 | 70 | style(gc_pad_bare, "#402000", "#ff6000", "#ffff80", 1); |
69 | 71 | style(gc_pad_mask, "#000040", "#0000ff", "#ffff80", 2); |
70 | 72 | style(gc_ptext, "#404040", "#ffffff", "#ffffff", 1); |
73 | style(gc_hole, "#000000", "#000000", "#000000", 0); | |
74 | style(gc_rim, "#202020", "#606060", "#ffff80", 3); | |
71 | 75 | style(gc_meas, "#280040", "#ff00ff", "#ffff80", 1); |
72 | 76 | style(gc_frame, "#005000", "#009000", "#ffff80", 1); |
73 | 77 |
gui_style.h | ||
---|---|---|
116 | 116 | extern GdkGC *gc_pad_bare[mode_n]; |
117 | 117 | extern GdkGC *gc_pad_mask[mode_n]; |
118 | 118 | extern GdkGC *gc_ptext[mode_n]; |
119 | extern GdkGC *gc_rim[mode_n]; | |
120 | extern GdkGC *gc_hole[mode_n]; | |
119 | 121 | extern GdkGC *gc_meas[mode_n]; |
120 | 122 | extern GdkGC *gc_frame[mode_n]; |
121 | 123 |
gui_tool.c | ||
---|---|---|
40 | 40 | #include "icons/meas_y.xpm" |
41 | 41 | #include "icons/pad.xpm" |
42 | 42 | #include "icons/rpad.xpm" |
43 | #include "icons/hole.xpm" | |
43 | 44 | #include "icons/point.xpm" |
44 | 45 | #include "icons/delete.xpm" |
45 | 46 | #include "icons/delete_off.xpm" |
... | ... | |
88 | 89 | |
89 | 90 | obj = alloc_type(struct obj); |
90 | 91 | obj->type = type; |
92 | obj->name = NULL; | |
91 | 93 | obj->frame = active_frame; |
92 | 94 | obj->base = inst_get_vec(base); |
93 | 95 | obj->next = NULL; |
... | ... | |
459 | 461 | }; |
460 | 462 | |
461 | 463 | |
464 | /* ----- hole -------------------------------------------------------------- */ | |
465 | ||
466 | ||
467 | static int end_new_hole(struct inst *from, struct inst *to) | |
468 | { | |
469 | struct obj *obj; | |
470 | ||
471 | if (from == to) | |
472 | return 0; | |
473 | obj = new_obj(ot_hole, from); | |
474 | obj->u.hole.other = inst_get_vec(to); | |
475 | return 1; | |
476 | } | |
477 | ||
478 | ||
479 | struct pix_buf *draw_move_hole(struct inst *inst, struct coord pos, int i) | |
480 | { | |
481 | return draw_move_rect_common(inst, inst->u.hole.other, pos, i); | |
482 | } | |
483 | ||
484 | ||
485 | static struct tool_ops hole_ops = { | |
486 | .drag_new = drag_new_rect, | |
487 | .end_new = end_new_hole, | |
488 | }; | |
489 | ||
490 | ||
462 | 491 | /* ----- circ -------------------------------------------------------------- */ |
463 | 492 | |
464 | 493 | |
... | ... | |
1049 | 1078 | case ip_pad_special: |
1050 | 1079 | image = inst->obj->u.pad.rounded ? xpm_rpad : xpm_pad; |
1051 | 1080 | break; |
1081 | case ip_hole: | |
1082 | image = xpm_hole; | |
1083 | break; | |
1052 | 1084 | case ip_circ: |
1053 | 1085 | image = xpm_circ; |
1054 | 1086 | break; |
... | ... | |
1166 | 1198 | tool_button(bar, drawable, xpm_rpad, |
1167 | 1199 | "Add a rounded pad", |
1168 | 1200 | tool_button_press_event, &rpad_ops); |
1201 | tool_button(bar, drawable, xpm_hole, | |
1202 | "Add a hole", | |
1203 | tool_button_press_event, &hole_ops); | |
1169 | 1204 | tool_button(bar, drawable, xpm_line, |
1170 | 1205 | "Add a silk screen line", |
1171 | 1206 | tool_button_press_event, &line_ops); |
gui_tool.h | ||
---|---|---|
36 | 36 | struct pix_buf *draw_move_rect(struct inst *inst, struct coord pos, int i); |
37 | 37 | struct pix_buf *draw_move_pad(struct inst *inst, struct coord pos, int i); |
38 | 38 | struct pix_buf *draw_move_rpad(struct inst *inst, struct coord pos, int i); |
39 | struct pix_buf *draw_move_hole(struct inst *inst, struct coord pos, int i); | |
39 | 40 | struct pix_buf *draw_move_arc(struct inst *inst, struct coord pos, int i); |
40 | 41 | struct pix_buf *draw_move_meas(struct inst *inst, struct coord pos, int i); |
41 | 42 | struct pix_buf *draw_move_frame(struct inst *inst, struct coord pos, int i); |
icons/hole.fig | ||
---|---|---|
1 | #FIG 3.2 Produced by xfig version 3.2.5a | |
2 | Landscape | |
3 | Center | |
4 | Inches | |
5 | A4 | |
6 | 100.00 | |
7 | Single | |
8 | -2 | |
9 | 1200 2 | |
10 | 6 3600 2400 6000 4800 | |
11 | 1 3 0 8 0 7 45 -1 20 0.000 1 0.0000 4800 3600 600 600 4800 3600 5400 3600 | |
12 | 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 | |
13 | 3600 2400 6000 2400 6000 4800 3600 4800 3600 2400 | |
14 | 2 1 0 5 0 7 50 -1 20 0.000 0 1 -1 0 0 2 | |
15 | 3900 4500 5700 2700 | |
16 | 2 1 0 5 0 7 50 -1 20 0.000 0 1 -1 0 0 2 | |
17 | 3900 3900 5100 2700 | |
18 | 2 1 0 5 0 7 50 -1 20 0.000 0 1 -1 0 0 2 | |
19 | 3900 3300 4500 2700 | |
20 | 2 1 0 5 0 7 50 -1 20 0.000 0 1 -1 0 0 2 | |
21 | 4500 4500 5700 3300 | |
22 | 2 1 0 5 0 7 50 -1 20 0.000 0 1 -1 0 0 2 | |
23 | 5100 4500 5700 3900 | |
24 | -6 |
inst.c | ||
---|---|---|
909 | 909 | } |
910 | 910 | |
911 | 911 | |
912 | /* ----- hole -------------------------------------------------------------- */ | |
913 | ||
914 | ||
915 | static void hole_op_select(struct inst *self) | |
916 | { | |
917 | rect_status_sort(self->base, self->u.hole.other, -1, 1); | |
918 | } | |
919 | ||
920 | ||
921 | static struct inst_ops hole_ops = { | |
922 | .draw = gui_draw_hole, | |
923 | .distance = gui_dist_hole, | |
924 | .select = hole_op_select, | |
925 | .draw_move = draw_move_hole, | |
926 | }; | |
927 | ||
928 | ||
929 | int inst_hole(struct obj *obj, struct coord a, struct coord b) | |
930 | { | |
931 | struct inst *inst; | |
932 | ||
933 | inst = add_inst(&hole_ops, ip_hole, a); | |
934 | inst->obj = obj; | |
935 | inst->u.hole.other = b; | |
936 | find_inst(inst); | |
937 | update_bbox(&inst->bbox, b); | |
938 | propagate_bbox(inst); | |
939 | return 1; | |
940 | } | |
941 | ||
942 | ||
912 | 943 | /* ----- arc --------------------------------------------------------------- */ |
913 | 944 | |
914 | 945 |
inst.h | ||
---|---|---|
40 | 40 | ip_frame, /* frames have their own selection */ |
41 | 41 | ip_pad_copper, /* pads also accept clicks inside; pads with copper */ |
42 | 42 | ip_pad_special, /* pads with only solder paste or mask, on top */ |
43 | ip_hole, /* holes in pads must be on top to be seen */ | |
43 | 44 | ip_circ, /* circles don't overlap easily */ |
44 | 45 | ip_arc, /* arcs are like circles, just shorter */ |
45 | 46 | ip_rect, /* rectangles have plenty of sides */ |
... | ... | |
99 | 100 | layer_type layers; /* bit-set of layers */ |
100 | 101 | } pad; |
101 | 102 | struct { |
103 | struct coord other; | |
104 | } hole; | |
105 | struct { | |
102 | 106 | unit_type r; |
103 | 107 | double a1, a2; |
104 | 108 | unit_type width; |
... | ... | |
173 | 177 | int inst_line(struct obj *obj, struct coord a, struct coord b, unit_type width); |
174 | 178 | int inst_rect(struct obj *obj, struct coord a, struct coord b, unit_type width); |
175 | 179 | int inst_pad(struct obj *obj, const char *name, struct coord a, struct coord b); |
180 | int inst_hole(struct obj *obj, struct coord a, struct coord b); | |
176 | 181 | int inst_arc(struct obj *obj, struct coord center, struct coord start, |
177 | 182 | struct coord stop, unit_type width); |
178 | 183 | int inst_meas(struct obj *obj, struct coord from, struct coord to); |
obj.c | ||
---|---|---|
112 | 112 | case ot_pad: |
113 | 113 | anchors[1] = &obj->u.pad.other; |
114 | 114 | return 2; |
115 | case ot_hole: | |
116 | anchors[1] = &obj->u.hole.other; | |
117 | return 2; | |
115 | 118 | case ot_meas: |
116 | 119 | anchors[1] = &obj->u.meas.high; |
117 | 120 | return 2; |
... | ... | |
234 | 237 | if (!ok) |
235 | 238 | goto error; |
236 | 239 | break; |
240 | case ot_hole: | |
241 | if (!inst_hole(obj, obj->base ? obj->base->pos : base, | |
242 | obj->u.hole.other ? obj->u.hole.other->pos : base)) | |
243 | goto error; | |
244 | break; | |
237 | 245 | case ot_arc: |
238 | 246 | width = eval_unit_default(obj->u.arc.width, frame, |
239 | 247 | DEFAULT_SILK_WIDTH); |
obj.h | ||
---|---|---|
178 | 178 | ot_frame, |
179 | 179 | ot_rect, |
180 | 180 | ot_pad, |
181 | ot_hole, | |
181 | 182 | ot_line, |
182 | 183 | ot_arc, |
183 | 184 | ot_meas, |
... | ... | |
200 | 201 | enum pad_type type; |
201 | 202 | }; |
202 | 203 | |
204 | struct hole { | |
205 | struct vec *other; /* NULL if frame origin */ | |
206 | }; | |
207 | ||
203 | 208 | struct arc { |
204 | 209 | struct vec *start; /* NULL if frame origin */ |
205 | 210 | struct vec *end; /* NULL if this is a circle */ |
... | ... | |
214 | 219 | struct rect rect; |
215 | 220 | struct rect line; |
216 | 221 | struct pad pad; |
222 | struct hole hole; | |
217 | 223 | struct arc arc; |
218 | 224 | struct meas meas; |
219 | 225 | } u; |
Branches:
master