r5482 - trunk/eda/fped
werner at docs.openmoko.org
werner at docs.openmoko.org
Wed Aug 19 00:03:51 CEST 2009
Author: werner
Date: 2009-08-19 00:03:51 +0200 (Wed, 19 Aug 2009)
New Revision: 5482
Modified:
trunk/eda/fped/inst.c
trunk/eda/fped/inst.h
trunk/eda/fped/postscript.c
Log:
- replaced awkward FOR_GLOBAL_INSTS / FOR_PKG_INSTS sequence with single
FOR_ALL_INSTS
- several functions only walked the active package instances, so we couldn't
access the origin of the root frame
Modified: trunk/eda/fped/inst.c
===================================================================
--- trunk/eda/fped/inst.c 2009-08-18 20:57:09 UTC (rev 5481)
+++ trunk/eda/fped/inst.c 2009-08-18 22:03:51 UTC (rev 5482)
@@ -158,7 +158,7 @@
enum inst_prio prio;
struct inst *inst;
int best_dist = 0; /* keep gcc happy */
- int dist;
+ int dist, i;
deselect_outside();
edit_nothing();
@@ -170,7 +170,7 @@
FOR_INST_PRIOS_DOWN(prio) {
if (!show(prio))
continue;
- for (inst = active_pkg->insts[prio]; inst; inst = inst->next) {
+ FOR_ALL_INSTS(i, prio, inst) {
if (!inst->active || !inst->ops->distance)
continue;
if (!inst_connected(inst))
@@ -190,7 +190,7 @@
/* give vectors a second chance */
- for (inst = active_pkg->insts[ip_vec]; inst; inst = inst->next) {
+ FOR_ALL_INSTS(i, ip_vec, inst) {
if (!inst->active)
continue;
if (!inst_connected(inst))
@@ -215,10 +215,10 @@
{
struct inst *inst, *found;
int best_dist = 0; /* keep gcc happy */
- int dist;
+ int dist, i;
found = NULL;
- for (inst = active_pkg->insts[ip_frame]; inst; inst = inst->next) {
+ FOR_ALL_INSTS(i, ip_frame, inst) {
if (!inst->u.frame.active)
continue;
dist = gui_dist_frame_eye(inst, pos, draw_ctx.scale);
@@ -230,7 +230,7 @@
if (found)
return found;
- for (inst = active_pkg->insts[ip_vec]; inst; inst = inst->next) {
+ FOR_ALL_INSTS(i, ip_vec, inst) {
if (!inst->active || !inst->ops->distance)
continue;
dist = inst->ops->distance(inst, pos, draw_ctx.scale);
@@ -249,14 +249,13 @@
int n, best_i, i;
struct inst *best = NULL;
struct inst *inst;
- int d_min, d;
+ int d_min, d, j;
assert(selected_inst);
n = inst_anchors(selected_inst, anchors);
for (i = 0; i != n; i++) {
if (*anchors[i]) {
- for (inst = active_pkg->insts[ip_vec]; inst;
- inst = inst->next) {
+ FOR_ALL_INSTS(j, ip_vec, inst) {
if (inst->vec != *anchors[i])
continue;
d = gui_dist_vec(inst, pos, draw_ctx.scale);
@@ -267,8 +266,7 @@
}
}
} else {
- for (inst = active_pkg->insts[ip_frame]; inst;
- inst = inst->next) {
+ FOR_ALL_INSTS(j, ip_vec, inst) {
if (inst != selected_inst->outer)
continue;
d = gui_dist_frame(inst, pos, draw_ctx.scale);
@@ -345,10 +343,11 @@
void inst_select_vec(struct vec *vec)
{
struct inst *inst;
+ int i;
if (vec->frame != active_frame)
select_frame(vec->frame);
- for (inst = active_pkg->insts[ip_vec]; inst; inst = inst->next)
+ FOR_ALL_INSTS(i, ip_vec, inst)
if (inst->vec == vec && inst->active) {
inst_deselect();
inst_select_inst(inst);
@@ -362,17 +361,14 @@
{
enum inst_prio prio;
struct inst *inst;
+ int i;
if (obj->frame != active_frame)
select_frame(obj->frame);
- FOR_INST_PRIOS_DOWN(prio) {
- FOR_GLOBAL_INSTS(prio, inst)
+ FOR_INST_PRIOS_DOWN(prio)
+ FOR_ALL_INSTS(i, prio, inst)
if (inst->obj && inst->obj == obj && inst->active)
goto found;
- FOR_PKG_INSTS(prio, inst)
- if (inst->obj && inst->obj == obj && inst->active)
- goto found;
- }
obj_edit(obj);
return;
@@ -1037,35 +1033,22 @@
{
enum inst_prio prio;
struct inst *inst;
+ int i;
- FOR_INST_PRIOS_UP(prio) {
- FOR_GLOBAL_INSTS(prio, inst)
+ FOR_INST_PRIOS_UP(prio)
+ FOR_ALL_INSTS(i, prio, inst)
if (show(prio) && !inst->active && inst->ops->draw)
inst->ops->draw(inst);
- FOR_PKG_INSTS(prio, inst)
- if (show(prio) && !inst->active && inst->ops->draw)
- inst->ops->draw(inst);
- }
- FOR_INST_PRIOS_UP(prio) {
- FOR_GLOBAL_INSTS(prio, inst)
+ FOR_INST_PRIOS_UP(prio)
+ FOR_ALL_INSTS(i, prio, inst)
if (show(prio) && prio != ip_frame && inst->active &&
inst != selected_inst && inst->ops->draw)
inst->ops->draw(inst);
- FOR_PKG_INSTS(prio, inst)
- if (show(prio) && prio != ip_frame && inst->active &&
- inst != selected_inst && inst->ops->draw)
- inst->ops->draw(inst);
- }
- if (show_stuff) {
- FOR_GLOBAL_INSTS(ip_frame, inst)
+ if (show_stuff)
+ FOR_ALL_INSTS(i, ip_frame, inst)
if (inst->active && inst != selected_inst &&
inst->ops->draw)
inst->ops->draw(inst);
- FOR_PKG_INSTS(ip_frame, inst)
- if (inst->active && inst != selected_inst &&
- inst->ops->draw)
- inst->ops->draw(inst);
- }
if (selected_inst && selected_inst->ops->draw)
selected_inst->ops->draw(selected_inst);
}
@@ -1074,13 +1057,11 @@
void inst_highlight_vecs(int (*pick)(struct inst *inst, void *user), void *user)
{
struct inst *inst;
+ int i;
- FOR_GLOBAL_INSTS(ip_vec, inst)
+ FOR_ALL_INSTS(i, ip_vec, inst)
if (pick(inst, user))
gui_highlight_vec(inst);
- FOR_PKG_INSTS(ip_vec, inst)
- if (pick(inst, user))
- gui_highlight_vec(inst);
}
@@ -1089,10 +1070,10 @@
{
struct inst *inst, *found;
int best_dist = 0; /* keep gcc happy */
- int dist;
+ int dist, i;
found = NULL;
- FOR_GLOBAL_INSTS(ip_vec, inst) {
+ FOR_ALL_INSTS(i, ip_vec, inst) {
if (!inst->ops->distance)
continue;
dist = inst->ops->distance(inst, pos, draw_ctx.scale);
@@ -1103,17 +1084,6 @@
found = inst;
best_dist = dist;
}
- FOR_PKG_INSTS(ip_vec, inst) {
- if (!inst->ops->distance)
- continue;
- dist = inst->ops->distance(inst, pos, draw_ctx.scale);
- if (dist < 0 || (found && best_dist <= dist))
- continue;
- if (!pick(inst, user))
- continue;
- found = inst;
- best_dist = dist;
- }
return found;
}
Modified: trunk/eda/fped/inst.h
===================================================================
--- trunk/eda/fped/inst.h 2009-08-18 20:57:09 UTC (rev 5481)
+++ trunk/eda/fped/inst.h 2009-08-18 22:03:51 UTC (rev 5482)
@@ -137,19 +137,18 @@
* allow other items shared by all packages be there as well.
*/
-#define FOR_INST_PRIOS_UP(prio) \
+#define FOR_INST_PRIOS_UP(prio) \
for (prio = 0; prio != ip_n; prio++)
-#define FOR_INST_PRIOS_DOWN(prio) \
+#define FOR_INST_PRIOS_DOWN(prio) \
for (prio = ip_n-1; prio != (enum inst_prio) -1; prio--)
-#define FOR_GLOBAL_INSTS(prio, inst) \
- for (inst = pkgs->insts[prio]; inst; inst = inst->next)
+#define FOR_ALL_INSTS(i, prio, inst) \
+ for (i = 0; i != 2; i++) \
+ for (inst = (i ? active_pkg : pkgs)->insts[prio]; inst; \
+ inst = inst->next)
-#define FOR_PKG_INSTS(prio, inst) \
- for (inst = active_pkg->insts[prio]; inst; inst = inst->next)
-
void inst_select_outside(void *item, void (*deselect)(void *item));
int inst_select(struct coord pos);
void inst_deselect(void);
Modified: trunk/eda/fped/postscript.c
===================================================================
--- trunk/eda/fped/postscript.c 2009-08-18 20:57:09 UTC (rev 5481)
+++ trunk/eda/fped/postscript.c 2009-08-18 22:03:51 UTC (rev 5482)
@@ -278,6 +278,7 @@
{
enum inst_prio prio;
const struct inst *inst;
+ int i;
fprintf(file, "%%!PS\n");
@@ -373,18 +374,12 @@
" dup false charpath stroke grestore\n"
" show } def\n");
- FOR_INST_PRIOS_UP(prio) {
- FOR_GLOBAL_INSTS(prio, inst)
+ FOR_INST_PRIOS_UP(prio)
+ FOR_ALL_INSTS(i, prio, inst)
ps_background(file, prio, inst);
- FOR_PKG_INSTS(prio, inst)
- ps_background(file, prio, inst);
- }
- FOR_INST_PRIOS_UP(prio) {
- FOR_GLOBAL_INSTS(prio, inst)
+ FOR_INST_PRIOS_UP(prio)
+ FOR_ALL_INSTS(i, prio, inst)
ps_foreground(file, prio, inst);
- FOR_PKG_INSTS(prio, inst)
- ps_foreground(file, prio, inst);
- }
fprintf(file, "showpage\n");
fprintf(file, "%%%%EOF\n");
More information about the commitlog
mailing list