Changeset 5404


Ignore:
Timestamp:
08/07/09 23:47:51 (4 years ago)
Author:
werner
Message:
  • added icons for new-style measurements (on-going)
  • increased default window size for make room for new icons
  • switch the canvas to dark blue when instantiation fails
  • modularized point lookup logic of instantiate_meas
  • added highlight mode (on-going)
Location:
trunk/eda/fped
Files:
2 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/eda/fped/Makefile

    r5403 r5404  
    1818 
    1919XPMS = point.xpm delete.xpm vec.xpm frame.xpm frame_locked.xpm frame_ready.xpm \ 
    20        line.xpm rect.xpm pad.xpm circ.xpm meas.xpm 
     20       line.xpm rect.xpm pad.xpm circ.xpm meas.xpm meas_x.xpm meas_y.xpm 
    2121 
    2222CFLAGS_GTK = `pkg-config --cflags gtk+-2.0` 
  • trunk/eda/fped/README

    r5403 r5404  
    423423make the changes in the input area at the bottom. 
    424424 
    425 To delete an object, select it and press Delete. Deleted objects can 
    426 be undeleted by pressing "u". If any other changes have been made 
    427 since deletion, fped may misbehave. If deleting a vector, all items 
    428 that reference it are deleted. 
     425To delete an object, select the delete tool and click on the object. 
     426Deleted objects can be undeleted by pressing "u". If any other changes 
     427have been made since deletion, fped may misbehave. If deleting a vector, 
     428all items that reference it are deleted as well. 
    429429 
    430430 
  • trunk/eda/fped/gui.c

    r5403 r5404  
    12261226        root = gtk_window_new(GTK_WINDOW_TOPLEVEL); 
    12271227        gtk_window_set_position(GTK_WINDOW(root), GTK_WIN_POS_CENTER); 
    1228         gtk_window_set_default_size(GTK_WINDOW(root), 600, 400); 
     1228        gtk_window_set_default_size(GTK_WINDOW(root), 620, 460); 
    12291229        gtk_window_set_title(GTK_WINDOW(root), "fped"); 
    12301230 
  • trunk/eda/fped/gui_canvas.c

    r5403 r5404  
    2626#include "gui_canvas.h" 
    2727 
     28 
     29void (*highlight)(struct draw_ctx *ctx) = NULL; 
    2830 
    2931static struct draw_ctx ctx; 
     
    102104        aw = ctx.widget->allocation.width; 
    103105        ah = ctx.widget->allocation.height; 
    104         gdk_draw_rectangle(ctx.widget->window, gc_bg, TRUE, 0, 0, aw, ah); 
     106        gdk_draw_rectangle(ctx.widget->window, 
     107            instantiation_ok ? gc_bg : gc_bg_error, TRUE, 0, 0, aw, ah); 
    105108 
    106109        inst_draw(&ctx); 
     110        if (highlight) 
     111                highlight(&ctx); 
    107112        tool_redraw(&ctx); 
    108113} 
  • trunk/eda/fped/gui_canvas.h

    r5374 r5404  
    1818 
    1919 
     20/* 
     21 * "highlight" is invoked at the end of each redraw, for optional highlighting 
     22 * of objects. 
     23 */ 
     24 
     25extern void (*highlight)(struct draw_ctx *ctx); 
     26 
     27 
    2028void redraw(void); 
    2129 
  • trunk/eda/fped/gui_inst.c

    r5400 r5404  
    157157        gc = gc_vec[mode_hover]; 
    158158        draw_circle(DA, gc, FALSE, center.x, center.y, VEC_EYE_R); 
     159} 
     160 
     161 
     162void gui_highlight_vec(struct inst *self, struct draw_ctx *ctx) 
     163{ 
     164        struct coord center = translate(ctx, self->u.rect.end); 
     165 
     166        draw_circle(DA, gc_highlight, FALSE, center.x, center.y, VEC_EYE_R); 
    159167} 
    160168 
  • trunk/eda/fped/gui_inst.h

    r5385 r5404  
    5151void gui_draw_frame(struct inst *self, struct draw_ctx *ctx); 
    5252 
     53void gui_highlight_vec(struct inst *self, struct draw_ctx *ctx); 
    5354void gui_hover_vec(struct inst *self, struct draw_ctx *ctx); 
    5455void gui_hover_frame(struct inst *self, struct draw_ctx *ctx); 
  • trunk/eda/fped/gui_style.c

    r5385 r5404  
    1 /* 
    2  * gui_style.c - GUI, style definitions 
     1/* * gui_style.c - GUI, style definitions 
    32 * 
    43 * Written 2009 by Werner Almesberger 
     
    2322 
    2423 
    25 GdkGC *gc_bg; 
     24GdkGC *gc_bg, *gc_bg_error; 
    2625GdkGC *gc_drag; 
     26GdkGC *gc_highlight; 
    2727GdkGC *gc_active_frame; 
    2828GdkGC *gc_vec[mode_n]; 
     
    6262{ 
    6363        gc_bg = gc("#000000", 0); 
     64        gc_bg_error = gc("#000040", 0); 
    6465        gc_drag = gc("#ffffff", 2); 
    6566        /*              inactive   in+path    active     act+path   selected */ 
     
    7071        style(gc_meas,  "#280040", INVALID,   "#ff00ff", INVALID,   "#ffff80"); 
    7172        style(gc_frame, "#004000", "#205020", "#009000", INVALID,   "#ffff80"); 
     73 
    7274        gc_active_frame = gc("#00ff00", 2); 
    73  
     75//      gc_highlight = gc("#ff8020", 2); 
     76        gc_highlight = gc("#ff90d0", 2); 
    7477        gc_frame[mode_hover] = gc_vec[mode_hover] = gc("#c00000", 1); 
    7578} 
  • trunk/eda/fped/gui_style.h

    r5401 r5404  
    8989 
    9090 
    91 extern GdkGC *gc_bg; 
     91extern GdkGC *gc_bg, *gc_bg_error; 
    9292extern GdkGC *gc_drag; 
     93extern GdkGC *gc_highlight; 
    9394extern GdkGC *gc_active_frame; 
    9495extern GdkGC *gc_vec[mode_n]; 
  • trunk/eda/fped/gui_tools.c

    r5403 r5404  
    2323#include "gui_style.h" 
    2424#include "gui_inst.h" 
     25#include "gui_canvas.h" 
    2526#include "gui_status.h" 
    2627#include "gui.h" 
     
    3435#include "icons/line.xpm" 
    3536#include "icons/meas.xpm" 
     37#include "icons/meas_x.xpm" 
     38#include "icons/meas_y.xpm" 
    3639#include "icons/pad.xpm" 
    3740#include "icons/point.xpm" 
     
    4649struct tool_ops { 
    4750        void (*tool_selected)(void); 
     51        void (*tool_deselected)(void); 
    4852        void (*click)(struct draw_ctx *ctx, struct coord pos); 
    4953        struct pix_buf *(*drag_new)(struct draw_ctx *ctx, struct inst *from, 
     
    518522 
    519523 
     524static int meas_x_pick_vec(struct inst *inst, void *ctx) 
     525{ 
     526        struct vec *vec = inst->vec; 
     527        struct coord min; 
     528 
     529        if (!vec->samples) 
     530                return 0; 
     531        min = meas_find_min(lt_xy, vec->samples); 
     532        return inst->u.rect.end.x == min.x && inst->u.rect.end.y == min.y; 
     533} 
     534 
     535 
     536static void highlight_vecs(struct draw_ctx *ctx) 
     537{ 
     538        inst_highlight_vecs(ctx, meas_x_pick_vec, NULL); 
     539} 
     540 
     541 
     542static void tool_selected_meas_x(void) 
     543{ 
     544        highlight = highlight_vecs; 
     545        redraw(); 
     546} 
     547 
     548 
     549static void tool_selected_meas_y(void) 
     550{ 
     551        highlight = NULL; 
     552        redraw(); 
     553} 
     554 
     555 
     556static void tool_deselected_meas(void) 
     557{ 
     558        highlight = NULL; 
     559        redraw(); 
     560} 
     561 
     562 
    520563static struct tool_ops meas_ops = { 
     564        .drag_new       = drag_new_line, 
     565        .end_new        = end_new_meas, 
     566}; 
     567 
     568static struct tool_ops meas_ops_x = { 
     569        .tool_selected  = tool_selected_meas_x, 
     570        .tool_deselected= tool_deselected_meas, 
     571        .drag_new       = drag_new_line, 
     572        .end_new        = end_new_meas, 
     573}; 
     574static struct tool_ops meas_ops_y = { 
     575        .tool_selected  = tool_selected_meas_y, 
     576        .tool_deselected= tool_deselected_meas, 
    521577        .drag_new       = drag_new_line, 
    522578        .end_new        = end_new_meas, 
     
    829885 
    830886        if (active_tool) { 
     887                if (active_ops && active_ops->tool_deselected) 
     888                        active_ops->tool_deselected(); 
    831889                col = get_color(TOOL_UNSELECTED); 
    832890                gtk_widget_modify_bg(active_tool, GTK_STATE_NORMAL, &col); 
     
    941999        last = tool_button(bar, drawable, xpm_rect, last, &rect_ops); 
    9421000        last = tool_button(bar, drawable, xpm_circ, last, &circ_ops); 
     1001        tool_separator(bar); 
    9431002        last = tool_button(bar, drawable, xpm_meas, last, &meas_ops); 
     1003        last = tool_button(bar, drawable, xpm_meas_x, last, &meas_ops_x); 
     1004        last = tool_button(bar, drawable, xpm_meas_y, last, &meas_ops_y); 
    9441005 
    9451006        frame_image = gtk_widget_ref(make_image(drawable, xpm_frame)); 
  • trunk/eda/fped/icons/meas.fig

    r5363 r5404  
    1111         3600 2400 6000 2400 6000 4800 3600 4800 3600 2400 
    12122 1 0 10 21 7 50 -1 -1 0.000 0 0 -1 0 0 2 
    13          3900 3300 3900 3900 
    14 2 1 0 10 21 7 50 -1 -1 0.000 0 0 -1 0 0 2 
    15          5700 3300 5700 3900 
     13         3900 3600 4200 4200 
    16142 1 0 10 21 7 50 -1 -1 0.000 0 0 -1 1 1 2 
    1715        0 0 10.00 450.00 450.00 
    1816        0 0 10.00 450.00 450.00 
    19          3900 3600 5700 3600 
     17         4050 3900 5550 3150 
     182 1 0 10 21 7 50 -1 -1 0.000 0 0 -1 0 0 2 
     19         5400 2850 5700 3450 
  • trunk/eda/fped/inst.c

    r5403 r5404  
    842842 
    843843 
     844void inst_highlight_vecs(struct draw_ctx *ctx, 
     845    int (*pick)(struct inst *inst, void *user), void *user) 
     846{ 
     847        struct inst *inst; 
     848 
     849        for (inst = insts[ip_vec]; inst; inst = inst->next) 
     850                if (pick(inst, user)) 
     851                        gui_highlight_vec(inst, ctx); 
     852} 
     853 
     854 
    844855struct pix_buf *inst_draw_move(struct inst *inst, struct draw_ctx *ctx, 
    845856    struct coord pos, int i) 
  • trunk/eda/fped/inst.h

    r5400 r5404  
    115115 
    116116void inst_draw(struct draw_ctx *ctx); 
     117void inst_highlight_vecs(struct draw_ctx *ctx,  
     118    int (*pick)(struct inst *inst, void *user), void *user); 
    117119struct pix_buf *inst_draw_move(struct inst *inst, struct draw_ctx *ctx, 
    118120    struct coord pos, int i); 
  • trunk/eda/fped/meas.c

    r5400 r5404  
    7676 
    7777 
    78 static int lt_x(struct coord a, struct coord b) 
     78int lt_x(struct coord a, struct coord b) 
    7979{ 
    8080        return a.x < b.x; 
     
    8282 
    8383 
    84 static int lt_y(struct coord a, struct coord b) 
     84int lt_y(struct coord a, struct coord b) 
    8585{ 
    8686        return a.y < b.y; 
     
    8888 
    8989 
    90 static int lt_xy(struct coord a, struct coord b) 
     90int lt_xy(struct coord a, struct coord b) 
    9191{ 
    9292        return a.y < b.y || (a.y == b.y && a.x < b.x); 
     
    9494 
    9595 
    96 static int (*lt_op[mt_n])(struct coord a, struct coord b) = { 
     96static lt_op_type lt_op[mt_n] = { 
    9797        lt_xy, 
    9898        lt_x, 
     
    110110 
    111111 
    112 static int better_next(int (*lt)(struct coord a, struct coord b), 
     112static int better_next(lt_op_type lt, 
    113113    struct coord a0, struct coord b0, struct coord b) 
    114114{ 
     
    144144 
    145145 
     146/* 
     147 * In order to obtain a stable order, we sort points equal on the measured 
     148 * coordinate also by xy: 
     149 * 
     150 * if (*a < a0) use *a 
     151 * else if (*a == a0 && *a <xy a0) use *a 
     152 */ 
     153 
     154struct coord meas_find_min(lt_op_type lt, const struct sample *s) 
     155{ 
     156        struct coord min; 
     157 
     158        min = s->pos; 
     159        while (s) { 
     160                if (lt(s->pos, min) || 
     161                    (!lt(min, s->pos) && lt_xy(s->pos, min))) 
     162                        min = s->pos; 
     163                s = s->next; 
     164        } 
     165        return min; 
     166} 
     167 
     168 
     169struct coord meas_find_next(lt_op_type lt, const struct sample *s, 
     170    struct coord ref) 
     171{ 
     172        struct coord next; 
     173 
     174        next = s->pos; 
     175        while (s) { 
     176                if (better_next(lt, ref, next, s->pos)) 
     177                        next = s->pos; 
     178                s = s->next; 
     179        } 
     180        return next; 
     181} 
     182 
     183 
     184struct coord meas_find_max(lt_op_type lt, const struct sample *s) 
     185{ 
     186        struct coord max; 
     187 
     188        max = s->pos; 
     189        while (s) { 
     190                if (lt(max, s->pos) || 
     191                    (!lt(s->pos, max) && lt_xy(max, s->pos))) 
     192                        max = s->pos; 
     193                s = s->next; 
     194        } 
     195        return max; 
     196} 
     197 
     198 
    146199int instantiate_meas(void) 
    147200{ 
    148201        struct meas *meas; 
    149202        struct coord a0, b0; 
    150         const struct sample *a, *b; 
    151         int (*lt)(struct coord a, struct coord b); 
     203        lt_op_type lt; 
    152204        struct num offset; 
    153205 
     
    157209 
    158210                lt = lt_op[meas->type]; 
    159  
    160                 /* 
    161                  * In order to obtain a stable order, we sort points equal on 
    162                  * the measured coordinate also by xy: 
    163                  * 
    164                  * if (*a < a0) use *a 
    165                  * else if (*a == a0 && *a <xy a0) use *a 
    166                  */ 
    167                 a0 = meas->low->samples->pos; 
    168                 for (a = meas->low->samples; a; a = a->next) 
    169                         if (lt(a->pos, a0) || 
    170                             (!lt(a0, a->pos) && lt_xy(a->pos, a0))) 
    171                                 a0 = a->pos; 
    172  
    173                 b0 = meas->high->samples->pos; 
    174                 for (b = meas->high->samples; b; b = b->next) { 
    175                         if (is_next[meas->type]) { 
    176                                 if (better_next(lt, a0, b0, b->pos)) 
    177                                         b0 = b->pos; 
    178                         } else { 
    179                                 if (lt(b0, b->pos) || 
    180                                     (!lt(b->pos, b0) && lt_xy(b0, b->pos))) 
    181                                         b0 = b->pos; 
    182                         } 
    183                 } 
     211                a0 = meas_find_min(lt, meas->low->samples); 
     212                if (is_next[meas->type]) 
     213                        b0 = meas_find_next(lt, meas->high->samples, a0); 
     214                else 
     215                        b0 = meas_find_max(lt, meas->high->samples); 
    184216 
    185217                offset = eval_unit(meas->offset, root_frame); 
  • trunk/eda/fped/meas.h

    r5400 r5404  
    1616 
    1717#include "obj.h" 
     18 
     19 
     20typedef int (*lt_op_type)(struct coord a, struct coord b); 
    1821 
    1922 
     
    3639}; 
    3740 
     41struct sample; 
     42 
    3843 
    3944extern struct meas *measurements; 
    4045 
     46 
     47int lt_x(struct coord a, struct coord b); 
     48int lt_y(struct coord a, struct coord b); 
     49int lt_xy(struct coord a, struct coord b); 
     50 
     51struct coord meas_find_min(lt_op_type lt, const struct sample *s); 
     52struct coord meas_find_next(lt_op_type lt, const struct sample *s, 
     53    struct coord ref); 
     54struct coord meas_find_max(lt_op_type lt, const struct sample *s); 
    4155 
    4256void meas_start(void); 
  • trunk/eda/fped/obj.c

    r5400 r5404  
    3333struct frame *root_frame = NULL; 
    3434struct frame *active_frame = NULL; 
     35int instantiation_ok; 
    3536 
    3637 
     
    274275        else 
    275276                inst_revert(); 
     277        instantiation_ok = ok; 
    276278        return ok; 
    277279} 
  • trunk/eda/fped/obj.h

    r5400 r5404  
    182182extern struct frame *root_frame; 
    183183extern struct frame *active_frame; 
     184extern int instantiation_ok; 
    184185 
    185186 
Note: See TracChangeset for help on using the changeset viewer.