Annotation of researchv9/cmd/grap/coord.c, revision 1.1

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

unix.superglobalmegacorp.com

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