1 #ifndef lint 2 static char sccsid[] = "@(#)coord.c 1.1 (CWI) 85/07/19"; 3 #endif lint 4 #include <stdio.h> 5 #include "grap.h" 6 #include "y.tab.h" 7 8 char *dflt_coord = "gg"; 9 char *curr_coord = "gg"; 10 int ncoord = 0; /* number of explicit coord's given */ 11 12 Point xcoord; 13 Point ycoord; 14 int xcflag = 0; /* 1 if xcoord set */ 15 int ycflag = 0; 16 int logcoord = 0; 17 18 coord_x(pt) /* remember x coord */ 19 Point pt; 20 { 21 xcoord = pt; 22 xcflag = 1; 23 margin = 0; /* no extra space around picture if explicit coords */ 24 } 25 26 coord_y(pt) 27 Point pt; 28 { 29 ycoord = pt; 30 ycflag = 1; 31 margin = 0; /* no extra space if explicit coords */ 32 } 33 34 coordlog(n) /* remember log scaling */ 35 int n; 36 { 37 logcoord = n; 38 } 39 40 coord(p) /* set coord range */ 41 Obj *p; 42 { 43 static char buf[10]; 44 45 ncoord++; 46 if (ncoord > 1 && strcmp(p->name, dflt_coord) == 0) { 47 /* resetting default coordinate by implication */ 48 sprintf(buf, "gg%d", ncoord); 49 dflt_coord = buf; 50 p = lookup(dflt_coord, 1); 51 } 52 if (xcflag) { 53 p->coord |= XFLAG; 54 p->pt.x = min(xcoord.x,xcoord.y); /* "xcoord" is xmin, xmax */ 55 p->pt1.x = max(xcoord.x,xcoord.y); 56 if ((logcoord&XFLAG) && p->pt.x <= 0.0) 57 fatal("can't have log of x coord %g,%g", p->pt.x, p->pt1.x); 58 xcflag = 0; 59 } 60 if (ycflag) { 61 p->coord |= YFLAG; 62 p->pt.y = min(ycoord.x,ycoord.y); /* "ycoord" is ymin, ymax */ 63 p->pt1.y = max(ycoord.x,ycoord.y); 64 if ((logcoord&YFLAG) && p->pt.y <= 0.0) 65 fatal("can't have log of y coord %g,%g", p->pt.y, p->pt1.y); 66 ycflag = 0; 67 } 68 p->log = logcoord; 69 logcoord = 0; 70 auto_x = 0; 71 } 72 73 resetcoord(p) /* reset current coordinate */ 74 Obj *p; 75 { 76 curr_coord = p->name; 77 } 78