obj *getpos(obj *p, int corner) /* find position of point */ { double x, y; whatpos(p, corner, &x, &y); return makepos(x, y); }
obj * fixpos(obj *p, double x, double y) /* this, addpos & subpos SHOULD be altered to give */ /* o_x,o_y as offset from position of p, with p as */ /* o_parent, but I haven't yet worked out the xform. */ { #if 1 /* DBK: 3/21/90 -- comment out the following if clause. It has the effect of changing A in the expression A + x,y !!! if (p->o_type == PLACE) { p->o_x += x; p->o_y += y; return p; } end of commented out code *************/ x += Xformx(p, 1, p->o_x, p->o_y); y += Xformy(p, 0, p->o_x, p->o_y); #else if (p->o_type == PLACE) { x += p->o_x; y += p->o_y; } else { x += Xformx(p, 1, p->o_x, p->o_y); y += Xformy(p, 0, p->o_x, p->o_y); } #endif return makepos(x, y, 0, (obj *)0); }
obj * subpos(obj *p, obj *q) { double x, y; x = Xformx(q, 1, q->o_x, q->o_y); y = Xformy(q, 0, q->o_x, q->o_y); /* DBK: see above if (p->o_type == PLACE) { p->o_x -= x; p->o_y -= y; return p; } */ x -= Xformx(p, 1, p->o_x, p->o_y); y -= Xformy(p, 0, p->o_x, p->o_y); return makepos(x, y, 0, (obj *)0); }
obj * getpos(obj *p, int corner) /* find position of point */ { float x, y; if (pic_compat && (p->o_type == CIRCLE || p->o_type == ELLIPSE) && (corner == NE || corner == NW || corner == SW || corner == SE)) return getnth(p, corner == NE ? 2 : corner == NW ? 4 : corner == SW ? 6 : 8); if (corner == -1 ) { if (pic_compat && (p->o_type == LINE || p->o_type == ARROW || p->o_type == SPLINE)) corner = START; else return p; } whatpos(p, corner, &x, &y); return makepos(x,y,corner,(corner < EAST || corner > SW)? p: (obj *)0); }
obj *subpos(obj *p, obj *q) { dprintf("subpos returns %g %g\n", p->o_x-q->o_x, p->o_y-q->o_y); return makepos(p->o_x-q->o_x, p->o_y-q->o_y); }
obj *addpos(obj *p, obj *q) { dprintf("addpos returns %g %g\n", p->o_x+q->o_x, p->o_y+q->o_y); return makepos(p->o_x+q->o_x, p->o_y+q->o_y); }
obj *fixpos(obj *p, double x, double y) { dprintf("fixpos returns %g %g\n", p->o_x + x, p->o_y + y); return makepos(p->o_x + x, p->o_y + y); }
obj *gethere(void) /* make a place for curx,cury */ { dprintf("gethere %g %g\n", curx, cury); return(makepos(curx, cury)); }
obj * gethere(void) /* make a place for curx,cury */ { return(makepos(curx, cury, 0, (obj *)0)); }
obj * getnth(obj *p, int nth) /* find nth point of an object */ { float x, y; double *tbox; int n = nth; switch (p->o_type) { default: if (n != 1) yyerror("object has only 1 point defined"); return p; case ARC: if (n > 2) { yyerror("arcs have only 2 points defined"); return p; } /* else fall through to SECTOR case */ case SECTOR: if ((n %= 3) == 0) return p; else if (n == 1) { x = p->o_val[N_VAL+2].f; y = p->o_val[N_VAL+3].f; } else { x = p->o_val[N_VAL+4].f; y = p->o_val[N_VAL+5].f; } break; case BLOCK: while (n--) { p = p->o_next; if (p->o_type <= TEXT) continue; else if (p->o_type == BLOCKEND) { yyerror("[] has less than %d objects", nth); p = p->o_parent; } } return p; case BOX: n %= 8; x = p->o_x + xdelta[n] * p->o_wid / 2; y = p->o_y + ydelta[n] * p->o_ht / 2; break; case ARROW: case LINE: case SPLINE: if (--n > p->o_val[N_VAL+3].f) { yyerror("line has less than %d points", nth); return p; } x = p->o_val[N_VAL + 4 + 2 * n].f; y = p->o_val[N_VAL + 5 + 2 * n].f; break; case CIRCLE: case ELLIPSE: n %= 8; x = xdelta[n] * p->o_wid / 2; y = ydelta[n] * p->o_ht / 2; if (n % 2 == 0) { x *= M_SQRT1_2; y *= M_SQRT1_2; } x += p->o_x; y += p->o_y; break; case TEXT: n %= 8; x = p->o_x; y = p->o_y; tbox = text_bounds(p); if (n >= 0 && n <= 2) x += tbox[2]; if (n >= 2 && n <= 4) y += tbox[3]; if (n >= 4 && n <= 6) x += tbox[0]; if (n == 6 || n == 7 || n == 0) y += tbox[1]; if (n == 1 || n == 5) x += (tbox[0] + tbox[2]) / 2; if (n == 3 || n == 7) y += (tbox[1] + tbox[3]) /2; break; } /* DBK--Here also there is a question of whether x and y should be transformed */ return makepos(x, y, nth, p); }