Changeset 5414


Ignore:
Timestamp:
08/10/09 15:51:51 (4 years ago)
Author:
werner
Message:
  • File>Save now saves to a file if a second name is given on the command line, to stdout if not
  • there's no reason anymore to disallow editing the offset in new-style measurements
  • struct inst_ops is no longer opaque, so we can avoid adding even more silly little access functions and open-code straightforward callbacks
  • (re)stuctured hover/click/drag logic in gui_tool.c
  • added optional debugging output to gui_canvas.c
  • don't let a vector's base be dragged onto the vector's own end or onto one of its children
  • measurements can now be properly changed by dragging
Location:
trunk/eda/fped
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/eda/fped/TODO

    r5413 r5414  
    33- add default unit (combine with grid unit selection ?) 
    44- consider adding auto/mm/mil selection for each dimension 
    5 - add measurements (partly done. still needed: find out how to define 
    6   non-trivial endpoints, e.g., some vector in last iteration of loop) 
    75- add KiCad output 
    86- add postscript output 
     
    3634- merge find_var_in_frame with similar mechanisms in expr.c and fpd.y 
    3735- add regression tests 
     36- the drag logic is too complex. Better: let tool/instance just generate the 
     37  list of points at each stage, then handle the highlighting and hovering 
     38  inside a dragging module. 
    3839 
    3940Open decisions: 
  • trunk/eda/fped/fped.c

    r5398 r5414  
    1212 
    1313 
     14#include <stdlib.h> 
     15#include <stdio.h> 
    1416 
    1517#include "cpp.h" 
     
    2426extern int yyparse(void); 
    2527 
     28char *save_file = NULL; 
     29 
    2630 
    2731static void load_file(const char *name) 
     
    3337 
    3438 
     39static void usage(const char *name) 
     40{ 
     41        fprintf(stderr, "usage: %s [in_file [out_file]]\n", name); 
     42        exit(1); 
     43} 
     44 
     45 
    3546int main(int argc, char **argv) 
    3647{ 
     48        const char *name = *argv; 
    3749        int error; 
    3850 
     
    4052        if (error) 
    4153                return error; 
    42         if (argc == 1) { 
     54        switch (argc) { 
     55        case 1: 
    4356                scan_empty(); 
    4457                (void) yyparse(); 
    45         } else { 
     58                break; 
     59        case 3: 
     60                save_file = argv[2]; 
     61                /* fall through */ 
     62        case 2: 
    4663                load_file(argv[1]); 
    47                 argc--; 
    48                 argv++; 
     64                break; 
     65        default: 
     66                usage(name); 
    4967        } 
    5068 
  • trunk/eda/fped/gui.c

    r5413 r5414  
    1212 
    1313 
     14#include <stdio.h> 
    1415#include <gtk/gtk.h> 
    1516 
     
    3132 
    3233 
     34extern char *save_file; 
     35 
    3336GtkWidget *root; 
    3437int show_stuff = 1; 
     
    4649static void menu_save(GtkWidget *widget, gpointer user) 
    4750{ 
    48         dump(stdout); 
     51        FILE *file; 
     52 
     53        if (!save_file) { 
     54                if (!dump(stdout)) 
     55                        perror("stdout"); 
     56                return; 
     57        } 
     58        file = fopen(save_file, "w"); 
     59        if (!file) { 
     60                perror(save_file); 
     61                return; 
     62        } 
     63        if (!dump(file)) 
     64                perror(save_file); 
     65        if (fclose(file) == EOF) 
     66                perror(save_file); 
    4967} 
    5068 
  • trunk/eda/fped/gui_canvas.c

    r5413 r5414  
    2626#include "gui.h" 
    2727#include "gui_canvas.h" 
     28 
     29 
     30#if 0 
     31#define DPRINTF(fmt, ...)       fprintf(stderr, fmt "\n", ##__VA_ARGS__) 
     32#else 
     33#define DPRINTF(fmt, ...) 
     34#endif 
    2835 
    2936 
     
    140147        struct coord pos = canvas_to_coord(event->x, event->y); 
    141148 
     149        DPRINTF("--- motion ---"); 
    142150        curr_pos.x = event->x; 
    143151        curr_pos.y = event->y; 
     
    162170        int res; 
    163171 
     172        DPRINTF("--- button press ---"); 
    164173        gtk_widget_grab_focus(widget); 
    165174        switch (event->button) { 
     
    207216        struct coord pos = canvas_to_coord(event->x, event->y); 
    208217 
     218        DPRINTF("--- button release ---"); 
    209219        switch (event->button) { 
    210220        case 1: 
     
    292302        struct coord pos = canvas_to_coord(curr_pos.x, curr_pos.y); 
    293303 
     304        DPRINTF("--- key press ---"); 
    294305        switch (event->keyval) { 
    295306        case ' ': 
     
    351362{ 
    352363        static int first = 1; 
     364 
     365        DPRINTF("--- expose ---"); 
    353366        if (first) { 
    354367                init_canvas(); 
    355368                first = 0; 
    356369        } 
     370        tool_dehover(); 
    357371        redraw(); 
    358372        return TRUE; 
     
    374388    gpointer data) 
    375389{ 
     390        DPRINTF("--- leave ---"); 
    376391        if (dragging) 
    377392                tool_cancel_drag(); 
  • trunk/eda/fped/gui_meas.c

    r5413 r5414  
    1313 
    1414#include "util.h" 
     15#include "coord.h" 
    1516#include "meas.h" 
     17#include "inst.h" 
    1618#include "gui_canvas.h" 
    1719#include "gui_tool.h" 
     
    154156                return is_min(meas_dsc->lt, inst); 
    155157        case next_to_min: 
    156                 return is_min_of_next(meas_dsc->lt, inst, a); 
     158                if (!is_min(meas_dsc->lt, inst)) 
     159                        return 0; 
     160                return is_next(meas_dsc->lt, a, inst); 
     161//              return is_min_of_next(meas_dsc->lt, inst, a); 
    157162        default: 
    158163                abort(); 
     
    223228 
    224229 
    225 /* ----- find point ------------------------------------------------------- */ 
    226  
    227  
    228 static struct inst *find_point_meas(struct coord pos) 
     230/* ----- find start point (new measurement) -------------------------------- */ 
     231 
     232 
     233static struct inst *find_point_meas_new(struct coord pos) 
    229234{ 
    230235        if (meas_inst) 
     
    261266 
    262267        meas_inst = NULL; 
     268        highlight = NULL; 
    263269        if (from == to) 
    264270                return 0; 
     
    291297        } 
    292298        meas->inverted = 
    293           mode == min_to_next_or_max && is_min(meas_dsc->lt, to) ? 0 : 
    294           meas_dsc->lt(from->u.rect.end, to->u.rect.end) != 
    295           (mode == min_to_next_or_max); 
     299            mode == min_to_next_or_max && is_min(meas_dsc->lt, to) ? 0 : 
     300            meas_dsc->lt(from->u.rect.end, to->u.rect.end) != 
     301            (mode == min_to_next_or_max); 
    296302{ 
    297303char *sm[] = { "min_to", "max_to", "next_to" }; 
     
    306312 
    307313 
     314static void cancel_drag_new_meas(void) 
     315{ 
     316        meas_inst = NULL; 
     317        highlight = NULL; 
     318        redraw(); 
     319} 
     320 
     321 
    308322/* ----- begin dragging existing measurement ------------------------------- */ 
     323 
     324 
     325/* 
     326 * We didn't record which instance provided the vector we're using here, so we 
     327 * have to search for it now. 
     328 */ 
     329 
     330static struct inst *vec_at(const struct vec *vec, struct coord pos) 
     331{ 
     332        struct inst *inst; 
     333        const struct sample *s; 
     334 
     335        for (inst = insts_ip_vec(); inst; inst = inst->next) 
     336                if (inst->vec == vec) 
     337                        for (s = vec->samples; s; s = s->next) 
     338                                if (coord_eq(s->pos, pos)) 
     339                                        return inst; 
     340        abort(); 
     341} 
    309342 
    310343 
     
    329362                abort(); 
    330363        } 
     364        highlight = meas_highlight_b; 
    331365        switch (i) { 
    332366        case 0: 
    333                 highlight = meas_highlight_a; 
    334367                mode = meas->type < 3 ? next_to_min : max_to_min; 
     368                meas_inst = vec_at(inst->obj->u.meas.high, inst->u.meas.end); 
    335369                break; 
    336370        case 1: 
    337                 highlight = meas_highlight_b; 
    338371                mode = min_to_next_or_max; 
     372                meas_inst = vec_at(inst->obj->base, inst->base); 
    339373                break; 
    340374        default: 
    341375                abort(); 
    342376        } 
     377//      redraw(); 
     378} 
     379 
     380 
     381/* ----- find end point (existing measurement) ----------------------------- */ 
     382 
     383 
     384struct inst *find_point_meas_move(struct inst *inst, struct coord pos) 
     385{ 
     386        return inst_find_vec(pos, meas_pick_vec_b, meas_inst); 
     387} 
     388 
     389 
     390/* ----- end dragging existing measurements -------------------------------- */ 
     391 
     392 
     393void end_drag_move_meas(void) 
     394{ 
     395        highlight = NULL; 
    343396        redraw(); 
    344397} 
    345398 
    346399 
    347 /* ----- operations ------------------------------------------------------- */ 
     400void do_move_to_meas(struct inst *inst, struct inst *to, int i) 
     401{ 
     402        struct meas *meas = &inst->obj->u.meas; 
     403 
     404        switch (i) { 
     405        case 0: 
     406                inst->obj->base = inst_get_vec(to); 
     407                break; 
     408        case 1: 
     409                meas->high = inst_get_vec(to); 
     410                if (is_max(meas_dsc->lt, to)) 
     411                        meas->type = (meas->type % 3)+3; 
     412                else 
     413                        meas->type = (meas->type % 3); 
     414                break; 
     415        default: 
     416                abort(); 
     417        } 
     418} 
     419 
     420 
     421/* ----- operations -------------------------------------------------------- */ 
    348422 
    349423 
     
    351425        .tool_selected  = tool_selected_meas_xy, 
    352426        .tool_deselected= tool_deselected_meas, 
    353         .find_point     = find_point_meas, 
     427        .find_point     = find_point_meas_new, 
    354428        .begin_drag_new = begin_drag_new_meas, 
    355429        .drag_new       = drag_new_line, 
    356430        .end_new        = end_new_meas, 
     431        .cancel_drag_new= cancel_drag_new_meas, 
    357432}; 
    358433 
     
    360435        .tool_selected  = tool_selected_meas_x, 
    361436        .tool_deselected= tool_deselected_meas, 
    362         .find_point     = find_point_meas, 
     437        .find_point     = find_point_meas_new, 
    363438        .begin_drag_new = begin_drag_new_meas, 
    364439        .drag_new       = drag_new_line, 
    365440        .end_new        = end_new_meas, 
     441        .cancel_drag_new= cancel_drag_new_meas, 
    366442}; 
    367443 
     
    370446        .tool_selected  = tool_selected_meas_y, 
    371447        .tool_deselected= tool_deselected_meas, 
    372         .find_point     = find_point_meas, 
     448        .find_point     = find_point_meas_new, 
    373449        .begin_drag_new = begin_drag_new_meas, 
    374450        .drag_new       = drag_new_line, 
    375451        .end_new        = end_new_meas, 
    376 }; 
     452        .cancel_drag_new= cancel_drag_new_meas, 
     453}; 
  • trunk/eda/fped/gui_meas.h

    r5413 r5414  
    2424 
    2525void begin_drag_move_meas(struct inst *inst, int i); 
     26struct inst *find_point_meas_move(struct inst *inst, struct coord pos); 
     27void end_drag_move_meas(void); 
     28void do_move_to_meas(struct inst *inst, struct inst *to, int i); 
    2629 
    2730#endif /* !GUI_MEAS_H */ 
  • trunk/eda/fped/gui_tool.c

    r5413 r5414  
    458458 
    459459 
    460 void do_move_to_arc(struct inst *inst, struct vec *vec, int i) 
    461 { 
     460void do_move_to_arc(struct inst *inst, struct inst *to, int i) 
     461{ 
     462        struct vec *vec = inst_get_vec(to); 
    462463        struct obj *obj = inst->obj; 
    463464        int is_circle; 
     
    592593 
    593594 
     595#if 0 
    594596static int may_move(struct inst *curr) 
    595597{ 
     
    606608        return 0; 
    607609} 
     610#endif 
    608611 
    609612 
     
    643646static void do_move_to(struct drag_state *state, struct inst *curr) 
    644647{ 
    645         assert(may_move_to(state, curr)); 
     648        assert(state->inst->ops->find_point || may_move_to(state, curr)); 
    646649        *state->anchors[state->anchor_i] = inst_get_vec(curr); 
    647650} 
     
    666669 
    667670 
     671/* 
     672 * When hovering, we have to consider the following states: 
     673 * 
     674 * selected (selected_inst != NULL) 
     675 * |  dragging new (drag.new != NULL) 
     676 * |  |  dragging existing (drag.anchors_n != 0) 
     677 * |  |  |  tool selected (active_ops) 
     678 * |  |  |  | 
     679 * Y  N  N  N  highlight if inst_find_point_selected else don't 
     680 * Y  N  N  Y  highlight if inst_find_point_selected else fall over to tool 
     681 * -  Y  N  -  highlight if inst_find_point / active_ops->find_point else don't 
     682 * -  N  Y  -  highlight if may_move_to else don't 
     683 * -  Y  Y  -  invalid state 
     684 * N  N  N  Y  highlight if inst_find_point / active_ops->find_point else don't 
     685 * N  N  N  N  don't highlight 
     686 */ 
     687 
     688static struct inst *get_hover_inst(struct coord pos) 
     689{ 
     690        struct inst *inst; 
     691        int i; 
     692 
     693        if (drag.new) { 
     694                if (active_ops->find_point) 
     695                        return active_ops->find_point(pos); 
     696                return inst_find_point(pos); 
     697        } 
     698        if (drag.anchors_n) { 
     699                if (drag.inst->ops->find_point) 
     700                        return drag.inst->ops->find_point(drag.inst, pos); 
     701                inst = inst_find_point(pos); 
     702                if (!inst) 
     703                        return NULL; 
     704                return may_move_to(&drag, inst) ? inst : NULL; 
     705        } 
     706        if (selected_inst) { 
     707                i = inst_find_point_selected(pos, &inst); 
     708                if (i != -1) 
     709                        return inst; 
     710        } 
     711        if (!active_ops) 
     712                return NULL; 
     713        if (active_ops->find_point) 
     714                return active_ops->find_point(pos); 
     715        return inst_find_point(pos); 
     716} 
     717 
     718 
    668719void tool_hover(struct coord pos) 
    669720{ 
    670         struct inst *curr; 
    671  
    672         if (active_ops && active_ops->find_point) 
    673                 curr = active_ops->find_point(pos); 
    674         else 
    675                 curr = inst_find_point(pos); 
     721        struct inst *curr = NULL; 
     722 
     723        curr = get_hover_inst(pos); 
     724#if 0 
    676725        if ((drag.new && curr == drag.new) || (drag.inst && curr == drag.inst)) 
    677726                return; 
     
    686735                } 
    687736        } 
     737got: 
     738#endif 
     739 
    688740        if (curr == hover_inst) 
    689741                return; 
     
    713765 
    714766 
     767/* 
     768 * When considering dragging, we have the following states: 
     769 * 
     770 * selected (selected_inst != NULL) 
     771 * |  tool selected (active_ops) 
     772 * |  | 
     773 * N  N  don't 
     774 * Y  -  if we could drag, drag_new/end_new, else fall over to tool 
     775 * N  Y  click, else single-click creation, else drag_new/end_new 
     776 */ 
     777 
    715778int tool_consider_drag(struct coord pos) 
    716779{ 
     
    720783        assert(!drag.anchors_n); 
    721784        last_canvas_pos = translate(pos); 
    722         if (active_ops && active_ops->click) { 
     785 
     786        if (!selected_inst && !active_ops) 
     787                return 0; 
     788        if (selected_inst) { 
     789                drag.anchor_i = inst_find_point_selected(pos, NULL); 
     790                if (drag.anchor_i != -1) { 
     791                        tool_dehover(); 
     792                        drag.inst = selected_inst; 
     793                        drag.new = NULL; 
     794                        drag.anchors_n = 
     795                            inst_anchors(selected_inst, drag.anchors); 
     796                        over_begin(drag_save_and_draw, NULL, pos); 
     797                        inst_begin_drag_move(selected_inst, drag.anchor_i); 
     798                        return 1; 
     799                } 
     800        } 
     801        if (!active_ops) 
     802                return 0; 
     803        if (active_ops->click) { 
    723804                active_ops->click(pos); 
    724805                return 0; 
    725806        } 
    726         if (active_ops && active_ops->find_point) 
    727                 curr = active_ops->find_point(pos); 
    728         else 
    729                 curr = inst_find_point(pos); 
     807 
     808        curr = get_hover_inst(pos); 
    730809        if (!curr) 
    731810                return 0; 
     811 
    732812        tool_dehover(); 
    733         if (active_ops) { 
    734                 if (active_ops->drag_new) { 
    735                         if (active_ops->begin_drag_new) 
    736                                 active_ops->begin_drag_new(curr); 
    737                         drag.inst = NULL; 
    738                         drag.new = curr; 
    739                         over_begin(drag_save_and_draw, NULL, pos); 
    740                         return 1; 
    741                 } else { 
    742                         /* object is created without dragging */ 
    743                         if (active_ops->end_new(curr, NULL)) { 
    744                                 tool_cancel_drag(); 
    745                                 return -1; 
    746                         } 
    747                         return 0; 
    748                 } 
    749         } 
    750         if (!may_move(curr)) 
    751                 return 0; 
    752         drag.inst = selected_inst; 
    753         drag.new = NULL; 
    754         inst_begin_drag_move(selected_inst, drag.anchor_i); 
    755         over_begin(drag_save_and_draw, NULL, pos); 
    756         return 1; 
     813 
     814        if (active_ops->drag_new) { 
     815                if (active_ops->begin_drag_new) 
     816                        active_ops->begin_drag_new(curr); 
     817                drag.inst = NULL; 
     818                drag.new = curr; 
     819                over_begin(drag_save_and_draw, NULL, pos); 
     820                return 1; 
     821        } 
     822 
     823        /* object is created without dragging */ 
     824        if (active_ops->end_new(curr, NULL)) { 
     825                tool_cancel_drag(); 
     826                return -1; 
     827        } 
     828        return 0; 
     829 
    757830} 
    758831 
     
    767840void tool_cancel_drag(void) 
    768841{ 
     842        if (drag.anchors_n && drag.inst->ops->end_drag_move) 
     843        if (drag.anchors_n && drag.inst->ops->end_drag_move) 
     844                drag.inst->ops->end_drag_move(); 
     845        drag.new = NULL; 
     846        active_ops = NULL; 
     847        drag.anchors_n = 0; 
    769848        over_end(); 
    770849        tool_dehover(); 
    771850        tool_reset(); 
    772         drag.new = NULL; 
    773         active_ops = NULL; 
    774         drag.anchors_n = 0; 
    775851} 
    776852 
     
    785861        if (state.new && ops->end_new_raw) 
    786862                return ops->end_new_raw(state.new, to); 
    787         if (ops->find_point) 
     863        if (state.new && ops->find_point) 
    788864                end = ops->find_point(to); 
    789         else 
    790                 end = inst_find_point(to); 
    791         if (!end) 
    792                 return 0; 
     865        else { 
     866                if (state.inst && state.inst->ops->find_point) 
     867                        end = state.inst->ops->find_point(state.inst, to); 
     868                else 
     869                        end = inst_find_point(to); 
     870        } 
     871        if (!end) { 
     872                if (state.new && ops->cancel_drag_new) 
     873                        ops->cancel_drag_new(); 
     874                return 0; 
     875        } 
    793876        if (state.new) 
    794877                return ops->end_new(state.new, end); 
    795         if (!may_move_to(&state, end)) 
    796                 return 0; 
    797         if (!inst_do_move_to(drag.inst, inst_get_vec(end), state.anchor_i)) 
     878 
     879        /* if we got the point from find_point, it's authoritative */ 
     880        if (!state.inst->ops->find_point && !may_move_to(&state, end)) 
     881                return 0; 
     882        if (!inst_do_move_to(state.inst, end, state.anchor_i)) 
    798883                do_move_to(&state, end); 
    799884        return 1; 
     
    803888void tool_redraw(void) 
    804889{ 
     890        struct coord pos; 
     891 
    805892        over_reset(); 
     893        hover_inst = NULL; 
    806894        if (!drag.new && !drag.anchors_n) 
    807895                return; 
    808         tool_hover(last_canvas_pos); 
    809         over_begin(drag_save_and_draw, NULL, 
    810             canvas_to_coord(last_canvas_pos.x, last_canvas_pos.y)); 
     896        pos = canvas_to_coord(last_canvas_pos.x, last_canvas_pos.y); 
     897        tool_hover(pos); 
     898        over_begin(drag_save_and_draw, NULL, pos); 
    811899} 
    812900 
     
    838926{ 
    839927        over_reset(); 
     928        hover_inst = NULL; 
    840929        tool_select(ev_point, NULL); 
    841930} 
  • trunk/eda/fped/gui_tool.h

    r5413 r5414  
    2929        int (*end_new_raw)(struct inst *from, struct coord to); 
    3030        int (*end_new)(struct inst *from, struct inst *to); 
     31        void (*cancel_drag_new)(void); 
    3132}; 
    3233 
     
    4344struct pix_buf *gui_hover_frame(struct inst *self); 
    4445 
    45 void do_move_to_arc(struct inst *inst, struct vec *vec, int i); 
     46void do_move_to_arc(struct inst *inst, struct inst *to, int i); 
    4647 
    4748void tool_dehover(void); 
  • trunk/eda/fped/inst.c

    r5413 r5414  
    2929#include "inst.h" 
    3030 
    31  
    32 struct inst_ops { 
    33         void (*debug)(struct inst *self); 
    34         void (*save)(FILE *file, struct inst *self); 
    35         void (*draw)(struct inst *self); 
    36         struct pix_buf *(*hover)(struct inst *self); 
    37         unit_type (*distance)(struct inst *self, struct coord pos,  
    38             unit_type scale); 
    39         void (*select)(struct inst *self); 
    40         int (*anchors)(struct inst *self, struct vec ***anchors); 
    41         void (*begin_drag_move)(struct inst *from, int i); 
    42         struct pix_buf *(*draw_move)(struct inst *inst, 
    43             struct coord pos, int i); 
    44         /* arcs and measurements need this special override */ 
    45         void (*do_move_to)(struct inst *inst, struct vec *vec, int i); 
    46 }; 
    4731 
    4832enum inst_prio { 
     
    236220 
    237221 
     222int inst_find_point_selected(struct coord pos, struct inst **res) 
     223{ 
     224        struct vec **anchors[3]; 
     225        int n, best_i, i; 
     226        struct inst *best = NULL; 
     227        struct inst *inst; 
     228        int d_min, d; 
     229 
     230        assert(selected_inst); 
     231        n = inst_anchors(selected_inst, anchors); 
     232        for (i = 0; i != n; i++) { 
     233                if (*anchors[i]) { 
     234                        for (inst = insts[ip_vec]; inst; inst = inst->next) { 
     235                                if (inst->vec != *anchors[i]) 
     236                                        continue; 
     237                                d = gui_dist_vec(inst, pos, draw_ctx.scale); 
     238                                if (d != -1 && (!best || d < d_min)) { 
     239                                        best = inst; 
     240                                        best_i = i; 
     241                                        d_min = d; 
     242                                } 
     243                        } 
     244                } else { 
     245                        for (inst = insts[ip_frame]; inst; inst = inst->next) { 
     246                                if (inst != selected_inst->outer) 
     247                                        continue; 
     248                                d = gui_dist_frame(inst, pos, draw_ctx.scale); 
     249                                if (d != -1 && (!best || d < d_min)) { 
     250                                        best = inst; 
     251                                        best_i = i; 
     252                                        d_min = d; 
     253                                } 
     254                        } 
     255                } 
     256        } 
     257        if (!best) 
     258                return -1; 
     259        if (res) 
     260                *res = best; 
     261        return best_i; 
     262} 
     263 
     264 
    238265struct coord inst_get_point(const struct inst *inst) 
    239266{ 
     
    318345static void propagate_bbox(const struct inst *inst) 
    319346{ 
    320         /* @@@ for new-style measurements */ 
    321347        struct inst *frame = curr_frame ? curr_frame : insts[ip_frame]; 
    322348 
     
    389415 
    390416 
     417/* 
     418 * @@@ The logic of gui_find_point_vec isn't great. Instead of selecting a 
     419 * point and then filtering, we should filter the candidates, so that a point 
     420 * that's close end eligible can win against one that's closer but not 
     421 * eligible. 
     422 */ 
     423 
     424static struct inst *find_point_vec(struct inst *self, struct coord pos) 
     425{ 
     426        struct inst *inst; 
     427        const struct vec *vec; 
     428 
     429        inst = inst_find_point(pos); 
     430        if (!inst) 
     431                return NULL; 
     432        if (inst->ops == &frame_ops) 
     433                return inst; 
     434        for (vec = inst->vec; vec; vec = vec->base) 
     435                if (vec == self->vec) 
     436                return NULL; 
     437        return inst; 
     438} 
     439 
     440 
    391441static int vec_op_anchors(struct inst *inst, struct vec ***anchors) 
    392442{ 
     
    402452        .distance       = gui_dist_vec, 
    403453        .select         = vec_op_select, 
     454        .find_point     = find_point_vec, 
    404455        .anchors        = vec_op_anchors, 
    405456        .draw_move      = draw_move_vec, 
     
    670721        status_set_type_entry("offset ="); 
    671722        status_set_name("%5.2f mm", units_to_mm(self->u.meas.offset)); 
    672         if (!self->obj) 
    673                 return; /* @@@ new-style measurements */ 
    674723        edit_expr(&self->obj->u.meas.offset); 
    675724} 
     
    693742        .anchors        = meas_op_anchors, 
    694743        .begin_drag_move= begin_drag_move_meas, 
     744        .find_point     = find_point_meas_move, 
    695745        .draw_move      = draw_move_meas, 
     746        .end_drag_move  = end_drag_move_meas, 
     747        .do_move_to     = do_move_to_meas, 
    696748}; 
    697749 
     
    912964 
    913965 
    914 int inst_do_move_to(struct inst *inst, struct vec *vec, int i) 
     966int inst_do_move_to(struct inst *inst, struct inst *to, int i) 
    915967{ 
    916968        if (!inst->ops->do_move_to) 
    917969                return 0; 
    918         inst->ops->do_move_to(inst, vec, i); 
     970        inst->ops->do_move_to(inst, to, i); 
    919971        return 1; 
    920972} 
  • trunk/eda/fped/inst.h

    r5413 r5414  
    3737}; 
    3838 
    39 struct inst_ops; 
     39struct inst; 
     40 
     41struct inst_ops { 
     42        void (*debug)(struct inst *self); 
     43        void (*save)(FILE *file, struct inst *self); 
     44        void (*draw)(struct inst *self); 
     45        struct pix_buf *(*hover)(struct inst *self); 
     46        unit_type (*distance)(struct inst *self, struct coord pos,  
     47            unit_type scale); 
     48        void (*select)(struct inst *self); 
     49        int (*anchors)(struct inst *self, struct vec ***anchors); 
     50        void (*begin_drag_move)(struct inst *from, int i); 
     51        struct inst *(*find_point)(struct inst *self, struct coord pos); 
     52        struct pix_buf *(*draw_move)(struct inst *inst, 
     53            struct coord pos, int i); 
     54        void (*end_drag_move)(void); 
     55        /* arcs and measurements need this special override */ 
     56        void (*do_move_to)(struct inst *inst, struct inst *to, int i); 
     57}; 
    4058 
    4159struct inst { 
     
    86104 
    87105struct inst *inst_find_point(struct coord pos); 
     106int inst_find_point_selected(struct coord pos, struct inst **res); 
    88107struct coord inst_get_point(const struct inst *inst); 
    89108int inst_anchors(struct inst *inst, struct vec ***anchors); 
     
    120139 
    121140struct pix_buf *inst_draw_move(struct inst *inst, struct coord pos, int i); 
    122 int inst_do_move_to(struct inst *inst, struct vec *vec, int i); 
     141int inst_do_move_to(struct inst *inst, struct inst *to, int i); 
    123142struct pix_buf *inst_hover(struct inst *inst); 
    124143void inst_begin_drag_move(struct inst *inst, int i); 
  • trunk/eda/fped/meas.c

    r5413 r5414  
    2424struct num eval_unit(const struct expr *expr, const struct frame *frame); 
    2525 
    26 struct sample { 
    27         struct coord pos; 
    28         struct sample *next; 
    29 }; 
    30  
    3126 
    3227static void reset_samples(struct sample **samples) 
  • trunk/eda/fped/meas.h

    r5412 r5414  
    4242}; 
    4343 
    44 struct sample; 
     44struct sample { 
     45        struct coord pos; 
     46        struct sample *next; 
     47}; 
    4548 
    4649 
Note: See TracChangeset for help on using the changeset viewer.