Changeset 5331
- Timestamp:
- 07/28/09 21:50:12 (4 years ago)
- Location:
- developers/werner/fped
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
developers/werner/fped/Makefile
r5326 r5331 1 OBJS = fped.o expr.o coord.o obj.o inst.o util.o error.o lex.yy.o y.tab.o \ 1 # 2 # Makefile - Makefile of fped, the footprint editor 3 # 4 # Written 2009 by Werner Almesberger 5 # Copyright 2009 by Werner Almesberger 6 # 7 # This program is free software; you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation; either version 2 of the License, or 10 # (at your option) any later version. 11 # 12 13 OBJS = fped.o expr.o coord.o obj.o inst.o util.o error.o \ 14 cpp.o lex.yy.o y.tab.o \ 2 15 gui.o gui_style.o gui_inst.o gui_status.o gui_canvas.o 3 16 … … 5 18 LIBS_GTK = `pkg-config --libs gtk+-2.0` 6 19 7 CFLAGS=-Wall -g $(CFLAGS_GTK) 8 CFLAGS_LEX=-g 9 CFLAGS_YACC=-g 20 CFLAGS_WARN=-Wall -Wshadow -Wmissing-prototypes \ 21 -Wmissing-declarations 22 CFLAGS=-g $(CFLAGS_GTK) -DCPP='"cpp"' $(CFLAGS_WARN) 23 SLOPPY=-Wno-unused -Wno-implicit-function-declaration -Wno-missing-prototypes \ 24 -Wno-missing-declarations 10 25 LDLIBS = -lm -lfl $(LIBS_GTK) 11 26 YACC=bison -y … … 21 36 22 37 lex.yy.o: lex.yy.c y.tab.h 23 $(CC) -c $(CFLAGS _LEX) lex.yy.c38 $(CC) -c $(CFLAGS) $(SLOPPY) lex.yy.c 24 39 25 40 y.tab.c y.tab.h: fpd.y … … 27 42 28 43 y.tab.o: y.tab.c 29 $(CC) -c $(CFLAGS _YACC) y.tab.c44 $(CC) -c $(CFLAGS) $(SLOPPY) y.tab.c 30 45 31 46 # ----- Dependencies ---------------------------------------------------------- -
developers/werner/fped/TODO
r5328 r5331 9 9 - detect recursive evaluation (through variables) 10 10 - eliminate duplicate instances 11 - populate input area 12 - bug: center moves in qfn.fpd 13 - bug: pad and silk geometry doesn't match in qfn.fpd 11 - populate input area (still needed: mm/mil, rezoom) 14 12 - add vec editor 15 13 - add obj editor … … 22 20 - syntax seems a little cryptic. too many dots and at signs. 23 21 - add measurements 24 - add continuous coordinate display25 - add user coordinates. hide if inactive ?26 22 - arc syntax is weird, with comma where we use spaces 23 - Q: allow reassignment of vector names ? 24 - add KiCad output 25 - add postscript output 26 - add option to include/omit helper vecs and frames (display and postscript) -
developers/werner/fped/fpd.y
r5325 r5331 357 357 $$->base = $2; 358 358 $$->u.arc.start = $3; 359 $$->u.arc.end = $ 3;359 $$->u.arc.end = $4 ? $4 : $3; 360 360 } 361 361 | TOK_FRAME ID base -
developers/werner/fped/fped.c
r5325 r5331 12 12 13 13 14 #include <stdarg.h>15 #include <stdlib.h>16 #include <stdio.h>17 #include <unistd.h>18 #include <fcntl.h>19 14 20 15 #include "cpp.h" 21 16 #include "obj.h" 22 17 #include "inst.h" … … 29 24 static void load_file(const char *name) 30 25 { 31 int fd; 32 33 fd = open(name, O_RDONLY); 34 if (fd < 0) { 35 perror(name); 36 exit(1); 37 } 38 if (dup2(fd, 0) < 0) { 39 perror("dup2"); 40 exit(1); 41 } 26 run_cpp_on_file(name); 42 27 (void) yyparse(); 43 28 } -
developers/werner/fped/gui_canvas.c
r5328 r5331 21 21 #include "gui_status.h" 22 22 #include "gui.h" 23 #include "gui_canvas.h" 23 24 24 25 25 26 static struct draw_ctx ctx; 26 27 28 /* ----- zoom display ------------------------------------------------------ */ 27 static struct coord curr_pos; 28 static struct coord user_origin = { 0, 0 }; 29 30 31 /* ----- status display ---------------------------------------------------- */ 29 32 30 33 … … 32 35 { 33 36 status_set_zoom("x%d", ctx.scale); 37 } 38 39 40 static void update_pos(struct coord pos) 41 { 42 status_set_sys_pos("%5.2lf %5.2lf mm", 43 units_to_mm(pos.x), units_to_mm(pos.y)); 44 status_set_user_pos("%5.2lf %5.2lf mm", 45 units_to_mm(pos.x-user_origin.x), units_to_mm(pos.y-user_origin.y)); 34 46 } 35 47 … … 107 119 struct coord pos = canvas_to_coord(&ctx, event->x, event->y); 108 120 121 curr_pos.x = event->x; 122 curr_pos.y = event->y; 109 123 if (event->state & GDK_BUTTON1_MASK) 110 124 drag_left(pos); 111 125 if (event->state & GDK_BUTTON2_MASK) 112 126 drag_middle(pos); 127 update_pos(pos); 113 128 return TRUE; 114 129 } … … 126 141 case 1: 127 142 /* select */ ; 143 break; 128 144 case 2: 129 145 ctx.center = pos; … … 138 154 gpointer data) 139 155 { 140 printf("R %d\n", event->button);141 156 return TRUE; 142 157 } … … 196 211 197 212 213 /* ----- keys -------------------------------------------------------------- */ 214 215 216 static gboolean key_press_event(GtkWidget *widget, GdkEventKey *event, 217 gpointer data) 218 { 219 struct coord pos = canvas_to_coord(&ctx, curr_pos.x, curr_pos.y); 220 221 switch (event->keyval) { 222 case ' ': 223 user_origin = pos; 224 update_pos(pos); 225 break; 226 } 227 return TRUE; 228 } 229 230 198 231 /* ----- expose event ------------------------------------------------------ */ 199 232 … … 213 246 redraw(); 214 247 248 return TRUE; 249 } 250 251 252 /* ----- enter/leave ------------------------------------------------------- */ 253 254 255 static gboolean enter_notify_event(GtkWidget *widget, GdkEventCrossing *event, 256 gpointer data) 257 { 258 gtk_widget_grab_focus(widget); 259 return TRUE; 260 } 261 262 263 static gboolean leave_notify_event(GtkWidget *widget, GdkEventCrossing *event, 264 gpointer data) 265 { 215 266 return TRUE; 216 267 } … … 240 291 G_CALLBACK(scroll_event), NULL); 241 292 293 GTK_WIDGET_SET_FLAGS(canvas, GTK_CAN_FOCUS); 294 295 g_signal_connect(G_OBJECT(canvas), "key_press_event", 296 G_CALLBACK(key_press_event), NULL); 297 242 298 g_signal_connect(G_OBJECT(canvas), "expose_event", 243 299 G_CALLBACK(expose_event), NULL); 300 g_signal_connect(G_OBJECT(canvas), "enter_notify_event", 301 G_CALLBACK(enter_notify_event), NULL); 302 g_signal_connect(G_OBJECT(canvas), "leave_notify_event", 303 G_CALLBACK(leave_notify_event), NULL); 244 304 245 305 gtk_widget_set_events(canvas, 246 GDK_EXPOSE | GDK_LEAVE_NOTIFY_MASK | 306 GDK_EXPOSE | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | 307 GDK_KEY_PRESS_MASK | 247 308 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | 248 309 GDK_SCROLL | -
developers/werner/fped/gui_inst.c
r5328 r5331 57 57 int x, int y, int r, double a1, double a2) 58 58 { 59 gdk_draw_arc(DA, gc, fill, x-r, y-r, 2*r, 2*r, a1*64, a2*64); 59 if (a1 == a2) 60 a2 = a1+360; 61 gdk_draw_arc(DA, gc, fill, x-r, y-r, 2*r, 2*r, a1*64, (a2-a1)*64); 60 62 } 61 63 -
developers/werner/fped/inst.c
r5327 r5331 200 200 201 201 inst = add_inst(&arc_ops, center); 202 r = hypot(start.x-center.x, start.y-center.y);202 r = hypot(start.x-center.x, start.y-center.y); 203 203 a1 = atan2(start.y-center.y, start.x-center.x)/M_PI*180.0; 204 204 a2 = atan2(end.y-center.y, end.x-center.x)/M_PI*180.0; … … 206 206 a1 += 360.0; 207 207 if (a2 < 0) 208 a2 += 2*M_PI;208 a2 += 360.0; 209 209 inst->u.arc.r = r; 210 210 inst->u.arc.a1 = a1; -
developers/werner/fped/qfn.fpd
r5328 r5331 33 33 e = .vec c -0.5mm, 0mm 34 34 .arc c r, e 35 36 r2 = .vec c 0mm, 0.8mm 37 .arc c r2
Note: See TracChangeset
for help on using the changeset viewer.
