From 208d29b4cc669c3a2d10fb381c80341c3f016b6c Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Thu, 12 Apr 2012 18:07:59 -0300 Subject: [PATCH] genex/: added page header with name, hierarchical path, and path to library --- genex/comp.h | 2 +- genex/pdf.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/genex/comp.h b/genex/comp.h index 1a12e93..511d2e6 100644 --- a/genex/comp.h +++ b/genex/comp.h @@ -14,7 +14,7 @@ struct node { const char *name; - const char *lib; /* NULL if not intermediate node */ + const char *lib; /* NULL if intermediate node */ const char *canon; /* canonical name of component */ int units; /* number of units */ int indent; /* level of indentation (characters) */ diff --git a/genex/pdf.c b/genex/pdf.c index 7b21163..2d80dea 100644 --- a/genex/pdf.c +++ b/genex/pdf.c @@ -29,12 +29,61 @@ static int children(const struct node *node) } +static void ps_string(FILE *file, const char *s) +{ + fputc('(', file); + while (*s) { + if (*s == '(' || *s == ')' || *s == '\\') + fputc('\\', file); + fputc(*s, file); + s++; + } + fputc(')', file); +} + + +static void print_path(FILE *file, const struct node *node) +{ + if (node->parent) { + print_path(file, node->parent); + fprintf(file, "( > ) show\n"); + } + ps_string(file, node->name); + fprintf(file, " 0.5 setgray show 0 setgray\n"); +} + + +static void make_title(FILE *file, const struct node *node, int unit) +{ + fprintf(file, "gsave 90 rotate 0 setgray\n" + "/Helvetica-Bold findfont 24 scalefont setfont\n" + "20 -30 moveto\n"); + ps_string(file, node->canon); + fprintf(file, " show\n"); + if (node->units > 1) + fprintf(file, " ( \\(%c\\)) show\n", 'A'+unit); + + fprintf(file, "/Hevetica-Bold findfont 18 scalefont setfont\n"); + fprintf(file, "20 -60 moveto\n"); + print_path(file, node); + + fprintf(file, "/Courier findfont 12 scalefont setfont\n"); + fprintf(file, "20 -75 moveto\n"); + ps_string(file, node->lib); + fprintf(file, " show\n"); + + fprintf(file, "grestore\n"); + fflush(file); +} + + static void convert_comp(const struct node *node, FILE *out) { char *tmp; int i, res; for (i = 0; i != node->units; i++) { + make_title(stdout, node, i); if (asprintf(&tmp, "./sym2xps '%s' '%s' %d '%s' '%s'", node->lib, node->canon, i+1, "tmp", "tmp.ps") < 0) { perror("asprintf");