summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-22 04:05:41 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-22 04:06:59 -0300
commit1776e011bad42b24905d5515f975bbd78641bff2 (patch)
tree57a9cd487d14d7cd2ac181d9c5b62ccdce966ab9
parentaa7e2782b14e596e6ccb373e55bdd18eff3cf4c4 (diff)
downloadeeshow-1776e011bad42b24905d5515f975bbd78641bff2.tar.gz
eeshow-1776e011bad42b24905d5515f975bbd78641bff2.tar.bz2
eeshow-1776e011bad42b24905d5515f975bbd78641bff2.zip
eeshow/gui/: experimental support for page layout; option -P pl-file.kicad_wks
Unlike libraries and schematics, page layouts are not (yet) tracked through revision history.
-rw-r--r--gui/common.h2
-rw-r--r--gui/gui.c5
-rw-r--r--gui/gui.h3
-rw-r--r--gui/render.c3
-rw-r--r--main.c21
5 files changed, 30 insertions, 4 deletions
diff --git a/gui/common.h b/gui/common.h
index dd2f1d3..9882121 100644
--- a/gui/common.h
+++ b/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/gui/gui.c b/gui/gui.c
index d2d220a..f7f2038 100644
--- a/gui/gui.c
+++ b/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/gui/gui.h b/gui/gui.h
index 04bc1dd..f0307cb 100644
--- a/gui/gui.h
+++ b/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/gui/render.c b/gui/render.c
index 32a3f1d..51dbd8e 100644
--- a/gui/render.c
+++ b/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/main.c b/main.c
index 7823aae..61807ff 100644
--- a/main.c
+++ b/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);