Changeset 5404
- Timestamp:
- 08/07/09 23:47:51 (4 years ago)
- Location:
- trunk/eda/fped
- Files:
-
- 2 added
- 17 edited
-
Makefile (modified) (1 diff)
-
README (modified) (1 diff)
-
gui.c (modified) (1 diff)
-
gui_canvas.c (modified) (2 diffs)
-
gui_canvas.h (modified) (1 diff)
-
gui_inst.c (modified) (1 diff)
-
gui_inst.h (modified) (1 diff)
-
gui_style.c (modified) (4 diffs)
-
gui_style.h (modified) (1 diff)
-
gui_tools.c (modified) (6 diffs)
-
icons/meas.fig (modified) (1 diff)
-
icons/meas_x.fig (added)
-
icons/meas_y.fig (added)
-
inst.c (modified) (1 diff)
-
inst.h (modified) (1 diff)
-
meas.c (modified) (7 diffs)
-
meas.h (modified) (2 diffs)
-
obj.c (modified) (2 diffs)
-
obj.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/eda/fped/Makefile
r5403 r5404 18 18 19 19 XPMS = point.xpm delete.xpm vec.xpm frame.xpm frame_locked.xpm frame_ready.xpm \ 20 line.xpm rect.xpm pad.xpm circ.xpm meas.xpm 20 line.xpm rect.xpm pad.xpm circ.xpm meas.xpm meas_x.xpm meas_y.xpm 21 21 22 22 CFLAGS_GTK = `pkg-config --cflags gtk+-2.0` -
trunk/eda/fped/README
r5403 r5404 423 423 make the changes in the input area at the bottom. 424 424 425 To delete an object, select it and press Delete. Deleted objects can426 be undeleted by pressing "u". If any other changes have been made 427 since deletion, fped may misbehave. If deleting a vector, all items 428 that reference it are deleted.425 To delete an object, select the delete tool and click on the object. 426 Deleted objects can be undeleted by pressing "u". If any other changes 427 have been made since deletion, fped may misbehave. If deleting a vector, 428 all items that reference it are deleted as well. 429 429 430 430 -
trunk/eda/fped/gui.c
r5403 r5404 1226 1226 root = gtk_window_new(GTK_WINDOW_TOPLEVEL); 1227 1227 gtk_window_set_position(GTK_WINDOW(root), GTK_WIN_POS_CENTER); 1228 gtk_window_set_default_size(GTK_WINDOW(root), 6 00, 400);1228 gtk_window_set_default_size(GTK_WINDOW(root), 620, 460); 1229 1229 gtk_window_set_title(GTK_WINDOW(root), "fped"); 1230 1230 -
trunk/eda/fped/gui_canvas.c
r5403 r5404 26 26 #include "gui_canvas.h" 27 27 28 29 void (*highlight)(struct draw_ctx *ctx) = NULL; 28 30 29 31 static struct draw_ctx ctx; … … 102 104 aw = ctx.widget->allocation.width; 103 105 ah = ctx.widget->allocation.height; 104 gdk_draw_rectangle(ctx.widget->window, gc_bg, TRUE, 0, 0, aw, ah); 106 gdk_draw_rectangle(ctx.widget->window, 107 instantiation_ok ? gc_bg : gc_bg_error, TRUE, 0, 0, aw, ah); 105 108 106 109 inst_draw(&ctx); 110 if (highlight) 111 highlight(&ctx); 107 112 tool_redraw(&ctx); 108 113 } -
trunk/eda/fped/gui_canvas.h
r5374 r5404 18 18 19 19 20 /* 21 * "highlight" is invoked at the end of each redraw, for optional highlighting 22 * of objects. 23 */ 24 25 extern void (*highlight)(struct draw_ctx *ctx); 26 27 20 28 void redraw(void); 21 29 -
trunk/eda/fped/gui_inst.c
r5400 r5404 157 157 gc = gc_vec[mode_hover]; 158 158 draw_circle(DA, gc, FALSE, center.x, center.y, VEC_EYE_R); 159 } 160 161 162 void gui_highlight_vec(struct inst *self, struct draw_ctx *ctx) 163 { 164 struct coord center = translate(ctx, self->u.rect.end); 165 166 draw_circle(DA, gc_highlight, FALSE, center.x, center.y, VEC_EYE_R); 159 167 } 160 168 -
trunk/eda/fped/gui_inst.h
r5385 r5404 51 51 void gui_draw_frame(struct inst *self, struct draw_ctx *ctx); 52 52 53 void gui_highlight_vec(struct inst *self, struct draw_ctx *ctx); 53 54 void gui_hover_vec(struct inst *self, struct draw_ctx *ctx); 54 55 void gui_hover_frame(struct inst *self, struct draw_ctx *ctx); -
trunk/eda/fped/gui_style.c
r5385 r5404 1 /* 2 * gui_style.c - GUI, style definitions 1 /* * gui_style.c - GUI, style definitions 3 2 * 4 3 * Written 2009 by Werner Almesberger … … 23 22 24 23 25 GdkGC *gc_bg ;24 GdkGC *gc_bg, *gc_bg_error; 26 25 GdkGC *gc_drag; 26 GdkGC *gc_highlight; 27 27 GdkGC *gc_active_frame; 28 28 GdkGC *gc_vec[mode_n]; … … 62 62 { 63 63 gc_bg = gc("#000000", 0); 64 gc_bg_error = gc("#000040", 0); 64 65 gc_drag = gc("#ffffff", 2); 65 66 /* inactive in+path active act+path selected */ … … 70 71 style(gc_meas, "#280040", INVALID, "#ff00ff", INVALID, "#ffff80"); 71 72 style(gc_frame, "#004000", "#205020", "#009000", INVALID, "#ffff80"); 73 72 74 gc_active_frame = gc("#00ff00", 2); 73 75 // gc_highlight = gc("#ff8020", 2); 76 gc_highlight = gc("#ff90d0", 2); 74 77 gc_frame[mode_hover] = gc_vec[mode_hover] = gc("#c00000", 1); 75 78 } -
trunk/eda/fped/gui_style.h
r5401 r5404 89 89 90 90 91 extern GdkGC *gc_bg ;91 extern GdkGC *gc_bg, *gc_bg_error; 92 92 extern GdkGC *gc_drag; 93 extern GdkGC *gc_highlight; 93 94 extern GdkGC *gc_active_frame; 94 95 extern GdkGC *gc_vec[mode_n]; -
trunk/eda/fped/gui_tools.c
r5403 r5404 23 23 #include "gui_style.h" 24 24 #include "gui_inst.h" 25 #include "gui_canvas.h" 25 26 #include "gui_status.h" 26 27 #include "gui.h" … … 34 35 #include "icons/line.xpm" 35 36 #include "icons/meas.xpm" 37 #include "icons/meas_x.xpm" 38 #include "icons/meas_y.xpm" 36 39 #include "icons/pad.xpm" 37 40 #include "icons/point.xpm" … … 46 49 struct tool_ops { 47 50 void (*tool_selected)(void); 51 void (*tool_deselected)(void); 48 52 void (*click)(struct draw_ctx *ctx, struct coord pos); 49 53 struct pix_buf *(*drag_new)(struct draw_ctx *ctx, struct inst *from, … … 518 522 519 523 524 static int meas_x_pick_vec(struct inst *inst, void *ctx) 525 { 526 struct vec *vec = inst->vec; 527 struct coord min; 528 529 if (!vec->samples) 530 return 0; 531 min = meas_find_min(lt_xy, vec->samples); 532 return inst->u.rect.end.x == min.x && inst->u.rect.end.y == min.y; 533 } 534 535 536 static void highlight_vecs(struct draw_ctx *ctx) 537 { 538 inst_highlight_vecs(ctx, meas_x_pick_vec, NULL); 539 } 540 541 542 static void tool_selected_meas_x(void) 543 { 544 highlight = highlight_vecs; 545 redraw(); 546 } 547 548 549 static void tool_selected_meas_y(void) 550 { 551 highlight = NULL; 552 redraw(); 553 } 554 555 556 static void tool_deselected_meas(void) 557 { 558 highlight = NULL; 559 redraw(); 560 } 561 562 520 563 static struct tool_ops meas_ops = { 564 .drag_new = drag_new_line, 565 .end_new = end_new_meas, 566 }; 567 568 static struct tool_ops meas_ops_x = { 569 .tool_selected = tool_selected_meas_x, 570 .tool_deselected= tool_deselected_meas, 571 .drag_new = drag_new_line, 572 .end_new = end_new_meas, 573 }; 574 static struct tool_ops meas_ops_y = { 575 .tool_selected = tool_selected_meas_y, 576 .tool_deselected= tool_deselected_meas, 521 577 .drag_new = drag_new_line, 522 578 .end_new = end_new_meas, … … 829 885 830 886 if (active_tool) { 887 if (active_ops && active_ops->tool_deselected) 888 active_ops->tool_deselected(); 831 889 col = get_color(TOOL_UNSELECTED); 832 890 gtk_widget_modify_bg(active_tool, GTK_STATE_NORMAL, &col); … … 941 999 last = tool_button(bar, drawable, xpm_rect, last, &rect_ops); 942 1000 last = tool_button(bar, drawable, xpm_circ, last, &circ_ops); 1001 tool_separator(bar); 943 1002 last = tool_button(bar, drawable, xpm_meas, last, &meas_ops); 1003 last = tool_button(bar, drawable, xpm_meas_x, last, &meas_ops_x); 1004 last = tool_button(bar, drawable, xpm_meas_y, last, &meas_ops_y); 944 1005 945 1006 frame_image = gtk_widget_ref(make_image(drawable, xpm_frame)); -
trunk/eda/fped/icons/meas.fig
r5363 r5404 11 11 3600 2400 6000 2400 6000 4800 3600 4800 3600 2400 12 12 2 1 0 10 21 7 50 -1 -1 0.000 0 0 -1 0 0 2 13 3900 3300 3900 3900 14 2 1 0 10 21 7 50 -1 -1 0.000 0 0 -1 0 0 2 15 5700 3300 5700 3900 13 3900 3600 4200 4200 16 14 2 1 0 10 21 7 50 -1 -1 0.000 0 0 -1 1 1 2 17 15 0 0 10.00 450.00 450.00 18 16 0 0 10.00 450.00 450.00 19 3900 3600 5700 3600 17 4050 3900 5550 3150 18 2 1 0 10 21 7 50 -1 -1 0.000 0 0 -1 0 0 2 19 5400 2850 5700 3450 -
trunk/eda/fped/inst.c
r5403 r5404 842 842 843 843 844 void inst_highlight_vecs(struct draw_ctx *ctx, 845 int (*pick)(struct inst *inst, void *user), void *user) 846 { 847 struct inst *inst; 848 849 for (inst = insts[ip_vec]; inst; inst = inst->next) 850 if (pick(inst, user)) 851 gui_highlight_vec(inst, ctx); 852 } 853 854 844 855 struct pix_buf *inst_draw_move(struct inst *inst, struct draw_ctx *ctx, 845 856 struct coord pos, int i) -
trunk/eda/fped/inst.h
r5400 r5404 115 115 116 116 void inst_draw(struct draw_ctx *ctx); 117 void inst_highlight_vecs(struct draw_ctx *ctx, 118 int (*pick)(struct inst *inst, void *user), void *user); 117 119 struct pix_buf *inst_draw_move(struct inst *inst, struct draw_ctx *ctx, 118 120 struct coord pos, int i); -
trunk/eda/fped/meas.c
r5400 r5404 76 76 77 77 78 staticint lt_x(struct coord a, struct coord b)78 int lt_x(struct coord a, struct coord b) 79 79 { 80 80 return a.x < b.x; … … 82 82 83 83 84 staticint lt_y(struct coord a, struct coord b)84 int lt_y(struct coord a, struct coord b) 85 85 { 86 86 return a.y < b.y; … … 88 88 89 89 90 staticint lt_xy(struct coord a, struct coord b)90 int lt_xy(struct coord a, struct coord b) 91 91 { 92 92 return a.y < b.y || (a.y == b.y && a.x < b.x); … … 94 94 95 95 96 static int (*lt_op[mt_n])(struct coord a, struct coord b)= {96 static lt_op_type lt_op[mt_n] = { 97 97 lt_xy, 98 98 lt_x, … … 110 110 111 111 112 static int better_next( int (*lt)(struct coord a, struct coord b),112 static int better_next(lt_op_type lt, 113 113 struct coord a0, struct coord b0, struct coord b) 114 114 { … … 144 144 145 145 146 /* 147 * In order to obtain a stable order, we sort points equal on the measured 148 * coordinate also by xy: 149 * 150 * if (*a < a0) use *a 151 * else if (*a == a0 && *a <xy a0) use *a 152 */ 153 154 struct coord meas_find_min(lt_op_type lt, const struct sample *s) 155 { 156 struct coord min; 157 158 min = s->pos; 159 while (s) { 160 if (lt(s->pos, min) || 161 (!lt(min, s->pos) && lt_xy(s->pos, min))) 162 min = s->pos; 163 s = s->next; 164 } 165 return min; 166 } 167 168 169 struct coord meas_find_next(lt_op_type lt, const struct sample *s, 170 struct coord ref) 171 { 172 struct coord next; 173 174 next = s->pos; 175 while (s) { 176 if (better_next(lt, ref, next, s->pos)) 177 next = s->pos; 178 s = s->next; 179 } 180 return next; 181 } 182 183 184 struct coord meas_find_max(lt_op_type lt, const struct sample *s) 185 { 186 struct coord max; 187 188 max = s->pos; 189 while (s) { 190 if (lt(max, s->pos) || 191 (!lt(s->pos, max) && lt_xy(max, s->pos))) 192 max = s->pos; 193 s = s->next; 194 } 195 return max; 196 } 197 198 146 199 int instantiate_meas(void) 147 200 { 148 201 struct meas *meas; 149 202 struct coord a0, b0; 150 const struct sample *a, *b; 151 int (*lt)(struct coord a, struct coord b); 203 lt_op_type lt; 152 204 struct num offset; 153 205 … … 157 209 158 210 lt = lt_op[meas->type]; 159 160 /* 161 * In order to obtain a stable order, we sort points equal on 162 * the measured coordinate also by xy: 163 * 164 * if (*a < a0) use *a 165 * else if (*a == a0 && *a <xy a0) use *a 166 */ 167 a0 = meas->low->samples->pos; 168 for (a = meas->low->samples; a; a = a->next) 169 if (lt(a->pos, a0) || 170 (!lt(a0, a->pos) && lt_xy(a->pos, a0))) 171 a0 = a->pos; 172 173 b0 = meas->high->samples->pos; 174 for (b = meas->high->samples; b; b = b->next) { 175 if (is_next[meas->type]) { 176 if (better_next(lt, a0, b0, b->pos)) 177 b0 = b->pos; 178 } else { 179 if (lt(b0, b->pos) || 180 (!lt(b->pos, b0) && lt_xy(b0, b->pos))) 181 b0 = b->pos; 182 } 183 } 211 a0 = meas_find_min(lt, meas->low->samples); 212 if (is_next[meas->type]) 213 b0 = meas_find_next(lt, meas->high->samples, a0); 214 else 215 b0 = meas_find_max(lt, meas->high->samples); 184 216 185 217 offset = eval_unit(meas->offset, root_frame); -
trunk/eda/fped/meas.h
r5400 r5404 16 16 17 17 #include "obj.h" 18 19 20 typedef int (*lt_op_type)(struct coord a, struct coord b); 18 21 19 22 … … 36 39 }; 37 40 41 struct sample; 42 38 43 39 44 extern struct meas *measurements; 40 45 46 47 int lt_x(struct coord a, struct coord b); 48 int lt_y(struct coord a, struct coord b); 49 int lt_xy(struct coord a, struct coord b); 50 51 struct coord meas_find_min(lt_op_type lt, const struct sample *s); 52 struct coord meas_find_next(lt_op_type lt, const struct sample *s, 53 struct coord ref); 54 struct coord meas_find_max(lt_op_type lt, const struct sample *s); 41 55 42 56 void meas_start(void); -
trunk/eda/fped/obj.c
r5400 r5404 33 33 struct frame *root_frame = NULL; 34 34 struct frame *active_frame = NULL; 35 int instantiation_ok; 35 36 36 37 … … 274 275 else 275 276 inst_revert(); 277 instantiation_ok = ok; 276 278 return ok; 277 279 } -
trunk/eda/fped/obj.h
r5400 r5404 182 182 extern struct frame *root_frame; 183 183 extern struct frame *active_frame; 184 extern int instantiation_ok; 184 185 185 186
Note: See TracChangeset
for help on using the changeset viewer.
