|
|
1.1 root 1: #include "idfilt.h"
2:
3: float xscale, yscale;
4: extern double atan2();
5:
6: #define xadj(x) (int)((abs(x)<0.00001)?0:(xscale*(x)))
7: #define yadj(y) (int)((abs(y)<0.00001)?0:(yscale*(y)))
8: #define PI 3.1415926535897932384626433832795028841971693993751
9: #define PI2 (2*PI)
10:
11: int inpicture=0; /* because of nesting, we can see more than one
12: .IS and more than one .IE for a given picture */
13:
14: void idjusttext (str)
15: char *str;
16: {
17: if (
18: strncmp (str, "...", 3) &&
19: strncmp (str, ".IS", 3) &&
20: strncmp (str, ".IE", 3) &&
21: strncmp (str, ".IF", 3) &&
22: strncmp (str, ".lf", 3)
23: )
24: fputs (str, stdout);
25: }
26:
27: void idstart ()
28: {
29: /*
30: * Don't print prologue here, because might not draw anything.
31: * Wait until bounds set.
32: */
33: }
34:
35: float realwidth, realheight;
36:
37: void idendbound ()
38: {
39: if (boundset)
40: return;
41: idminx (-6.0);
42: idmaxy (6.0);
43: idmaxx (6.0);
44: idminy (-6.0);
45: if (!banzai && maxx - minx < 0.2) {
46: maxx += 1;
47: minx -= 1;
48: }
49: if (!banzai && maxy - miny < 0.2) {
50: maxy += 1;
51: miny -= 1;
52: }
53: /*
54: * The tpic special coordinate system is in milli-inches,
55: * with positive y downward.
56: */
57: if (!samescale) {
58: realwidth = width;
59: xscale = 1000*width/(maxx - minx);
60: if (!heightset) {
61: yscale = - xscale;
62: } else
63: yscale = 1000*height/(miny - maxy);
64: } else
65: realwidth = (maxx - minx)*xscale;
66: realheight = heightset?height:yscale*(miny-maxy)/1000;
67: boundset = TRUE;
68: inpicture = 1;
69:
70: /*
71: * First, allocate a \graph box if there isn't one.
72: * Expand plain's \newbox here because plain makes it "outer".
73: */
74: printf ("\\catcode`@=11\n");
75: printf ("\\expandafter\\ifx\\csname graph\\endcsname\\relax\n");
76: printf (" \\alloc@4\\box\\chardef\\insc@unt\\graph\\fi\n");
77: printf ("\\catcode`@=12\n");
78: /*
79: * Now set \graph to a vtop containing a vbox containing an hbox.
80: */
81: printf ("\\setbox\\graph=\\vtop{%%\n");
82: printf (" \\baselineskip=0pt \\lineskip=0pt \\lineskiplimit=0pt\n");
83: printf (" \\vbox to0pt{\\hbox{%%\n");
84: }
85:
86: void idendE ()
87: {
88: if (inpicture) {
89: printf (" \\kern %gin\n", realwidth);
90: printf (" }\\vss}%%\n");
91: printf (" \\kern %gin\n}\n", realheight);
92: inpicture = 0;
93: }
94: }
95:
96: void idendF ()
97: {
98: if (inpicture) {
99: printf (" \\kern %gin\n", realwidth);
100: printf (" }\\vss}%%\n");
101: printf (" \\kern %gin\n}\n", realwidth);
102: inpicture = 0;
103: }
104: }
105:
106: void idline (x1, y1, x2, y2)
107: float x1;
108: float y1;
109: float x2;
110: float y2;
111: {
112: printf (" \\special{pa %d %d}\\special{pa %d %d}\\special{fp}%%\n",
113: xadj(x1-minx),
114: yadj(y1-maxy),
115: xadj(x2-minx),
116: yadj(y2-maxy)
117: );
118: }
119:
120: void idcircle (x0, y0, r)
121: float x0;
122: float y0;
123: float r;
124: {
125: printf (" \\special{ar %d %d %d %d %f %f}%%\n",
126: xadj(x0-minx),
127: yadj(y0-maxy),
128: xadj(r),
129: -yadj(r),
130: 0.0,
131: PI2
132: );
133: }
134:
135: void idarc (x0, y0, x1, y1, x2, y2, t1, t2, r)
136: float x0;
137: float y0;
138: float x1;
139: float y1;
140: float x2;
141: float y2;
142: float t1;
143: float t2;
144: float r;
145: {
146: if (xscale*r > 30000.0)
147: idline (x1, y1, x2, y2);
148: else
149: printf (" \\special{ar %d %d %d %d %f %f}%%\n",
150: xadj(x0-minx),
151: yadj(y0-maxy),
152: xadj(r),
153: - yadj(r),
154: PI2 - t2,
155: PI2 - t1
156: );
157: }
158:
159: void idleft (x, y, str)
160: float x;
161: float y;
162: char *str;
163: {
164: str == ++str;
165: printf (" \\smash{\\rlap{\\kern%5.2fin\\raise%5.2fin\\hbox{%s}}}%%\n",
166: xadj(x-minx)/1000.,
167: yadj(maxy-y)/1000.,
168: str
169: );
170: }
171:
172: void idcenter (x, y, str)
173: float x;
174: float y;
175: char *str;
176: {
177: str = ++str;
178: printf (" \\smash{\\rlap{\\kern%5.2fin\\raise%5.2fin\\hbox to 0pt{\\hss %s\\hss}}}%%\n",
179: xadj(x-minx)/1000.,
180: yadj(maxy-y)/1000.,
181: str
182: );
183: }
184:
185: void idright (x, y, str)
186: float x;
187: float y;
188: char *str;
189: {
190: str = ++str;
191: printf (" \\smash{\\rlap{\\kern%5.2fin\\raise%5.2fin\\llap{%s}}}%%\n",
192: xadj(x-minx)/1000.,
193: yadj(maxy-y)/1000.,
194: str
195: );
196: }
197:
198: void idspline (sx, sy)
199: float sx, sy;
200: {
201: printf (" \\special{pa %d %d}%%\n",
202: xadj(sx-minx),
203: yadj(sy-maxy)
204: );
205: }
206:
207: void idknot (sx, sy)
208: float sx, sy;
209: {
210: printf (" \\special{pa %d %d}%%\n",
211: xadj(sx-minx),
212: yadj(sy-maxy)
213: );
214: }
215:
216: void idendspline ()
217: {
218: printf (" \\special{sp}%%\n");
219: }
220:
221: void idnoerase ()
222: {
223: }
224:
225:
226: void idyeserase ()
227: {
228: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.