1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-23 00:48:26 +02:00

genkicat: new option "-t title.ps" to include a title page file

This commit is contained in:
Werner Almesberger 2012-12-21 00:11:14 -03:00
parent afae5c753e
commit 560bf9d64a
4 changed files with 24 additions and 16 deletions

View File

@ -1,3 +0,0 @@
#!/bin/sh
PATH=$PATH:.
exec genkicat-bin "$@"

View File

@ -28,7 +28,7 @@ static void usage(const char *name)
{ {
fprintf(stderr, fprintf(stderr,
"usage: %s [-F] [-d|-D] [-p] [-P] [-q] [-L libdir ...] [-l lib ...]\n" "usage: %s [-F] [-d|-D] [-p] [-P] [-q] [-L libdir ...] [-l lib ...]\n"
" %*s hierarchy [descriptions ...]\n\n" " %*s [-t title.ps] hierarchy [descriptions ...]\n\n"
" -d dump the tree instead of generating a PDF\n" " -d dump the tree instead of generating a PDF\n"
" -D dump all the canonical component names (without aliases)\n" " -D dump all the canonical component names (without aliases)\n"
" -F use fped footprints instead of KiCad components\n" " -F use fped footprints instead of KiCad components\n"
@ -37,6 +37,7 @@ static void usage(const char *name)
" -p use portrait orientation; default: landscape\n" " -p use portrait orientation; default: landscape\n"
" -P generate Postscript instead of PDF (mainly for debugging)\n" " -P generate Postscript instead of PDF (mainly for debugging)\n"
" -q don't show progress\n" " -q don't show progress\n"
" -t title.ps Postscript file with title page\n"
, name, (int) strlen(name), ""); , name, (int) strlen(name), "");
exit(1); exit(1);
} }
@ -48,9 +49,10 @@ int main(int argc, char **argv)
FILE *file; FILE *file;
int c; int c;
int opt_dump_tree = 0, opt_dump_comp = 0, postscript = 0, portrait = 0; int opt_dump_tree = 0, opt_dump_comp = 0, postscript = 0, portrait = 0;
const char *title_page = NULL;
char **arg; char **arg;
while ((c = getopt(argc, argv, "dDFL:l:Ppq")) != EOF) while ((c = getopt(argc, argv, "dDFL:l:Ppqt:")) != EOF)
switch (c) { switch (c) {
case 'd': case 'd':
opt_dump_tree = 1; opt_dump_tree = 1;
@ -76,6 +78,9 @@ int main(int argc, char **argv)
case 'q': case 'q':
quiet = 1; quiet = 1;
break; break;
case 't':
title_page = optarg;
break;
default: default:
usage(*argv); usage(*argv);
} }
@ -114,6 +119,6 @@ int main(int argc, char **argv)
else if (opt_dump_comp) else if (opt_dump_comp)
dump_comp(); dump_comp();
else else
make_pdf(!postscript, portrait); make_pdf(!postscript, portrait, title_page);
return 0; return 0;
} }

View File

@ -15,6 +15,7 @@
#include <string.h> #include <string.h>
#include "util.h" #include "util.h"
#include "run.h"
#include "genkicat.h" #include "genkicat.h"
#include "tree.h" #include "tree.h"
#include "libs.h" #include "libs.h"
@ -334,7 +335,7 @@ static int count_tree(const struct node *node)
} }
void make_pdf(int pdf, int use_portrait) void make_pdf(int pdf, int use_portrait, const char *title_page)
{ {
FILE *out; FILE *out;
int res; int res;
@ -354,6 +355,11 @@ void make_pdf(int pdf, int use_portrait)
exit(1); exit(1);
} }
fprintf(out, "%%!PS\n%s\n", format->file_setup); fprintf(out, "%%!PS\n%s\n", format->file_setup);
if (title_page) {
fprintf(out, "gsave\n");
cat(out, title_page);
fprintf(out, "grestore\n");
}
make_index(out, tree); make_index(out, tree);
total = count_tree(tree); total = count_tree(tree);
convert_tree(tree, out); convert_tree(tree, out);

View File

@ -12,6 +12,6 @@
#ifndef PDF_H #ifndef PDF_H
#define PDF_H #define PDF_H
void make_pdf(int pdf, int use_portrait); void make_pdf(int pdf, int use_portrait, const char *title_page);
#endif /* !PDF_H */ #endif /* !PDF_H */