Annotation of researchv10no/cmd/grap/coord.c, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.