FreeCalypso > hg > ueda-linux
view ueda/uschem-print/decor.c @ 30:a93e4b07fdf3
unet-destar: pass attributes through
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Sat, 08 Aug 2015 21:23:19 +0000 |
parents | cd92449fdb51 |
children |
line wrap: on
line source
/* * Printing object decorations */ #include <sys/types.h> #include <stdio.h> #include <strings.h> #include "../libueda/mcl.h" #include "../libuschem/schemstruct.h" #include "../libuschem/graphsym.h" extern char *get_comp_attr(); extern struct graphsym_pininst *find_comp_pininst(); extern struct schem *schem_being_printed; extern char *gschem_text_halign[9]; extern char *gschem_text_valign[9]; static int decor_font_ptsize; char * pull_attr_from_obj(obj, attrname) register struct schemobj *obj; register char *attrname; { register struct decoration *decor; if (obj->obj_type == OBJTYPE_COMPINST) { if (!strcmp(attrname, "refdes")) return(obj->compobj_mclcomp->name); if (!strcmp(attrname, "instname")) return(obj->compobj_instname); } for (decor = obj->obj_decorations; decor; decor = decor->decor_next) if (decor->decor_type == DECOR_TYPE_ATTR && !strcmp(decor->decorattr_name, attrname)) return(decor->decorattr_value); if (obj->obj_type == OBJTYPE_COMPINST) return(get_comp_attr(obj->compobj_mclcomp, attrname)); else return(NULL); } reset_decor_font() { decor_font_ptsize = 0; } print_obj_decors(obj) struct schemobj *obj; { register struct decoration *decor; register char *dispval; for (decor = obj->obj_decorations; decor; decor = decor->decor_next) switch (decor->decor_type) { case DECOR_TYPE_DISPLAYATTR: dispval = pull_attr_from_obj(obj, decor->decordisp_attr); if (dispval) print_textdisp_decor(decor, dispval); else fprintf(stderr, "%s: line %d: DisplayAttr: attribute %s unknown\n", schem_being_printed->orig_filename, decor->decor_lineno, decor->decordisp_attr); continue; case DECOR_TYPE_DISPLAYNETNAME: if (obj->obj_type != OBJTYPE_GRAPHNET) { fprintf(stderr, "%s: line %d: DisplayNetName invalid in objects other than GraphNet\n", schem_being_printed->orig_filename, decor->decor_lineno); continue; } dispval = obj->netobj_netname; if (dispval) print_textdisp_decor(decor, dispval); else fprintf(stderr, "%s: line %d: DisplayNetName on an unnamed GraphNet\n", schem_being_printed->orig_filename, decor->decor_lineno); continue; case DECOR_TYPE_SYMONPIN: if (obj->obj_type != OBJTYPE_COMPINST) { fprintf(stderr, "%s: line %d: SymOnPin invalid in objects other than components\n", schem_being_printed->orig_filename, decor->decor_lineno); continue; } print_symonpin(obj, decor); continue; case DECOR_TYPE_GRAPHBLOCK: print_graphblock(decor->decorgraph_body); continue; } } print_textdisp_decor(decor, dispval) register struct decoration *decor; char *dispval; { if (decor->decordisp_alignment < 0 || decor->decordisp_alignment > 8) { fprintf(stderr, "%s: line %d: display decoration: alignment %d is invalid\n", schem_being_printed->orig_filename, decor->decor_lineno, decor->decordisp_alignment); return; } if (decor_font_ptsize != decor->decordisp_ptsize) { decor_font_ptsize = decor->decordisp_ptsize; printf("/Helvetica %d selisofnt\n", decor_font_ptsize); } emit_ps_string(dispval); printf(" %s %s %d %d %d Tshow\n", gschem_text_halign[decor->decordisp_alignment], gschem_text_valign[decor->decordisp_alignment], decor->decordisp_rotate, decor->decordisp_x, decor->decordisp_y); } print_symonpin(comp, symdec) struct schemobj *comp; struct decoration *symdec; { struct graphsym *sop_gs; register struct graphsym_pindef *sop_pindef; register char *soughtpin; int bynum; register struct graphsym_pininst *hostpin; struct schemobj fakeobj; sop_gs = symdec->decorpinsym_gs; if (sop_gs->gs_npins > 1) { fprintf(stderr, "%s: line %d: SymOnPin symbols may not have more than 1 pin\n", schem_being_printed->orig_filename, symdec->decor_lineno); return; } sop_pindef = sop_gs->gs_pins; soughtpin = symdec->decorpinsym_pin; if (soughtpin[0] == '#') { bynum = 1; soughtpin++; } else bynum = 0; hostpin = find_comp_pininst(comp, soughtpin, bynum); if (!hostpin) { fprintf(stderr, "%s: line %d: SymOnPin: %s pin %s not found\n", schem_being_printed->orig_filename, symdec->decor_lineno, comp->compobj_instname, symdec->decorpinsym_pin); return; } /* everything located, do it */ bzero(&fakeobj, sizeof fakeobj); fakeobj.obj_type = OBJTYPE_GRAPHSYM; fakeobj.obj_lineno = symdec->decor_lineno; fakeobj.compobj_graphsym = sop_gs; fakeobj.compobj_x = -sop_pindef->gspd_x; fakeobj.compobj_y = -sop_pindef->gspd_y; if (symdec->decorpinsym_mirror) { fakeobj.compobj_mirror = 1; fakeobj.compobj_x = -fakeobj.compobj_x; } fakeobj.compobj_x += hostpin->x; fakeobj.compobj_y += hostpin->y; print_graph_compinst(&fakeobj); }