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. r5461 - trunk/eda/fped (wer...@docs.openmoko.org)
   2. r5462 - trunk/eda/fped (wer...@docs.openmoko.org)
   3. r5463 - trunk/eda/fped (wer...@docs.openmoko.org)
--- Begin Message ---
Author: werner
Date: 2009-08-16 13:21:48 +0200 (Sun, 16 Aug 2009)
New Revision: 5461

Modified:
   trunk/eda/fped/Makefile
   trunk/eda/fped/TODO
   trunk/eda/fped/error.c
   trunk/eda/fped/error.h
   trunk/eda/fped/gui_canvas.c
   trunk/eda/fped/gui_canvas.h
   trunk/eda/fped/gui_inst.c
   trunk/eda/fped/gui_inst.h
   trunk/eda/fped/gui_status.c
   trunk/eda/fped/gui_status.h
   trunk/eda/fped/gui_style.h
   trunk/eda/fped/postscript.c
   trunk/eda/fped/util.h
Log:
Added Postscript outout for measurements, plus assorted changes.

- postscript.c: added patterns backhatchpath and crosspath (for pad overlaid 
  with solder paste)
- postscript.c: added measurements
- postscript.c: prefixed style parameters with PS_ to avoid future conflicts
  with gui_style.h
- when changing the default unit, we now cancel the selection, and refresh 
  canvas and current position
- on-screen measurements now suppress the unit if set to anything but "auto"
- use  __attribute__((format(printf, ...))) for printf-like functions
- the unit selector now has a white background to make it clearer that it can 
  be clicked



Modified: trunk/eda/fped/Makefile
===================================================================
--- trunk/eda/fped/Makefile     2009-08-16 05:05:12 UTC (rev 5460)
+++ trunk/eda/fped/Makefile     2009-08-16 11:21:48 UTC (rev 5461)
@@ -28,7 +28,7 @@
 LIBS_GTK = `pkg-config --libs gtk+-2.0`
 
 CFLAGS_WARN=-Wall -Wshadow -Wmissing-prototypes \
-            -Wmissing-declarations
+            -Wmissing-declarations -Wno-format-zero-length
 CFLAGS=-g -std=gnu99 $(CFLAGS_GTK) -DCPP='"cpp"' $(CFLAGS_WARN)
 SLOPPY=-Wno-unused -Wno-implicit-function-declaration -Wno-missing-prototypes \
        -Wno-missing-declarations

Modified: trunk/eda/fped/TODO
===================================================================
--- trunk/eda/fped/TODO 2009-08-16 05:05:12 UTC (rev 5460)
+++ trunk/eda/fped/TODO 2009-08-16 11:21:48 UTC (rev 5461)
@@ -21,6 +21,10 @@
 - status area looks awful
 - add button with GTK_STOCK_UNDELETE for "undelete" to menu bar
 - edit names/values/etc. in place if possible
+- maximizing pad name size creates uneven text sizes. Particularly "1" gets
+  excessively large.
+- pango_layout_get_size doesn't seem to consider rotation, so we currently
+  don't properly size rotated text.
 
 Bugs:
 - default silk width has no business being hard-coded in obj.c

Modified: trunk/eda/fped/error.c
===================================================================
--- trunk/eda/fped/error.c      2009-08-16 05:05:12 UTC (rev 5460)
+++ trunk/eda/fped/error.c      2009-08-16 11:21:48 UTC (rev 5461)
@@ -38,7 +38,7 @@
        va_start(ap, fmt);
        vsnprintf(buf, n+1, fmt, ap);
        va_end(ap);
-       fail(buf);
+       fail("%s", buf);
        free(buf);
 }
 

Modified: trunk/eda/fped/error.h
===================================================================
--- trunk/eda/fped/error.h      2009-08-16 05:05:12 UTC (rev 5460)
+++ trunk/eda/fped/error.h      2009-08-16 11:21:48 UTC (rev 5461)
@@ -20,11 +20,13 @@
 extern void (*reporter)(const char *s);
 
 
-void yyerrorf(const char *fmt, ...);
+void yyerrorf(const char *fmt, ...)
+    __attribute__((format(printf, 1, 2)));
 void yyerror(const char *s);
 
 void report_to_stderr(const char *s);
 void report_parse_error(const char *s);
-void fail(const char *fmt, ...);
+void fail(const char *fmt, ...)
+    __attribute__((format(printf, 1, 2)));
 
 #endif /* !ERROR_H */

Modified: trunk/eda/fped/gui_canvas.c
===================================================================
--- trunk/eda/fped/gui_canvas.c 2009-08-16 05:05:12 UTC (rev 5460)
+++ trunk/eda/fped/gui_canvas.c 2009-08-16 11:21:48 UTC (rev 5461)
@@ -62,6 +62,12 @@
 }
 
 
+void refresh_pos(void)
+{
+       update_pos(curr_pos);
+}
+
+
 /* ----- coordinate system ------------------------------------------------- */
 
 

Modified: trunk/eda/fped/gui_canvas.h
===================================================================
--- trunk/eda/fped/gui_canvas.h 2009-08-16 05:05:12 UTC (rev 5460)
+++ trunk/eda/fped/gui_canvas.h 2009-08-16 11:21:48 UTC (rev 5461)
@@ -25,6 +25,8 @@
 extern void (*highlight)(void);
 
 
+void refresh_pos(void);
+
 void redraw(void);
 
 GtkWidget *make_canvas(void);

Modified: trunk/eda/fped/gui_inst.c
===================================================================
--- trunk/eda/fped/gui_inst.c   2009-08-16 05:05:12 UTC (rev 5460)
+++ trunk/eda/fped/gui_inst.c   2009-08-16 11:21:48 UTC (rev 5461)
@@ -21,6 +21,7 @@
 #include "gui.h"
 #include "gui_util.h"
 #include "gui_style.h"
+#include "gui_status.h"
 #include "gui_inst.h"
 
 
@@ -378,7 +379,7 @@
 }
 
 
-static void project_meas(struct inst *inst, struct coord *a1, struct coord *b1)
+void project_meas(const struct inst *inst, struct coord *a1, struct coord *b1)
 {
        const struct meas *meas = &inst->obj->u.meas;
        struct coord off;
@@ -417,6 +418,35 @@
 }
 
 
+char *format_len(const char *label, unit_type len, enum curr_unit unit)
+{
+       const char *u = "";
+       double n;
+       int mm;
+
+       switch (unit) {
+       case curr_unit_mm:
+               n = units_to_mm(len);
+               mm = 1;
+               break;
+       case curr_unit_mil:
+               n = units_to_mil(len);
+               mm = 0;
+               break;
+       case curr_unit_auto:
+               n = units_to_best(len, &mm);
+               u = mm ? "mm" : "mil";
+               break;
+       default:
+               abort();
+       }
+       return stralloc_printf(mm ?
+           "%s" MM_FORMAT_SHORT "%s" : 
+           "%s" MIL_FORMAT_SHORT "%s",
+           label, n, u);
+}
+
+
 void gui_draw_meas(struct inst *self)
 {
        const struct meas *meas = &self->obj->u.meas;
@@ -429,7 +459,7 @@
        b0 = translate(self->u.meas.end);
        project_meas(self, &a1, &b1);
 
-       len = units_to_mm(dist_point(a1, b1));
+       len = dist_point(a1, b1);
        a1 = translate(a1);
        b1 = translate(b1);
        gc = gc_meas[get_mode(self)];
@@ -441,7 +471,7 @@
 
        c = add_vec(a1, b1);
        d = sub_vec(b1, a1);
-       s = stralloc_printf("%s%lgmm", meas->label ? meas->label : "", len);
+       s = format_len(meas->label ? meas->label : "", len, curr_unit);
        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_inst.h
===================================================================
--- trunk/eda/fped/gui_inst.h   2009-08-16 05:05:12 UTC (rev 5460)
+++ trunk/eda/fped/gui_inst.h   2009-08-16 11:21:48 UTC (rev 5461)
@@ -18,6 +18,7 @@
 
 #include "coord.h"
 #include "inst.h"
+#include "gui_status.h"
 
 
 struct coord translate(struct coord pos);
@@ -35,6 +36,9 @@
 unit_type gui_dist_frame_eye(struct inst *self, struct coord pos,
     unit_type scale);
 
+void project_meas(const struct inst *inst, struct coord *a1, struct coord *b1);
+char *format_len(const char *label, unit_type len, enum curr_unit unit);
+
 void gui_draw_vec(struct inst *self);
 void gui_draw_line(struct inst *self);
 void gui_draw_rect(struct inst *self);

Modified: trunk/eda/fped/gui_status.c
===================================================================
--- trunk/eda/fped/gui_status.c 2009-08-16 05:05:12 UTC (rev 5460)
+++ trunk/eda/fped/gui_status.c 2009-08-16 11:21:48 UTC (rev 5461)
@@ -25,6 +25,7 @@
 #include "unparse.h"
 #include "gui_util.h"
 #include "gui_style.h"
+#include "gui_canvas.h"
 #include "gui.h"
 #include "gui_status.h"
 
@@ -43,12 +44,7 @@
 };
 
 
-static enum curr_unit {
-       unit_mm,
-       unit_mil,
-       unit_auto,
-       unit_n
-} curr_unit = unit_mm;
+enum curr_unit curr_unit = curr_unit_mm;
 
 
 static GtkWidget *open_edits = NULL;
@@ -116,15 +112,15 @@
        int mm;
 
        switch (curr_unit) {
-       case unit_mm:
+       case curr_unit_mm:
                n = units_to_mm(u);
                mm = 1;
                break;
-       case unit_mil:
+       case curr_unit_mil:
                n = units_to_mil(u);
                mm = 0;
                break;
-       case unit_auto:
+       case curr_unit_auto:
                n = units_to_best(u, &mm);
                break;
        default:
@@ -132,10 +128,10 @@
        }
        if (mm) {
                /* -NNN.NNN mm */
-               set("%s%8.3f mm", prefix, n);
+               set("%s" MM_FORMAT_FIXED " mm", prefix, n);
        } else {
                /* -NNNN.N mil */
-               set("%s%7.1f mil", prefix, n);
+               set("%s" MIL_FORMAT_FIXED " mil", prefix, n);
        }
 }
 
@@ -745,15 +741,15 @@
 {
        switch (event->button) {
        case 1:
-               curr_unit = (curr_unit+1) % unit_n;
+               curr_unit = (curr_unit+1) % curr_unit_n;
                switch (curr_unit) {
-               case unit_mm:
+               case curr_unit_mm:
                        status_set_unit("mm");
                        break;
-               case unit_mil:
+               case curr_unit_mil:
                        status_set_unit("mil");
                        break;
-               case unit_auto:
+               case curr_unit_auto:
                        status_set_unit("auto");
                        break;
                default:
@@ -761,6 +757,8 @@
                }
                break;
        }
+       refresh_pos();
+       change_world();
        return TRUE;
 }
 
@@ -860,6 +858,7 @@
 
        /* unit selection */
 
+       label_in_box_bg(status_unit, COLOR_UNIT_SELECTOR);
        status_set_unit("mm");
        g_signal_connect(G_OBJECT(box_of_label(status_unit)),
            "button_press_event", G_CALLBACK(unit_button_press_event), NULL);

Modified: trunk/eda/fped/gui_status.h
===================================================================
--- trunk/eda/fped/gui_status.h 2009-08-16 05:05:12 UTC (rev 5460)
+++ trunk/eda/fped/gui_status.h 2009-08-16 11:21:48 UTC (rev 5461)
@@ -20,6 +20,17 @@
 #include "expr.h"
 
 
+enum curr_unit {
+       curr_unit_mm,
+       curr_unit_mil,
+       curr_unit_auto,
+       curr_unit_n
+};
+
+
+extern enum curr_unit curr_unit;
+
+
 void edit_unique(const char **s, int (*validate)(const char *s, void *ctx),
     void *ctx);
 void edit_unique_null(const char **s, int (*validate)(const char *s, void 
*ctx),
@@ -40,21 +51,36 @@
 void set_with_units(void (*set)(const char *fmt, ...), const char *prefix,
     unit_type u);
 
-void status_set_type_x(const char *fmt, ...);
-void status_set_type_y(const char *fmt, ...);
-void status_set_type_entry(const char *fmt, ...);
-void status_set_name(const char *fmt, ...);
-void status_set_x(const char *fmt, ...);
-void status_set_y(const char *fmt, ...);
-void status_set_r(const char *fmt, ...);
-void status_set_angle(const char *fmt, ...);
-void status_set_sys_x(const char *fmt, ...);
-void status_set_sys_y(const char *fmt, ...);
-void status_set_user_x(const char *fmt, ...);
-void status_set_user_y(const char *fmt, ...);
-void status_set_zoom(const char *fmt, ...);
-void status_set_grid(const char *fmt, ...);
-void status_set_unit(const char *fmt, ...);
+void status_set_type_x(const char *fmt, ...)
+    __attribute__((format(printf, 1, 2)));
+void status_set_type_y(const char *fmt, ...)
+    __attribute__((format(printf, 1, 2)));
+void status_set_type_entry(const char *fmt, ...)
+    __attribute__((format(printf, 1, 2)));
+void status_set_name(const char *fmt, ...)
+    __attribute__((format(printf, 1, 2)));
+void status_set_x(const char *fmt, ...)
+    __attribute__((format(printf, 1, 2)));
+void status_set_y(const char *fmt, ...)
+    __attribute__((format(printf, 1, 2)));
+void status_set_r(const char *fmt, ...)
+    __attribute__((format(printf, 1, 2)));
+void status_set_angle(const char *fmt, ...)
+    __attribute__((format(printf, 1, 2)));
+void status_set_sys_x(const char *fmt, ...)
+    __attribute__((format(printf, 1, 2)));
+void status_set_sys_y(const char *fmt, ...)
+    __attribute__((format(printf, 1, 2)));
+void status_set_user_x(const char *fmt, ...)
+    __attribute__((format(printf, 1, 2)));
+void status_set_user_y(const char *fmt, ...)
+    __attribute__((format(printf, 1, 2)));
+void status_set_zoom(const char *fmt, ...)
+    __attribute__((format(printf, 1, 2)));
+void status_set_grid(const char *fmt, ...)
+    __attribute__((format(printf, 1, 2)));
+void status_set_unit(const char *fmt, ...)
+    __attribute__((format(printf, 1, 2)));
 
 void status_set_xy(struct coord coord);
 

Modified: trunk/eda/fped/gui_style.h
===================================================================
--- trunk/eda/fped/gui_style.h  2009-08-16 05:05:12 UTC (rev 5460)
+++ trunk/eda/fped/gui_style.h  2009-08-16 11:21:48 UTC (rev 5461)
@@ -55,7 +55,12 @@
 
 #define        MIN_FONT_SCALE          0.20    /* don't scale fonts below this 
*/
 
+#define        MM_FORMAT_FIXED         "%8.3f" /* -NNN.NNN */
+#define        MIL_FORMAT_FIXED        "%7.1f" /* -NNNN.N */
+#define        MM_FORMAT_SHORT         "%.4g"
+#define        MIL_FORMAT_SHORT        "%.4g"
 
+
 /* ----- assorted colors --------------------------------------------------- */
 
 
@@ -90,7 +95,9 @@
 #define        COLOR_ITEM_SELECTED     COLOR_FRAME_SELECTED
 #define        COLOR_ITEM_ERROR        "red"
 
+#define        COLOR_UNIT_SELECTOR     "white"
 
+
 /* ----- canvas drawing styles --------------------------------------------- */
 
 

Modified: trunk/eda/fped/postscript.c
===================================================================
--- trunk/eda/fped/postscript.c 2009-08-16 05:05:12 UTC (rev 5460)
+++ trunk/eda/fped/postscript.c 2009-08-16 11:21:48 UTC (rev 5461)
@@ -16,14 +16,21 @@
 
 #include "coord.h"
 #include "inst.h"
+#include "gui_status.h"
+#include "gui_inst.h"
 #include "postscript.h"
 
 
-#define        DOT_DIST        mm_to_units(0.03)
-#define        DOT_DIAM        mm_to_units(0.01)
-#define        HATCH           mm_to_units(0.1)
-#define        HATCH_LINE      mm_to_units(0.02)
-#define        FONT_OUTLINE    mm_to_units(0.025)
+#define        PS_DOT_DIST             mm_to_units(0.03)
+#define        PS_DOT_DIAM             mm_to_units(0.01)
+#define        PS_HATCH                mm_to_units(0.1)
+#define        PS_HATCH_LINE           mm_to_units(0.015)
+#define        PS_FONT_OUTLINE         mm_to_units(0.025)
+#define        PS_MEAS_LINE            mm_to_units(0.015)
+#define        PS_MEAS_ARROW_LEN       mm_to_units(0.07)
+#define        PS_MEAS_ARROW_ANGLE     30
+#define        PS_MEAS_TEXT_HEIGHT     mm_to_units(0.2)
+#define        PS_MEAS_BASE_OFFSET     mm_to_units(0.05)
 
 
 struct postscript_params postscript_params = {
@@ -31,7 +38,7 @@
        .show_pad_names = 1,
        .show_stuff     = 0,
        .label_vecs     = 0,
-       .show_meas      = 0,
+       .show_meas      = 1,
 };
 
 
@@ -53,7 +60,7 @@
        fprintf(file, "   maxfont scalefont setfont\n");
        fprintf(file, "   %d %d moveto\n", (a.x+b.x)/2, (a.y+b.y)/2);
        fprintf(file, "   (%s) center %d showoutlined newpath\n",
-           inst->u.pad.name, FONT_OUTLINE);
+           inst->u.pad.name, PS_FONT_OUTLINE);
 }
 
 
@@ -62,12 +69,12 @@
        struct coord a = inst->base;
        struct coord b = inst->u.pad.other;
 
-       fprintf(file, "0 setgray %d setlinewidth\n", HATCH_LINE);
+       fprintf(file, "0 setgray %d setlinewidth\n", PS_HATCH_LINE);
        fprintf(file, "  %d %d moveto\n", a.x, a.y);
        fprintf(file, "  %d %d lineto\n", b.x, a.y);
        fprintf(file, "  %d %d lineto\n", b.x, b.y);
        fprintf(file, "  %d %d lineto\n", a.x, b.y);
-       fprintf(file, "  closepath gsave hatchpath grestore stroke\n");
+       fprintf(file, "  closepath gsave crosspath grestore stroke\n");
 
        if (show_name)
                ps_pad_name(file, inst);
@@ -83,7 +90,7 @@
        sort_coord(&a, &b);
        h = b.y-a.y;
        w = b.x-a.x;
-       fprintf(file, "0 setgray %d setlinewidth\n", HATCH_LINE);
+       fprintf(file, "0 setgray %d setlinewidth\n", PS_HATCH_LINE);
        if (h > w) {
                r = w/2;
                fprintf(file, "  %d %d moveto\n", b.x, b.y-r);
@@ -157,11 +164,68 @@
 }
 
 
-static void ps_meas(FILE *file, const struct inst *inst)
+static void ps_arrow(FILE *file, struct coord from, struct coord to, int len,
+    int angle)
 {
+       struct coord side, p;
+
+       if (from.x == to.x && from.y == to.y) {
+               side.x = 0;
+               side.y = -len;
+       } else {
+               side = normalize(sub_vec(to, from), len);
+       }
+
+       p = add_vec(to, rotate(side, 180-angle));
+       fprintf(file, "  %d %d moveto\n", p.x, p.y);
+       fprintf(file, "  %d %d lineto\n", to.x, to.y);
+
+       p = add_vec(to, rotate(side, 180+angle));
+       fprintf(file, "  %d %d moveto\n", p.x, p.y);
+       fprintf(file, "  %d %d lineto\n", to.x, to.y);
+       fprintf(file, "  stroke\n");
 }
 
 
+static void ps_meas(FILE *file, const struct inst *inst,
+    enum curr_unit unit)
+{
+       struct coord a0, b0, a1, b1;
+       struct coord c, d;
+       char *s;
+
+       a0 = inst->base;
+       b0 = inst->u.meas.end;
+       project_meas(inst, &a1, &b1);
+       fprintf(file, "1 setlinecap 0 setgray %d setlinewidth\n", PS_MEAS_LINE);
+       fprintf(file, "  %d %d moveto\n", a0.x, a0.y);
+       fprintf(file, "  %d %d lineto\n", a1.x, a1.y);
+       fprintf(file, "  %d %d lineto\n", b1.x, b1.y);
+       fprintf(file, "  %d %d lineto\n", b0.x, b0.y);
+       fprintf(file, "  stroke\n");
+
+       ps_arrow(file, a1, b1, PS_MEAS_ARROW_LEN, PS_MEAS_ARROW_ANGLE);
+       ps_arrow(file, b1, a1, PS_MEAS_ARROW_LEN, PS_MEAS_ARROW_ANGLE);
+
+       s = format_len(inst->obj->u.meas.label ? inst->obj->u.meas.label : "",
+           dist_point(a1, b1), unit);
+
+       c = add_vec(a1, b1);
+       d = sub_vec(b1, a1);
+//s = stralloc_printf("%s%lgmm", meas->label ? meas->label : "", len);
+       fprintf(file, "gsave %d %d moveto\n", c.x/2, c.y/2);
+       fprintf(file, "    /Helvetica-Bold findfont dup\n");
+       fprintf(file, "    (%s) %d %d\n", s,
+           (int) (dist_point(a1, b1)-1.5*PS_MEAS_ARROW_LEN),
+           PS_MEAS_TEXT_HEIGHT);
+       fprintf(file, "    4 copy 100 maxfont maxfont scalefont setfont\n");
+       fprintf(file, "    %f rotate\n", atan2(d.y, d.x)/M_PI*180);
+       fprintf(file, "    (%s) %d hcenter\n", s, PS_MEAS_BASE_OFFSET);
+       fprintf(file, "    show grestore\n");
+       free(s);
+}
+
+
 static void ps_background(FILE *file, enum inst_prio prio,
      const struct inst *inst)
 {
@@ -202,7 +266,7 @@
                break;
        case ip_meas:
                if (postscript_params.show_meas)
-                       ps_meas(file, inst);
+                       ps_meas(file, inst, curr_unit);
                break;
        default:
                break;
@@ -235,7 +299,7 @@
 "          1 index exch moveto 0 0 rlineto stroke\n"
 "      } for\n"
 "    } for\n"
-"    grestore newpath } def\n", DOT_DIAM, DOT_DIST, DOT_DIST);
+"    grestore newpath } def\n", PS_DOT_DIAM, PS_DOT_DIST, PS_DOT_DIST);
 
        fprintf(file,
 "/hatchpath {\n"
@@ -245,8 +309,22 @@
 "      llx add dup lly moveto\n"
 "      ury lly sub add ury lineto stroke\n"
 "    } for\n"
-"    grestore newpath } def\n", HATCH);
+"    grestore newpath } def\n", PS_HATCH);
 
+       fprintf(file,
+"/backhatchpath {\n"
+"     gsave pathbbox clip newpath\n"
+"    /ury exch def /urx exch def /lly exch def /llx exch def\n"
+"    0 %d ury lly sub urx llx sub add {\n"     /* for 0 to urx-llx_ury-lly */
+"      llx add dup lly moveto\n"
+"      ury lly sub sub ury lineto stroke\n"
+"    } for\n"
+"    grestore newpath } def\n", PS_HATCH);
+
+fprintf(file,
+"/crosspath {\n"
+"    gsave hatchpath grestore backhatchpath } def\n");
+
        /*
         * Stack: font string width height factor -> factor
         */
@@ -273,6 +351,19 @@
 "    llx urx sub 2 div lly ury sub 2 div rmoveto } def\n");
 
        /*
+        * Stack: string dist -> string
+        */
+
+       fprintf(file,
+"/hcenter {\n"
+"    /off exch def\n"
+"    gsave dup false charpath pathbbox\n"
+"    /ury exch def /urx exch def /lly exch def /llx exch def\n"
+"    grestore\n"
+"    llx urx sub 2 div\n"
+"    currentpoint exch pop lly sub off add rmoveto } def\n");
+
+       /*
         * Stack: string outline_width -> -
         */
 

Modified: trunk/eda/fped/util.h
===================================================================
--- trunk/eda/fped/util.h       2009-08-16 05:05:12 UTC (rev 5460)
+++ trunk/eda/fped/util.h       2009-08-16 11:21:48 UTC (rev 5461)
@@ -48,7 +48,8 @@
 
 
 char *stralloc_vprintf(const char *fmt, va_list ap);
-char *stralloc_printf(const char *fmt, ...);
+char *stralloc_printf(const char *fmt, ...)
+    __attribute__((format(printf, 1, 2)));
 
 int is_id_char(char c, int first);
 int is_id(const char *s);




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2009-08-16 14:04:01 +0200 (Sun, 16 Aug 2009)
New Revision: 5462

Modified:
   trunk/eda/fped/gui.c
   trunk/eda/fped/gui_canvas.c
   trunk/eda/fped/gui_canvas.h
   trunk/eda/fped/gui_frame.c
   trunk/eda/fped/gui_meas.c
   trunk/eda/fped/inst.c
Log:
- adjust measurement bbox for projection (still not perfect, but better)
- we can now scroll-wheel through table rows
- added menu branch "View" with zoom and var/code display controls
- commented out is_min_of_next until its fate is decided, so that we don't get 
  a warning



Modified: trunk/eda/fped/gui.c
===================================================================
--- trunk/eda/fped/gui.c        2009-08-16 11:21:48 UTC (rev 5461)
+++ trunk/eda/fped/gui.c        2009-08-16 12:04:01 UTC (rev 5462)
@@ -39,18 +39,37 @@
 static GtkWidget *stuff_image[2], *meas_image[2];
 
 
+/* ----- view callbacks ---------------------------------------------------- */
+
+
+static void swap_var_code(void)
+{
+       extern int show_vars;
+
+       show_vars = !show_vars;
+       change_world();
+}
+
+
 /* ----- menu bar ---------------------------------------------------------- */
 
 
 static GtkItemFactoryEntry menu_entries[] = {
        { "/File",              NULL,   NULL,           0, "<Branch>" },
        { "/File/Save",         NULL,   save_fpd,       0, "<Item>" },
-        { "/File/sep0",                NULL,   NULL,           0, 
"<Separator>" },
+        { "/File/sep1",                NULL,   NULL,           0, 
"<Separator>" },
         { "/File/Write KiCad", NULL,   write_kicad,    0, "<Item>" },
         { "/File/Write Postscript",
                                NULL,   write_ps,       0, "<Item>" },
         { "/File/sep2",                NULL,   NULL,           0, 
"<Separator>" },
         { "/File/Quit",                NULL,   gtk_main_quit,  0, "<Item>" },
+       { "/View",              NULL,   NULL,           0, "<Branch>" },
+       { "/View/Zoom in",      NULL,   zoom_in_center, 0, "<Item>" },
+       { "/View/Zoom out",     NULL,   zoom_out_center,0, "<Item>" },
+       { "/View/Zoom all",     NULL,   zoom_to_extents,0, "<Item>" },
+       { "/View/Zoom frame",   NULL,   zoom_to_frame,  0, "<Item>" },
+       { "/View/sep1",         NULL,   NULL,           0, "<Separator>" },
+       { "/View/Swap var&code",NULL,   swap_var_code,  0, "<Item>" },
 };
 
 

Modified: trunk/eda/fped/gui_canvas.c
===================================================================
--- trunk/eda/fped/gui_canvas.c 2009-08-16 11:21:48 UTC (rev 5461)
+++ trunk/eda/fped/gui_canvas.c 2009-08-16 12:04:01 UTC (rev 5462)
@@ -279,6 +279,38 @@
 }
 
 
+void zoom_in_center(void)
+{
+       zoom_in(draw_ctx.center);
+}
+
+
+void zoom_out_center(void)
+{
+       zoom_out(draw_ctx.center);
+}
+
+
+void zoom_to_frame(void)
+{
+       tool_dehover();
+       center(&active_frame_bbox);
+       auto_scale(&active_frame_bbox);
+       redraw();
+       tool_hover(canvas_to_coord(curr_pos.x, curr_pos.y));
+}
+
+
+void zoom_to_extents(void)
+{
+       tool_dehover();
+       center(NULL);
+       auto_scale(NULL);
+       redraw();
+       tool_hover(canvas_to_coord(curr_pos.x, curr_pos.y));
+}
+
+
 static gboolean scroll_event(GtkWidget *widget, GdkEventScroll *event,
     gpointer data)
 {
@@ -321,18 +353,10 @@
                zoom_out(pos);
                break;
        case '*':
-               tool_dehover();
-               center(NULL);
-               auto_scale(NULL);
-               redraw();
-               tool_hover(canvas_to_coord(curr_pos.x, curr_pos.y));
+               zoom_to_extents();
                break;
        case '#':
-               tool_dehover();
-               center(&active_frame_bbox);
-               auto_scale(&active_frame_bbox);
-               redraw();
-               tool_hover(canvas_to_coord(curr_pos.x, curr_pos.y));
+               zoom_to_frame();
                break;
        case '.':
                tool_dehover();

Modified: trunk/eda/fped/gui_canvas.h
===================================================================
--- trunk/eda/fped/gui_canvas.h 2009-08-16 11:21:48 UTC (rev 5461)
+++ trunk/eda/fped/gui_canvas.h 2009-08-16 12:04:01 UTC (rev 5462)
@@ -29,6 +29,11 @@
 
 void redraw(void);
 
+void zoom_in_center(void);
+void zoom_out_center(void);
+void zoom_to_frame(void);
+void zoom_to_extents(void);
+
 GtkWidget *make_canvas(void);
 void init_canvas(void);
 

Modified: trunk/eda/fped/gui_frame.c
===================================================================
--- trunk/eda/fped/gui_frame.c  2009-08-16 11:21:48 UTC (rev 5461)
+++ trunk/eda/fped/gui_frame.c  2009-08-16 12:04:01 UTC (rev 5462)
@@ -743,6 +743,34 @@
 }
 
 
+static gboolean table_scroll_event(GtkWidget *widget, GdkEventScroll *event,
+    gpointer data)
+{
+       struct table *table = data;
+       struct row *row, *last;
+
+       switch (event->direction) {
+       case GDK_SCROLL_UP:
+               last = NULL;
+               for (row = table->rows;
+                   row && (!last || row != table->active_row); row = row->next)
+                       last = row;
+               table->active_row = last;
+               change_world();
+               break;
+       case GDK_SCROLL_DOWN:
+               table->active_row = table->active_row->next;
+               if (!table->active_row)
+                       table->active_row = table->rows;
+               change_world();
+               break;
+       default:
+               /* ignore */;
+       }
+       return TRUE;
+}
+
+
 static void build_table(GtkWidget *vbox, struct frame *frame,
     struct table *table)
 {
@@ -786,6 +814,9 @@
                g_signal_connect(G_OBJECT(box_of_label(field)),
                    "button_press_event",
                    G_CALLBACK(table_var_select_event), var);
+               g_signal_connect(G_OBJECT(box_of_label(field)),
+                   "scroll_event",
+                   G_CALLBACK(table_scroll_event), table);
                var->widget = field;
                n_vars++;
        }
@@ -805,6 +836,9 @@
                        g_signal_connect(G_OBJECT(box_of_label(field)),
                            "button_press_event",
                            G_CALLBACK(table_value_select_event), value);
+                       g_signal_connect(G_OBJECT(box_of_label(field)),
+                           "scroll_event",
+                           G_CALLBACK(table_scroll_event), table);
                        value->widget = field;
                        n_vars++;
                }

Modified: trunk/eda/fped/gui_meas.c
===================================================================
--- trunk/eda/fped/gui_meas.c   2009-08-16 11:21:48 UTC (rev 5461)
+++ trunk/eda/fped/gui_meas.c   2009-08-16 12:04:01 UTC (rev 5462)
@@ -102,6 +102,7 @@
 }
 
 
+#if 0
 static int is_min_of_next(lt_op_type lt,
     const struct inst *inst, const struct inst *ref)
 {
@@ -111,6 +112,7 @@
        next = meas_find_next(lt, ref->vec->samples, min);
        return coord_eq(next, ref->u.rect.end);
 }
+#endif
 
 
 /* ----- picker functions -------------------------------------------------- */

Modified: trunk/eda/fped/inst.c
===================================================================
--- trunk/eda/fped/inst.c       2009-08-16 11:21:48 UTC (rev 5461)
+++ trunk/eda/fped/inst.c       2009-08-16 12:04:01 UTC (rev 5462)
@@ -879,14 +879,18 @@
     struct coord from, struct coord to, unit_type offset)
 {
        struct inst *inst;
+       struct coord a1, b1;
 
        inst = add_inst(&meas_ops, ip_meas, from);
        inst->obj = obj;
        inst->u.meas.end = to;
        inst->u.meas.offset = offset;
        inst->active = 1; /* measurements are always active */
-       /* @@@ our bbox is actually a bit more complex than this */
+       /* @@@ we still need to consider the text size as well */
        update_bbox(&inst->bbox, to);
+       project_meas(inst, &a1, &b1);
+       update_bbox(&inst->bbox, a1);
+       update_bbox(&inst->bbox, b1);
        propagate_bbox(inst);
        return 1;
 }




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2009-08-16 14:24:03 +0200 (Sun, 16 Aug 2009)
New Revision: 5463

Modified:
   trunk/eda/fped/kicad.c
Log:
- ctime(3) already provides a newline, so don't add an extra one to the .mod 
  file, possibly confusing KiCad



Modified: trunk/eda/fped/kicad.c
===================================================================
--- trunk/eda/fped/kicad.c      2009-08-16 12:04:01 UTC (rev 5462)
+++ trunk/eda/fped/kicad.c      2009-08-16 12:24:03 UTC (rev 5463)
@@ -273,7 +273,7 @@
 {
        time_t now = time(NULL);
 
-       fprintf(file, "PCBNEW-LibModule-V1 %s\n", ctime(&now));
+       fprintf(file, "PCBNEW-LibModule-V1 %s", ctime(&now));
 
        fprintf(file, "$INDEX\n");
        fprintf(file, "%s\n", part_name);




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

Reply via email to