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

genex/: added page header with name, hierarchical path, and path to library

This commit is contained in:
Werner Almesberger 2012-04-12 18:07:59 -03:00
parent dcee3901f5
commit 208d29b4cc
2 changed files with 50 additions and 1 deletions

View File

@ -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) */

View File

@ -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");