r5393 - trunk/eda/fped

werner at docs.openmoko.org werner at docs.openmoko.org
Thu Aug 6 08:54:42 CEST 2009


Author: werner
Date: 2009-08-06 08:54:41 +0200 (Thu, 06 Aug 2009)
New Revision: 5393

Modified:
   trunk/eda/fped/README
   trunk/eda/fped/TODO
   trunk/eda/fped/fpd.l
   trunk/eda/fped/fpd.y
   trunk/eda/fped/gui.c
   trunk/eda/fped/gui_style.h
   trunk/eda/fped/obj.c
   trunk/eda/fped/obj.h
   trunk/eda/fped/qfn.fpd
   trunk/eda/fped/quad.fpd
   trunk/eda/fped/tab.fpd
Log:
- 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



Modified: trunk/eda/fped/README
===================================================================
--- trunk/eda/fped/README	2009-08-06 04:56:47 UTC (rev 5392)
+++ trunk/eda/fped/README	2009-08-06 06:54:41 UTC (rev 5393)
@@ -75,7 +75,15 @@
 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 @@
 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
 - - -
 

Modified: trunk/eda/fped/TODO
===================================================================
--- trunk/eda/fped/TODO	2009-08-06 04:56:47 UTC (rev 5392)
+++ trunk/eda/fped/TODO	2009-08-06 06:54:41 UTC (rev 5393)
@@ -8,7 +8,6 @@
 - 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 @@
 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: 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

Modified: trunk/eda/fped/fpd.l
===================================================================
--- trunk/eda/fped/fpd.l	2009-08-06 04:56:47 UTC (rev 5392)
+++ trunk/eda/fped/fpd.l	2009-08-06 06:54:41 UTC (rev 5393)
@@ -72,6 +72,8 @@
 				  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; }

Modified: trunk/eda/fped/fpd.y
===================================================================
--- trunk/eda/fped/fpd.y	2009-08-06 04:56:47 UTC (rev 5392)
+++ trunk/eda/fped/fpd.y	2009-08-06 06:54:41 UTC (rev 5393)
@@ -142,7 +142,7 @@
 
 
 %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 @@
 			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 @@
 		}
 	;
 
+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
 	;

Modified: trunk/eda/fped/gui.c
===================================================================
--- trunk/eda/fped/gui.c	2009-08-06 04:56:47 UTC (rev 5392)
+++ trunk/eda/fped/gui.c	2009-08-06 06:54:41 UTC (rev 5393)
@@ -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 @@
 /* ----- 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 @@
 	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 @@
 }
 
 
+/* ----- 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 GtkWidget *build_frame_delete(struct frame *frame)
 {
 	GtkWidget *evbox, *image;
+	GtkWidget *align;
 
 	evbox = gtk_event_box_new();
 	image = 
@@ -577,12 +639,14 @@
 	        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 @@
 	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);

Modified: trunk/eda/fped/gui_style.h
===================================================================
--- trunk/eda/fped/gui_style.h	2009-08-06 04:56:47 UTC (rev 5392)
+++ trunk/eda/fped/gui_style.h	2009-08-06 06:54:41 UTC (rev 5393)
@@ -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

Modified: trunk/eda/fped/obj.c
===================================================================
--- trunk/eda/fped/obj.c	2009-08-06 04:56:47 UTC (rev 5392)
+++ trunk/eda/fped/obj.c	2009-08-06 06:54:41 UTC (rev 5393)
@@ -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;

Modified: trunk/eda/fped/obj.h
===================================================================
--- trunk/eda/fped/obj.h	2009-08-06 04:56:47 UTC (rev 5392)
+++ trunk/eda/fped/obj.h	2009-08-06 06:54:41 UTC (rev 5393)
@@ -171,6 +171,7 @@
 };
 
 
+extern char *part_name;
 extern struct frame *frames;
 extern struct frame *root_frame;
 extern struct frame *active_frame;

Modified: trunk/eda/fped/qfn.fpd
===================================================================
--- trunk/eda/fped/qfn.fpd	2009-08-06 04:56:47 UTC (rev 5392)
+++ trunk/eda/fped/qfn.fpd	2009-08-06 06:54:41 UTC (rev 5393)
@@ -25,6 +25,9 @@
 }
 
 
+part "qfn"
+
+
 set N = 24
 
 /*

Modified: trunk/eda/fped/quad.fpd
===================================================================
--- trunk/eda/fped/quad.fpd	2009-08-06 04:56:47 UTC (rev 5392)
+++ trunk/eda/fped/quad.fpd	2009-08-06 06:54:41 UTC (rev 5393)
@@ -3,6 +3,8 @@
 	circ . @
 }
 
+part "quad"
+
 vec @(-1mm, 1mm)
 frame c .
 vec @(1mm, -1mm)

Modified: trunk/eda/fped/tab.fpd
===================================================================
--- trunk/eda/fped/tab.fpd	2009-08-06 04:56:47 UTC (rev 5392)
+++ trunk/eda/fped/tab.fpd	2009-08-06 06:54:41 UTC (rev 5393)
@@ -2,6 +2,8 @@
  * row selection example
  */
 
+part "tab"
+
 table
     { x, x2 }
     { 1mm, 1 }




More information about the commitlog mailing list