1
0
mirror of git://projects.qi-hardware.com/fped.git synced 2024-07-02 18:26:21 +03:00

- added the usual COLOR_ prefix also to TOOL_SELECTED/TOOL_UNSELECTED

- instantiate_meas if a mesurements has no samples, do the next one, don't stop
  completely
- when instantiation fails, the corresponding vector, object, or loop is now
  marked red in the variables/items list.



git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5432 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
werner 2009-08-13 09:30:16 +00:00
parent 2d8b36d65c
commit 8e54c1f7c3
9 changed files with 56 additions and 21 deletions

View File

@ -111,7 +111,7 @@ void redraw(void)
aw = draw_ctx.widget->allocation.width; aw = draw_ctx.widget->allocation.width;
ah = draw_ctx.widget->allocation.height; ah = draw_ctx.widget->allocation.height;
gdk_draw_rectangle(draw_ctx.widget->window, gdk_draw_rectangle(draw_ctx.widget->window,
instantiation_ok ? gc_bg : gc_bg_error, TRUE, 0, 0, aw, ah); instantiation_error ? gc_bg_error : gc_bg, TRUE, 0, 0, aw, ah);
inst_draw(); inst_draw();
if (highlight) if (highlight)

View File

@ -852,6 +852,8 @@ static void build_loop(GtkWidget *vbox, struct frame *frame,
field = label_in_box_new(loop->var.name); field = label_in_box_new(loop->var.name);
gtk_box_pack_start(GTK_BOX(hbox), box_of_label(field), FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), box_of_label(field), FALSE, FALSE, 0);
label_in_box_bg(field, COLOR_VAR_PASSIVE); label_in_box_bg(field, COLOR_VAR_PASSIVE);
if (instantiation_error == loop)
label_in_box_fg(field, COLOR_ITEM_ERROR);
g_signal_connect(G_OBJECT(box_of_label(field)), g_signal_connect(G_OBJECT(box_of_label(field)),
"button_press_event", "button_press_event",
G_CALLBACK(loop_var_select_event), loop); G_CALLBACK(loop_var_select_event), loop);
@ -1037,6 +1039,9 @@ static GtkWidget *build_items(struct frame *frame)
s = print_obj(item->obj, item->vec); s = print_obj(item->obj, item->vec);
item->obj->list_widget = item_label(tab, s, 1, n, item->obj->list_widget = item_label(tab, s, 1, n,
item_select_obj, item->obj); item_select_obj, item->obj);
if (item->obj == instantiation_error)
label_in_box_fg(item->obj->list_widget,
COLOR_ITEM_ERROR);
} else { } else {
s = print_label(item->vec); s = print_label(item->vec);
t = stralloc_printf("%s: ", s); t = stralloc_printf("%s: ", s);
@ -1046,6 +1051,9 @@ static GtkWidget *build_items(struct frame *frame)
s = print_vec(item->vec); s = print_vec(item->vec);
item->vec->list_widget = item_label(tab, s, 1, n, item->vec->list_widget = item_label(tab, s, 1, n,
item_select_vec, item->vec); item_select_vec, item->vec);
if (item->vec == instantiation_error)
label_in_box_fg(item->vec->list_widget,
COLOR_ITEM_ERROR);
} }
n++; n++;
} }
@ -1083,6 +1091,8 @@ static GtkWidget *build_meas(struct frame *frame)
s = print_meas(obj); s = print_meas(obj);
obj->list_widget = item_label(tab, s, 0, n, obj->list_widget = item_label(tab, s, 0, n,
item_select_obj, obj); item_select_obj, obj);
if (obj == instantiation_error)
label_in_box_fg(obj->list_widget, COLOR_ITEM_ERROR);
n++; n++;
} }

View File

@ -83,11 +83,12 @@
#define COLOR_VAR_TABLE_SEP "black" #define COLOR_VAR_TABLE_SEP "black"
#define TOOL_UNSELECTED "#dcdad5" #define COLOR_TOOL_UNSELECTED "#dcdad5"
#define TOOL_SELECTED "red" #define COLOR_TOOL_SELECTED "red"
#define COLOR_ITEM_NORMAL "#dcdad5" #define COLOR_ITEM_NORMAL "#dcdad5"
#define COLOR_ITEM_SELECTED COLOR_FRAME_SELECTED #define COLOR_ITEM_SELECTED COLOR_FRAME_SELECTED
#define COLOR_ITEM_ERROR "red"
/* ----- canvas drawing styles --------------------------------------------- */ /* ----- canvas drawing styles --------------------------------------------- */

View File

@ -926,11 +926,11 @@ static void tool_select(GtkWidget *evbox, struct tool_ops *ops)
if (active_tool) { if (active_tool) {
if (active_ops && active_ops->tool_deselected) if (active_ops && active_ops->tool_deselected)
active_ops->tool_deselected(); active_ops->tool_deselected();
col = get_color(TOOL_UNSELECTED); col = get_color(COLOR_TOOL_UNSELECTED);
gtk_widget_modify_bg(active_tool, GTK_STATE_NORMAL, &col); gtk_widget_modify_bg(active_tool, GTK_STATE_NORMAL, &col);
active_tool = NULL; active_tool = NULL;
} }
col = get_color(TOOL_SELECTED); col = get_color(COLOR_TOOL_SELECTED);
gtk_widget_modify_bg(evbox, GTK_STATE_NORMAL, &col); gtk_widget_modify_bg(evbox, GTK_STATE_NORMAL, &col);
active_tool = evbox; active_tool = evbox;
active_ops = ops; active_ops = ops;

View File

@ -151,6 +151,14 @@ GtkWidget *box_of_label(GtkWidget *label)
} }
void label_in_box_fg(GtkWidget *label, const char *color)
{
GdkColor col = get_color(color);
gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &col);
}
void label_in_box_bg(GtkWidget *label, const char *color) void label_in_box_bg(GtkWidget *label, const char *color)
{ {
GtkWidget *box; GtkWidget *box;

View File

@ -54,6 +54,7 @@ void draw_circle(GdkDrawable *da, GdkGC *gc, int fill,
GtkWidget *label_in_box_new(const char *s); GtkWidget *label_in_box_new(const char *s);
GtkWidget *box_of_label(GtkWidget *label); GtkWidget *box_of_label(GtkWidget *label);
void label_in_box_fg(GtkWidget *box, const char *color);
void label_in_box_bg(GtkWidget *box, const char *color); void label_in_box_bg(GtkWidget *box, const char *color);
GtkWidget *make_image(GdkDrawable *drawable, char **xpm); GtkWidget *make_image(GdkDrawable *drawable, char **xpm);

6
meas.c
View File

@ -232,7 +232,7 @@ int instantiate_meas(void)
continue; continue;
meas = &obj->u.meas; meas = &obj->u.meas;
if (!obj->base->samples || !meas->high->samples) if (!obj->base->samples || !meas->high->samples)
return 1; continue;
lt = lt_op[meas->type]; lt = lt_op[meas->type];
a0 = meas_find_min(lt, obj->base->samples); a0 = meas_find_min(lt, obj->base->samples);
@ -245,8 +245,10 @@ int instantiate_meas(void)
offset.n = 0; offset.n = 0;
else { else {
offset = eval_unit(meas->offset, root_frame); offset = eval_unit(meas->offset, root_frame);
if (is_undef(offset)) if (is_undef(offset)) {
instantiation_error = obj;
return 0; return 0;
}
} }
inst_meas(obj, inst_meas(obj,
meas->inverted ? b0 : a0, meas->inverted ? a0 : b0, meas->inverted ? b0 : a0, meas->inverted ? a0 : b0,

39
obj.c
View File

@ -32,7 +32,7 @@ char *part_name = NULL;
struct frame *frames = NULL; struct frame *frames = NULL;
struct frame *root_frame = NULL; struct frame *root_frame = NULL;
struct frame *active_frame = NULL; struct frame *active_frame = NULL;
int instantiation_ok; void *instantiation_error = NULL;
static int generate_frame(struct frame *frame, struct coord base, static int generate_frame(struct frame *frame, struct coord base,
@ -71,19 +71,23 @@ static int generate_vecs(struct frame *frame, struct coord base)
for (vec = frame->vecs; vec; vec = vec->next) { for (vec = frame->vecs; vec; vec = vec->next) {
x = eval_unit(vec->x, frame); x = eval_unit(vec->x, frame);
if (is_undef(x)) if (is_undef(x))
return 0; goto error;
y = eval_unit(vec->y, frame); y = eval_unit(vec->y, frame);
if (is_undef(y)) if (is_undef(y))
return 0; goto error;
vec_base = vec->base ? vec->base->pos : base; vec_base = vec->base ? vec->base->pos : base;
vec->pos = vec_base; vec->pos = vec_base;
vec->pos.x += x.n; vec->pos.x += x.n;
vec->pos.y += y.n; vec->pos.y += y.n;
if (!inst_vec(vec, vec_base)) if (!inst_vec(vec, vec_base))
return 0; goto error;
meas_post(vec, vec->pos); meas_post(vec, vec->pos);
} }
return 1; return 1;
error:
instantiation_error = vec;
return 0;
} }
@ -106,43 +110,43 @@ static int generate_objs(struct frame *frame, struct coord base, int active)
width = eval_unit_default(obj->u.line.width, frame, width = eval_unit_default(obj->u.line.width, frame,
DEFAULT_SILK_WIDTH); DEFAULT_SILK_WIDTH);
if (is_undef(width)) if (is_undef(width))
return 0; goto error;
if (!inst_line(obj, obj->base ? obj->base->pos : base, if (!inst_line(obj, obj->base ? obj->base->pos : base,
obj->u.line.other ? obj->u.line.other->pos : base, obj->u.line.other ? obj->u.line.other->pos : base,
width.n)) width.n))
return 0; goto error;
break; break;
case ot_rect: case ot_rect:
width = eval_unit_default(obj->u.rect.width, frame, width = eval_unit_default(obj->u.rect.width, frame,
DEFAULT_SILK_WIDTH); DEFAULT_SILK_WIDTH);
if (is_undef(width)) if (is_undef(width))
return 0; goto error;
if (!inst_rect(obj, obj->base ? obj->base->pos : base, if (!inst_rect(obj, obj->base ? obj->base->pos : base,
obj->u.rect.other ? obj->u.rect.other->pos : base, obj->u.rect.other ? obj->u.rect.other->pos : base,
width.n)) width.n))
return 0; goto error;
break; break;
case ot_pad: case ot_pad:
name = expand(obj->u.pad.name, frame); name = expand(obj->u.pad.name, frame);
if (!name) if (!name)
return 0; goto error;
ok = inst_pad(obj, name, ok = inst_pad(obj, name,
obj->base ? obj->base->pos : base, obj->base ? obj->base->pos : base,
obj->u.pad.other ? obj->u.pad.other->pos : base); obj->u.pad.other ? obj->u.pad.other->pos : base);
free(name); free(name);
if (!ok) if (!ok)
return 0; goto error;
break; break;
case ot_arc: case ot_arc:
width = eval_unit_default(obj->u.arc.width, frame, width = eval_unit_default(obj->u.arc.width, frame,
DEFAULT_SILK_WIDTH); DEFAULT_SILK_WIDTH);
if (is_undef(width)) if (is_undef(width))
return 0; goto error;
if (!inst_arc(obj, obj->base ? obj->base->pos : base, if (!inst_arc(obj, obj->base ? obj->base->pos : base,
obj->u.arc.start ? obj->u.arc.start->pos : base, obj->u.arc.start ? obj->u.arc.start->pos : base,
obj->u.arc.end ? obj->u.arc.end->pos : base, obj->u.arc.end ? obj->u.arc.end->pos : base,
width.n)) width.n))
return 0; goto error;
break; break;
case ot_meas: case ot_meas:
break; break;
@ -150,6 +154,10 @@ static int generate_objs(struct frame *frame, struct coord base, int active)
abort(); abort();
} }
return 1; return 1;
error:
instantiation_error = obj;
return 0;
} }
@ -175,22 +183,26 @@ static int run_loops(struct frame *frame, struct loop *loop,
from = eval_num(loop->from.expr, frame); from = eval_num(loop->from.expr, frame);
if (is_undef(from)) { if (is_undef(from)) {
fail_expr(loop->from.expr); fail_expr(loop->from.expr);
instantiation_error = loop;
return 0; return 0;
} }
if (!is_dimensionless(from)) { if (!is_dimensionless(from)) {
fail("incompatible type for start value"); fail("incompatible type for start value");
fail_expr(loop->from.expr); fail_expr(loop->from.expr);
instantiation_error = loop;
return 0; return 0;
} }
to = eval_num(loop->to.expr, frame); to = eval_num(loop->to.expr, frame);
if (is_undef(to)) { if (is_undef(to)) {
fail_expr(loop->to.expr); fail_expr(loop->to.expr);
instantiation_error = loop;
return 0; return 0;
} }
if (!is_dimensionless(to)) { if (!is_dimensionless(to)) {
fail("incompatible type for end value"); fail("incompatible type for end value");
fail_expr(loop->to.expr); fail_expr(loop->to.expr);
instantiation_error = loop;
return 0; return 0;
} }
@ -203,6 +215,7 @@ static int run_loops(struct frame *frame, struct loop *loop,
if (n >= MAX_ITERATIONS) { if (n >= MAX_ITERATIONS) {
fail("%s: too many iterations (%d)", loop->var.name, fail("%s: too many iterations (%d)", loop->var.name,
MAX_ITERATIONS); MAX_ITERATIONS);
instantiation_error = loop;
goto fail; goto fail;
} }
if (!run_loops(frame, loop->next, base, if (!run_loops(frame, loop->next, base,
@ -259,6 +272,7 @@ int instantiate(void)
inst_start(); inst_start();
meas_start(); meas_start();
instantiation_error = NULL;
ok = generate_frame(root_frame, zero, NULL, NULL, 1); ok = generate_frame(root_frame, zero, NULL, NULL, 1);
if (ok) if (ok)
ok = instantiate_meas(); ok = instantiate_meas();
@ -266,6 +280,5 @@ int instantiate(void)
inst_commit(); inst_commit();
else else
inst_revert(); inst_revert();
instantiation_ok = ok;
return ok; return ok;
} }

2
obj.h
View File

@ -183,7 +183,7 @@ extern char *part_name;
extern struct frame *frames; extern struct frame *frames;
extern struct frame *root_frame; extern struct frame *root_frame;
extern struct frame *active_frame; extern struct frame *active_frame;
extern int instantiation_ok; extern void *instantiation_error;
int instantiate(void); int instantiate(void);