1
0
mirror of git://projects.qi-hardware.com/fped.git synced 2024-09-28 19:55:06 +03:00

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(n^3) 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.



git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5552 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
werner 2009-08-27 09:01:24 +00:00
parent 3497aabf5c
commit c37648e2a5
5 changed files with 33 additions and 30 deletions

View File

@ -122,7 +122,7 @@ unit_type gui_dist_vec(struct inst *self, struct coord pos, unit_type scale)
{
unit_type d;
d = dist_point(pos, self->u.rect.end)/scale;
d = dist_point(pos, self->u.vec.end)/scale;
return d > VEC_EYE_R ? -1 : d;
}
@ -138,14 +138,14 @@ unit_type gui_dist_vec_fallback(struct inst *self, struct coord pos,
{
unit_type d;
d = dist_line(pos, self->base, self->u.rect.end)/scale;
d = dist_line(pos, self->base, self->u.vec.end)/scale;
return d > SELECT_R ? -1 : d;
}
void gui_highlight_vec(struct inst *self)
{
struct coord center = translate(self->u.rect.end);
struct coord center = translate(self->u.vec.end);
draw_circle(DA, gc_highlight, FALSE, center.x, center.y, VEC_EYE_R);
}
@ -154,7 +154,7 @@ void gui_highlight_vec(struct inst *self)
void gui_draw_vec(struct inst *self)
{
struct coord from = translate(self->base);
struct coord to = translate(self->u.rect.end);
struct coord to = translate(self->u.vec.end);
GdkGC *gc;
gc = gc_vec[get_mode(self)];

View File

@ -64,7 +64,7 @@ static int is_min(lt_op_type lt, const struct inst *inst)
struct coord min;
min = meas_find_min(lt, active_pkg->samples[inst->vec->n]);
return coord_eq(inst->u.rect.end, min);
return coord_eq(inst->u.vec.end, min);
}
@ -74,8 +74,8 @@ static int is_next(lt_op_type lt,
struct coord next;
next = meas_find_next(lt, active_pkg->samples[inst->vec->n],
ref->u.rect.end);
return coord_eq(inst->u.rect.end, next);
ref->u.vec.end);
return coord_eq(inst->u.vec.end, next);
}
@ -84,7 +84,7 @@ static int is_max(lt_op_type lt, const struct inst *inst)
struct coord max;
max = meas_find_max(lt, active_pkg->samples[inst->vec->n]);
return coord_eq(inst->u.rect.end, max);
return coord_eq(inst->u.vec.end, max);
}
@ -97,7 +97,7 @@ static int is_a_next(lt_op_type lt, struct inst *inst)
min = meas_find_min(lt, active_pkg->samples[a->vec->n]);
next = meas_find_next(lt, active_pkg->samples[inst->vec->n],
min);
if (coord_eq(next, inst->u.rect.end))
if (coord_eq(next, inst->u.vec.end))
return 1;
}
return 0;
@ -112,7 +112,7 @@ static int is_min_of_next(lt_op_type lt,
min = meas_find_min(lt, inst->vec->samples);
next = meas_find_next(lt, ref->vec->samples, min);
return coord_eq(next, ref->u.rect.end);
return coord_eq(next, ref->u.vec.end);
}
#endif
@ -234,12 +234,15 @@ static void tool_deselected_meas(void)
/* ----- find start point (new measurement) -------------------------------- */
static int is_highlighted(struct inst *inst, void *user)
{
return inst->u.vec.highlighted;
}
static struct inst *find_point_meas_new(struct coord pos)
{
if (meas_inst)
return inst_find_vec(pos, meas_pick_vec_b, meas_inst);
else
return inst_find_vec(pos, meas_pick_vec_a, NULL);
return inst_find_vec(pos, is_highlighted, NULL);
}
@ -302,14 +305,8 @@ static int end_new_meas(struct inst *from, struct inst *to)
}
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) !=
meas_dsc->lt(from->u.vec.end, to->u.vec.end) !=
(mode == min_to_next_or_max);
{
char *sm[] = { "min_to", "max_to", "next_to" };
char *st[] = { "nxy", "nx", "ny", "mxy", "mx", "my" };
fprintf(stderr, "mode %s type %s, inverted %d\n",
sm[mode], st[meas->type], meas->inverted);
}
meas->offset = NULL;
meas_dsc = NULL;
return 1;
@ -388,7 +385,7 @@ void begin_drag_move_meas(struct inst *inst, int i)
struct inst *find_point_meas_move(struct inst *inst, struct coord pos)
{
return inst_find_vec(pos, meas_pick_vec_b, meas_inst);
return inst_find_vec(pos, is_highlighted, NULL);
}

View File

@ -274,14 +274,14 @@ static struct pix_buf *drag_new_vec(struct inst *from, struct coord to)
struct pix_buf *draw_move_vec(struct inst *inst, struct coord pos, int i)
{
return draw_move_line_common(inst,
add_vec(sub_vec(inst->u.rect.end, inst->base), pos), pos, i);
add_vec(sub_vec(inst->u.vec.end, inst->base), pos), pos, i);
}
struct pix_buf *gui_hover_vec(struct inst *self)
{
return hover_common(gc_vec[mode_hover],
self->u.rect.end, VEC_EYE_R);
self->u.vec.end, VEC_EYE_R);
}

12
inst.c
View File

@ -353,7 +353,7 @@ int inst_find_point_selected(struct coord pos, struct inst **res)
struct coord inst_get_point(const struct inst *inst)
{
if (inst->ops == &vec_ops)
return inst->u.rect.end;
return inst->u.vec.end;
if (inst->ops == &frame_ops)
return inst->base;
abort();
@ -575,7 +575,7 @@ static void vec_op_select(struct inst *self)
{
status_set_type_entry("ref =");
status_set_name("%s", self->vec->name ? self->vec->name : "");
rect_status(self->base, self->u.rect.end, -1, 0);
rect_status(self->base, self->u.vec.end, -1, 0);
vec_edit(self->vec);
}
@ -628,7 +628,7 @@ int inst_vec(struct vec *vec, struct coord base)
inst = add_inst(&vec_ops, ip_vec, base);
inst->vec = vec;
inst->u.rect.end = vec->pos;
inst->u.vec.end = vec->pos;
update_bbox(&inst->bbox, vec->pos);
propagate_bbox(inst);
return 1;
@ -1199,9 +1199,11 @@ void inst_highlight_vecs(int (*pick)(struct inst *inst, void *user), void *user)
struct inst *inst;
int i;
FOR_ALL_INSTS(i, ip_vec, inst)
if (pick(inst, user))
FOR_ALL_INSTS(i, ip_vec, inst) {
inst->u.vec.highlighted = pick(inst, user);
if (inst->u.vec.highlighted)
gui_highlight_vec(inst);
}
}

6
inst.h
View File

@ -78,14 +78,18 @@ struct inst {
struct inst *outer; /* frame containing this item */
int active;
union {
struct {
int highlighted; /* for measurements */
struct coord end;
} vec;
struct {
struct frame *ref;
int active;
} frame;
const char *name;
struct {
struct coord end;
unit_type width;
struct coord end;
} rect;
struct {
char *name;