#include "defs.h" /* * Redraw the picture from within a mode. * * head = head item, or zero. * zero displays the main drawing area in norma style * If head item is 'w', 'c', or 'J' the entire picture appears * with textual legends only appear for the current item. * The current item is drawn with a solid line, others are drawn * as dotted (wires), dashed (others), or dot-dashed (chips). * */ redraw(head) REG DL head; { REG INT style=0; erase(); who(head); switch(head->type){ case 'L': drawshape(head); break; case 'B': drawbord(head); break; case 'c': case 'w': showh(head, 0); style=1; case 'M': drawmain(style); } } /* * Erase the screen and display the border data. * * The data in this item within the ranges 5632 <= x <= 9472, * 0 <= y <= 11520 will appear in the right border under the * hard-copy options of draw * * h = 'B' item entry */ LOC drawbord(h) DL h; { REG DL p; DL1 p1, p2; style(0, 0, 1); copypt(point(5632, 0), p1); copypt(point(9472, 11520), p2); box(p1, p2); style(-1, 0, 0); destyl = 0; p = h; while(p=nexta('B', p)) { switch(p->type){ case 'a': showa(p, nil(DL)); break; case 'h': case 'e': case 'o': show(h, p); break; } } } /* * Redraw a shape definition from within shape mode. * * h = 'L' entry */ LOC drawshape(h) REG DL h; { DL1 p1; REG DL tx; style(0, 0, 0); destyl = 0; center(h); tx = succ('x',h); p1->styl = 0; p1->flag = 0; p1->x = 0; p1->y = 0; showshape(p1, tx, h, h); } /* * Erase screen and display the picture. */ drawmain(s) INT s; { REG DL head, q; style(0, 0, 0); destyl = 0; head = first('M'); do{ q = showh(head, s); /* clean up empty headers */ if(q == succa(head) && q->type == head->type) delete(head); else head = q; } while(head->type != 'M'); } /* * Center shape definition on screen. * * h = 'L' entry */ LOC center(h) DL h; { REG DL p, px, mp; INT xc, yc; px = fixext(h); mp = minpt(h); xc = ((maxx - px->x) / 2) & ~511; yc = ((maxy - px->y) / 2) & ~511; p=h; while(p=nexta('L',p)) if(p->type != 'x'){ p->x = (p->x - mp->x) + xc; p->y = (p->y - mp->y) + yc; } } /* * print mode indication * * h is header addr */ who(h) REG DL h; { CHAR buf[2*ITEMSIZ+4]; REG DL p; REG STRING tp, cp; cp = buf; *cp++ = h->type; *cp++ = ' '; switch(h->type) { case 'c': case 'L': if(p = finda(h, xhairs)){ if(p->type == 'a') reply(p->tag); else reply("circle"); } case 'w': cp = movstr(dln(h)->name, cp); } if(any(h->type, "cw")) { if(tp = ctype(h)){ *cp++ = ','; cp = movstr(tp, cp); } } *cp++ = 0; send(buf); } prxy() { ITEM i; STRING ip=i; ip=itoa(xhairs->x, ip); *ip++ = ','; itoa(xhairs->y, ip); reply(i); }