mirror of
git://projects.qi-hardware.com/fped.git
synced 2024-11-22 13:14:04 +02:00
- added menu item "Save" to dump the footprint to stdout
- added temporary solution for having a part name - added part name to FPD example files - reduced area in which the frame delete button responds git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5393 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
parent
b5dd18c564
commit
995aa4ca04
22
README
22
README
@ -75,6 +75,14 @@ and - to a limited extent - also macros. Long lines can be split by
|
||||
ending them with a backslash. If multiple items need to be placed in a
|
||||
single line, e.g., in a macro, they can be separated with semicolons.
|
||||
|
||||
The file has the following structure:
|
||||
|
||||
frame definitions
|
||||
...
|
||||
part name
|
||||
objects
|
||||
...
|
||||
|
||||
|
||||
Geometry model
|
||||
--------------
|
||||
@ -214,6 +222,20 @@ b: vec @(1mm, 1mm)
|
||||
meas a b 0.2 mm
|
||||
|
||||
|
||||
Part name
|
||||
- - - - -
|
||||
|
||||
The part name is a string of alphanumerical characters. Underscores are
|
||||
allowed in the part name as well.
|
||||
|
||||
part "<name>"
|
||||
|
||||
Examples:
|
||||
|
||||
part "SSOP_48"
|
||||
part "0603"
|
||||
|
||||
|
||||
Frames
|
||||
- - -
|
||||
|
||||
|
3
TODO
3
TODO
@ -8,7 +8,6 @@ Missing features:
|
||||
- add KiCad output
|
||||
- add postscript output
|
||||
- add option to include/omit helper vecs and frames (display and postscript)
|
||||
- define part name
|
||||
|
||||
Error detection:
|
||||
- eliminate duplicate instances
|
||||
@ -16,7 +15,6 @@ Error detection:
|
||||
Style:
|
||||
- make column of entry field greedily consume all unallocated space
|
||||
- status area looks awful
|
||||
- status area bounces when something becomes editable
|
||||
- add button with GTK_STOCK_UNDELETE for "undelete" to menu bar
|
||||
|
||||
Bugs:
|
||||
@ -54,3 +52,4 @@ Future directions:
|
||||
- future: when encountering an error after a change, we could try to find the
|
||||
same element in the old instance, and select it
|
||||
- future: consider editing off-canvas items in place
|
||||
- near future: treat part name as pattern
|
||||
|
2
fpd.l
2
fpd.l
@ -72,6 +72,8 @@ SP [\t ]*
|
||||
return TOK_SET; }
|
||||
<INITIAL>"loop" { BEGIN(NOKEYWORD);
|
||||
return TOK_LOOP; }
|
||||
<INITIAL>"part" { BEGIN(NOKEYWORD);
|
||||
return TOK_PART; }
|
||||
<INITIAL>"frame" { BEGIN(NOKEYWORD);
|
||||
is_table = 0;
|
||||
return TOK_FRAME; }
|
||||
|
22
fpd.y
22
fpd.y
@ -142,7 +142,7 @@ static struct obj *new_obj(enum obj_type type)
|
||||
|
||||
|
||||
%token START_FPD START_EXPR
|
||||
%token TOK_SET TOK_LOOP TOK_FRAME TOK_TABLE TOK_VEC
|
||||
%token TOK_SET TOK_LOOP TOK_PART TOK_FRAME TOK_TABLE TOK_VEC
|
||||
%token TOK_PAD TOK_RECT TOK_LINE TOK_CIRC TOK_ARC TOK_MEAS
|
||||
|
||||
%token <num> NUMBER
|
||||
@ -172,7 +172,7 @@ fpd:
|
||||
root_frame = zalloc_type(struct frame);
|
||||
set_frame(root_frame);
|
||||
}
|
||||
frame_defs frame_items
|
||||
frame_defs part_name frame_items
|
||||
{
|
||||
root_frame->prev = last_frame;
|
||||
if (last_frame)
|
||||
@ -182,6 +182,24 @@ fpd:
|
||||
}
|
||||
;
|
||||
|
||||
part_name:
|
||||
TOK_PART STRING
|
||||
{
|
||||
const char *p;
|
||||
|
||||
if (!*p) {
|
||||
yyerrorf("invalid part name");
|
||||
YYABORT;
|
||||
}
|
||||
for (p = $2; *p; *p++)
|
||||
if (!is_id_char(*p, 0)) {
|
||||
yyerrorf("invalid part name");
|
||||
YYABORT;
|
||||
}
|
||||
part_name = $2;
|
||||
}
|
||||
;
|
||||
|
||||
frame_defs:
|
||||
| frame_defs frame_def
|
||||
;
|
||||
|
87
gui.c
87
gui.c
@ -23,6 +23,7 @@
|
||||
#include "obj.h"
|
||||
#include "delete.h"
|
||||
#include "unparse.h"
|
||||
#include "dump.h"
|
||||
#include "gui_util.h"
|
||||
#include "gui_style.h"
|
||||
#include "gui_status.h"
|
||||
@ -39,10 +40,16 @@ static GtkWidget *frames_box;
|
||||
/* ----- menu bar ---------------------------------------------------------- */
|
||||
|
||||
|
||||
static void menu_save(GtkWidget *widget, gpointer user)
|
||||
{
|
||||
dump(stdout);
|
||||
}
|
||||
|
||||
|
||||
static void make_menu_bar(GtkWidget *vbox)
|
||||
{
|
||||
GtkWidget *bar;
|
||||
GtkWidget *file_menu, *file, *quit;
|
||||
GtkWidget *file_menu, *file, *quit, *save;
|
||||
|
||||
bar = gtk_menu_bar_new();
|
||||
gtk_box_pack_start(GTK_BOX(vbox), bar, FALSE, FALSE, 0);
|
||||
@ -53,9 +60,13 @@ static void make_menu_bar(GtkWidget *vbox)
|
||||
gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), file_menu);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(bar), file);
|
||||
|
||||
save = gtk_menu_item_new_with_label("Save");
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), save);
|
||||
g_signal_connect(G_OBJECT(save), "activate",
|
||||
G_CALLBACK(menu_save), NULL);
|
||||
|
||||
quit = gtk_menu_item_new_with_label("Quit");
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), quit);
|
||||
|
||||
g_signal_connect(G_OBJECT(quit), "activate",
|
||||
G_CALLBACK(gtk_main_quit), NULL);
|
||||
}
|
||||
@ -460,6 +471,56 @@ static GtkWidget *build_vars(struct frame *frame)
|
||||
}
|
||||
|
||||
|
||||
/* ----- part name --------------------------------------------------------- */
|
||||
|
||||
|
||||
static int validate_part_name(const char *s, void *ctx)
|
||||
{
|
||||
if (!*s)
|
||||
return 0;
|
||||
while (*s)
|
||||
if (!is_id_char(*s++, 0))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void unselect_part_name(void *data)
|
||||
{
|
||||
GtkWidget *widget = data;
|
||||
|
||||
label_in_box_bg(widget, COLOR_PART_NAME);
|
||||
}
|
||||
|
||||
|
||||
static gboolean part_name_edit_event(GtkWidget *widget, GdkEventButton *event,
|
||||
gpointer data)
|
||||
{
|
||||
inst_select_outside(widget, unselect_part_name);
|
||||
label_in_box_bg(widget, COLOR_PART_NAME_EDITING);
|
||||
status_set_type_entry("part =");
|
||||
status_set_name("%s", part_name);
|
||||
edit_name(&part_name, validate_part_name, NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static GtkWidget *build_part_name(void)
|
||||
{
|
||||
GtkWidget *label;
|
||||
|
||||
label = label_in_box_new(part_name);
|
||||
gtk_misc_set_padding(GTK_MISC(label), 2, 2);
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
|
||||
|
||||
label_in_box_bg(label, COLOR_PART_NAME);
|
||||
|
||||
g_signal_connect(G_OBJECT(box_of_label(label)),
|
||||
"button_press_event", G_CALLBACK(part_name_edit_event), NULL);
|
||||
|
||||
return box_of_label(label);
|
||||
}
|
||||
|
||||
|
||||
/* ----- frame labels ------------------------------------------------------ */
|
||||
|
||||
|
||||
@ -570,6 +631,7 @@ static gboolean frame_delete_event(GtkWidget *widget, GdkEventButton *event,
|
||||
static GtkWidget *build_frame_delete(struct frame *frame)
|
||||
{
|
||||
GtkWidget *evbox, *image;
|
||||
GtkWidget *align;
|
||||
|
||||
evbox = gtk_event_box_new();
|
||||
image =
|
||||
@ -577,12 +639,14 @@ static GtkWidget *build_frame_delete(struct frame *frame)
|
||||
GTK_ICON_SIZE_SMALL_TOOLBAR);
|
||||
gtk_container_add(GTK_CONTAINER(evbox), image);
|
||||
|
||||
gtk_misc_set_padding(GTK_MISC(image), 2, 2);
|
||||
gtk_misc_set_alignment(GTK_MISC(image), 0.3, 0);
|
||||
align = gtk_alignment_new(0.3, 0, 0, 0);
|
||||
gtk_container_add(GTK_CONTAINER(align), evbox);
|
||||
gtk_alignment_set_padding(GTK_ALIGNMENT(align), 2, 0, 0, 0);
|
||||
|
||||
g_signal_connect(G_OBJECT(evbox),
|
||||
"button_press_event", G_CALLBACK(frame_delete_event), frame);
|
||||
return evbox;
|
||||
|
||||
return align;
|
||||
}
|
||||
|
||||
|
||||
@ -629,28 +693,31 @@ static void build_frames(GtkWidget *vbox)
|
||||
for (frame = frames; frame; frame = frame->next)
|
||||
n++;
|
||||
|
||||
tab = gtk_table_new(n*2, 2, FALSE);
|
||||
tab = gtk_table_new(n*2+1, 2, FALSE);
|
||||
gtk_table_set_row_spacings(GTK_TABLE(tab), 1);
|
||||
gtk_table_set_col_spacings(GTK_TABLE(tab), 1);
|
||||
gtk_box_pack_start(GTK_BOX(vbox), tab, FALSE, FALSE, 0);
|
||||
|
||||
label = build_part_name();
|
||||
gtk_table_attach_defaults(GTK_TABLE(tab), label, 0, 1, 0, 1);
|
||||
|
||||
n = 0;
|
||||
for (frame = root_frame; frame; frame = frame->prev) {
|
||||
label = build_frame_label(frame);
|
||||
gtk_table_attach_defaults(GTK_TABLE(tab), label,
|
||||
0, 1, n*2, n*2+1);
|
||||
0, 1, n*2+1, n*2+2);
|
||||
|
||||
delete = build_frame_delete(frame);
|
||||
gtk_table_attach_defaults(GTK_TABLE(tab), delete,
|
||||
0, 1, n*2+1, n*2+2);
|
||||
0, 1, n*2+2, n*2+3);
|
||||
|
||||
refs = build_frame_refs(frame);
|
||||
gtk_table_attach_defaults(GTK_TABLE(tab), refs,
|
||||
1, 2, n*2, n*2+1);
|
||||
1, 2, n*2+1, n*2+2);
|
||||
|
||||
vars = build_vars(frame);
|
||||
gtk_table_attach_defaults(GTK_TABLE(tab), vars,
|
||||
1, 2, n*2+1, n*2+2);
|
||||
1, 2, n*2+2, n*2+3);
|
||||
n++;
|
||||
}
|
||||
gtk_widget_show_all(tab);
|
||||
|
@ -60,6 +60,9 @@
|
||||
|
||||
#define COLOR_EDITING "#ff00ff"
|
||||
|
||||
#define COLOR_PART_NAME "#ffa050"
|
||||
#define COLOR_PART_NAME_EDITING COLOR_EDITING
|
||||
|
||||
#define COLOR_FRAME_UNSELECTED "#c0c0c0"
|
||||
#define COLOR_FRAME_SELECTED "#fff0a0"
|
||||
#define COLOR_FRAME_EDITING COLOR_EDITING
|
||||
|
1
obj.c
1
obj.c
@ -27,6 +27,7 @@
|
||||
#define MAX_ITERATIONS 1000 /* abort "loop"s at this limit */
|
||||
|
||||
|
||||
char *part_name = NULL;
|
||||
struct frame *frames = NULL;
|
||||
struct frame *root_frame = NULL;
|
||||
struct frame *active_frame = NULL;
|
||||
|
1
obj.h
1
obj.h
@ -171,6 +171,7 @@ struct obj {
|
||||
};
|
||||
|
||||
|
||||
extern char *part_name;
|
||||
extern struct frame *frames;
|
||||
extern struct frame *root_frame;
|
||||
extern struct frame *active_frame;
|
||||
|
2
quad.fpd
2
quad.fpd
@ -3,6 +3,8 @@ frame c {
|
||||
circ . @
|
||||
}
|
||||
|
||||
part "quad"
|
||||
|
||||
vec @(-1mm, 1mm)
|
||||
frame c .
|
||||
vec @(1mm, -1mm)
|
||||
|
Loading…
Reference in New Issue
Block a user