Send commitlog mailing list submissions to
        commitlog@lists.openmoko.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.openmoko.org/mailman/listinfo/commitlog
or, via email, send a message with subject or body 'help' to
        commitlog-requ...@lists.openmoko.org

You can reach the person managing the list at
        commitlog-ow...@lists.openmoko.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of commitlog digest..."
Today's Topics:

   1. r5411 - in trunk/eda/fped: . icons (wer...@docs.openmoko.org)
   2. r5412 - trunk/eda/fped (wer...@docs.openmoko.org)
--- Begin Message ---
Author: werner
Date: 2009-08-08 23:59:33 +0200 (Sat, 08 Aug 2009)
New Revision: 5411

Added:
   trunk/eda/fped/icons/meas_off.fig
   trunk/eda/fped/icons/stuff.fig
   trunk/eda/fped/icons/stuff_off.fig
Modified:
   trunk/eda/fped/Makefile
   trunk/eda/fped/gui.c
   trunk/eda/fped/gui.h
   trunk/eda/fped/gui_meas.c
   trunk/eda/fped/gui_tool.c
   trunk/eda/fped/gui_util.c
   trunk/eda/fped/gui_util.h
   trunk/eda/fped/inst.c
Log:
- simplified tool_button and moved it from gui_tool.c to into gui_util.c
- moved make_image from gui_tool.c to into gui_util.c as well
- generalized set_frame_image and moved it to gui_util.c as set_image
- tool_button_press_event didn't check which button was pressed
- added buttons to switch visibility of frames, vectors, and measurements
- when creating a measurement through the GUI, don't invert if both points are
  minima (otherwise, one could never get the text point the other way)



Modified: trunk/eda/fped/Makefile
===================================================================
--- trunk/eda/fped/Makefile     2009-08-08 19:44:17 UTC (rev 5410)
+++ trunk/eda/fped/Makefile     2009-08-08 21:59:33 UTC (rev 5411)
@@ -17,7 +17,8 @@
        gui_tool.o gui_over.o gui_meas.o gui_frame.o
 
 XPMS = point.xpm delete.xpm vec.xpm frame.xpm frame_locked.xpm frame_ready.xpm 
\
-       line.xpm rect.xpm pad.xpm circ.xpm meas.xpm meas_x.xpm meas_y.xpm
+       line.xpm rect.xpm pad.xpm circ.xpm meas.xpm meas_x.xpm meas_y.xpm \
+       stuff.xpm stuff_off.xpm meas_off.xpm
 
 CFLAGS_GTK = `pkg-config --cflags gtk+-2.0`
 LIBS_GTK = `pkg-config --libs gtk+-2.0`
@@ -95,7 +96,7 @@
 y.tab.o:       y.tab.c
                $(CC) -c $(CFLAGS) $(SLOPPY) y.tab.c
 
-gui_tool.o:    $(XPMS:%=icons/%)
+gui_tool.o gui.o: $(XPMS:%=icons/%)
 
 # ----- Dependencies ----------------------------------------------------------
 

Modified: trunk/eda/fped/gui.c
===================================================================
--- trunk/eda/fped/gui.c        2009-08-08 19:44:17 UTC (rev 5410)
+++ trunk/eda/fped/gui.c        2009-08-08 21:59:33 UTC (rev 5411)
@@ -24,10 +24,20 @@
 #include "gui_frame.h"
 #include "gui.h"
 
+#include "icons/stuff.xpm"
+#include "icons/stuff_off.xpm"
+#include "icons/meas.xpm"
+#include "icons/meas_off.xpm"
 
+
 GtkWidget *root;
+int show_stuff = 1;
+int show_meas = 1;
 
+
 static GtkWidget *frames_box;
+static GtkWidget *ev_stuff, *ev_meas;
+static GtkWidget *stuff_image[2], *meas_image[2];
 
 
 /* ----- menu bar ---------------------------------------------------------- */
@@ -39,13 +49,13 @@
 }
 
 
-static void make_menu_bar(GtkWidget *vbox)
+static void make_menu_bar(GtkWidget *hbox)
 {
        GtkWidget *bar;
        GtkWidget *file_menu, *file, *quit, *save;
 
        bar = gtk_menu_bar_new();
-       gtk_box_pack_start(GTK_BOX(vbox), bar, FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(hbox), bar, TRUE, TRUE, 0);
 
        file_menu = gtk_menu_new();
 
@@ -65,6 +75,67 @@
 }
 
 
+static gboolean toggle_stuff(GtkWidget *widget, GdkEventButton *event,
+    gpointer data)
+{
+       switch (event->button) {
+       case 1:
+               show_stuff = !show_stuff;
+               set_image(ev_stuff, stuff_image[show_stuff]);
+               redraw();
+               break;
+       }
+        return TRUE;
+}
+
+
+static gboolean toggle_meas(GtkWidget *widget, GdkEventButton *event,
+    gpointer data)
+{
+       switch (event->button) {
+       case 1:
+               show_meas = !show_meas;
+               set_image(ev_meas, meas_image[show_meas]);
+               redraw();
+               break;
+       }
+        return TRUE;
+}
+
+
+static void make_tool_bar(GtkWidget *hbox, GdkDrawable *drawable)
+{
+       GtkWidget *bar;
+
+       bar = gtk_toolbar_new();
+       gtk_box_pack_end(GTK_BOX(hbox), bar, TRUE, TRUE, 0);
+       //gtk_box_pack_end(GTK_BOX(hbox), bar, FALSE, FALSE, 0);
+       gtk_toolbar_set_style(GTK_TOOLBAR(bar), GTK_TOOLBAR_ICONS);
+
+       ev_stuff = tool_button(bar, drawable, NULL, toggle_stuff, NULL);
+       ev_meas = tool_button(bar, drawable, NULL, toggle_meas, NULL);
+
+       stuff_image[0] = gtk_widget_ref(make_image(drawable, xpm_stuff_off));
+       stuff_image[1] = gtk_widget_ref(make_image(drawable, xpm_stuff));
+       meas_image[0] = gtk_widget_ref(make_image(drawable, xpm_meas_off));
+       meas_image[1] = gtk_widget_ref(make_image(drawable, xpm_meas));
+
+       set_image(ev_stuff, stuff_image[show_stuff]);
+       set_image(ev_meas, meas_image[show_meas]);
+}
+
+
+static void make_top_bar(GtkWidget *vbox)
+{
+       GtkWidget *hbox;
+
+       hbox = gtk_hbox_new(FALSE, 0);
+       make_menu_bar(hbox);
+       make_tool_bar(hbox, root->window);
+       gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+}
+
+
 /* ----- central screen area ----------------------------------------------- */
 
 
@@ -125,7 +196,7 @@
        vbox = gtk_vbox_new(FALSE, 0);
        gtk_container_add(GTK_CONTAINER(window), vbox);
 
-       make_menu_bar(vbox);
+       make_top_bar(vbox);
        make_center_area(vbox);
        make_status_area(vbox);
 }

Modified: trunk/eda/fped/gui.h
===================================================================
--- trunk/eda/fped/gui.h        2009-08-08 19:44:17 UTC (rev 5410)
+++ trunk/eda/fped/gui.h        2009-08-08 21:59:33 UTC (rev 5411)
@@ -18,6 +18,8 @@
 
 
 extern GtkWidget *root;
+extern int show_stuff;
+extern int show_meas;
 
 
 /* update everything after a model change */

Modified: trunk/eda/fped/gui_meas.c
===================================================================
--- trunk/eda/fped/gui_meas.c   2009-08-08 19:44:17 UTC (rev 5410)
+++ trunk/eda/fped/gui_meas.c   2009-08-08 21:59:33 UTC (rev 5411)
@@ -286,8 +286,10 @@
        default:
                abort();
        }
-       meas->inverted = meas_dsc->lt(from->u.rect.end, to->u.rect.end) !=
-           (mode == min_to_next_or_max);
+       meas->inverted =
+         mode == min_to_next_or_max && is_min(meas_dsc->lt, to) ? 0 :
+         meas_dsc->lt(from->u.rect.end, to->u.rect.end) !=
+         (mode == min_to_next_or_max);
 {
 char *sm[] = { "min_to", "max_to", "next_to" };
 char *st[] = { "nxy", "nx", "ny", "mxy", "mx", "my" };

Modified: trunk/eda/fped/gui_tool.c
===================================================================
--- trunk/eda/fped/gui_tool.c   2009-08-08 19:44:17 UTC (rev 5410)
+++ trunk/eda/fped/gui_tool.c   2009-08-08 21:59:33 UTC (rev 5411)
@@ -510,17 +510,9 @@
 static struct frame *locked_frame = NULL;
 
 
-static void remove_child(GtkWidget *widget, gpointer data)
-{
-       gtk_container_remove(GTK_CONTAINER(data), widget);
-}
-
-
 static void set_frame_image(GtkWidget *image)
 {
-       gtk_container_foreach(GTK_CONTAINER(ev_frame), remove_child, ev_frame);
-       gtk_container_add(GTK_CONTAINER(ev_frame), image);
-       gtk_widget_show_all(ev_frame);
+       set_image(ev_frame, image);
 }
 
 
@@ -851,66 +843,15 @@
 static gboolean tool_button_press_event(GtkWidget *widget,
     GdkEventButton *event, gpointer data)
 {
-       tool_select(widget, data);
+       switch (event->button) {
+       case 1:
+               tool_select(widget, data);
+               break;
+       }
        return TRUE;
 }
 
 
-static GtkWidget *make_image(GdkDrawable *drawable,  char **xpm)
-{
-       GdkPixmap *pixmap;
-       GtkWidget *image;
-
-       pixmap = gdk_pixmap_create_from_xpm_d(drawable, NULL, NULL, xpm);
-       image = gtk_image_new_from_pixmap(pixmap, NULL);
-       gtk_misc_set_padding(GTK_MISC(image), 1, 1);
-       return image;
-}
-
-
-static GtkWidget *tool_button(GtkWidget *bar, GdkDrawable *drawable,
-    char **xpm, GtkWidget *last_evbox, struct tool_ops *ops)
-{
-       GtkWidget *image, *evbox;       
-       GtkToolItem *item;
-       GtkToolItem *last = NULL;
-
-       if (last_evbox)
-               last = GTK_TOOL_ITEM(gtk_widget_get_ancestor(last_evbox,
-                   GTK_TYPE_TOOL_ITEM));
-
-/*
- * gtk_radio_tool_button_new_from_widget is *huge*. we try to do things in a
- * more compact way.
- */
-#if 0
-       if (last)
-               item = gtk_radio_tool_button_new_from_widget(
-                   GTK_RADIO_TOOL_BUTTON(last));
-       else
-               item = gtk_radio_tool_button_new(NULL);
-       gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(item), image);
-#else
-       evbox = gtk_event_box_new();
-       if (xpm) {
-               image = make_image(drawable, xpm);
-               gtk_container_add(GTK_CONTAINER(evbox), image);
-       }
-       g_signal_connect(G_OBJECT(evbox), "button_press_event",
-            G_CALLBACK(tool_button_press_event), ops);
-
-       item = gtk_tool_item_new();
-       gtk_container_add(GTK_CONTAINER(item), evbox);
-
-       gtk_container_set_border_width(GTK_CONTAINER(item), 0);
-#endif
-
-       gtk_toolbar_insert(GTK_TOOLBAR(bar), item, -1);
-
-       return evbox;
-}
-
-
 static void tool_separator(GtkWidget *bar)
 {
        GtkToolItem *item;
@@ -924,27 +865,36 @@
 GtkWidget *gui_setup_tools(GdkDrawable *drawable)
 {
        GtkWidget *bar;
-       GtkWidget *last;
 
        bar = gtk_toolbar_new();
        gtk_toolbar_set_style(GTK_TOOLBAR(bar), GTK_TOOLBAR_ICONS);
        gtk_toolbar_set_orientation(GTK_TOOLBAR(bar),
            GTK_ORIENTATION_VERTICAL);
 
-       ev_point = tool_button(bar, drawable, xpm_point, NULL, NULL);
-       last = tool_button(bar, drawable, xpm_delete, ev_point, &delete_ops);
+       ev_point = tool_button(bar, drawable, xpm_point,
+           tool_button_press_event, NULL);
+       tool_button(bar, drawable, xpm_delete,
+           tool_button_press_event, &delete_ops);
        tool_separator(bar);
-       last = tool_button(bar, drawable, xpm_vec, last, &vec_ops);
-       ev_frame = tool_button(bar, drawable, NULL, last, &frame_ops);
-       last = ev_frame;
-       last = tool_button(bar, drawable, xpm_pad, last, &pad_ops);
-       last = tool_button(bar, drawable, xpm_line, last, &line_ops);
-       last = tool_button(bar, drawable, xpm_rect, last, &rect_ops);
-       last = tool_button(bar, drawable, xpm_circ, last, &circ_ops);
+       tool_button(bar, drawable, xpm_vec,
+           tool_button_press_event, &vec_ops);
+       ev_frame = tool_button(bar, drawable, NULL,
+           tool_button_press_event, &frame_ops);
+       tool_button(bar, drawable, xpm_pad,
+           tool_button_press_event, &pad_ops);
+       tool_button(bar, drawable, xpm_line,
+           tool_button_press_event, &line_ops);
+       tool_button(bar, drawable, xpm_rect,
+           tool_button_press_event, &rect_ops);
+       tool_button(bar, drawable, xpm_circ,
+           tool_button_press_event, &circ_ops);
        tool_separator(bar);
-       last = tool_button(bar, drawable, xpm_meas, last, &meas_ops);
-       last = tool_button(bar, drawable, xpm_meas_x, last, &meas_ops_x);
-       last = tool_button(bar, drawable, xpm_meas_y, last, &meas_ops_y);
+       tool_button(bar, drawable, xpm_meas,
+           tool_button_press_event, &meas_ops);
+       tool_button(bar, drawable, xpm_meas_x,
+           tool_button_press_event, &meas_ops_x);
+       tool_button(bar, drawable, xpm_meas_y,
+           tool_button_press_event, &meas_ops_y);
 
        frame_image = gtk_widget_ref(make_image(drawable, xpm_frame));
        frame_image_locked =

Modified: trunk/eda/fped/gui_util.c
===================================================================
--- trunk/eda/fped/gui_util.c   2009-08-08 19:44:17 UTC (rev 5410)
+++ trunk/eda/fped/gui_util.c   2009-08-08 21:59:33 UTC (rev 5411)
@@ -161,6 +161,67 @@
 }
 
 
+/* ----- generate a tool button with an XPM image -------------------------- */
+
+
+GtkWidget *make_image(GdkDrawable *drawable, char **xpm)
+{
+       GdkPixmap *pixmap;
+       GtkWidget *image;
+
+       pixmap = gdk_pixmap_create_from_xpm_d(drawable, NULL, NULL, xpm);
+       image = gtk_image_new_from_pixmap(pixmap, NULL);
+       gtk_misc_set_padding(GTK_MISC(image), 1, 1);
+       return image;
+}
+
+
+static void remove_child(GtkWidget *widget, gpointer data)
+{
+       gtk_container_remove(GTK_CONTAINER(data), widget);
+}
+
+
+void set_image(GtkWidget *widget, GtkWidget *image)
+{
+       gtk_container_foreach(GTK_CONTAINER(widget), remove_child, widget);
+       gtk_container_add(GTK_CONTAINER(widget), image);
+       gtk_widget_show_all(widget);
+}
+
+
+GtkWidget *tool_button(GtkWidget *bar, GdkDrawable *drawable, char **xpm,
+    gboolean (*cb)(GtkWidget *widget, GdkEventButton *event, gpointer data),
+    gpointer data)
+{
+       GtkWidget *image, *evbox;       
+       GtkToolItem *item;
+
+       /*
+        * gtk_radio_tool_button_new_from_widget is *huge*. We try to do things
+        * in a
+        * more compact way.
+        */
+
+       evbox = gtk_event_box_new();
+       if (xpm) {
+               image = make_image(drawable, xpm);
+               gtk_container_add(GTK_CONTAINER(evbox), image);
+       }
+       g_signal_connect(G_OBJECT(evbox), "button_press_event",
+            G_CALLBACK(cb), data);
+
+       item = gtk_tool_item_new();
+       gtk_container_add(GTK_CONTAINER(item), evbox);
+
+       gtk_container_set_border_width(GTK_CONTAINER(item), 0);
+
+       gtk_toolbar_insert(GTK_TOOLBAR(bar), item, -1);
+
+       return evbox;
+}
+
+
 /* ----- render a text string ---------------------------------------------- */
 
 

Modified: trunk/eda/fped/gui_util.h
===================================================================
--- trunk/eda/fped/gui_util.h   2009-08-08 19:44:17 UTC (rev 5410)
+++ trunk/eda/fped/gui_util.h   2009-08-08 21:59:33 UTC (rev 5411)
@@ -56,6 +56,12 @@
 GtkWidget *box_of_label(GtkWidget *label);
 void label_in_box_bg(GtkWidget *box, const char *color);
 
+GtkWidget *make_image(GdkDrawable *drawable, char **xpm);
+void set_image(GtkWidget *widget, GtkWidget *image);
+GtkWidget *tool_button(GtkWidget *bar, GdkDrawable *drawable, char **xpm,
+    gboolean (*cb)(GtkWidget *widget, GdkEventButton *event, gpointer data),
+    gpointer data);
+
 void render_text(GdkDrawable *da, GdkGC *gc, int x, int y, double angle,
     const char *s, const char *font, double xalign, double yalign,
     int xmax, int ymax);

Added: trunk/eda/fped/icons/meas_off.fig
===================================================================
--- trunk/eda/fped/icons/meas_off.fig                           (rev 0)
+++ trunk/eda/fped/icons/meas_off.fig   2009-08-08 21:59:33 UTC (rev 5411)
@@ -0,0 +1,19 @@
+#FIG 3.2  Produced by xfig version 3.2.5a
+Landscape
+Center
+Inches
+A4      
+100.00
+Single
+-2
+1200 2
+2 2 0 1 0 7 50 -1 10 0.000 0 0 -1 0 0 5
+        3600 2400 6000 2400 6000 4800 3600 4800 3600 2400
+2 1 0 10 0 7 40 -1 -1 0.000 0 0 -1 0 0 2
+        3900 3600 4200 4200
+2 1 0 10 0 7 40 -1 -1 0.000 0 0 -1 1 1 2
+       0 0 10.00 450.00 450.00
+       0 0 10.00 450.00 450.00
+        4050 3900 5550 3150
+2 1 0 10 0 7 40 -1 -1 0.000 0 0 -1 0 0 2
+        5400 2850 5700 3450

Added: trunk/eda/fped/icons/stuff.fig
===================================================================
--- trunk/eda/fped/icons/stuff.fig                              (rev 0)
+++ trunk/eda/fped/icons/stuff.fig      2009-08-08 21:59:33 UTC (rev 5411)
@@ -0,0 +1,17 @@
+#FIG 3.2  Produced by xfig version 3.2.5a
+Landscape
+Center
+Inches
+A4      
+100.00
+Single
+-2
+1200 2
+0 32 #c0c000
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+        3600 2400 6000 2400 6000 4800 3600 4800 3600 2400
+2 1 0 10 32 7 50 -1 -1 0.000 0 0 -1 1 0 2
+       1 1 10.00 300.00 300.00
+        3900 4515 5700 3315
+2 1 0 10 12 7 50 -1 -1 0.000 0 1 -1 0 0 3
+        3900 3600 3900 2760 5700 2760

Added: trunk/eda/fped/icons/stuff_off.fig
===================================================================
--- trunk/eda/fped/icons/stuff_off.fig                          (rev 0)
+++ trunk/eda/fped/icons/stuff_off.fig  2009-08-08 21:59:33 UTC (rev 5411)
@@ -0,0 +1,17 @@
+#FIG 3.2  Produced by xfig version 3.2.5a
+Landscape
+Center
+Inches
+A4      
+100.00
+Single
+-2
+1200 2
+0 32 #c0c000
+2 1 0 10 0 7 40 -1 -1 0.000 0 0 -1 1 0 2
+       1 1 10.00 300.00 300.00
+        3900 4515 5700 3315
+2 1 0 10 0 7 40 -1 -1 0.000 0 1 -1 0 0 3
+        3900 3600 3900 2760 5700 2760
+2 2 0 1 0 7 50 -1 10 0.000 0 0 -1 0 0 5
+        3600 2400 6000 2400 6000 4800 3600 4800 3600 2400

Modified: trunk/eda/fped/inst.c
===================================================================
--- trunk/eda/fped/inst.c       2009-08-08 19:44:17 UTC (rev 5410)
+++ trunk/eda/fped/inst.c       2009-08-08 21:59:33 UTC (rev 5411)
@@ -24,6 +24,7 @@
 #include "gui_status.h"
 #include "gui_tool.h"
 #include "gui_inst.h"
+#include "gui.h"
 #include "inst.h"
 
 
@@ -83,6 +84,23 @@
 #define        IS_ACTIVE       ((active_set & 1))
 
 
+/* ----- selective visibility ---------------------------------------------- */
+
+
+static int show(enum inst_prio prio)
+{
+       switch (prio) {
+       case ip_vec:
+       case ip_frame:
+               return show_stuff;
+       case ip_meas:
+               return show_meas;
+       default:
+               return 1;
+       }
+}
+
+
 /* ----- selection of items not on the canvas ------------------------------ */
 
 
@@ -142,6 +160,8 @@
        edit_nothing();
        selected_inst = NULL;
        FOR_INST_PRIOS_DOWN(prio) {
+               if (!show(prio))
+                       continue;
                for (inst = insts[prio]; inst; inst = inst->next) {
                        if (!inst->active || !inst->ops->distance)
                                continue;
@@ -155,6 +175,9 @@
                        goto selected;
        }
 
+       if (!show_stuff)
+               return 0;
+
        /* give vectors a second chance */
 
        for (inst = insts[ip_vec]; inst; inst = inst->next) {
@@ -828,15 +851,17 @@
        struct inst *inst;
 
        FOR_INSTS_UP(prio, inst)
-               if (!inst->active && inst->ops->draw)
+               if (show(prio) && !inst->active && inst->ops->draw)
                        inst->ops->draw(inst);
        FOR_INSTS_UP(prio, inst)
-               if (prio != ip_frame && inst->active &&
+               if (show(prio) && prio != ip_frame && inst->active &&
                    inst != selected_inst && inst->ops->draw)
                        inst->ops->draw(inst);
-       for (inst = insts[ip_frame]; inst; inst = inst->next)
-               if (inst->active && inst != selected_inst && inst->ops->draw)
-                       inst->ops->draw(inst);
+       if (show_stuff)
+               for (inst = insts[ip_frame]; inst; inst = inst->next)
+                       if (inst->active && inst != selected_inst &&
+                           inst->ops->draw)
+                               inst->ops->draw(inst);
        if (selected_inst && selected_inst->ops->draw)
                selected_inst->ops->draw(selected_inst);
 }




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2009-08-09 02:06:54 +0200 (Sun, 09 Aug 2009)
New Revision: 5412

Modified:
   trunk/eda/fped/README
   trunk/eda/fped/TODO
   trunk/eda/fped/delete.c
   trunk/eda/fped/dump.c
   trunk/eda/fped/fpd.l
   trunk/eda/fped/fpd.y
   trunk/eda/fped/gui_inst.c
   trunk/eda/fped/gui_meas.c
   trunk/eda/fped/gui_tool.c
   trunk/eda/fped/gui_tool.h
   trunk/eda/fped/inst.c
   trunk/eda/fped/inst.h
   trunk/eda/fped/meas.c
   trunk/eda/fped/meas.fpd
   trunk/eda/fped/meas.h
   trunk/eda/fped/obj.c
   trunk/eda/fped/obj.h
   trunk/eda/fped/qfn.fpd
   trunk/eda/fped/sc89.fpd
Log:
More work on measurements. Getting there ...

- removed support for old-style measurements
- new-style measurements are now embedded in "struct obj", so we can dump and 
  delete them
- "measxy" is now called "meas"
- updated examples to use new-style measurements



Modified: trunk/eda/fped/README
===================================================================
--- trunk/eda/fped/README       2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/README       2009-08-09 00:06:54 UTC (rev 5412)
@@ -202,6 +202,8 @@
 Measurements
 - - - - - -
 
+*** This is obsolete - see the section on new-style mesurements at the end. ***
+
 Measurements show the distance between two points:
 
 meas <point-a> <point-b> <offset>
@@ -439,16 +441,15 @@
 items.
 
 Known issues:
-- they are currently not dumped and they can't be entered or edited
-  through the GUI
-- 
+- they currently can't be edited through the GUI
+- tie-breaking heuristics don't always do what one expects
 
 Syntax:
 
 <type> [<label>] <from> <op> <to> [<offset>]
 
 Types:
-- measxy: measure diagonally
+- meas: measure diagonally
 - measx: measure along the X axis
 - measy: measure along the y axis
 

Modified: trunk/eda/fped/TODO
===================================================================
--- trunk/eda/fped/TODO 2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/TODO 2009-08-09 00:06:54 UTC (rev 5412)
@@ -1,4 +1,4 @@
-Missing features:
+Major missing features:
 - populate input area (still needed: mm/mil, rezoom)
 - add default unit (combine with grid unit selection ?)
 - consider adding auto/mm/mil selection for each dimension
@@ -6,7 +6,10 @@
   non-trivial endpoints, e.g., some vector in last iteration of loop)
 - add KiCad output
 - add postscript output
-- add option to include/omit helper vecs and frames (display and postscript)
+- add option to include/omit helper vecs and frames (done for display, still
+  need postscript)
+
+Minor missing features:
 - reorder frames (can use text editor)
 - reorder rows in a table (can use text editor)
 - reorder columns in a table
@@ -17,6 +20,8 @@
 
 Style:
 - make column of entry field greedily consume all unallocated space
+- make menu bar consume all unallocated space instead of sharing it evenly with
+  upper toolbar
 - status area looks awful
 - add button with GTK_STOCK_UNDELETE for "undelete" to menu bar
 - edit names/values/etc. in place if possible

Modified: trunk/eda/fped/delete.c
===================================================================
--- trunk/eda/fped/delete.c     2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/delete.c     2009-08-09 00:06:54 UTC (rev 5412)
@@ -124,6 +124,7 @@
        case ot_arc:
                return obj->u.arc.start == ref || obj->u.arc.end == ref;
        case ot_meas:
+               return obj->u.meas.high == ref;
        default:
                abort();
        }
@@ -203,7 +204,8 @@
                free_expr(obj->u.arc.width);
                break;
        case ot_meas:
-               free_expr(obj->u.meas.offset);
+               if (obj->u.meas.offset)
+                       free_expr(obj->u.meas.offset);
                break;
        default:
                abort();

Modified: trunk/eda/fped/dump.c
===================================================================
--- trunk/eda/fped/dump.c       2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/dump.c       2009-08-09 00:06:54 UTC (rev 5412)
@@ -201,9 +201,7 @@
                l |= later(obj->u.arc.end, prev);
                break;
        case ot_meas:
-               n |= need(obj->u.meas.other, prev);
-               l |= later(obj->u.meas.other, prev);
-               break;
+               return 0;
        default:
                abort();
        }
@@ -212,6 +210,21 @@
 }
 
 
+static const char *meas_type_name[mt_n] = {
+       "meas", "measx", "measy",
+       "meas", "measx", "measy",
+};
+
+
+
+static void print_meas_base(FILE *file, struct vec *base)
+{
+       if (base->frame != root_frame)
+               fprintf(file, "%s.", base->frame->name);
+       fprintf(file, "%s", base->name);
+}
+
+
 static void dump_obj(FILE *file, struct obj *obj, const char *indent,
     const struct vec *prev)
 {
@@ -262,11 +275,22 @@
                free(s3);
                break;
        case ot_meas:
-               s1 = obj_base_name(obj->u.meas.other, prev);
-               s2 = unparse(obj->u.meas.offset);
-               fprintf(file, "%smeas %s %s %s\n", indent, base, s1, s2);
-               free(s1);
-               free(s2);
+               fprintf(file, "%s%s ", indent,
+                   meas_type_name[obj->u.meas.type]);
+               if (obj->u.meas.label)
+                       fprintf(file, "\"%s\" ", obj->u.meas.label);
+               print_meas_base(file, obj->base);
+               fprintf(file, " %s ",
+                   obj->u.meas.type < 3 ? obj->u.meas.inverted ? "<-" : "->" :
+                   obj->u.meas.inverted ? "<<" : ">>");
+               print_meas_base(file, obj->u.meas.high);
+               if (!obj->u.meas.offset)
+                       fprintf(file, "\n");
+               else {
+                       s1 = unparse(obj->u.meas.offset);
+                       fprintf(file, " %s\n", s1);
+                       free(s1);
+               }
                break;
        default:
                abort();
@@ -340,7 +364,7 @@
                obj->dumped = 0;
        dump_vecs(file, frame->vecs, indent);
 
-       /* duh. do we need this ? */
+       /* do we need this for anything but measurements ? */
        for (obj = frame->objs; obj; obj = obj->next)
                dump_obj(file, obj, indent, NULL);
 }

Modified: trunk/eda/fped/fpd.l
===================================================================
--- trunk/eda/fped/fpd.l        2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/fpd.l        2009-08-09 00:06:54 UTC (rev 5412)
@@ -95,8 +95,6 @@
                                  return TOK_ARC; }
 <INITIAL>"meas"                        { BEGIN(NOKEYWORD);
                                  return TOK_MEAS; }
-<INITIAL>"measxy"              { BEGIN(NOKEYWORD);
-                                 return TOK_MEASXY; }
 <INITIAL>"measx"               { BEGIN(NOKEYWORD);
                                  return TOK_MEASX; }
 <INITIAL>"measy"               { BEGIN(NOKEYWORD);

Modified: trunk/eda/fped/fpd.y
===================================================================
--- trunk/eda/fped/fpd.y        2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/fpd.y        2009-08-09 00:06:54 UTC (rev 5412)
@@ -141,7 +141,6 @@
        struct value *value;
        struct vec *vec;
        struct obj *obj;
-       struct meas *meas;
        enum meas_type mt;
        struct {
                int inverted;
@@ -153,7 +152,7 @@
 %token         START_FPD START_EXPR
 %token         TOK_SET TOK_LOOP TOK_PART TOK_FRAME TOK_TABLE TOK_VEC
 %token         TOK_PAD TOK_RECT TOK_LINE TOK_CIRC TOK_ARC
-%token         TOK_MEAS TOK_MEASXY TOK_MEASX TOK_MEASY
+%token         TOK_MEAS TOK_MEASX TOK_MEASY
 %token         TOK_NEXT TOK_NEXT_INVERTED TOK_MAX TOK_MAX_INVERTED
 
 %token <num>   NUMBER
@@ -165,9 +164,8 @@
 %type  <row>   rows
 %type  <value> row value
 %type  <vec>   vec base qbase
-%type  <obj>   obj
+%type  <obj>   obj meas
 %type  <expr>  expr opt_expr add_expr mult_expr unary_expr primary_expr
-%type  <meas>  measurements meas
 %type  <str>   opt_string
 %type  <mt>    meas_type
 %type  <mo>    meas_op
@@ -246,9 +244,6 @@
 
 frame_items:
        measurements
-               {
-                       measurements = $1;
-               }
        | frame_item frame_items
        ;
 
@@ -455,13 +450,6 @@
                        $$->u.arc.end = $4;
                        $$->u.arc.width = $5;
                }
-       | TOK_MEAS base base expr
-               {
-                       $$ = new_obj(ot_meas);
-                       $$->base = $2;
-                       $$->u.meas.other = $3;
-                       $$->u.meas.offset = $4;
-               }
        | TOK_FRAME ID 
                { 
                    $<num>$.n = lineno;
@@ -482,26 +470,26 @@
        ;
 
 measurements:
+       | measurements meas
                {
-                       $$ = NULL;
+                       *next_obj = $2;
+                       next_obj = &$2->next;
                }
-       | meas measurements
-               {
-                       $$ = $1;
-                       $$->next = $2;
-               }
        ;
 
 meas:
        meas_type opt_string qbase meas_op qbase opt_expr
                {
-                       $$ = alloc_type(struct meas);
-                       $$->type = $4.max ? $1+3 : $1;
-                       $$->label = $2;
-                       $$->low = $3;
-                       $$->inverted = $4.inverted;
-                       $$->high = $5;
-                       $$->offset = $6;
+                       struct meas *meas;
+
+                       $$ = new_obj(ot_meas);
+                       meas = &$$->u.meas;
+                       meas->type = $4.max ? $1+3 : $1;
+                       meas->label = $2;
+                       $$->base = $3;
+                       meas->inverted = $4.inverted;
+                       meas->high = $5;
+                       meas->offset = $6;
                        $$->next = NULL;
                }
        ;
@@ -529,7 +517,7 @@
        ;
 
 meas_type:
-       TOK_MEASXY
+       TOK_MEAS
                {
                        $$ = mt_xy_next;
                }

Modified: trunk/eda/fped/gui_inst.c
===================================================================
--- trunk/eda/fped/gui_inst.c   2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/gui_inst.c   2009-08-09 00:06:54 UTC (rev 5412)
@@ -358,15 +358,14 @@
        struct coord a0, b0, a1, b1, off, c, d;
        GdkGC *gc;
        double len;
-       const char *label = self->u.meas.meas ?
-           self->u.meas.meas->label ? self->u.meas.meas->label : "" : "";
+       const struct meas *meas = &self->obj->u.meas;
        char *s;
 
        a0 = translate(self->base);
        b0 = translate(self->u.meas.end);
        a1 = self->base;
        b1 = self->u.meas.end;
-       switch (self->u.meas.meas ? self->u.meas.meas->type : mt_xy_next) {
+       switch (meas->type) {
        case mt_xy_next:
        case mt_xy_max:
                break;
@@ -394,7 +393,7 @@
 
        c = add_vec(a1, b1);
        d = sub_vec(b1, a1);
-       s = stralloc_printf("%s%lgmm", label, len);
+       s = stralloc_printf("%s%lgmm", meas->label ? meas->label : "", len);
        render_text(DA, gc, c.x/2, c.y/2, -atan2(d.y, d.x)/M_PI*180, s,
            MEAS_FONT, 0.5, -MEAS_BASELINE_OFFSET,
            dist_point(a1, b1)-1.5*MEAS_ARROW_LEN, 0);

Modified: trunk/eda/fped/gui_meas.c
===================================================================
--- trunk/eda/fped/gui_meas.c   2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/gui_meas.c   2009-08-09 00:06:54 UTC (rev 5412)
@@ -256,12 +256,15 @@
 
 static int end_new_meas(struct inst *from, struct inst *to)
 {
+       struct obj *obj;
        struct meas *meas;
 
        meas_inst = NULL;
        if (from == to)
                return 0;
-       meas = alloc_type(struct meas);
+       /* it's safe to pass "from" here, but we may change it later */
+       obj = new_obj(ot_meas, from);
+       meas = &obj->u.meas;
        meas->label = NULL;
        switch (mode) {
        case min_to_next_or_max:
@@ -270,17 +273,17 @@
                } else {
                        meas->type = meas_dsc->type+3;
                }
-               meas->low = from->vec;
+               obj->base = from->vec;
                meas->high = to->vec;
                break;
        case next_to_min:
                meas->type = meas_dsc->type;
-               meas->low = to->vec;
+               obj->base = to->vec;
                meas->high = from->vec;
                break;
        case max_to_min:
                meas->type = meas_dsc->type+3;
-               meas->low = to->vec;
+               obj->base = to->vec;
                meas->high = from->vec;
                break;
        default:
@@ -296,9 +299,7 @@
 fprintf(stderr, "mode %s type %s, inverted %d\n",
 sm[mode], st[meas->type], meas->inverted);
 }
-       meas->offset = parse_expr("0mm");
-       meas->next = measurements;
-       measurements = meas;
+       meas->offset = NULL;
        meas_dsc = NULL;
        return 1;
 }

Modified: trunk/eda/fped/gui_tool.c
===================================================================
--- trunk/eda/fped/gui_tool.c   2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/gui_tool.c   2009-08-09 00:06:54 UTC (rev 5412)
@@ -81,7 +81,7 @@
 }
 
 
-static struct obj *new_obj(enum obj_type type, struct inst *base)
+struct obj *new_obj(enum obj_type type, struct inst *base)
 {
        struct obj *obj, **walk;
 

Modified: trunk/eda/fped/gui_tool.h
===================================================================
--- trunk/eda/fped/gui_tool.h   2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/gui_tool.h   2009-08-09 00:06:54 UTC (rev 5412)
@@ -59,6 +59,7 @@
  * compilation unit.
  */
 
+struct obj *new_obj(enum obj_type type, struct inst *base);
 struct pix_buf *draw_move_line_common(struct inst *inst,
     struct coord end, struct coord pos, int i);
 struct pix_buf *drag_new_line(struct inst *from, struct coord to);

Modified: trunk/eda/fped/inst.c
===================================================================
--- trunk/eda/fped/inst.c       2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/inst.c       2009-08-09 00:06:54 UTC (rev 5412)
@@ -677,10 +677,8 @@
 {
        struct obj *obj = inst->obj;
 
-       if (!inst->obj)
-               return 0; /* @@@ new-style measurements */
        anchors[0] = &obj->base;
-       anchors[1] = &obj->u.meas.other;
+       anchors[1] = &obj->u.meas.high;
        return 2;
 }
 
@@ -695,7 +693,7 @@
 };
 
 
-int inst_meas(struct obj *obj, struct meas *meas,
+int inst_meas(struct obj *obj,
     struct coord from, struct coord to, unit_type offset)
 {
        struct inst *inst;
@@ -704,9 +702,7 @@
        inst->obj = obj;
        inst->u.meas.end = to;
        inst->u.meas.offset = offset;
-       inst->u.meas.meas = meas;
-       if (!obj)
-               inst->active = 1; /* @@@ new-style measurements */
+       inst->active = 1; /* measurements are always active */
        /* @@@ our bbox is actually a bit more complex than this */
        update_bbox(&inst->bbox, to);
        propagate_bbox(inst);

Modified: trunk/eda/fped/inst.h
===================================================================
--- trunk/eda/fped/inst.h       2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/inst.h       2009-08-09 00:06:54 UTC (rev 5412)
@@ -70,7 +70,6 @@
                struct {
                        struct coord end;
                        double offset;
-                       struct meas *meas; /* new-style measurement */
                } meas;
        } u;
        struct inst *next;
@@ -96,8 +95,8 @@
 int inst_pad(struct obj *obj, const char *name, struct coord a, struct coord 
b);
 int inst_arc(struct obj *obj, struct coord center, struct coord start,
     struct coord stop, unit_type width);
-int inst_meas(struct obj *obj, struct meas *meas,
-    struct coord from, struct coord to, unit_type offset);
+int inst_meas(struct obj *obj, struct coord from, struct coord to,
+    unit_type offset);
 
 void inst_begin_active(int active);
 void inst_end_active(void);

Modified: trunk/eda/fped/meas.c
===================================================================
--- trunk/eda/fped/meas.c       2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/meas.c       2009-08-09 00:06:54 UTC (rev 5412)
@@ -28,9 +28,7 @@
        struct sample *next;
 };
 
-struct meas *measurements = NULL;
 
-
 static void reset_samples(struct sample **samples)
 {
        struct sample *next;
@@ -210,17 +208,21 @@
 
 int instantiate_meas(void)
 {
-       struct meas *meas;
+       struct obj *obj;
+       const struct meas *meas;
        struct coord a0, b0;
        lt_op_type lt;
        struct num offset;
 
-       for (meas = measurements; meas; meas = meas->next) {
-               if (!meas->low->samples || !meas->high->samples)
+       for (obj = root_frame->objs; obj; obj = obj->next) {
+               if (obj->type != ot_meas)
                        continue;
+               meas = &obj->u.meas;
+               if (!obj->base->samples || !meas->high->samples)
+                       return 1;
 
                lt = lt_op[meas->type];
-               a0 = meas_find_min(lt, meas->low->samples);
+               a0 = meas_find_min(lt, obj->base->samples);
                if (is_next[meas->type])
                        b0 = meas_find_next(lt, meas->high->samples, a0);
                else
@@ -233,7 +235,7 @@
                        if (is_undef(offset))
                                return 0;
                }
-               inst_meas(NULL, meas,
+               inst_meas(obj,
                    meas->inverted ? b0 : a0, meas->inverted ? a0 : b0,
                    offset.n);
        }

Modified: trunk/eda/fped/meas.fpd
===================================================================
--- trunk/eda/fped/meas.fpd     2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/meas.fpd     2009-08-09 00:06:54 UTC (rev 5412)
@@ -11,14 +11,14 @@
 /*
  * If we measure (x, y), y trumps x
  */
-measxy "A -> B = " A -> B 0.2mm
-measxy "A <- B = " A <- B 0.5mm
+meas "A -> B = " A -> B 0.2mm
+meas "A <- B = " A <- B 0.5mm
 
-measxy "A >> B = " A >> B 1.5mm
+meas "A >> B = " A >> B 1.5mm
 
 measx "x(A -> B) = " A -> B -0.5mm
 measx "x(A >> B) = " A >> B -1mm
 measy "y(A -> B) = " A -> B -2mm
 measy "y(A >> B) = " A >> B -4.5mm
 
-measxy "B -> C = " B -> C 0.5mm
+meas "B -> C = " B -> C 0.5mm

Modified: trunk/eda/fped/meas.h
===================================================================
--- trunk/eda/fped/meas.h       2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/meas.h       2009-08-09 00:06:54 UTC (rev 5412)
@@ -14,11 +14,15 @@
 #ifndef MEAS_H
 #define MEAS_H
 
-#include "obj.h"
 
+#include "coord.h"
+#include "expr.h"
 
+
 typedef int (*lt_op_type)(struct coord a, struct coord b);
 
+struct vec;
+struct obj;
 
 struct meas {
        enum meas_type {
@@ -32,18 +36,14 @@
        } type;
        char *label; /* or NULL */
        int inverted;
-       struct vec *low;
+       /* low is obj->base */
        struct vec *high;
        struct expr *offset;
-       struct meas *next;
 };
 
 struct sample;
 
 
-extern struct meas *measurements;
-
-
 int lt_x(struct coord a, struct coord b);
 int lt_y(struct coord a, struct coord b);
 int lt_xy(struct coord a, struct coord b);

Modified: trunk/eda/fped/obj.c
===================================================================
--- trunk/eda/fped/obj.c        2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/obj.c        2009-08-09 00:06:54 UTC (rev 5412)
@@ -92,7 +92,7 @@
        struct obj *obj;
        char *name;
        int ok;
-       struct num width, offset;
+       struct num width;
 
        for (obj = frame->objs; obj; obj = obj->next)
                switch (obj->type) {
@@ -145,14 +145,6 @@
                                return 0;
                        break;
                case ot_meas:
-                       offset = eval_unit(obj->u.meas.offset, frame);
-                       if (is_undef(offset))
-                               return 0;
-                       if (!inst_meas(obj, NULL,
-                           obj->base ? obj->base->pos : base,
-                           obj->u.meas.other ? obj->u.meas.other->pos : base,
-                           offset.n))
-                               return 0;
                        break;
                default:
                        abort();

Modified: trunk/eda/fped/obj.h
===================================================================
--- trunk/eda/fped/obj.h        2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/obj.h        2009-08-09 00:06:54 UTC (rev 5412)
@@ -19,6 +19,7 @@
 
 #include "expr.h"
 #include "coord.h"
+#include "meas.h"
 
 
 struct var {
@@ -152,11 +153,6 @@
        struct expr *width;
 };
 
-struct old_meas {
-       struct vec *other; /* NULL if frame origin */
-       struct expr *offset;
-};
-
 struct obj {
        enum obj_type type;
        union {
@@ -165,7 +161,7 @@
                struct rect line;
                struct pad pad;
                struct arc arc;
-               struct old_meas meas;
+               struct meas meas;
        } u;
        struct frame *frame;
        struct vec *base;

Modified: trunk/eda/fped/qfn.fpd
===================================================================
--- trunk/eda/fped/qfn.fpd      2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/qfn.fpd      2009-08-09 00:06:54 UTC (rev 5412)
@@ -9,9 +9,7 @@
 
 frame pad_up {
        c: vec @(-D/2, 0mm)
-       vec .(0mm, C)
-       meas c . 0.2mm
-       vec c(D, C)
+       o: vec c(D, C)
        set pad = n+1
        pad "$pad" c .
 }
@@ -71,3 +69,5 @@
 x2 = (1+2)*3
 x3 = 1-(2+3)
 */
+
+measy pad_up.c -> pad_up.o 0.2mm

Modified: trunk/eda/fped/sc89.fpd
===================================================================
--- trunk/eda/fped/sc89.fpd     2009-08-08 21:59:33 UTC (rev 5411)
+++ trunk/eda/fped/sc89.fpd     2009-08-09 00:06:54 UTC (rev 5412)
@@ -5,8 +5,6 @@
        se: vec sw(Px, 0mm)
        nw: vec sw(0mm, Py)
        pad "$pad" se nw
-//     meas sw se -0.1mm
-//     meas sw nw 0.1mm
 }
 
 frame pad_ne {




--- End Message ---
_______________________________________________
commitlog mailing list
commitlog@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/commitlog

Reply via email to