[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.14

1.4       noro        1: /*
                      2:  * Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED
                      3:  * All rights reserved.
                      4:  *
                      5:  * FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited,
                      6:  * non-exclusive and royalty-free license to use, copy, modify and
                      7:  * redistribute, solely for non-commercial and non-profit purposes, the
                      8:  * computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and
                      9:  * conditions of this Agreement. For the avoidance of doubt, you acquire
                     10:  * only a limited right to use the SOFTWARE hereunder, and FLL or any
                     11:  * third party developer retains all rights, including but not limited to
                     12:  * copyrights, in and to the SOFTWARE.
                     13:  *
                     14:  * (1) FLL does not grant you a license in any way for commercial
                     15:  * purposes. You may use the SOFTWARE only for non-commercial and
                     16:  * non-profit purposes only, such as academic, research and internal
                     17:  * business use.
                     18:  * (2) The SOFTWARE is protected by the Copyright Law of Japan and
                     19:  * international copyright treaties. If you make copies of the SOFTWARE,
                     20:  * with or without modification, as permitted hereunder, you shall affix
                     21:  * to all such copies of the SOFTWARE the above copyright notice.
                     22:  * (3) An explicit reference to this SOFTWARE and its copyright owner
                     23:  * shall be made on your publication or presentation in any form of the
                     24:  * results obtained by use of the SOFTWARE.
                     25:  * (4) In the event that you modify the SOFTWARE, you shall notify FLL by
1.5       noro       26:  * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
1.4       noro       27:  * for such modification or the source code of the modified part of the
                     28:  * SOFTWARE.
                     29:  *
                     30:  * THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL
                     31:  * MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND
                     32:  * EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS
                     33:  * FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES'
                     34:  * RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY
                     35:  * MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY.
                     36:  * UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT,
                     37:  * OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY
                     38:  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL
                     39:  * DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES
                     40:  * ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES
                     41:  * FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY
                     42:  * DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF
                     43:  * SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART
                     44:  * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY
                     45:  * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
                     46:  * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
                     47:  *
1.14    ! noro       48:  * $OpenXM: OpenXM_contrib2/asir2000/plot/plotf.c,v 1.13 2002/08/02 02:28:29 noro Exp $
1.4       noro       49: */
1.1       noro       50: #include "ca.h"
                     51: #include "parse.h"
                     52: #include "ox.h"
                     53: #include "ifplot.h"
                     54:
                     55: void Pifplot(), Pconplot(), Pplotover(), Pplot(), Parrayplot(), Pdrawcircle();
1.10      noro       56: void Pmemory_ifplot();
1.12      noro       57: void Popen_canvas(), Pclear_canvas(), Pdraw_obj(), Pdraw_string();
1.11      noro       58: void Pox_rpc();
                     59: void Pox_cmo_rpc();
1.1       noro       60:
                     61: struct ftab plot_tab[] = {
                     62:        {"ifplot",Pifplot,-7},
1.10      noro       63:        {"memory_ifplot",Pmemory_ifplot,-7},
1.1       noro       64:        {"conplot",Pconplot,-8},
                     65:        {"plot",Pplot,-6},
                     66:        {"plotover",Pplotover,3},
                     67:        {"drawcircle",Pdrawcircle,5},
1.6       noro       68:        {"open_canvas",Popen_canvas,-3},
                     69:        {"clear_canvas",Pclear_canvas,2},
1.7       noro       70:        {"draw_obj",Pdraw_obj,-4},
1.12      noro       71:        {"draw_string",Pdraw_string,-5},
1.1       noro       72: /*
                     73:        {"arrayplot",Parrayplot,2},
                     74: */
                     75:        {0,0,0},
                     76: };
                     77:
1.11      noro       78: void Popen_canvas(NODE arg,Obj *rp)
1.6       noro       79: {
1.9       noro       80:        Q w300,s_id;
1.6       noro       81:        LIST geom;
1.11      noro       82:        int stream;
1.6       noro       83:        NODE n,n0;
                     84:        STRING fname,wname;
                     85:
                     86:        geom = 0; wname = 0; stream = -1;
                     87:        for ( ; arg; arg = NEXT(arg) )
                     88:                if ( !BDY(arg) )
                     89:                        stream = 0;
                     90:                else
                     91:                switch ( OID(BDY(arg)) ) {
                     92:                        case O_LIST:
                     93:                                geom = (LIST)BDY(arg);
                     94:                                break;
                     95:                        case O_N:
                     96:                                stream = QTOS((Q)BDY(arg)); break;
                     97:                        case O_STR:
                     98:                                wname = (STRING)BDY(arg); break;
                     99:                        default:
                    100:                                error("open_canvas : invalid argument"); break;
                    101:                }
                    102:        /* open_canvas in ox_plot requires
1.9       noro      103:           [s_id (Q),
1.6       noro      104:                geom=[xsize,ysize] (LIST),
                    105:                wname=name (STRING)]
                    106:        */
                    107:
1.13      noro      108:        stream = validate_ox_plot_stream(stream);
1.9       noro      109:        STOQ(stream,s_id);
1.6       noro      110:        if ( !geom ) {
                    111:                STOQ(300,w300);
                    112:                MKNODE(n0,w300,0); MKNODE(n,w300,n0); MKLIST(geom,n);
                    113:        }
                    114:        MKSTR(fname,"open_canvas");
1.9       noro      115:        arg = mknode(4,s_id,fname,geom,wname);
1.6       noro      116:        Pox_cmo_rpc(arg,rp);
                    117: }
                    118:
1.13      noro      119: void Pifplot(NODE arg,Q *rp)
1.1       noro      120: {
1.9       noro      121:        Q m2,p2,w300,s_id;
1.1       noro      122:        NODE defrange;
                    123:        LIST xrange,yrange,range[2],list,geom;
                    124:        VL vl,vl0;
                    125:        V v[2],av[2];
1.11      noro      126:        int stream,ri,i;
1.1       noro      127:        P poly;
                    128:        P var;
                    129:        NODE n,n0;
                    130:        STRING fname,wname;
1.13      noro      131:        Obj t;
1.1       noro      132:
                    133:        STOQ(-2,m2); STOQ(2,p2);
                    134:        MKNODE(n,p2,0); MKNODE(defrange,m2,n);
                    135:        poly = 0; vl = 0; geom = 0; wname = 0; stream = -1; ri = 0;
1.14    ! noro      136:        v[0] = v[1] = 0;
1.1       noro      137:        for ( ; arg; arg = NEXT(arg) )
                    138:                if ( !BDY(arg) )
                    139:                        stream = 0;
                    140:                else
                    141:                switch ( OID(BDY(arg)) ) {
                    142:                        case O_P:
                    143:                                poly = (P)BDY(arg);
1.11      noro      144:                                get_vars_recursive((Obj)poly,&vl);
1.1       noro      145:                                for ( vl0 = vl, i = 0; vl0; vl0 = NEXT(vl0) )
1.11      noro      146:                                        if ( vl0->v->attr == (pointer)V_IND )
1.1       noro      147:                                                if ( i >= 2 )
                    148:                                                        error("ifplot : invalid argument");
                    149:                                                else
                    150:                                                        v[i++] = vl0->v;
                    151:                                break;
                    152:                        case O_LIST:
                    153:                                list = (LIST)BDY(arg);
                    154:                                if ( OID(BDY(BDY(list))) == O_P )
                    155:                                        if ( ri > 1 )
                    156:                                                error("ifplot : invalid argument");
                    157:                                        else
                    158:                                                range[ri++] = list;
                    159:                                else
                    160:                                        geom = list;
                    161:                                break;
                    162:                        case O_N:
                    163:                                stream = QTOS((Q)BDY(arg)); break;
                    164:                        case O_STR:
                    165:                                wname = (STRING)BDY(arg); break;
                    166:                        default:
                    167:                                error("ifplot : invalid argument"); break;
                    168:                }
                    169:        if ( !poly )
                    170:                error("ifplot : invalid argument");
                    171:        switch ( ri ) {
                    172:                case 0:
                    173:                        if ( !v[1] )
                    174:                                error("ifplot : please specify all variables");
                    175:                        MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
                    176:                        MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
                    177:                        break;
                    178:                case 1:
                    179:                        if ( !v[1] )
                    180:                                error("ifplot : please specify all variables");
                    181:                        av[0] = VR((P)BDY(BDY(range[0])));
                    182:                        if ( v[0] == av[0] ) {
                    183:                                xrange = range[0];
                    184:                                MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
                    185:                        } else if ( v[1] == av[0] ) {
                    186:                                MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
                    187:                                yrange = range[0];
                    188:                        } else
                    189:                                error("ifplot : invalid argument");
                    190:                        break;
                    191:                case 2:
                    192:                        av[0] = VR((P)BDY(BDY(range[0])));
                    193:                        av[1] = VR((P)BDY(BDY(range[1])));
                    194:                        if ( ((v[0] == av[0]) && (!v[1] || v[1] == av[1])) ||
                    195:                                 ((v[0] == av[1]) && (!v[1] || v[1] == av[0])) ) {
                    196:                                        xrange = range[0]; yrange = range[1];
                    197:                        } else
                    198:                                        error("ifplot : invalid argument");
                    199:                        break;
                    200:                default:
                    201:                        error("ifplot : cannot happen"); break;
                    202:        }
                    203:        /* ifplot in ox_plot requires
1.9       noro      204:           [s_id (Q),
1.1       noro      205:                formula (Obj),
                    206:                xrange=[x,xmin,xmax] (LIST),
                    207:                yrange=[y,ymin,ymax] (LIST),
                    208:                zrange=0,
                    209:                geom=[xsize,ysize] (LIST),
                    210:                wname=name (STRING)]
                    211:        */
                    212:
1.13      noro      213:        stream = validate_ox_plot_stream(stream);
1.9       noro      214:        STOQ(stream,s_id);
1.1       noro      215:        if ( !geom ) {
                    216:                STOQ(300,w300);
                    217:                MKNODE(n0,w300,0); MKNODE(n,w300,n0); MKLIST(geom,n);
                    218:        }
                    219:        MKSTR(fname,"plot");
1.9       noro      220:        arg = mknode(8,s_id,fname,poly,xrange,yrange,0,geom,wname);
1.13      noro      221:        Pox_rpc(arg,&t);
                    222:        *rp = s_id;
1.10      noro      223: }
                    224:
1.13      noro      225: void Pmemory_ifplot(NODE arg,Q *rp)
1.10      noro      226: {
                    227:        Q m2,p2,w300,s_id;
                    228:        NODE defrange;
                    229:        LIST xrange,yrange,range[2],list,geom;
                    230:        VL vl,vl0;
                    231:        V v[2],av[2];
1.11      noro      232:        int stream,ri,i;
1.10      noro      233:        P poly;
                    234:        P var;
                    235:        NODE n,n0;
1.11      noro      236:        STRING fname;
1.13      noro      237:        Obj t;
1.10      noro      238:
                    239:        STOQ(-2,m2); STOQ(2,p2);
                    240:        MKNODE(n,p2,0); MKNODE(defrange,m2,n);
                    241:        poly = 0; vl = 0; geom = 0; stream = -1; ri = 0;
                    242:        for ( ; arg; arg = NEXT(arg) )
                    243:                if ( !BDY(arg) )
                    244:                        stream = 0;
                    245:                else
                    246:                switch ( OID(BDY(arg)) ) {
                    247:                        case O_P:
                    248:                                poly = (P)BDY(arg);
1.11      noro      249:                                get_vars_recursive((Obj)poly,&vl);
1.10      noro      250:                                for ( vl0 = vl, i = 0; vl0; vl0 = NEXT(vl0) )
1.11      noro      251:                                        if ( vl0->v->attr == (pointer)V_IND )
1.10      noro      252:                                                if ( i >= 2 )
                    253:                                                        error("ifplot : invalid argument");
                    254:                                                else
                    255:                                                        v[i++] = vl0->v;
                    256:                                break;
                    257:                        case O_LIST:
                    258:                                list = (LIST)BDY(arg);
                    259:                                if ( OID(BDY(BDY(list))) == O_P )
                    260:                                        if ( ri > 1 )
                    261:                                                error("ifplot : invalid argument");
                    262:                                        else
                    263:                                                range[ri++] = list;
                    264:                                else
                    265:                                        geom = list;
                    266:                                break;
                    267:                        case O_N:
                    268:                                stream = QTOS((Q)BDY(arg)); break;
                    269:                        default:
                    270:                                error("memory_ifplot : invalid argument"); break;
                    271:                }
                    272:        if ( !poly )
                    273:                error("memory_ifplot : invalid argument");
                    274:        switch ( ri ) {
                    275:                case 0:
                    276:                        if ( !v[1] )
                    277:                                error("memory_ifplot : please specify all variables");
                    278:                        MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
                    279:                        MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
                    280:                        break;
                    281:                case 1:
                    282:                        if ( !v[1] )
                    283:                                error("memory_ifplot : please specify all variables");
                    284:                        av[0] = VR((P)BDY(BDY(range[0])));
                    285:                        if ( v[0] == av[0] ) {
                    286:                                xrange = range[0];
                    287:                                MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
                    288:                        } else if ( v[1] == av[0] ) {
                    289:                                MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
                    290:                                yrange = range[0];
                    291:                        } else
                    292:                                error("memory_ifplot : invalid argument");
                    293:                        break;
                    294:                case 2:
                    295:                        av[0] = VR((P)BDY(BDY(range[0])));
                    296:                        av[1] = VR((P)BDY(BDY(range[1])));
                    297:                        if ( ((v[0] == av[0]) && (!v[1] || v[1] == av[1])) ||
                    298:                                 ((v[0] == av[1]) && (!v[1] || v[1] == av[0])) ) {
                    299:                                        xrange = range[0]; yrange = range[1];
                    300:                        } else
                    301:                                        error("memory_ifplot : invalid argument");
                    302:                        break;
                    303:                default:
                    304:                        error("memory_ifplot : cannot happen"); break;
                    305:        }
                    306:        /* memory_ifplot in ox_plot requires
                    307:           [s_id (Q),
                    308:                formula (Obj),
                    309:                xrange=[x,xmin,xmax] (LIST),
                    310:                yrange=[y,ymin,ymax] (LIST),
                    311:                zrange=0,
                    312:                geom=[xsize,ysize] (LIST)]
                    313:        */
                    314:
1.13      noro      315:        stream = validate_ox_plot_stream(stream);
1.10      noro      316:        STOQ(stream,s_id);
                    317:        if ( !geom ) {
                    318:                STOQ(300,w300);
                    319:                MKNODE(n0,w300,0); MKNODE(n,w300,n0); MKLIST(geom,n);
                    320:        }
                    321:        MKSTR(fname,"memory_plot");
                    322:        arg = mknode(7,s_id,fname,poly,xrange,yrange,0,geom);
1.13      noro      323:        Pox_rpc(arg,&t);
                    324:        *rp = s_id;
1.1       noro      325: }
                    326:
1.13      noro      327: void Pconplot(NODE arg,Q *rp)
1.1       noro      328: {
1.9       noro      329:        Q m2,p2,w300,s_id;
1.1       noro      330:        NODE defrange;
                    331:        LIST xrange,yrange,zrange,range[3],list,geom;
                    332:        VL vl,vl0;
                    333:        V v[2],av[2];
1.11      noro      334:        int stream,ri,i;
1.1       noro      335:        P poly;
                    336:        P var;
                    337:        NODE n,n0;
                    338:        STRING fname,wname;
1.13      noro      339:        Obj t;
1.1       noro      340:
                    341:        STOQ(-2,m2); STOQ(2,p2);
                    342:        MKNODE(n,p2,0); MKNODE(defrange,m2,n);
                    343:        poly = 0; vl = 0; geom = 0; wname = 0; stream = -1; ri = 0;
1.14    ! noro      344:        v[0] = v[1] = 0;
1.1       noro      345:        for ( ; arg; arg = NEXT(arg) )
                    346:                if ( !BDY(arg) )
                    347:                        stream = 0;
                    348:                else
                    349:                switch ( OID(BDY(arg)) ) {
                    350:                        case O_P:
                    351:                                poly = (P)BDY(arg);
1.11      noro      352:                                get_vars_recursive((Obj)poly,&vl);
1.1       noro      353:                                for ( vl0 = vl, i = 0; vl0; vl0 = NEXT(vl0) )
1.11      noro      354:                                        if ( vl0->v->attr == (pointer)V_IND )
1.1       noro      355:                                                if ( i >= 2 )
                    356:                                                        error("ifplot : invalid argument");
                    357:                                                else
                    358:                                                        v[i++] = vl0->v;
                    359:                                break;
                    360:                        case O_LIST:
                    361:                                list = (LIST)BDY(arg);
                    362:                                if ( OID(BDY(BDY(list))) == O_P )
                    363:                                        if ( ri > 2 )
                    364:                                                error("ifplot : invalid argument");
                    365:                                        else
                    366:                                                range[ri++] = list;
                    367:                                else
                    368:                                        geom = list;
                    369:                                break;
                    370:                        case O_N:
                    371:                                stream = QTOS((Q)BDY(arg)); break;
                    372:                        case O_STR:
                    373:                                wname = (STRING)BDY(arg); break;
                    374:                        default:
                    375:                                error("ifplot : invalid argument"); break;
                    376:                }
                    377:        if ( !poly )
                    378:                error("ifplot : invalid argument");
                    379:        switch ( ri ) {
                    380:                case 0:
                    381:                        if ( !v[1] )
                    382:                                error("ifplot : please specify all variables");
                    383:                        MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
                    384:                        MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
                    385:                        MKNODE(n,0,defrange); MKLIST(zrange,n);
                    386:                        break;
                    387:                case 1:
                    388:                        if ( !v[1] )
                    389:                                error("ifplot : please specify all variables");
                    390:                        av[0] = VR((P)BDY(BDY(range[0])));
                    391:                        if ( v[0] == av[0] ) {
                    392:                                xrange = range[0];
                    393:                                MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
                    394:                                MKNODE(n,0,defrange); MKLIST(zrange,n);
                    395:                        } else if ( v[1] == av[0] ) {
                    396:                                MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
                    397:                                yrange = range[0];
                    398:                                MKNODE(n,0,defrange); MKLIST(zrange,n);
                    399:                        } else {
                    400:                                MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
                    401:                                MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
                    402:                                zrange = range[0];
                    403:                        }
                    404:                        break;
                    405:                case 2: case 3:
                    406:                        av[0] = VR((P)BDY(BDY(range[0])));
                    407:                        av[1] = VR((P)BDY(BDY(range[1])));
                    408:                        if ( ((v[0] == av[0]) && (!v[1] || v[1] == av[1])) ||
                    409:                                 ((v[0] == av[1]) && (!v[1] || v[1] == av[0])) ) {
                    410:                                xrange = range[0]; yrange = range[1];
                    411:                                if ( ri == 3 )
                    412:                                        zrange = range[2];
                    413:                                else {
                    414:                                        MKNODE(n,0,defrange); MKLIST(zrange,n);
                    415:                                }
                    416:                        } else
                    417:                                error("ifplot : invalid argument");
                    418:                        break;
                    419:                default:
                    420:                        error("ifplot : cannot happen"); break;
                    421:        }
                    422:        /* conplot in ox_plot requires
1.9       noro      423:           [s_id (Q),
1.1       noro      424:                formula (Obj),
                    425:                xrange=[x,xmin,xmax] (LIST),
                    426:                yrange=[y,ymin,ymax] (LIST),
                    427:                zrange=[z,zmin,zmax] (LIST),
                    428:                geom=[xsize,ysize] (LIST),
                    429:                wname=name (STRING)]
                    430:        */
                    431:
1.13      noro      432:        stream = validate_ox_plot_stream(stream);
1.9       noro      433:        STOQ(stream,s_id);
1.1       noro      434:        if ( !geom ) {
                    435:                STOQ(300,w300);
                    436:                MKNODE(n0,w300,0); MKNODE(n,w300,n0); MKLIST(geom,n);
                    437:        }
                    438:        MKSTR(fname,"plot");
1.9       noro      439:        arg = mknode(8,s_id,fname,poly,xrange,yrange,zrange,geom,wname);
1.13      noro      440:        Pox_rpc(arg,&t);
                    441:        *rp = s_id;
1.1       noro      442: }
                    443:
1.13      noro      444: void Pplot(NODE arg,Q *rp)
1.1       noro      445: {
1.9       noro      446:        Q m2,p2,w300,s_id;
1.1       noro      447:        NODE defrange;
                    448:        LIST xrange,range[1],list,geom;
                    449:        VL vl,vl0;
                    450:        V v[1],av[1];
1.11      noro      451:        int stream,ri,i;
1.1       noro      452:        P poly;
                    453:        P var;
                    454:        NODE n,n0;
                    455:        STRING fname,wname;
1.13      noro      456:        Obj t;
1.1       noro      457:
                    458:        STOQ(-2,m2); STOQ(2,p2);
                    459:        MKNODE(n,p2,0); MKNODE(defrange,m2,n);
                    460:        poly = 0; vl = 0; geom = 0; wname = 0; stream = -1; ri = 0;
1.14    ! noro      461:        v[0] = 0;
1.1       noro      462:        for ( ; arg; arg = NEXT(arg) )
                    463:                if ( !BDY(arg) )
                    464:                        stream = 0;
                    465:                else
                    466:                switch ( OID(BDY(arg)) ) {
                    467:                        case O_P: case O_R:
                    468:                                poly = (P)BDY(arg);
1.11      noro      469:                                get_vars_recursive((Obj)poly,&vl);
1.1       noro      470:                                for ( vl0 = vl, i = 0; vl0; vl0 = NEXT(vl0) )
1.11      noro      471:                                        if ( vl0->v->attr == (pointer)V_IND )
1.1       noro      472:                                                if ( i >= 1 )
                    473:                                                        error("ifplot : invalid argument");
                    474:                                                else
                    475:                                                        v[i++] = vl0->v;
1.8       noro      476:                                if ( i != 1 )
                    477:                                        error("ifplot : invalid argument");
1.1       noro      478:                                break;
                    479:                        case O_LIST:
                    480:                                list = (LIST)BDY(arg);
                    481:                                if ( OID(BDY(BDY(list))) == O_P )
                    482:                                        if ( ri > 0 )
                    483:                                                error("plot : invalid argument");
                    484:                                        else
                    485:                                                range[ri++] = list;
                    486:                                else
                    487:                                        geom = list;
                    488:                                break;
                    489:                        case O_N:
                    490:                                stream = QTOS((Q)BDY(arg)); break;
                    491:                        case O_STR:
                    492:                                wname = (STRING)BDY(arg); break;
                    493:                        default:
                    494:                                error("plot : invalid argument"); break;
                    495:                }
                    496:        if ( !poly )
                    497:                error("plot : invalid argument");
                    498:        switch ( ri ) {
                    499:                case 0:
                    500:                        MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
                    501:                        break;
                    502:                case 1:
                    503:                        av[0] = VR((P)BDY(BDY(range[0])));
                    504:                        if ( v[0] == av[0] )
                    505:                                xrange = range[0];
                    506:                        else
                    507:                                error("plot : invalid argument");
                    508:                        break;
                    509:                default:
                    510:                        error("plot : cannot happen"); break;
                    511:        }
                    512:        /* conplot in ox_plot requires
1.9       noro      513:           [s_id (Q),
1.1       noro      514:                formula (Obj),
                    515:                xrange=[x,xmin,xmax] (LIST),
                    516:                yrange=0,
                    517:                zrange=0,
                    518:                geom=[xsize,ysize] (LIST),
                    519:                wname=name (STRING)]
                    520:        */
1.13      noro      521:        stream = validate_ox_plot_stream(stream);
1.9       noro      522:        STOQ(stream,s_id);
1.1       noro      523:        if ( !geom ) {
                    524:                STOQ(300,w300);
                    525:                MKNODE(n0,w300,0); MKNODE(n,w300,n0); MKLIST(geom,n);
                    526:        }
                    527:        MKSTR(fname,"plot");
1.9       noro      528:        arg = mknode(8,s_id,fname,poly,xrange,0,0,geom,wname);
1.13      noro      529:        Pox_rpc(arg,&t);
                    530:        *rp = s_id;
1.1       noro      531: }
                    532:
1.13      noro      533: void Pplotover(NODE arg,Q *rp)
1.1       noro      534: {
1.9       noro      535:        Q s_id,index;
1.1       noro      536:        P poly;
                    537:        STRING fname;
1.13      noro      538:        Obj t;
1.1       noro      539:
                    540:        poly = (P)ARG0(arg);
1.9       noro      541:        s_id = (Q)ARG1(arg);
1.1       noro      542:        index = (Q)ARG2(arg);
                    543:        MKSTR(fname,"plotover");
1.9       noro      544:        arg = mknode(4,s_id,fname,index,poly);
1.13      noro      545:        Pox_rpc(arg,&t);
                    546:        *rp = s_id;
1.1       noro      547: }
                    548:
1.9       noro      549: /* arg = [x,y,r,s_id,index] */
1.1       noro      550:
1.13      noro      551: void Pdrawcircle(NODE arg,Q *rp)
1.1       noro      552: {
1.9       noro      553:        Q s_id,index;
1.1       noro      554:        Obj x,y,r;
                    555:        STRING fname;
                    556:        NODE n;
                    557:        LIST pos;
1.13      noro      558:        Obj t;
1.1       noro      559:
                    560:        x = (Obj)ARG0(arg);
                    561:        y = (Obj)ARG1(arg);
                    562:        r = (Obj)ARG2(arg);
1.9       noro      563:        s_id = (Q)ARG3(arg);
1.1       noro      564:        index = (Q)ARG4(arg);
                    565:        MKSTR(fname,"drawcircle");
                    566:        n = mknode(3,x,y,r); MKLIST(pos,n);
1.9       noro      567:        arg = mknode(4,s_id,fname,index,pos);
1.13      noro      568:        Pox_rpc(arg,&t);
                    569:        *rp = s_id;
1.6       noro      570: }
                    571:
1.9       noro      572: /* draw_obj(s_id,cindex,point|line); point = [x,y], line = [xa,ya,xb,yb] */
1.13      noro      573: void Pdraw_obj(NODE arg,Q *rp)
1.6       noro      574: {
                    575:        static STRING fname;
1.9       noro      576:        Q s_id,index;
1.6       noro      577:        LIST obj;
1.13      noro      578:        Obj t;
1.6       noro      579:
                    580:        if ( !fname ) {
                    581:                MKSTR(fname,"draw_obj");
                    582:        }
1.9       noro      583:        s_id = (Q)ARG0(arg);
1.6       noro      584:        index = (Q)ARG1(arg);
                    585:        obj = (LIST)ARG2(arg);
1.7       noro      586:        /* ARG3(arg) = color */
                    587:        if ( argc(arg) == 4 )
1.9       noro      588:                arg = mknode(5,s_id,fname,index,obj,ARG3(arg));
1.7       noro      589:        else
1.9       noro      590:                arg = mknode(4,s_id,fname,index,obj);
1.13      noro      591:        Pox_cmo_rpc(arg,&t);
                    592:        *rp = s_id;
1.12      noro      593: }
                    594:
                    595: /* draw_string(s_id,cindex,pos,string,[,color]); pos=[x,y] */
1.13      noro      596: void Pdraw_string(NODE arg,Q *rp)
1.12      noro      597: {
                    598:        static STRING fname;
                    599:        STRING str;
                    600:        Q s_id,index;
                    601:        LIST pos;
1.13      noro      602:        Obj t;
1.12      noro      603:
                    604:        if ( !fname ) {
                    605:                MKSTR(fname,"draw_string");
                    606:        }
                    607:        s_id = (Q)ARG0(arg);
                    608:        index = (Q)ARG1(arg);
                    609:        pos = (LIST)ARG2(arg);
                    610:        str = (STRING)ARG3(arg);
                    611:        /* ARG4(arg) = color */
                    612:        if ( argc(arg) == 5 )
                    613:                arg = mknode(6,s_id,fname,index,pos,str,ARG4(arg));
                    614:        else
                    615:                arg = mknode(5,s_id,fname,index,pos,str);
1.13      noro      616:        Pox_cmo_rpc(arg,&t);
                    617:        *rp = s_id;
1.6       noro      618: }
                    619:
1.13      noro      620: void Pclear_canvas(NODE arg,Q *rp)
1.6       noro      621: {
                    622:        static STRING fname;
1.9       noro      623:        Q s_id,index;
1.13      noro      624:        Obj t;
1.6       noro      625:
                    626:        if ( !fname ) {
                    627:                MKSTR(fname,"clear_canvas");
                    628:        }
1.9       noro      629:        s_id = (Q)ARG0(arg);
1.6       noro      630:        index = (Q)ARG1(arg);
1.9       noro      631:        arg = mknode(3,s_id,fname,index);
1.13      noro      632:        Pox_cmo_rpc(arg,&t);
                    633:        *rp = s_id;
1.1       noro      634: }
                    635:
                    636: #if 0
1.11      noro      637: void Parrayplot(NODE arg,Obj *rp)
1.1       noro      638: {
                    639:        int s;
                    640:        int id;
                    641:
                    642:        if ( ID((Obj)ARG0(arg)) == O_VECT && ID((Obj)ARG1(arg)) == O_LIST ) {
                    643:                s = current_s;
                    644:                gensend(s,C_APLOT,0);
                    645:                gensend(s,C_OBJ,ARG0(arg)); gensend(s,C_OBJ,ARG1(arg)); genflush(s);
                    646:        }
                    647:        genrecv(s,&id,rp);
                    648: }
                    649: #endif

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