Changeset 5552


Ignore:
Timestamp:
08/27/09 11:01:24 (4 years ago)
Author:
werner
Message:

Made interactive selection of measurement points a little less inefficient.

  • vectors now have their own struct in inst.u and don't share inst.u.rect.end
  • when selecting points for measurements, use the highlighting we've already done and don't redo all the O(n3) searching for each mouse pointer movement
  • removed debug code that printed what new measurements are like. We can now use the code view for that.
Location:
trunk/eda/fped
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/eda/fped/gui_inst.c

    r5527 r5552  
    123123        unit_type d; 
    124124 
    125         d = dist_point(pos, self->u.rect.end)/scale; 
     125        d = dist_point(pos, self->u.vec.end)/scale; 
    126126        return d > VEC_EYE_R ? -1 : d; 
    127127} 
     
    139139        unit_type d; 
    140140 
    141         d = dist_line(pos, self->base, self->u.rect.end)/scale; 
     141        d = dist_line(pos, self->base, self->u.vec.end)/scale; 
    142142        return d > SELECT_R ? -1 : d; 
    143143} 
     
    146146void gui_highlight_vec(struct inst *self) 
    147147{ 
    148         struct coord center = translate(self->u.rect.end); 
     148        struct coord center = translate(self->u.vec.end); 
    149149 
    150150        draw_circle(DA, gc_highlight, FALSE, center.x, center.y, VEC_EYE_R); 
     
    155155{ 
    156156        struct coord from = translate(self->base); 
    157         struct coord to = translate(self->u.rect.end); 
     157        struct coord to = translate(self->u.vec.end); 
    158158        GdkGC *gc; 
    159159 
  • trunk/eda/fped/gui_meas.c

    r5478 r5552  
    6565 
    6666        min = meas_find_min(lt, active_pkg->samples[inst->vec->n]); 
    67         return coord_eq(inst->u.rect.end, min); 
     67        return coord_eq(inst->u.vec.end, min); 
    6868} 
    6969 
     
    7575 
    7676        next = meas_find_next(lt, active_pkg->samples[inst->vec->n], 
    77             ref->u.rect.end); 
    78         return coord_eq(inst->u.rect.end, next); 
     77            ref->u.vec.end); 
     78        return coord_eq(inst->u.vec.end, next); 
    7979} 
    8080 
     
    8585 
    8686        max = meas_find_max(lt, active_pkg->samples[inst->vec->n]); 
    87         return coord_eq(inst->u.rect.end, max); 
     87        return coord_eq(inst->u.vec.end, max); 
    8888} 
    8989 
     
    9898                next = meas_find_next(lt, active_pkg->samples[inst->vec->n], 
    9999                    min); 
    100                 if (coord_eq(next, inst->u.rect.end)) 
     100                if (coord_eq(next, inst->u.vec.end)) 
    101101                        return 1; 
    102102        } 
     
    113113        min = meas_find_min(lt, inst->vec->samples); 
    114114        next = meas_find_next(lt, ref->vec->samples, min); 
    115         return coord_eq(next, ref->u.rect.end); 
     115        return coord_eq(next, ref->u.vec.end); 
    116116} 
    117117#endif 
     
    235235 
    236236 
     237static int is_highlighted(struct inst *inst, void *user) 
     238{ 
     239        return inst->u.vec.highlighted; 
     240} 
     241 
     242 
    237243static struct inst *find_point_meas_new(struct coord pos) 
    238244{ 
    239         if (meas_inst) 
    240                 return inst_find_vec(pos, meas_pick_vec_b, meas_inst); 
    241         else 
    242                 return inst_find_vec(pos, meas_pick_vec_a, NULL); 
     245        return inst_find_vec(pos, is_highlighted, NULL); 
    243246} 
    244247 
     
    303306        meas->inverted = 
    304307            mode == min_to_next_or_max && is_min(meas_dsc->lt, to) ? 0 : 
    305             meas_dsc->lt(from->u.rect.end, to->u.rect.end) != 
     308            meas_dsc->lt(from->u.vec.end, to->u.vec.end) != 
    306309            (mode == min_to_next_or_max); 
    307 { 
    308 char *sm[] = { "min_to", "max_to", "next_to" }; 
    309 char *st[] = { "nxy", "nx", "ny", "mxy", "mx", "my" }; 
    310 fprintf(stderr, "mode %s type %s, inverted %d\n", 
    311 sm[mode], st[meas->type], meas->inverted); 
    312 } 
    313310        meas->offset = NULL; 
    314311        meas_dsc = NULL; 
     
    389386struct inst *find_point_meas_move(struct inst *inst, struct coord pos) 
    390387{ 
    391         return inst_find_vec(pos, meas_pick_vec_b, meas_inst); 
     388        return inst_find_vec(pos, is_highlighted, NULL); 
    392389} 
    393390 
  • trunk/eda/fped/gui_tool.c

    r5525 r5552  
    275275{ 
    276276        return draw_move_line_common(inst, 
    277             add_vec(sub_vec(inst->u.rect.end, inst->base), pos), pos, i); 
     277            add_vec(sub_vec(inst->u.vec.end, inst->base), pos), pos, i); 
    278278} 
    279279 
     
    282282{ 
    283283        return hover_common(gc_vec[mode_hover], 
    284             self->u.rect.end, VEC_EYE_R); 
     284            self->u.vec.end, VEC_EYE_R); 
    285285} 
    286286 
  • trunk/eda/fped/inst.c

    r5527 r5552  
    354354{ 
    355355        if (inst->ops == &vec_ops) 
    356                 return inst->u.rect.end; 
     356                return inst->u.vec.end; 
    357357        if (inst->ops == &frame_ops) 
    358358                return inst->base; 
     
    576576        status_set_type_entry("ref ="); 
    577577        status_set_name("%s", self->vec->name ? self->vec->name : ""); 
    578         rect_status(self->base, self->u.rect.end, -1, 0); 
     578        rect_status(self->base, self->u.vec.end, -1, 0); 
    579579        vec_edit(self->vec); 
    580580} 
     
    629629        inst = add_inst(&vec_ops, ip_vec, base); 
    630630        inst->vec = vec; 
    631         inst->u.rect.end = vec->pos; 
     631        inst->u.vec.end = vec->pos; 
    632632        update_bbox(&inst->bbox, vec->pos); 
    633633        propagate_bbox(inst); 
     
    12001200        int i; 
    12011201 
    1202         FOR_ALL_INSTS(i, ip_vec, inst) 
    1203                 if (pick(inst, user)) 
     1202        FOR_ALL_INSTS(i, ip_vec, inst) { 
     1203                inst->u.vec.highlighted = pick(inst, user); 
     1204                if (inst->u.vec.highlighted) 
    12041205                        gui_highlight_vec(inst); 
     1206        } 
    12051207} 
    12061208 
  • trunk/eda/fped/inst.h

    r5527 r5552  
    8080        union { 
    8181                struct { 
     82                        int highlighted; /* for measurements */ 
     83                        struct coord end; 
     84                } vec; 
     85                struct { 
    8286                        struct frame *ref; 
    8387                        int active; 
     
    8589                const char *name; 
    8690                struct { 
     91                        unit_type width; 
    8792                        struct coord end; 
    88                         unit_type width; 
    8993                } rect; 
    9094                struct { 
Note: See TracChangeset for help on using the changeset viewer.