FreeCalypso > hg > ueda-linux
comparison ueda/uschem-print/decor.c @ 0:cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 20 Jul 2015 00:24:37 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:cd92449fdb51 |
---|---|
1 /* | |
2 * Printing object decorations | |
3 */ | |
4 | |
5 #include <sys/types.h> | |
6 #include <stdio.h> | |
7 #include <strings.h> | |
8 #include "../libueda/mcl.h" | |
9 #include "../libuschem/schemstruct.h" | |
10 #include "../libuschem/graphsym.h" | |
11 | |
12 extern char *get_comp_attr(); | |
13 extern struct graphsym_pininst *find_comp_pininst(); | |
14 | |
15 extern struct schem *schem_being_printed; | |
16 | |
17 extern char *gschem_text_halign[9]; | |
18 extern char *gschem_text_valign[9]; | |
19 | |
20 static int decor_font_ptsize; | |
21 | |
22 char * | |
23 pull_attr_from_obj(obj, attrname) | |
24 register struct schemobj *obj; | |
25 register char *attrname; | |
26 { | |
27 register struct decoration *decor; | |
28 | |
29 if (obj->obj_type == OBJTYPE_COMPINST) { | |
30 if (!strcmp(attrname, "refdes")) | |
31 return(obj->compobj_mclcomp->name); | |
32 if (!strcmp(attrname, "instname")) | |
33 return(obj->compobj_instname); | |
34 } | |
35 for (decor = obj->obj_decorations; decor; decor = decor->decor_next) | |
36 if (decor->decor_type == DECOR_TYPE_ATTR && | |
37 !strcmp(decor->decorattr_name, attrname)) | |
38 return(decor->decorattr_value); | |
39 if (obj->obj_type == OBJTYPE_COMPINST) | |
40 return(get_comp_attr(obj->compobj_mclcomp, attrname)); | |
41 else | |
42 return(NULL); | |
43 } | |
44 | |
45 reset_decor_font() | |
46 { | |
47 decor_font_ptsize = 0; | |
48 } | |
49 | |
50 print_obj_decors(obj) | |
51 struct schemobj *obj; | |
52 { | |
53 register struct decoration *decor; | |
54 register char *dispval; | |
55 | |
56 for (decor = obj->obj_decorations; decor; decor = decor->decor_next) | |
57 switch (decor->decor_type) { | |
58 case DECOR_TYPE_DISPLAYATTR: | |
59 dispval = pull_attr_from_obj(obj, decor->decordisp_attr); | |
60 if (dispval) | |
61 print_textdisp_decor(decor, dispval); | |
62 else | |
63 fprintf(stderr, | |
64 "%s: line %d: DisplayAttr: attribute %s unknown\n", | |
65 schem_being_printed->orig_filename, | |
66 decor->decor_lineno, decor->decordisp_attr); | |
67 continue; | |
68 case DECOR_TYPE_DISPLAYNETNAME: | |
69 if (obj->obj_type != OBJTYPE_GRAPHNET) { | |
70 fprintf(stderr, | |
71 "%s: line %d: DisplayNetName invalid in objects other than GraphNet\n", | |
72 schem_being_printed->orig_filename, | |
73 decor->decor_lineno); | |
74 continue; | |
75 } | |
76 dispval = obj->netobj_netname; | |
77 if (dispval) | |
78 print_textdisp_decor(decor, dispval); | |
79 else | |
80 fprintf(stderr, | |
81 "%s: line %d: DisplayNetName on an unnamed GraphNet\n", | |
82 schem_being_printed->orig_filename, | |
83 decor->decor_lineno); | |
84 continue; | |
85 case DECOR_TYPE_SYMONPIN: | |
86 if (obj->obj_type != OBJTYPE_COMPINST) { | |
87 fprintf(stderr, | |
88 "%s: line %d: SymOnPin invalid in objects other than components\n", | |
89 schem_being_printed->orig_filename, | |
90 decor->decor_lineno); | |
91 continue; | |
92 } | |
93 print_symonpin(obj, decor); | |
94 continue; | |
95 case DECOR_TYPE_GRAPHBLOCK: | |
96 print_graphblock(decor->decorgraph_body); | |
97 continue; | |
98 } | |
99 } | |
100 | |
101 print_textdisp_decor(decor, dispval) | |
102 register struct decoration *decor; | |
103 char *dispval; | |
104 { | |
105 if (decor->decordisp_alignment < 0 || decor->decordisp_alignment > 8) { | |
106 fprintf(stderr, | |
107 "%s: line %d: display decoration: alignment %d is invalid\n", | |
108 schem_being_printed->orig_filename, | |
109 decor->decor_lineno, decor->decordisp_alignment); | |
110 return; | |
111 } | |
112 if (decor_font_ptsize != decor->decordisp_ptsize) { | |
113 decor_font_ptsize = decor->decordisp_ptsize; | |
114 printf("/Helvetica %d selisofnt\n", decor_font_ptsize); | |
115 } | |
116 emit_ps_string(dispval); | |
117 printf(" %s %s %d %d %d Tshow\n", | |
118 gschem_text_halign[decor->decordisp_alignment], | |
119 gschem_text_valign[decor->decordisp_alignment], | |
120 decor->decordisp_rotate, | |
121 decor->decordisp_x, decor->decordisp_y); | |
122 } | |
123 | |
124 print_symonpin(comp, symdec) | |
125 struct schemobj *comp; | |
126 struct decoration *symdec; | |
127 { | |
128 struct graphsym *sop_gs; | |
129 register struct graphsym_pindef *sop_pindef; | |
130 register char *soughtpin; | |
131 int bynum; | |
132 register struct graphsym_pininst *hostpin; | |
133 struct schemobj fakeobj; | |
134 | |
135 sop_gs = symdec->decorpinsym_gs; | |
136 if (sop_gs->gs_npins > 1) { | |
137 fprintf(stderr, | |
138 "%s: line %d: SymOnPin symbols may not have more than 1 pin\n", | |
139 schem_being_printed->orig_filename, | |
140 symdec->decor_lineno); | |
141 return; | |
142 } | |
143 sop_pindef = sop_gs->gs_pins; | |
144 soughtpin = symdec->decorpinsym_pin; | |
145 if (soughtpin[0] == '#') { | |
146 bynum = 1; | |
147 soughtpin++; | |
148 } else | |
149 bynum = 0; | |
150 hostpin = find_comp_pininst(comp, soughtpin, bynum); | |
151 if (!hostpin) { | |
152 fprintf(stderr, "%s: line %d: SymOnPin: %s pin %s not found\n", | |
153 schem_being_printed->orig_filename, | |
154 symdec->decor_lineno, comp->compobj_instname, | |
155 symdec->decorpinsym_pin); | |
156 return; | |
157 } | |
158 /* everything located, do it */ | |
159 bzero(&fakeobj, sizeof fakeobj); | |
160 fakeobj.obj_type = OBJTYPE_GRAPHSYM; | |
161 fakeobj.obj_lineno = symdec->decor_lineno; | |
162 fakeobj.compobj_graphsym = sop_gs; | |
163 fakeobj.compobj_x = -sop_pindef->gspd_x; | |
164 fakeobj.compobj_y = -sop_pindef->gspd_y; | |
165 if (symdec->decorpinsym_mirror) { | |
166 fakeobj.compobj_mirror = 1; | |
167 fakeobj.compobj_x = -fakeobj.compobj_x; | |
168 } | |
169 fakeobj.compobj_x += hostpin->x; | |
170 fakeobj.compobj_y += hostpin->y; | |
171 print_graph_compinst(&fakeobj); | |
172 } |