|
|
1.1 root 1: /*
2: %Z% %M% version %I% %Q%of %H% %T%
3: Last Delta: %G% %U% to %P%
4: */
5:
6: #include "cip.h"
7:
8: Rectangle BBpic;
9:
10: findBBpic(h)
11: register struct thing *h;
12: {
13: register struct thing *t;
14:
15: BBpic.origin.x = Xmax; BBpic.corner.x=Xmin;
16: BBpic.origin.y = YBOT-YPIC; BBpic.corner.y=0;
17: if ((t=h) != (struct thing *) NULL) {
18: do {
19: BBpic.origin.x = min(BBpic.origin.x,t->bb.origin.x);
20: BBpic.origin.y = min(BBpic.origin.y,t->bb.origin.y);
21: BBpic.corner.x = max(BBpic.corner.x,t->bb.corner.x);
22: BBpic.corner.y = max(BBpic.corner.y,t->bb.corner.y);
23: t = t->next;
24: } while (t != h);
25: }
26: }
27:
28: Point
29: translate(p,b)
30: Point p;
31: Rectangle b;
32: {
33: return(sub(Pt(p.x,b.corner.y),Pt(b.origin.x,p.y)));
34: }
35:
36: writePIC(t,f,b)
37: register struct thing *t;
38: FILE *f;
39: Rectangle b;
40: {
41: Point p, q, r;
42: register int i;
43:
44: switch (t->type) {
45: case CIRCLE: {
46: p = translate(t->origin,b);
47: fprintf(f,"circle rad %d at %d,%d\n",
48: t->otherValues.radius,p.x,p.y);
49: break;
50: }
51: case BOX: {
52: p = translate(t->bb.origin,b);
53: fprintf(f,"box ht %d wid %d with .nw at %d,%d %s\n",
54: t->bb.corner.y - t->bb.origin.y,
55: t->bb.corner.x - t->bb.origin.x,p.x,p.y,
56: (t->boorder==DOTTED) ? "dotted" :
57: ((t->boorder==DASHED)?"dashed":""));
58: break;
59: }
60: case ELLIPSE: {
61: p= translate(t->origin,b);
62: fprintf(f,"ellipse ht %d wid %d at %d,%d\n",
63: t->otherValues.ellipse.ht,
64: t->otherValues.ellipse.wid,p.x,p.y);
65: break;
66: }
67: case LINE: {
68: p = translate(t->origin,b);
69: q = translate(t->otherValues.end,b);
70: fprintf(f,"line ");
71: switch (t->arrow) {
72: case startARROW: {
73: fprintf(f,"<-");
74: break;
75: }
76: case endARROW: {
77: fprintf(f,"->");
78: break;
79: }
80: case doubleARROW: {
81: fprintf(f,"<->");
82: break;
83: }
84: }
85: fprintf(f," from %d,%d to %d,%d ",p.x,p.y,q.x,q.y);
86: if (t->boorder==DOTTED) {
87: fprintf(f,"dotted");
88: }
89: else {
90: if (t->boorder==DASHED) {
91: fprintf(f,"dashed");
92: }
93: }
94: fprintf(f,"\n");
95: break;
96: }
97: case ARC: {
98: p = translate(t->otherValues.arc.start,b);
99: q = translate(t->otherValues.arc.end,b);
100: r = translate(t->origin,b);
101: fprintf(f,"arc from %d,%d to %d,%d at %d,%d\n",
102: p.x,p.y,q.x,q.y,r.x,r.y);
103: break;
104: }
105: case TEXT: {
106: i = fontheight(t->otherValues.text.f->f)>>1;
107: p = translate(Pt(t->origin.x,t->origin.y+i),b);
108: fprintf(f,"\"\\f%d\\s%d\\&%s\\f1\\s0\" at %d,%d%s\n",
109: t->otherValues.text.f->num,t->otherValues.text.f->ps,
110: t->otherValues.text.s, p.x, p.y,
111: (t->otherValues.text.just==LEFTJUST)?" ljust" :
112: ((t->otherValues.text.just==RIGHTJUST)?" rjust":""));
113: break;
114: }
115: case SPLINE: {
116: fprintf(f,"spline ");
117: switch (t->arrow) {
118: case startARROW: {
119: fprintf(f,"<-");
120: break;
121: }
122: case endARROW: {
123: fprintf(f,"->");
124: break;
125: }
126: case doubleARROW: {
127: fprintf(f,"<->");
128: break;
129: }
130: }
131: for (i=1; i<t->otherValues.spline.used; i++) {
132: p = translate(t->otherValues.spline.plist[i],b);
133: if (i==1) {
134: fprintf(f," from %d,%d",p.x,p.y);
135: }
136: else {
137: fprintf(f,"\\\nto %d,%d",p.x,p.y);
138: }
139: }
140: fprintf(f,"\n");
141: break;
142: }
143: case MACRO: {
144: p = translate(t->origin,b);
145: fprintf(f,"m%d with .nw at %d,%d\n",
146: t->otherValues.list->outName,p.x,p.y);
147: break;
148: }
149: }
150: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.