diff --git a/eeshow/gui/common.h b/eeshow/gui/common.h index dd2f1d3..9882121 100644 --- a/eeshow/gui/common.h +++ b/eeshow/gui/common.h @@ -66,6 +66,8 @@ struct gui_ctx { unsigned zoom; /* scale by 1.0 / (1 << zoom) */ int x, y; /* center, in eeschema coordinates */ + struct pl_ctx *pl; // @@@ + struct gui_hist *hist; /* revision history; NULL if none */ struct hist *vcs_hist; /* underlying VCS data; NULL if none */ diff --git a/eeshow/gui/gui.c b/eeshow/gui/gui.c index d2d220a..f7f2038 100644 --- a/eeshow/gui/gui.c +++ b/eeshow/gui/gui.c @@ -30,6 +30,7 @@ #include "misc/util.h" #include "misc/diag.h" #include "file/git-hist.h" +#include "kicad/pl.h" #include "kicad/lib.h" #include "kicad/sch.h" #include "kicad/delta.h" @@ -381,12 +382,14 @@ static void get_history(struct gui_ctx *ctx, const char *sch_name, int limit) /* ----- Initialization ---------------------------------------------------- */ -int gui(unsigned n_args, char **args, bool recurse, int limit) +int gui(unsigned n_args, char **args, bool recurse, int limit, + struct pl_ctx *pl) { GtkWidget *window; char *title; struct gui_ctx ctx = { .zoom = 4, /* scale by 1 / 16 */ + .pl = pl, // @@@ .hist = NULL, .vcs_hist = NULL, .showing_history= 0, diff --git a/eeshow/gui/gui.h b/eeshow/gui/gui.h index 04bc1dd..f0307cb 100644 --- a/eeshow/gui/gui.h +++ b/eeshow/gui/gui.h @@ -20,6 +20,7 @@ * and there is no NULL at the end. */ -int gui(unsigned n_args, char **args, bool recurse, int limit); +int gui(unsigned n_args, char **args, bool recurse, int limit, + struct pl_ctx *pl); #endif /* !GUI_GUI_H */ diff --git a/eeshow/gui/render.c b/eeshow/gui/render.c index 32a3f1d..51dbd8e 100644 --- a/eeshow/gui/render.c +++ b/eeshow/gui/render.c @@ -21,6 +21,7 @@ #include "gfx/style.h" #include "gfx/cro.h" #include "gfx/gfx.h" +#include "kicad/pl.h" #include "kicad/sch.h" #include "kicad/delta.h" #include "gfx/diff.h" @@ -230,6 +231,8 @@ void render_sheet(struct gui_sheet *sheet) char *argv[] = { "gui", NULL }; gfx_init(&cro_canvas_ops, 1, argv); + if (sheet->ctx->pl) + pl_render(sheet->ctx->pl, sheet->sch->w, sheet->sch->h); sch_render(sheet->sch); cro_canvas_end(gfx_ctx, &sheet->w, &sheet->h, &sheet->xmin, &sheet->ymin); diff --git a/eeshow/main.c b/eeshow/main.c index 7823aae..61807ff 100644 --- a/eeshow/main.c +++ b/eeshow/main.c @@ -27,6 +27,7 @@ #include "gfx/gfx.h" #include "file/file.h" #include "kicad/sexpr.h" +#include "kicad/pl.h" #include "kicad/lib.h" #include "kicad/sch.h" #include "gui/fmt-pango.h" @@ -120,6 +121,8 @@ int main(int argc, char **argv) const char *cat = NULL; const char *history = NULL; const char *fmt = NULL; + const char *page_layout = NULL; + struct pl_ctx *pl = NULL; int limit = 0; char c; int arg, dashdash; @@ -150,7 +153,7 @@ int main(int argc, char **argv) if (!have_dashdash) gtk_init(&argc, &argv); - while ((c = getopt(dashdash, argv, "rvC:F:H:N:SV")) != EOF) + while ((c = getopt(dashdash, argv, "P:rvC:F:H:N:SV")) != EOF) switch (c) { case 'r': recurse = 1; @@ -170,6 +173,9 @@ int main(int argc, char **argv) case 'N': limit = atoi(optarg); break; + case 'P': + page_layout = optarg; + break; case 'S': sexpr(); return 0; @@ -209,6 +215,17 @@ int main(int argc, char **argv) return 0; } + if (page_layout) { + struct file file; + + if (!file_open(&file, page_layout, NULL)) + return 1; + pl = pl_parse(&file); + file_close(&file); + if (!pl) + return 1; + } + if (dashdash - optind < 1) usage(*argv); @@ -220,7 +237,7 @@ int main(int argc, char **argv) memcpy(args, argv + optind, sizeof(const char *) * n); optind = 0; /* reset getopt */ - return gui(n, args, recurse, limit); + return gui(n, args, recurse, limit, pl); } sch_init(&sch_ctx, recurse);