|
|
1.1 ! root 1: /* Copyright (c) 1988 AT&T */ ! 2: /* All Rights Reserved */ ! 3: ! 4: /* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T */ ! 5: /* The copyright notice above does not evidence any */ ! 6: /* actual or intended publication of such source code. */ ! 7: ! 8: /* @(#)picasso:circgen.c 1.0 */ ! 9: #include "picasso.h" ! 10: #include "y.tab.h" ! 11: ! 12: extern int pic_compat; ! 13: ! 14: obj *circgen(type) ! 15: int type; ! 16: { ! 17: static double rad[2] = { HT2, WID2 }; ! 18: static double rad2[2] = { HT2, HT2 }; ! 19: ! 20: struct objattr obat; ! 21: double xwith, ywith, r, r2; ! 22: int i, at, t, with; ! 23: obj *p, *ppos; ! 24: Attr *ap; ! 25: ! 26: obat.a_layer = (int)getfval("curlayer"); ! 27: obat.a_flags = EDGED; ! 28: obat.a_weight = obat.a_lcolor = obat.a_pcolor = obat.a_tcolor = -1; ! 29: obat.a_dashpat.a = (float *)0; ! 30: at = with = xwith = ywith = 0; ! 31: if (t = (type == CIRCLE) ? 0 : 1) { ! 32: r = getfval("ellipsewid") / 2; ! 33: r2 = getfval("ellipseht") / 2; ! 34: } ! 35: else ! 36: r = r2 = getfval("circlerad"); ! 37: set_text(); ! 38: for (i = 0; i < nattr; i++) { ! 39: ap = &attr[i]; ! 40: switch (ap->a_type) { ! 41: default: ! 42: miscattrs(ap, &obat); ! 43: break; ! 44: case RADIUS: ! 45: r = ap->a_val.f; ! 46: break; ! 47: case DIAMETER: ! 48: case WIDTH: ! 49: r = ap->a_val.f / 2; ! 50: break; ! 51: case HEIGHT: ! 52: r2 = ap->a_val.f / 2; ! 53: break; ! 54: case SAME: ! 55: r = rad[t]; ! 56: r2 = rad2[t]; ! 57: break; ! 58: case WITH: ! 59: with = ap->a_val.i; ! 60: break; ! 61: case AT: ! 62: ppos = ap->a_val.o; ! 63: curx = Xformx(ppos, 1, ppos->o_x, ppos->o_y); ! 64: cury = Xformy(ppos, 0, ppos->o_x, ppos->o_y); ! 65: at++; ! 66: break; ! 67: } ! 68: } ! 69: if (type == CIRCLE) ! 70: r2 = r; /* probably superfluous */ ! 71: if (with) { ! 72: if (pic_compat) /* map NE to 2nd, etc. */ ! 73: with = with == NE ? 2 : ! 74: with == NW ? 4 : ! 75: with == SW ? 6 : ! 76: with == SE ? 8 : with; ! 77: switch (with) { ! 78: case NORTH: ywith = -r2; break; ! 79: case SOUTH: ywith = r2; break; ! 80: case EAST: xwith = -r; break; ! 81: case WEST: xwith = r; break; ! 82: case NE: xwith = -r; ywith = -r2; break; ! 83: case SE: xwith = -r; ywith = r2; break; ! 84: case NW: xwith = r; ywith = -r2; break; ! 85: case SW: xwith = r; ywith = r2; break; ! 86: case CENTER: ! 87: case START: ! 88: case END: break; ! 89: default: xwith = -r * xdelta[with % 8]; ! 90: ywith = -r2 * ydelta[with % 8]; ! 91: if (with % 2 == 0) { ! 92: xwith *= M_SQRT1_2; ! 93: ywith *= M_SQRT1_2; ! 94: } ! 95: break; ! 96: } ! 97: curx += xwith; ! 98: cury += ywith; ! 99: } ! 100: if (!at) { ! 101: if (isright(hvmode)) ! 102: curx += r; ! 103: else if (isleft(hvmode)) ! 104: curx -= r; ! 105: else if (isup(hvmode)) ! 106: cury += r2; ! 107: else ! 108: cury -= r2; ! 109: } ! 110: if (r <= 0 || r2 <= 0) ! 111: yyerror("%s has invalid radius %g", ! 112: (type==CIRCLE) ? "circle" : "ellipse", r<r2 ? r : r2); ! 113: p = makenode(type, N_VAL, obat.a_layer); ! 114: p->o_wid = 2 * (rad[t] = r); ! 115: p->o_ht = 2 * (rad2[t] = r2); ! 116: primattrs(p, &obat); ! 117: text_bounds(p); ! 118: if (isright(hvmode)) ! 119: curx += r; ! 120: else if (isleft(hvmode)) ! 121: curx -= r; ! 122: else if (isup(hvmode)) ! 123: cury += r2; ! 124: else ! 125: cury -= r2; ! 126: r += p->o_weight/2; ! 127: r2 += p->o_weight/2; ! 128: track_bounds (p->o_x - r, p->o_y - r2, p->o_x + r, p->o_y + r2); ! 129: return(p); ! 130: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.