r5552 - trunk/eda/fped
werner at docs.openmoko.org
werner at docs.openmoko.org
Thu Aug 27 11:01:25 CEST 2009
Author: werner
Date: 2009-08-27 11:01:24 +0200 (Thu, 27 Aug 2009)
New Revision: 5552
Modified:
trunk/eda/fped/gui_inst.c
trunk/eda/fped/gui_meas.c
trunk/eda/fped/gui_tool.c
trunk/eda/fped/inst.c
trunk/eda/fped/inst.h
Log:
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.
Modified: trunk/eda/fped/gui_inst.c
===================================================================
--- trunk/eda/fped/gui_inst.c 2009-08-27 09:00:28 UTC (rev 5551)
+++ trunk/eda/fped/gui_inst.c 2009-08-27 09:01:24 UTC (rev 5552)
@@ -122,7 +122,7 @@
{
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 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_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)];
Modified: trunk/eda/fped/gui_meas.c
===================================================================
--- trunk/eda/fped/gui_meas.c 2009-08-27 09:00:28 UTC (rev 5551)
+++ trunk/eda/fped/gui_meas.c 2009-08-27 09:01:24 UTC (rev 5552)
@@ -64,7 +64,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
/* ----- 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 @@
}
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 @@
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);
}
Modified: trunk/eda/fped/gui_tool.c
===================================================================
--- trunk/eda/fped/gui_tool.c 2009-08-27 09:00:28 UTC (rev 5551)
+++ trunk/eda/fped/gui_tool.c 2009-08-27 09:01:24 UTC (rev 5552)
@@ -274,14 +274,14 @@
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);
}
Modified: trunk/eda/fped/inst.c
===================================================================
--- trunk/eda/fped/inst.c 2009-08-27 09:00:28 UTC (rev 5551)
+++ trunk/eda/fped/inst.c 2009-08-27 09:01:24 UTC (rev 5552)
@@ -353,7 +353,7 @@
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 @@
{
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 @@
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 @@
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);
+ }
}
Modified: trunk/eda/fped/inst.h
===================================================================
--- trunk/eda/fped/inst.h 2009-08-27 09:00:28 UTC (rev 5551)
+++ trunk/eda/fped/inst.h 2009-08-27 09:01:24 UTC (rev 5552)
@@ -79,13 +79,17 @@
int active;
union {
struct {
+ int highlighted; /* for measurements */
+ struct coord end;
+ } vec;
+ struct {
struct frame *ref;
int active;
} frame;
const char *name;
struct {
+ unit_type width;
struct coord end;
- unit_type width;
} rect;
struct {
char *name;
More information about the commitlog
mailing list