summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-09-30 00:48:00 (GMT)
committerWerner Almesberger <werner@almesberger.net>2016-09-30 01:00:26 (GMT)
commit2f6677ab8f5f15fc09fc02d6ea86fd5b3f650a1d (patch)
tree0f0595cbd998d30e0178035f91b30f7ed6757e54
parent2c9e549c9554e0cabb4d4ccdb2c3a2238d62bcf4 (diff)
downloadeeshow-2f6677ab8f5f15fc09fc02d6ea86fd5b3f650a1d.zip
eeshow-2f6677ab8f5f15fc09fc02d6ea86fd5b3f650a1d.tar.gz
eeshow-2f6677ab8f5f15fc09fc02d6ea86fd5b3f650a1d.tar.bz2
get rid of sch_render_extra and move selection to rendering (WIP)
This works for eeshow, but this breaks the -e option of eeplot and eediff, permanently enabling it in FIG, and permanently disabling it in all the Cairo-based formats.
-rw-r--r--gfx/cro.c15
-rw-r--r--gfx/cro.h4
-rw-r--r--gfx/diff.c18
-rw-r--r--gfx/diff.h3
-rw-r--r--gui/common.h1
-rw-r--r--gui/index.c2
-rw-r--r--gui/render.c39
-rw-r--r--kicad/lib-render.c31
-rw-r--r--kicad/lib.h2
-rw-r--r--kicad/sch-render.c27
-rw-r--r--kicad/sch.h1
-rw-r--r--main/eeplot.c6
12 files changed, 30 insertions, 119 deletions
diff --git a/gfx/cro.c b/gfx/cro.c
index f1d44b6..5b23113 100644
--- a/gfx/cro.c
+++ b/gfx/cro.c
@@ -1053,7 +1053,7 @@ void cro_canvas_prepare(cairo_t *cr)
void cro_canvas_draw(struct cro_ctx *cc, cairo_t *cr, int xo, int yo,
- float scale)
+ float scale, enum gfx_extra extra)
{
cc->cr = cr;
@@ -1062,14 +1062,14 @@ void cro_canvas_draw(struct cro_ctx *cc, cairo_t *cr, int xo, int yo,
cc->scale = scale;
cc->xo = xo;
cc->yo = yo;
- record_replay(&cc->record, 0);
+ record_replay(&cc->record, extra);
}
/* ----- Image for external use (simplified API) --------------------------- */
-uint32_t *cro_img(struct cro_ctx *cc, struct cro_ctx *cc_extra,
+uint32_t *cro_img(struct cro_ctx *cc, enum gfx_extra extra,
int xo, int yo, int w, int h,
float scale, double alpha, cairo_t **res_cr, int *res_stride)
{
@@ -1119,14 +1119,7 @@ uint32_t *cro_img(struct cro_ctx *cc, struct cro_ctx *cc_extra,
setup_font(cc);
- if (cc_extra) {
- void *old = cc_extra->record.user;
-
- cc_extra->record.user = cc->record.user; /* @@@ eww ! */
- record_replay(&cc_extra->record, 0);
- cc_extra->record.user = old;
- }
- record_replay(&cc->record, 0);
+ record_replay(&cc->record, extra);
if (res_cr)
*res_cr = cr;
diff --git a/gfx/cro.h b/gfx/cro.h
index 8018e26..f24ba38 100644
--- a/gfx/cro.h
+++ b/gfx/cro.h
@@ -50,9 +50,9 @@ void cro_img_destroy(struct cro_ctx *cc);
void cro_canvas_end(struct cro_ctx *cc, int *w, int *h, int *xmin, int *ymin);
void cro_canvas_prepare(cairo_t *cr);
void cro_canvas_draw(struct cro_ctx *cc, cairo_t *cr,
- int x, int y, float scale);
+ int x, int y, float scale, enum gfx_extra extra);
-uint32_t *cro_img(struct cro_ctx *cc, struct cro_ctx *cc_extra,
+uint32_t *cro_img(struct cro_ctx *cc, enum gfx_extra extra,
int x0, int yo, int w, int h,
float scale, double alpha, cairo_t **res_cr, int *res_stride);
cairo_surface_t *cro_img_surface(struct cro_ctx *cc);
diff --git a/gfx/diff.c b/gfx/diff.c
index 6aef353..fd7245c 100644
--- a/gfx/diff.c
+++ b/gfx/diff.c
@@ -196,8 +196,7 @@ void *diff_process_file(struct diff *diff, struct file_names *file_names,
if (!gfx_args(diff->gfx, argc, argv, opts))
goto fail_open;
sch_render(sch.sheets, diff->gfx);
- if (diff->extra)
- sch_render_extra(sch.sheets, diff->gfx);
+ /* @@@ filter extra */
sch_free(&sch);
lib_free(&lib);
@@ -384,8 +383,7 @@ static void merge_coord(int pos_a, int pos_b, int dim_a, int dim_b,
static cairo_t *make_diff(cairo_t *cr, int cx, int cy, float scale,
- struct cro_ctx *old, struct cro_ctx *old_extra,
- struct cro_ctx *new, struct cro_ctx *new_extra,
+ struct cro_ctx *old, struct cro_ctx *new, enum gfx_extra extra,
const struct area *areas, bool *changed)
{
int old_xmin, old_ymin, old_w, old_h;
@@ -419,9 +417,9 @@ static cairo_t *make_diff(cairo_t *cr, int cx, int cy, float scale,
yo = -ymin * scale;
}
- img_old = cro_img(old, old_extra, xo, yo, sw, sh, scale, 1,
+ img_old = cro_img(old, extra, xo, yo, sw, sh, scale, 1,
&old_cr, &stride);
- img_new = cro_img(new, new_extra, xo, yo, sw, sh, scale, 1,
+ img_new = cro_img(new, extra, xo, yo, sw, sh, scale, 1,
NULL, NULL);
struct diff diff = {
@@ -469,7 +467,7 @@ static int diff_end(void *ctx)
cro_img_reset(gfx_user(diff->gfx));
old_cr = make_diff(NULL, 0, 0, diff->scale,
- gfx_user(diff->gfx), NULL, gfx_user(diff->new_gfx), NULL, NULL,
+ gfx_user(diff->gfx), gfx_user(diff->new_gfx), 0, NULL,
&changed);
s = cairo_get_target(old_cr);
@@ -494,15 +492,13 @@ static int diff_end(void *ctx)
void diff_to_canvas(cairo_t *cr, int cx, int cy, float scale,
- struct cro_ctx *old, struct cro_ctx *old_extra,
- struct cro_ctx *new, struct cro_ctx *new_extra,
+ struct cro_ctx *old, struct cro_ctx *new, enum gfx_extra extra,
const struct area *areas)
{
cairo_t *old_cr;
cairo_surface_t *s;
- old_cr = make_diff(cr, cx, cy, scale, old, old_extra, new, new_extra,
- areas, NULL);
+ old_cr = make_diff(cr, cx, cy, scale, old, new, extra, areas, NULL);
s = cairo_get_target(old_cr);
cairo_set_source_surface(cr, s, 0, 0);
diff --git a/gfx/diff.h b/gfx/diff.h
index d1fbc18..189261c 100644
--- a/gfx/diff.h
+++ b/gfx/diff.h
@@ -40,8 +40,7 @@ void add_area(struct area **areas, int xa, int ya, int xb, int yb,
void free_areas(struct area **areas);
void diff_to_canvas(cairo_t *cr, int cx, int cy, float scale,
- struct cro_ctx *old, struct cro_ctx *old_extra,
- struct cro_ctx *new, struct cro_ctx *new_extra,
+ struct cro_ctx *old, struct cro_ctx *new, enum gfx_extra extra,
const struct area *areas);
void *diff_process_file(struct diff *diff, struct file_names *file_names,
diff --git a/gui/common.h b/gui/common.h
index 9808e31..18f0ab2 100644
--- a/gui/common.h
+++ b/gui/common.h
@@ -35,7 +35,6 @@ struct gui_sheet {
struct gui *gui; /* back link */
struct gui_hist *hist; /* back link */
struct gfx *gfx;
- struct gfx *gfx_extra;
int w, h; /* in eeschema coordinates */
int xmin, ymin;
diff --git a/gui/index.c b/gui/index.c
index a72ce21..3ee581e 100644
--- a/gui/index.c
+++ b/gui/index.c
@@ -279,7 +279,7 @@ static void index_render_sheet(const struct gui *gui,
xo = -(xmin + w / 2) * f + thumb_w / 2;
yo = -(ymin + h / 2) * f + thumb_h / 2;
- cro_img(gfx_user(sheet->gfx_thumb), NULL,
+ cro_img(gfx_user(sheet->gfx_thumb), 0,
xo, yo, thumb_w, thumb_h, f, 0, NULL, &stride);
sheet->thumb_surf = cro_img_surface(gfx_user(sheet->gfx_thumb));
diff --git a/gui/render.c b/gui/render.c
index 1686042..a6289a4 100644
--- a/gui/render.c
+++ b/gui/render.c
@@ -159,9 +159,8 @@ static void hack(const struct gui *gui, cairo_t *cr,
areas = changed_sheets(gui, xo, yo, f);
diff_to_canvas(cr, gui->x, gui->y, gui->scale,
- gfx_user(old->gfx), show_extra ? gfx_user(old->gfx_extra) : NULL,
- gfx_user(new->gfx), show_extra ? gfx_user(new->gfx_extra) : NULL,
- areas);
+ gfx_user(old->gfx), gfx_user(new->gfx),
+ show_extra ? gfx_pin_type : 0, areas);
free_areas(&areas);
}
@@ -174,6 +173,7 @@ static gboolean on_draw_event(GtkWidget *widget, cairo_t *cr,
GtkAllocation alloc;
float f = gui->scale;
int x, y;
+ enum gfx_extra extra = show_extra ? gfx_pin_type : 0;
gtk_widget_get_allocation(gui->da, &alloc);
x = -(sheet->xmin + gui->x) * f + alloc.width / 2;
@@ -182,18 +182,12 @@ static gboolean on_draw_event(GtkWidget *widget, cairo_t *cr,
cro_canvas_prepare(cr);
if (!gui->old_hist || gui->diff_mode == diff_new) {
highlight_glabel(gui, sheet, cr, x, y, f);
- if (show_extra)
- cro_canvas_draw(gfx_user(sheet->gfx_extra),
- cr, x, y, f);
- cro_canvas_draw(gfx_user(sheet->gfx), cr, x, y, f);
+ cro_canvas_draw(gfx_user(sheet->gfx), cr, x, y, f, extra);
} else if (gui->diff_mode == diff_old) {
sheet = find_corresponding_sheet(gui->old_hist->sheets,
gui->new_hist->sheets, gui->curr_sheet);
highlight_glabel(gui, sheet, cr, x, y, f);
- if (show_extra)
- cro_canvas_draw(gfx_user(sheet->gfx_extra),
- cr, x, y, f);
- cro_canvas_draw(gfx_user(sheet->gfx), cr, x, y, f);
+ cro_canvas_draw(gfx_user(sheet->gfx), cr, x, y, f, extra);
} else if (use_delta) {
struct area *areas = changed_sheets(gui, x, y, f);
const struct area *area;
@@ -207,17 +201,10 @@ static gboolean on_draw_event(GtkWidget *widget, cairo_t *cr,
free_areas(&areas);
/* @@@ fix geometry later */
- if (show_extra) {
- cro_canvas_draw(gfx_user(gui->delta_ab.gfx_extra),
- cr, x, y, f);
- cro_canvas_draw(gfx_user(gui->delta_a.gfx_extra),
- cr, x, y, f);
- cro_canvas_draw(gfx_user(gui->delta_b.gfx_extra),
- cr, x, y, f);
- }
- cro_canvas_draw(gfx_user(gui->delta_ab.gfx), cr, x, y, f);
- cro_canvas_draw(gfx_user(gui->delta_a.gfx), cr, x, y, f);
- cro_canvas_draw(gfx_user(gui->delta_b.gfx), cr, x, y, f);
+ cro_canvas_draw(gfx_user(gui->delta_ab.gfx), cr, x, y, f,
+ extra);
+ cro_canvas_draw(gfx_user(gui->delta_a.gfx), cr, x, y, f, extra);
+ cro_canvas_draw(gfx_user(gui->delta_b.gfx), cr, x, y, f, extra);
} else {
hack(gui, cr, x, y, f);
}
@@ -264,10 +251,6 @@ void render_sheet(struct gui_sheet *sheet)
cro_canvas_end(gfx_user(sheet->gfx),
&sheet->w, &sheet->h, &sheet->xmin, &sheet->ymin);
- sheet->gfx_extra = gfx_init(&cro_canvas_ops);
- sch_render_extra(sheet->sch, sheet->gfx_extra);
- cro_canvas_end(gfx_user(sheet->gfx_extra), NULL, NULL, NULL, NULL);
-
sheet->rendered = 1;
// gfx_end();
}
@@ -302,10 +285,6 @@ void render_delta(struct gui *gui)
cro_color_override(gfx_user(gui->delta_a.gfx), COLOR_RED);
cro_color_override(gfx_user(gui->delta_b.gfx), COLOR_GREEN2);
- cro_color_override(gfx_user(gui->delta_ab.gfx_extra), COLOR_LIGHT_GREY);
- cro_color_override(gfx_user(gui->delta_a.gfx_extra), COLOR_RED);
- cro_color_override(gfx_user(gui->delta_b.gfx_extra), COLOR_GREEN2);
-
// @@@ clean up when leaving sheet
#endif
diff --git a/kicad/lib-render.c b/kicad/lib-render.c
index 8562976..17e6c78 100644
--- a/kicad/lib-render.c
+++ b/kicad/lib-render.c
@@ -631,7 +631,7 @@ static void draw_pin(const struct comp *comp, const struct lib_pin *pin,
/* ----- Pin extras -------------------------------------------------------- */
-static void draw_pin_extra(const struct comp *comp, const struct lib_pin *pin,
+static void draw_pin_type(const struct comp *comp, const struct lib_pin *pin,
struct gfx *gfx, const int m[6])
{
int dx = 0, dy = 0;
@@ -752,25 +752,9 @@ static void draw(const struct comp *comp, const struct lib_obj *obj,
break;
case lib_obj_pin:
draw_pin(comp, &obj->u.pin, gfx, m);
- break;
- default:
- BUG("invalid object type %d", obj->type);
- }
-}
-
-
-static void draw_extra(const struct comp *comp, const struct lib_obj *obj,
- struct gfx *gfx, const int m[6])
-{
- switch (obj->type) {
- case lib_obj_poly:
- case lib_obj_rect:
- case lib_obj_circ:
- case lib_obj_arc:
- case lib_obj_text:
- break;
- case lib_obj_pin:
- draw_pin_extra(comp, &obj->u.pin, gfx, m);
+ gfx_set_extra(gfx, gfx_pin_type);
+ draw_pin_type(comp, &obj->u.pin, gfx, m);
+ gfx_set_extra(gfx, 0);
break;
default:
BUG("invalid object type %d", obj->type);
@@ -818,10 +802,3 @@ void lib_render(const struct comp *comp, struct gfx *gfx,
{
render_lib(comp, gfx, unit, convert, m, draw);
}
-
-
-void lib_render_extra(const struct comp *comp, struct gfx *gfx,
- unsigned unit, unsigned convert, const int m[4])
-{
- render_lib(comp, gfx, unit, convert, m, draw_extra);
-}
diff --git a/kicad/lib.h b/kicad/lib.h
index 2f628d1..37347ff 100644
--- a/kicad/lib.h
+++ b/kicad/lib.h
@@ -136,8 +136,6 @@ extern struct comp *comps;
const struct comp *lib_find(const struct lib *lib, const char *name);
void lib_render(const struct comp *comp, struct gfx *gfx,
unsigned unit, unsigned convert, const int m[6]);
-void lib_render_extra(const struct comp *comp, struct gfx *gfx,
- unsigned unit, unsigned convert, const int m[4]);
bool lib_parse_file(struct lib *lib, struct file *file);
bool lib_parse(struct lib *lib, const char *name, const struct file *related);
diff --git a/kicad/sch-render.c b/kicad/sch-render.c
index 81a97e4..830c99a 100644
--- a/kicad/sch-render.c
+++ b/kicad/sch-render.c
@@ -187,30 +187,3 @@ void sch_render(const struct sheet *sheet, struct gfx *gfx)
BUG("invalid object type \"%d\"", obj->type);
}
}
-
-
-void sch_render_extra(const struct sheet *sheet, struct gfx *gfx)
-{
- struct sch_obj *obj;
-
- for (obj = sheet->objs; obj; obj = obj->next)
- switch (obj->type) {
- case sch_obj_wire:
- case sch_obj_junction:
- case sch_obj_noconn:
- case sch_obj_glabel:
- case sch_obj_text:
- case sch_obj_sheet:
- break;
- case sch_obj_comp:
- {
- const struct sch_comp *comp = &obj->u.comp;
-
- lib_render_extra(comp->comp, gfx, comp->unit,
- comp->convert, comp->m);
- }
- break;
- default:
- BUG("invalid object type \"%d\"", obj->type);
- }
-}
diff --git a/kicad/sch.h b/kicad/sch.h
index 4dde552..92e6de9 100644
--- a/kicad/sch.h
+++ b/kicad/sch.h
@@ -147,7 +147,6 @@ struct sch_ctx {
void decode_alignment(struct text *txt, char hor, char vert);
void sch_render(const struct sheet *sheet, struct gfx *gfx);
-void sch_render_extra(const struct sheet *sheet, struct gfx *gfx);
bool sch_parse(struct sch_ctx *ctx, struct file *file, const struct lib *lib,
const struct sch_ctx *prev);
void sch_init(struct sch_ctx *ctx, bool recurse);
diff --git a/main/eeplot.c b/main/eeplot.c
index 55ba7d4..17bc3e3 100644
--- a/main/eeplot.c
+++ b/main/eeplot.c
@@ -239,8 +239,7 @@ int main(int argc, char **argv)
if (one_sheet) {
sch_render(sch_ctx.sheets, gfx);
- if (extra)
- sch_render_extra(sch_ctx.sheets, gfx);
+ /* @@@ filter extra */
if (pl)
pl_render(pl, gfx, sch_ctx.sheets, sch_ctx.sheets);
} else {
@@ -249,8 +248,7 @@ int main(int argc, char **argv)
for (sheet = sch_ctx.sheets; sheet; sheet = sheet->next) {
gfx_sheet_name(gfx, sheet->title);
sch_render(sheet, gfx);
- if (extra)
- sch_render_extra(sheet, gfx);
+ /* @@@ filter extra */
if (pl)
pl_render(pl, gfx, sch_ctx.sheets, sheet);
if (sheet->next)