9 static double prevdx = HT;
10 static double prevdy = 0;
11 static double prevw = HT10;
12 static double prevh = HT5;
13 int i, j, some, head, ddtype, invis, chop;
14 double ddval, chop1, chop2, x0, y0, x1, y1;
18 static int xtab[] = { 1, 0, -1, 0 }; /* R=0, U=1, L=2, D=3 */
19 static int ytab[] = { 0, 1, 0, -1 };
20 double dx[500], dy[500];
27 defx = getfval("linewid");
28 defy = getfval("lineht");
29 prevh = getfval("arrowht");
30 prevw = getfval("arrowwid");
31 dx[0] = dy[0] = ndxy = some = head = invis = 0;
32 chop = chop1 = chop2 = 0;
34 for (i = 0; i < nattr; i++) {
38 savetext(ap->a_sub, ap->a_val.p);
48 chop1 = chop2 = ap->a_val.f;
54 ddtype = ap->a_type==DOT ? DOTBIT : DASHBIT;
55 if (ap->a_sub == DEFAULT)
56 ddval = getfval("dashwid");
66 dx[ndxy] -= (ap->a_sub==DEFAULT) ? defx : ap->a_val.f;
71 dx[ndxy] += (ap->a_sub==DEFAULT) ? defx : ap->a_val.f;
76 dy[ndxy] += (ap->a_sub==DEFAULT) ? defy : ap->a_val.f;
81 dy[ndxy] -= (ap->a_sub==DEFAULT) ? defy : ap->a_val.f;
85 case HEIGHT: /* length of arrowhead */
88 case WIDTH: /* width of arrowhead */
96 dx[ndxy] = dy[ndxy] = some = 0;
98 ppos = attr[i].a_val.o;
99 dx[ndxy] = ppos->o_x - nx;
100 dy[ndxy] = ppos->o_y - ny;
108 dx[ndxy] = dy[ndxy] = some = 0;
111 dx[ndxy] = ppos->o_x;
112 dy[ndxy] = ppos->o_y;
115 case THEN: /* turn off any previous accumulation */
120 dx[ndxy] = dy[ndxy] = some = 0;
126 nx = curx = ppos->o_x;
127 ny = cury = ppos->o_y;
138 defx *= xtab[hvmode];
139 defy *= ytab[hvmode];
149 if (chop == 1 && chop1 == 0) /* just said "chop", so use default */
150 chop1 = chop2 = getfval("circlerad");
151 theta = atan2(dy[0], dx[0]);
152 x0 = chop1 * cos(theta);
153 y0 = chop1 * sin(theta);
159 theta = atan2(dy[ndxy-1], dx[ndxy-1]);
160 x1 = chop2 * cos(theta);
161 y1 = chop2 * sin(theta);
166 dprintf("chopping %g %g %g %g; cur=%g,%g end=%g,%g\n",
167 x0, y0, x1, y1, curx, cury, nx, ny);
169 p = makenode(type, 5 + 2 * ndxy);
170 curx = p->o_val[0] = nx;
171 cury = p->o_val[1] = ny;
172 if (head || type == ARROW) {
173 p->o_nhead = getfval("arrowhead");
177 head = HEAD2; /* default arrow head */
179 p->o_attr = head | invis | ddtype;
183 for (i = 0, j = 5; i < ndxy; i++, j += 2) {
185 p->o_val[j+1] = dy[i];
186 if (type == LINE || type == ARROW)
187 extreme(nx += dx[i], ny += dy[i]);
188 else if (type == SPLINE && i < ndxy-1) {
189 /* to compute approx extreme of spline at p,
190 /* compute midway between p-1 and p+1,
191 /* then go 3/4 from there to p */
192 double ex, ey, xi, yi, xi1, yi1;
193 xi = nx + dx[i]; yi = ny + dy[i]; /* p */
194 xi1 = xi + dx[i+1]; yi1 = yi + dy[i+1]; /* p+1 */
195 ex = (nx+xi1)/2; ey = (ny+yi1)/2; /* midway */
196 ex += 0.75*(xi-ex); ey += 0.75*(yi-ey);
204 printf("S or L from %g %g to %g %g with %d elements:\n", p->o_x, p->o_y, curx, cury, ndxy);
205 for (i = 0, j = 5; i < ndxy; i++, j += 2)
206 printf("%g %g\n", p->o_val[j], p->o_val[j+1]);
208 extreme(p->o_x, p->o_y);