Changeset 5331


Ignore:
Timestamp:
07/28/09 21:50:12 (4 years ago)
Author:
werner
Message:
  • added continuous coordinate display and user coordinates
  • corrected calculation of second angle in arc
  • circles were stored and rendered incorrectly
  • we now run CPP on the input file
  • enabled more compiler warnings
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 
     13OBJS = fped.o expr.o coord.o obj.o inst.o util.o error.o \ 
     14       cpp.o lex.yy.o y.tab.o \ 
    215       gui.o gui_style.o gui_inst.o gui_status.o gui_canvas.o 
    316 
     
    518LIBS_GTK = `pkg-config --libs gtk+-2.0` 
    619 
    7 CFLAGS=-Wall -g $(CFLAGS_GTK) 
    8 CFLAGS_LEX=-g 
    9 CFLAGS_YACC=-g 
     20CFLAGS_WARN=-Wall -Wshadow -Wmissing-prototypes \ 
     21            -Wmissing-declarations 
     22CFLAGS=-g $(CFLAGS_GTK) -DCPP='"cpp"' $(CFLAGS_WARN) 
     23SLOPPY=-Wno-unused -Wno-implicit-function-declaration -Wno-missing-prototypes \ 
     24       -Wno-missing-declarations 
    1025LDLIBS = -lm -lfl $(LIBS_GTK) 
    1126YACC=bison -y 
     
    2136 
    2237lex.yy.o:       lex.yy.c y.tab.h 
    23                 $(CC) -c $(CFLAGS_LEX) lex.yy.c 
     38                $(CC) -c $(CFLAGS) $(SLOPPY) lex.yy.c 
    2439 
    2540y.tab.c y.tab.h: fpd.y 
     
    2742 
    2843y.tab.o:        y.tab.c 
    29                 $(CC) -c $(CFLAGS_YACC) y.tab.c 
     44                $(CC) -c $(CFLAGS) $(SLOPPY) y.tab.c 
    3045 
    3146# ----- Dependencies ---------------------------------------------------------- 
  • developers/werner/fped/TODO

    r5328 r5331  
    99- detect recursive evaluation (through variables) 
    1010- 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) 
    1412- add vec editor 
    1513- add obj editor 
     
    2220- syntax seems a little cryptic. too many dots and at signs. 
    2321- add measurements 
    24 - add continuous coordinate display 
    25 - add user coordinates. hide if inactive ? 
    2622- 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  
    357357                        $$->base = $2; 
    358358                        $$->u.arc.start = $3; 
    359                         $$->u.arc.end = $3; 
     359                        $$->u.arc.end = $4 ? $4 : $3; 
    360360                } 
    361361        | TOK_FRAME ID base 
  • developers/werner/fped/fped.c

    r5325 r5331  
    1212 
    1313 
    14 #include <stdarg.h> 
    15 #include <stdlib.h> 
    16 #include <stdio.h> 
    17 #include <unistd.h> 
    18 #include <fcntl.h> 
    1914 
    20  
     15#include "cpp.h" 
    2116#include "obj.h" 
    2217#include "inst.h" 
     
    2924static void load_file(const char *name) 
    3025{ 
    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); 
    4227        (void) yyparse(); 
    4328} 
  • developers/werner/fped/gui_canvas.c

    r5328 r5331  
    2121#include "gui_status.h" 
    2222#include "gui.h" 
     23#include "gui_canvas.h" 
    2324 
    2425 
    2526static struct draw_ctx ctx; 
    26  
    27  
    28 /* ----- zoom display ------------------------------------------------------ */ 
     27static struct coord curr_pos; 
     28static struct coord user_origin = { 0, 0 }; 
     29 
     30 
     31/* ----- status display ---------------------------------------------------- */ 
    2932 
    3033 
     
    3235{ 
    3336        status_set_zoom("x%d", ctx.scale); 
     37} 
     38 
     39 
     40static 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)); 
    3446} 
    3547 
     
    107119        struct coord pos = canvas_to_coord(&ctx, event->x, event->y); 
    108120 
     121        curr_pos.x = event->x; 
     122        curr_pos.y = event->y; 
    109123        if (event->state & GDK_BUTTON1_MASK) 
    110124                drag_left(pos); 
    111125        if (event->state & GDK_BUTTON2_MASK) 
    112126                drag_middle(pos); 
     127        update_pos(pos); 
    113128        return TRUE; 
    114129} 
     
    126141        case 1: 
    127142                /* select */ ; 
     143                break; 
    128144        case 2: 
    129145                ctx.center = pos; 
     
    138154     gpointer data) 
    139155{ 
    140 printf("R %d\n", event->button); 
    141156        return TRUE; 
    142157} 
     
    196211 
    197212 
     213/* ----- keys -------------------------------------------------------------- */ 
     214 
     215 
     216static 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 
    198231/* ----- expose event ------------------------------------------------------ */ 
    199232 
     
    213246        redraw(); 
    214247 
     248        return TRUE; 
     249} 
     250 
     251 
     252/* ----- enter/leave ------------------------------------------------------- */ 
     253 
     254 
     255static gboolean enter_notify_event(GtkWidget *widget, GdkEventCrossing *event, 
     256     gpointer data) 
     257{ 
     258        gtk_widget_grab_focus(widget); 
     259        return TRUE; 
     260} 
     261 
     262 
     263static gboolean leave_notify_event(GtkWidget *widget, GdkEventCrossing *event, 
     264     gpointer data) 
     265{ 
    215266        return TRUE; 
    216267} 
     
    240291            G_CALLBACK(scroll_event), NULL); 
    241292 
     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 
    242298        g_signal_connect(G_OBJECT(canvas), "expose_event", 
    243299            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); 
    244304 
    245305        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 | 
    247308            GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | 
    248309            GDK_SCROLL | 
  • developers/werner/fped/gui_inst.c

    r5328 r5331  
    5757    int x, int y, int r, double a1, double a2) 
    5858{ 
    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); 
    6062} 
    6163 
  • developers/werner/fped/inst.c

    r5327 r5331  
    200200 
    201201        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); 
    203203        a1 = atan2(start.y-center.y, start.x-center.x)/M_PI*180.0; 
    204204        a2 = atan2(end.y-center.y, end.x-center.x)/M_PI*180.0; 
     
    206206                a1 += 360.0; 
    207207        if (a2 < 0) 
    208                 a2 += 2*M_PI; 
     208                a2 += 360.0; 
    209209        inst->u.arc.r = r; 
    210210        inst->u.arc.a1 = a1; 
  • developers/werner/fped/qfn.fpd

    r5328 r5331  
    3333e = .vec c -0.5mm, 0mm 
    3434.arc c r, e 
     35 
     36r2 = .vec c 0mm, 0.8mm 
     37.arc c r2 
Note: See TracChangeset for help on using the changeset viewer.