Date: | 2016-08-23 01:47:06 (7 years 3 months ago) |
---|---|
Author: | Werner Almesberger |
Commit: | 1b250bd46737db7133fe9314be6baa3edab3d5c7 |
Message: | eeshow/: change file name handling from positional to be
extension-driven This also enables versioning for page layouts. We no longer need the option -P. |
Files: |
eeshow/Makefile (1 diff) eeshow/gui/common.h (2 diffs) eeshow/gui/gui.c (9 diffs) eeshow/gui/gui.h (1 diff) eeshow/gui/render.c (1 diff) eeshow/main.c (8 diffs) eeshow/main.h (1 diff) |
Change Details
eeshow/Makefile | ||
---|---|---|
131 | 131 | $(NEO900_HW)/neo900.sch |
132 | 132 | |
133 | 133 | pdf: $(NAME) |
134 | ./eeshow -r -P $(NEO900_HW)/neo900pageframe_A3.kicad_wks \ | |
134 | ./eeshow -r $(NEO900_HW)/neo900pageframe_A3.kicad_wks \ | |
135 | 135 | neo900.lib kicad-libs/components/powered.lib \ |
136 | 136 | $(NEO900_HW)/neo900.sch -- pdf -o neo900.pdf |
137 | 137 |
eeshow/gui/common.h | ||
---|---|---|
52 | 52 | struct gui_sheet *sheets; /* NULL if failed */ |
53 | 53 | unsigned age; /* 0-based; uncommitted or HEAD = 0 */ |
54 | 54 | |
55 | struct pl_ctx *pl; /* NULL if none or failed */ | |
56 | ||
55 | 57 | /* caching support */ |
56 | 58 | void **oids; /* file object IDs */ |
57 | int libs_open; | |
59 | unsigned libs_open; | |
58 | 60 | struct sch_ctx sch_ctx; |
59 | 61 | struct lib lib; /* combined library */ |
60 | 62 | bool identical; /* identical with previous entry */ |
... | ... | |
68 | 70 | float scale; /* pixels = eeschema * scale */ |
69 | 71 | int x, y; /* center, in eeschema coordinates */ |
70 | 72 | |
71 | struct pl_ctx *pl; // @@@ | |
72 | ||
73 | 73 | struct gui_hist *hist; /* revision history; NULL if none */ |
74 | 74 | struct hist *vcs_hist; /* underlying VCS data; NULL if none */ |
75 | 75 |
eeshow/gui/gui.c | ||
---|---|---|
30 | 30 | #include "misc/util.h" |
31 | 31 | #include "misc/diag.h" |
32 | 32 | #include "file/git-hist.h" |
33 | #include "kicad/ext.h" | |
33 | 34 | #include "kicad/pl.h" |
34 | 35 | #include "kicad/lib.h" |
35 | 36 | #include "kicad/sch.h" |
... | ... | |
212 | 213 | */ |
213 | 214 | |
214 | 215 | static const struct sheet *parse_files(struct gui_hist *hist, |
215 | int n_args, char **args, bool recurse, struct gui_hist *prev) | |
216 | const struct file_names *fn, bool recurse, struct gui_hist *prev) | |
216 | 217 | { |
217 | 218 | char *rev = NULL; |
218 | 219 | struct file sch_file; |
219 | struct file lib_files[n_args - 1]; | |
220 | int libs_open, i; | |
220 | struct file lib_files[fn->n_libs]; | |
221 | struct file pl_file; | |
222 | unsigned libs_open, i; | |
221 | 223 | bool libs_cached = 0; |
222 | 224 | bool ok; |
223 | 225 | |
... | ... | |
225 | 227 | rev = vcs_git_get_rev(hist->vcs_hist); |
226 | 228 | |
227 | 229 | sch_init(&hist->sch_ctx, recurse); |
228 | ok = file_open_revision(&sch_file, rev, args[n_args - 1], NULL); | |
230 | ok = file_open_revision(&sch_file, rev, fn->sch, NULL); | |
229 | 231 | |
230 | 232 | if (rev) |
231 | 233 | free(rev); |
... | ... | |
235 | 237 | } |
236 | 238 | |
237 | 239 | lib_init(&hist->lib); |
238 | for (libs_open = 0; libs_open != n_args - 1; libs_open++) | |
239 | if (!file_open(lib_files + libs_open, args[libs_open], | |
240 | for (libs_open = 0; libs_open != fn->n_libs; libs_open++) | |
241 | if (!file_open(lib_files + libs_open, fn->libs[libs_open], | |
240 | 242 | &sch_file)) |
241 | 243 | goto fail; |
242 | 244 | |
245 | if (fn->pl) { | |
246 | if (!file_open(&pl_file, fn->pl, &sch_file)) | |
247 | goto fail; | |
248 | hist->pl = pl_parse(&pl_file); | |
249 | file_close(&pl_file); | |
250 | /* | |
251 | * We treat failing to parse the page layout as a "minor" | |
252 | * failure and don't reject the revision just because of it. | |
253 | */ | |
254 | } | |
255 | ||
243 | 256 | if (hist->vcs_hist) { |
244 | 257 | hist->oids = alloc_type_n(void *, libs_open); |
245 | 258 | hist->libs_open = libs_open; |
... | ... | |
293 | 306 | |
294 | 307 | struct add_hist_ctx { |
295 | 308 | struct gui_ctx *ctx; |
296 | int n_args; | |
297 | char **args; | |
309 | const struct file_names *fn; | |
298 | 310 | bool recurse; |
299 | 311 | unsigned limit; |
300 | 312 | }; |
... | ... | |
324 | 336 | hist->vcs_hist = h; |
325 | 337 | hist->libs_open = 0; |
326 | 338 | hist->identical = 0; |
327 | sch = parse_files(hist, ahc->n_args, ahc->args, ahc->recurse, prev); | |
339 | hist->pl = NULL; | |
340 | sch = parse_files(hist, ahc->fn, ahc->recurse, prev); | |
328 | 341 | hist->sheets = sch ? get_sheets(ctx, hist, sch) : NULL; |
329 | 342 | hist->age = age; |
330 | 343 | |
... | ... | |
336 | 349 | } |
337 | 350 | |
338 | 351 | |
339 | static void get_revisions(struct gui_ctx *ctx, | |
340 | int n_args, char **args, bool recurse, int limit) | |
352 | static void get_revisions(struct gui_ctx *ctx, const struct file_names *fn, | |
353 | bool recurse, int limit) | |
341 | 354 | { |
342 | 355 | struct add_hist_ctx add_hist_ctx = { |
343 | 356 | .ctx = ctx, |
344 | .n_args = n_args, | |
345 | .args = args, | |
357 | .fn = fn, | |
346 | 358 | .recurse = recurse, |
347 | 359 | .limit = limit ? limit < 0 ? -limit : limit : -1, |
348 | 360 | }; |
... | ... | |
383 | 395 | /* ----- Initialization ---------------------------------------------------- */ |
384 | 396 | |
385 | 397 | |
386 | int gui(unsigned n_args, char **args, bool recurse, int limit, | |
387 | struct pl_ctx *pl) | |
398 | int gui(const struct file_names *fn, bool recurse, int limit) | |
388 | 399 | { |
389 | 400 | GtkWidget *window; |
390 | 401 | char *title; |
391 | 402 | struct gui_ctx ctx = { |
392 | 403 | .scale = 1 / 16.0, |
393 | .pl = pl, // @@@ | |
394 | 404 | .hist = NULL, |
395 | 405 | .vcs_hist = NULL, |
396 | 406 | .showing_history= 0, |
... | ... | |
422 | 432 | |
423 | 433 | gtk_widget_show_all(window); |
424 | 434 | |
425 | get_history(&ctx, args[n_args - 1], limit); | |
435 | get_history(&ctx, fn->sch, limit); | |
426 | 436 | if (ctx.hist_size) |
427 | 437 | setup_progress_bar(&ctx, window); |
428 | 438 | |
429 | get_revisions(&ctx, n_args, args, recurse, limit); | |
439 | get_revisions(&ctx, fn, recurse, limit); | |
430 | 440 | for (ctx.new_hist = ctx.hist; ctx.new_hist && !ctx.new_hist->sheets; |
431 | 441 | ctx.new_hist = ctx.new_hist->next); |
432 | 442 | if (!ctx.new_hist) |
eeshow/gui/gui.h | ||
---|---|---|
15 | 15 | |
16 | 16 | #include <stdbool.h> |
17 | 17 | |
18 | /* | |
19 | * Note: this isn't (argc, argv) ! args stars right with the first file name | |
20 | * and there is no NULL at the end. | |
21 | */ | |
18 | #include "kicad/ext.h" | |
19 | ||
22 | 20 | |
23 | int gui(unsigned n_args, char **args, bool recurse, int limit, | |
24 | struct pl_ctx *pl); | |
21 | int gui(const struct file_names *fn, bool recurse, int limit); | |
25 | 22 | |
26 | 23 | #endif /* !GUI_GUI_H */ |
eeshow/gui/render.c | ||
---|---|---|
231 | 231 | char *argv[] = { "gui", NULL }; |
232 | 232 | |
233 | 233 | gfx_init(&cro_canvas_ops, 1, argv); |
234 | if (sheet->ctx && sheet->ctx->pl) /* @@@ no pl_render for delta */ | |
235 | pl_render(sheet->ctx->pl, sheet->hist->sch_ctx.sheets, | |
234 | if (sheet->hist && sheet->hist->pl) /* @@@ no pl_render for delta */ | |
235 | pl_render(sheet->hist->pl, sheet->hist->sch_ctx.sheets, | |
236 | 236 | sheet->sch); |
237 | 237 | sch_render(sheet->sch); |
238 | 238 | cro_canvas_end(gfx_ctx, |
eeshow/main.c | ||
---|---|---|
1 | 1 | /* |
2 | * main.c - Convert Eeschema schematics to FIG | |
2 | * main.c - Visualize and convert Eeschema schematics | |
3 | 3 | * |
4 | 4 | * Written 2016 by Werner Almesberger |
5 | 5 | * Copyright 2016 by Werner Almesberger |
... | ... | |
26 | 26 | #include "gfx/diff.h" |
27 | 27 | #include "gfx/gfx.h" |
28 | 28 | #include "file/file.h" |
29 | #include "kicad/ext.h" | |
29 | 30 | #include "kicad/sexpr.h" |
30 | 31 | #include "kicad/pl.h" |
31 | 32 | #include "kicad/lib.h" |
... | ... | |
60 | 61 | exit(1); |
61 | 62 | } |
62 | 63 | |
63 | ||
64 | ||
64 | 65 | void usage(const char *name) |
65 | 66 | { |
66 | 67 | fprintf(stderr, |
67 | "usage: %s [gtk_flags] [-r] [-N n] [[rev:]file.lib ...] [rev:]file.sch\n" | |
68 | " %s [-r] [-v ...] [[rev:]file.lib ...] [rev:]file.sch\n" | |
68 | "usage: %s [gtk_flags] [-r] [-N n] kicad_file ...\n" | |
69 | " %s [-r] [-v ...] kicad_file ...\n" | |
69 | 70 | " %*s[-- driver_spec]\n" |
70 | 71 | " %s [-v ...] -C [rev:]file\n" |
71 | 72 | " %s [-v ...] -H path_into_repo\n" |
... | ... | |
73 | 74 | " %s -V\n" |
74 | 75 | " %s gdb ...\n" |
75 | 76 | "\n" |
76 | " rev git revision\n" | |
77 | " kicad_file [rev:]file.ext\n" | |
78 | " ext .lib, .sch, or .kicad_wks\n" | |
79 | " rev git revision\n" | |
80 | "\n" | |
77 | 81 | " -r recurse into sub-sheets\n" |
78 | 82 | " -v increase verbosity of diagnostic output\n" |
79 | 83 | " -C 'cat' the file to standard output\n" |
... | ... | |
121 | 125 | const char *cat = NULL; |
122 | 126 | const char *history = NULL; |
123 | 127 | const char *fmt = NULL; |
124 | const char *page_layout = NULL; | |
125 | 128 | struct pl_ctx *pl = NULL; |
126 | 129 | int limit = 0; |
127 | 130 | char c; |
128 | int arg, dashdash; | |
131 | int dashdash; | |
132 | unsigned i; | |
129 | 133 | bool have_dashdash = 0; |
134 | struct file_names file_names; | |
130 | 135 | int gfx_argc; |
131 | 136 | char **gfx_argv; |
132 | 137 | const struct gfx_ops **ops = ops_list; |
... | ... | |
153 | 158 | if (!have_dashdash) |
154 | 159 | gtk_init(&argc, &argv); |
155 | 160 | |
156 | while ((c = getopt(dashdash, argv, "P:rvC:F:H:N:SV")) != EOF) | |
161 | while ((c = getopt(dashdash, argv, "rvC:F:H:N:SV")) != EOF) | |
157 | 162 | switch (c) { |
158 | 163 | case 'r': |
159 | 164 | recurse = 1; |
... | ... | |
173 | 178 | case 'N': |
174 | 179 | limit = atoi(optarg); |
175 | 180 | break; |
176 | case 'P': | |
177 | page_layout = optarg; | |
178 | break; | |
179 | 181 | case 'S': |
180 | 182 | sexpr(); |
181 | 183 | return 0; |
... | ... | |
215 | 217 | return 0; |
216 | 218 | } |
217 | 219 | |
218 | if (page_layout) { | |
219 | struct file file; | |
220 | ||
221 | if (!file_open(&file, page_layout, NULL)) | |
222 | return 1; | |
223 | pl = pl_parse(&file); | |
224 | file_close(&file); | |
225 | if (!pl) | |
226 | return 1; | |
227 | } | |
228 | ||
229 | 220 | if (dashdash - optind < 1) |
230 | 221 | usage(*argv); |
231 | 222 | |
232 | if (!have_dashdash) { | |
233 | unsigned n = argc - optind; | |
234 | char **args; | |
223 | classify_files(&file_names, argv + optind, dashdash - optind); | |
224 | if (!file_names.sch) | |
225 | fatal("top sheet name required"); | |
235 | 226 | |
236 | args = alloc_type_n(char *, n); | |
237 | memcpy(args, argv + optind, sizeof(const char *) * n); | |
238 | ||
227 | if (!have_dashdash) { | |
239 | 228 | optind = 0; /* reset getopt */ |
240 | return gui(n, args, recurse, limit, pl); | |
229 | return gui(&file_names, recurse, limit); | |
241 | 230 | } |
242 | 231 | |
243 | 232 | sch_init(&sch_ctx, recurse); |
244 | if (!file_open(&sch_file, argv[dashdash - 1], NULL)) | |
233 | if (!file_open(&sch_file, file_names.sch, NULL)) | |
245 | 234 | return 1; |
246 | 235 | |
247 | 236 | lib_init(&lib); |
248 | for (arg = optind; arg != dashdash - 1; arg++) | |
249 | if (!lib_parse(&lib, argv[arg], &sch_file)) | |
237 | for (i = 0; i != file_names.n_libs; i++) | |
238 | if (!lib_parse(&lib, file_names.libs[i], &sch_file)) | |
239 | return 1; | |
240 | ||
241 | if (file_names.pl) { | |
242 | struct file file; | |
243 | ||
244 | if (!file_open(&file, file_names.pl, &sch_file)) | |
245 | return 1; | |
246 | pl = pl_parse(&file); | |
247 | file_close(&file); | |
248 | if (!pl) | |
250 | 249 | return 1; |
250 | } | |
251 | 251 | |
252 | 252 | if (dashdash == argc) { |
253 | 253 | gfx_argc = 1; |
eeshow/main.h | ||
---|---|---|
1 | 1 | /* |
2 | * main.h - Convert Eeschema schematics to FIG | |
2 | * main.h - Visualize and convert Eeschema schematics | |
3 | 3 | * |
4 | 4 | * Written 2016 by Werner Almesberger |
5 | 5 | * Copyright 2016 by Werner Almesberger |
Branches:
master