[BACK]Return to plotf.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / plot

Annotation of OpenXM_contrib2/asir2000/plot/plotf.c, Revision 1.2

1.2     ! noro        1: /* $OpenXM: OpenXM_contrib2/asir2000/plot/plotf.c,v 1.1.1.1 1999/12/03 07:39:13 noro Exp $ */
1.1       noro        2: #include "ca.h"
                      3: #include "parse.h"
                      4: #include "ox.h"
                      5: #include "ifplot.h"
                      6:
                      7: void Pifplot(), Pconplot(), Pplotover(), Pplot(), Parrayplot(), Pdrawcircle();
                      8:
                      9: struct ftab plot_tab[] = {
                     10:        {"ifplot",Pifplot,-7},
                     11:        {"conplot",Pconplot,-8},
                     12:        {"plot",Pplot,-6},
                     13:        {"plotover",Pplotover,3},
                     14:        {"drawcircle",Pdrawcircle,5},
                     15: /*
                     16:        {"arrayplot",Parrayplot,2},
                     17: */
                     18:        {0,0,0},
                     19: };
                     20:
                     21: int current_s;
                     22:
                     23: void Pifplot(arg,rp)
                     24: NODE arg;
                     25: Obj *rp;
                     26: {
                     27:        Q m2,p2,w300,sid;
                     28:        NODE defrange;
                     29:        LIST xrange,yrange,range[2],list,geom;
                     30:        VL vl,vl0;
                     31:        V v[2],av[2];
                     32:        int stream,ri,id,i;
                     33:        P poly;
                     34:        P var;
                     35:        NODE n,n0;
                     36:        STRING fname,wname;
                     37:
                     38:        STOQ(-2,m2); STOQ(2,p2);
                     39:        MKNODE(n,p2,0); MKNODE(defrange,m2,n);
                     40:        poly = 0; vl = 0; geom = 0; wname = 0; stream = -1; ri = 0;
                     41:        for ( ; arg; arg = NEXT(arg) )
                     42:                if ( !BDY(arg) )
                     43:                        stream = 0;
                     44:                else
                     45:                switch ( OID(BDY(arg)) ) {
                     46:                        case O_P:
                     47:                                poly = (P)BDY(arg);
                     48:                                get_vars_recursive(poly,&vl);
                     49:                                for ( vl0 = vl, i = 0; vl0; vl0 = NEXT(vl0) )
                     50:                                        if ( vl0->v->attr == V_IND )
                     51:                                                if ( i >= 2 )
                     52:                                                        error("ifplot : invalid argument");
                     53:                                                else
                     54:                                                        v[i++] = vl0->v;
                     55:                                break;
                     56:                        case O_LIST:
                     57:                                list = (LIST)BDY(arg);
                     58:                                if ( OID(BDY(BDY(list))) == O_P )
                     59:                                        if ( ri > 1 )
                     60:                                                error("ifplot : invalid argument");
                     61:                                        else
                     62:                                                range[ri++] = list;
                     63:                                else
                     64:                                        geom = list;
                     65:                                break;
                     66:                        case O_N:
                     67:                                stream = QTOS((Q)BDY(arg)); break;
                     68:                        case O_STR:
                     69:                                wname = (STRING)BDY(arg); break;
                     70:                        default:
                     71:                                error("ifplot : invalid argument"); break;
                     72:                }
                     73:        if ( !poly )
                     74:                error("ifplot : invalid argument");
                     75:        switch ( ri ) {
                     76:                case 0:
                     77:                        if ( !v[1] )
                     78:                                error("ifplot : please specify all variables");
                     79:                        MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
                     80:                        MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
                     81:                        break;
                     82:                case 1:
                     83:                        if ( !v[1] )
                     84:                                error("ifplot : please specify all variables");
                     85:                        av[0] = VR((P)BDY(BDY(range[0])));
                     86:                        if ( v[0] == av[0] ) {
                     87:                                xrange = range[0];
                     88:                                MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
                     89:                        } else if ( v[1] == av[0] ) {
                     90:                                MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
                     91:                                yrange = range[0];
                     92:                        } else
                     93:                                error("ifplot : invalid argument");
                     94:                        break;
                     95:                case 2:
                     96:                        av[0] = VR((P)BDY(BDY(range[0])));
                     97:                        av[1] = VR((P)BDY(BDY(range[1])));
                     98:                        if ( ((v[0] == av[0]) && (!v[1] || v[1] == av[1])) ||
                     99:                                 ((v[0] == av[1]) && (!v[1] || v[1] == av[0])) ) {
                    100:                                        xrange = range[0]; yrange = range[1];
                    101:                        } else
                    102:                                        error("ifplot : invalid argument");
                    103:                        break;
                    104:                default:
                    105:                        error("ifplot : cannot happen"); break;
                    106:        }
                    107:        /* ifplot in ox_plot requires
                    108:           [sid (Q),
                    109:                formula (Obj),
                    110:                xrange=[x,xmin,xmax] (LIST),
                    111:                yrange=[y,ymin,ymax] (LIST),
                    112:                zrange=0,
                    113:                geom=[xsize,ysize] (LIST),
                    114:                wname=name (STRING)]
                    115:        */
                    116:
                    117:        if ( stream < 0 )
                    118:                stream = current_s;
                    119:        else
                    120:                current_s = stream;
                    121:        STOQ(stream,sid);
                    122:        if ( !geom ) {
                    123:                STOQ(300,w300);
                    124:                MKNODE(n0,w300,0); MKNODE(n,w300,n0); MKLIST(geom,n);
                    125:        }
                    126:        MKSTR(fname,"plot");
                    127:        arg = mknode(8,sid,fname,poly,xrange,yrange,0,geom,wname);
1.2     ! noro      128:        Pox_cmo_rpc(arg,rp);
1.1       noro      129: }
                    130:
                    131: void Pconplot(arg,rp)
                    132: NODE arg;
                    133: Obj *rp;
                    134: {
                    135:        Q m2,p2,w300,sid;
                    136:        NODE defrange;
                    137:        LIST xrange,yrange,zrange,range[3],list,geom;
                    138:        VL vl,vl0;
                    139:        V v[2],av[2];
                    140:        int stream,ri,id,i;
                    141:        P poly;
                    142:        P var;
                    143:        NODE n,n0;
                    144:        STRING fname,wname;
                    145:
                    146:        STOQ(-2,m2); STOQ(2,p2);
                    147:        MKNODE(n,p2,0); MKNODE(defrange,m2,n);
                    148:        poly = 0; vl = 0; geom = 0; wname = 0; stream = -1; ri = 0;
                    149:        for ( ; arg; arg = NEXT(arg) )
                    150:                if ( !BDY(arg) )
                    151:                        stream = 0;
                    152:                else
                    153:                switch ( OID(BDY(arg)) ) {
                    154:                        case O_P:
                    155:                                poly = (P)BDY(arg);
                    156:                                get_vars_recursive(poly,&vl);
                    157:                                for ( vl0 = vl, i = 0; vl0; vl0 = NEXT(vl0) )
                    158:                                        if ( vl0->v->attr == V_IND )
                    159:                                                if ( i >= 2 )
                    160:                                                        error("ifplot : invalid argument");
                    161:                                                else
                    162:                                                        v[i++] = vl0->v;
                    163:                                break;
                    164:                        case O_LIST:
                    165:                                list = (LIST)BDY(arg);
                    166:                                if ( OID(BDY(BDY(list))) == O_P )
                    167:                                        if ( ri > 2 )
                    168:                                                error("ifplot : invalid argument");
                    169:                                        else
                    170:                                                range[ri++] = list;
                    171:                                else
                    172:                                        geom = list;
                    173:                                break;
                    174:                        case O_N:
                    175:                                stream = QTOS((Q)BDY(arg)); break;
                    176:                        case O_STR:
                    177:                                wname = (STRING)BDY(arg); break;
                    178:                        default:
                    179:                                error("ifplot : invalid argument"); break;
                    180:                }
                    181:        if ( !poly )
                    182:                error("ifplot : invalid argument");
                    183:        switch ( ri ) {
                    184:                case 0:
                    185:                        if ( !v[1] )
                    186:                                error("ifplot : please specify all variables");
                    187:                        MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
                    188:                        MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
                    189:                        MKNODE(n,0,defrange); MKLIST(zrange,n);
                    190:                        break;
                    191:                case 1:
                    192:                        if ( !v[1] )
                    193:                                error("ifplot : please specify all variables");
                    194:                        av[0] = VR((P)BDY(BDY(range[0])));
                    195:                        if ( v[0] == av[0] ) {
                    196:                                xrange = range[0];
                    197:                                MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
                    198:                                MKNODE(n,0,defrange); MKLIST(zrange,n);
                    199:                        } else if ( v[1] == av[0] ) {
                    200:                                MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
                    201:                                yrange = range[0];
                    202:                                MKNODE(n,0,defrange); MKLIST(zrange,n);
                    203:                        } else {
                    204:                                MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
                    205:                                MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
                    206:                                zrange = range[0];
                    207:                        }
                    208:                        break;
                    209:                case 2: case 3:
                    210:                        av[0] = VR((P)BDY(BDY(range[0])));
                    211:                        av[1] = VR((P)BDY(BDY(range[1])));
                    212:                        if ( ((v[0] == av[0]) && (!v[1] || v[1] == av[1])) ||
                    213:                                 ((v[0] == av[1]) && (!v[1] || v[1] == av[0])) ) {
                    214:                                xrange = range[0]; yrange = range[1];
                    215:                                if ( ri == 3 )
                    216:                                        zrange = range[2];
                    217:                                else {
                    218:                                        MKNODE(n,0,defrange); MKLIST(zrange,n);
                    219:                                }
                    220:                        } else
                    221:                                error("ifplot : invalid argument");
                    222:                        break;
                    223:                default:
                    224:                        error("ifplot : cannot happen"); break;
                    225:        }
                    226:        if ( stream < 0 )
                    227:                stream = current_s;
                    228:        else
                    229:                current_s = stream;
                    230:
                    231:        /* conplot in ox_plot requires
                    232:           [sid (Q),
                    233:                formula (Obj),
                    234:                xrange=[x,xmin,xmax] (LIST),
                    235:                yrange=[y,ymin,ymax] (LIST),
                    236:                zrange=[z,zmin,zmax] (LIST),
                    237:                geom=[xsize,ysize] (LIST),
                    238:                wname=name (STRING)]
                    239:        */
                    240:
                    241:        if ( stream < 0 )
                    242:                stream = current_s;
                    243:        else
                    244:                current_s = stream;
                    245:        STOQ(stream,sid);
                    246:        if ( !geom ) {
                    247:                STOQ(300,w300);
                    248:                MKNODE(n0,w300,0); MKNODE(n,w300,n0); MKLIST(geom,n);
                    249:        }
                    250:        MKSTR(fname,"plot");
                    251:        arg = mknode(8,sid,fname,poly,xrange,yrange,zrange,geom,wname);
1.2     ! noro      252:        Pox_cmo_rpc(arg,rp);
1.1       noro      253: }
                    254:
                    255: void Pplot(arg,rp)
                    256: NODE arg;
                    257: Obj *rp;
                    258: {
                    259:        Q m2,p2,w300,sid;
                    260:        NODE defrange;
                    261:        LIST xrange,range[1],list,geom;
                    262:        VL vl,vl0;
                    263:        V v[1],av[1];
                    264:        int stream,ri,id,i;
                    265:        P poly;
                    266:        P var;
                    267:        NODE n,n0;
                    268:        STRING fname,wname;
                    269:
                    270:        STOQ(-2,m2); STOQ(2,p2);
                    271:        MKNODE(n,p2,0); MKNODE(defrange,m2,n);
                    272:        poly = 0; vl = 0; geom = 0; wname = 0; stream = -1; ri = 0;
                    273:        for ( ; arg; arg = NEXT(arg) )
                    274:                if ( !BDY(arg) )
                    275:                        stream = 0;
                    276:                else
                    277:                switch ( OID(BDY(arg)) ) {
                    278:                        case O_P: case O_R:
                    279:                                poly = (P)BDY(arg);
                    280:                                get_vars_recursive(poly,&vl);
                    281:                                for ( vl0 = vl, i = 0; vl0; vl0 = NEXT(vl0) )
                    282:                                        if ( vl0->v->attr == V_IND )
                    283:                                                if ( i >= 1 )
                    284:                                                        error("ifplot : invalid argument");
                    285:                                                else
                    286:                                                        v[i++] = vl0->v;
                    287:                                break;
                    288:                        case O_LIST:
                    289:                                list = (LIST)BDY(arg);
                    290:                                if ( OID(BDY(BDY(list))) == O_P )
                    291:                                        if ( ri > 0 )
                    292:                                                error("plot : invalid argument");
                    293:                                        else
                    294:                                                range[ri++] = list;
                    295:                                else
                    296:                                        geom = list;
                    297:                                break;
                    298:                        case O_N:
                    299:                                stream = QTOS((Q)BDY(arg)); break;
                    300:                        case O_STR:
                    301:                                wname = (STRING)BDY(arg); break;
                    302:                        default:
                    303:                                error("plot : invalid argument"); break;
                    304:                }
                    305:        if ( !poly )
                    306:                error("plot : invalid argument");
                    307:        switch ( ri ) {
                    308:                case 0:
                    309:                        MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
                    310:                        break;
                    311:                case 1:
                    312:                        av[0] = VR((P)BDY(BDY(range[0])));
                    313:                        if ( v[0] == av[0] )
                    314:                                xrange = range[0];
                    315:                        else
                    316:                                error("plot : invalid argument");
                    317:                        break;
                    318:                default:
                    319:                        error("plot : cannot happen"); break;
                    320:        }
                    321:        /* conplot in ox_plot requires
                    322:           [sid (Q),
                    323:                formula (Obj),
                    324:                xrange=[x,xmin,xmax] (LIST),
                    325:                yrange=0,
                    326:                zrange=0,
                    327:                geom=[xsize,ysize] (LIST),
                    328:                wname=name (STRING)]
                    329:        */
                    330:        if ( stream < 0 )
                    331:                stream = current_s;
                    332:        else
                    333:                current_s = stream;
                    334:        STOQ(stream,sid);
                    335:        if ( !geom ) {
                    336:                STOQ(300,w300);
                    337:                MKNODE(n0,w300,0); MKNODE(n,w300,n0); MKLIST(geom,n);
                    338:        }
                    339:        MKSTR(fname,"plot");
                    340:        arg = mknode(8,sid,fname,poly,xrange,0,0,geom,wname);
1.2     ! noro      341:        Pox_cmo_rpc(arg,rp);
1.1       noro      342: }
                    343:
                    344: void Pplotover(arg,rp)
                    345: NODE arg;
                    346: Obj *rp;
                    347: {
                    348:        Q sid,index;
                    349:        P poly;
                    350:        STRING fname;
                    351:
                    352:        poly = (P)ARG0(arg);
                    353:        sid = (Q)ARG1(arg);
                    354:        index = (Q)ARG2(arg);
                    355:        MKSTR(fname,"plotover");
                    356:        arg = mknode(4,sid,fname,index,poly);
1.2     ! noro      357:        Pox_cmo_rpc(arg,rp);
1.1       noro      358: }
                    359:
                    360: /* arg = [x,y,r,sid,index] */
                    361:
                    362: void Pdrawcircle(arg,rp)
                    363: NODE arg;
                    364: Obj *rp;
                    365: {
                    366:        Q sid,index;
                    367:        Obj x,y,r;
                    368:        STRING fname;
                    369:        NODE n;
                    370:        LIST pos;
                    371:
                    372:        x = (Obj)ARG0(arg);
                    373:        y = (Obj)ARG1(arg);
                    374:        r = (Obj)ARG2(arg);
                    375:        sid = (Q)ARG3(arg);
                    376:        index = (Q)ARG4(arg);
                    377:        MKSTR(fname,"drawcircle");
                    378:        n = mknode(3,x,y,r); MKLIST(pos,n);
                    379:        arg = mknode(4,sid,fname,index,pos);
1.2     ! noro      380:        Pox_cmo_rpc(arg,rp);
1.1       noro      381: }
                    382:
                    383: #if 0
                    384: void Parrayplot(arg,rp)
                    385: NODE arg;
                    386: Obj *rp;
                    387: {
                    388:        int s;
                    389:        int id;
                    390:
                    391:        if ( ID((Obj)ARG0(arg)) == O_VECT && ID((Obj)ARG1(arg)) == O_LIST ) {
                    392:                s = current_s;
                    393:                gensend(s,C_APLOT,0);
                    394:                gensend(s,C_OBJ,ARG0(arg)); gensend(s,C_OBJ,ARG1(arg)); genflush(s);
                    395:        }
                    396:        genrecv(s,&id,rp);
                    397: }
                    398: #endif

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>