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

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.33    ! noro       48:  * $OpenXM: OpenXM_contrib2/asir2000/plot/plotf.c,v 1.32 2017/09/01 01:48:40 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:
1.26      saito      55: int validate_ox_plot_stream(int);
1.24      saito      56: void ListCheck(char *,LIST);
1.26      saito      57: void Pplot(NODE,Obj *);
                     58: void Ppolarplot(NODE,Obj *);
                     59: void Pobj_cp(NODE,Obj *),Parrayplot(NODE,Obj*),Pdrawcircle(NODE,Obj*);
1.24      saito      60: void Pifplot(NODE,Obj *),Pconplot(NODE,Obj *),Pplotover(NODE,Obj *);
1.26      saito      61: void Pmemory_ifplot(NODE,Obj *),Pmemory_conplot(NODE,Obj *);
                     62: void Pmemory_plot(NODE,Obj *);
                     63: void ifplot_main(NODE,int,char *,Obj *);
                     64: void plot_main(NODE,int,char *,Obj *);
                     65: void conplot_main(NODE,int,Obj *);
1.24      saito      66:
                     67: void Popen_canvas(NODE,Obj *),Pclear_canvas(NODE,Obj *),Pdraw_obj(NODE,Obj *);
                     68: void Pdraw_string(NODE,Obj *);
1.26      saito      69: void Pox_rpc(NODE,Obj *), Pox_cmo_rpc(NODE,Obj *);
1.1       noro       70:
1.24      saito      71: //NG
                     72: #if defined(INTERVAL)
                     73: void Pitvifplot(NODE, Obj *);
                     74: #endif
                     75: void PifplotD(NODE,Obj *),PifplotQ(NODE,Obj *),PifplotB(NODE,Obj *);
                     76: void PineqnD(NODE,Obj *), PineqnQ(NODE,Obj *), PineqnB(NODE,Obj *);
                     77: void PineqnandD(NODE,Obj *), PineqnandQ(NODE,Obj *), PineqnandB(NODE,Obj *);
                     78: void PineqnorD(NODE,Obj *), PineqnorQ(NODE,Obj *), PineqnorB(NODE,Obj *);
                     79: void PineqnxorD(NODE,Obj *), PineqnxorQ(NODE,Obj *), PineqnxorB(NODE,Obj *);
                     80: void PconplotD(NODE,Obj *),PconplotQ(NODE,Obj *),PconplotB(NODE,Obj *);
1.29      saito      81: void PpolarplotD(NODE,Obj *);
1.24      saito      82: void PplotoverD(NODE,Obj *),PplotoverQ(NODE,Obj *),PplotoverB(NODE,Obj *);
1.26      saito      83: void ifplot_mainNG(NODE,char *,Obj *);
                     84: void conplot_mainNG(NODE,char *,Obj *);
                     85: void plotover_mainNG(NODE,char *,Obj *);
1.24      saito      86:
                     87: struct ftab plot_tab[]={
1.26      saito      88:        {PLOT,Pplot,-7},
1.22      saito      89: #if defined(INTERVAL)
1.26      saito      90:        {ITVIFPLOT,Pitvifplot,-8},
1.24      saito      91: #endif
1.29      saito      92:        {OBJ_CP,Pobj_cp,4},
1.26      saito      93:        {POLARPLOT,Ppolarplot,-6},
1.29      saito      94:        {POLARPLOTD,PpolarplotD,-7},
1.26      saito      95:        {IFPLOT,Pifplot,-7},
                     96:        {IFPLOTD,PifplotD,-8},
                     97:        {IFPLOTQ,PifplotQ,-8},
                     98:        {IFPLOTB,PifplotB,-8},
                     99:        {INEQN,PineqnD,-8},
                    100:        {INEQND,PineqnD,-8},
                    101:        {INEQNQ,PineqnQ,-8},
                    102:        {INEQNB,PineqnB,-8},
                    103:        {INEQNAND,PineqnandD,-4},
                    104:        {INEQNDAND,PineqnandD,-4},
                    105:        {INEQNQAND,PineqnandQ,-4},
                    106:        {INEQNBAND,PineqnandB,-4},
                    107:        {INEQNOR,PineqnorD,-4},
                    108:        {INEQNDOR,PineqnorD,-4},
                    109:        {INEQNQOR,PineqnorQ,-4},
                    110:        {INEQNBOR,PineqnorB,-4},
                    111:        {INEQNXOR,PineqnxorD,-4},
                    112:        {INEQNDXOR,PineqnxorD,-4},
                    113:        {INEQNQXOR,PineqnxorQ,-4},
                    114:        {INEQNBXOR,PineqnxorB,-4},
                    115:        {CONPLOT,Pconplot,-7},
                    116:        {CONPLOTD,PconplotD,-8},
                    117:        {CONPLOTB,PconplotB,-8},
                    118:        {CONPLOTQ,PconplotQ,-8},
                    119:        {PLOTOVER,Pplotover,-4},
                    120:        {PLOTOVERD,PplotoverD,-4},
                    121:        {PLOTOVERQ,PplotoverQ,-4},
                    122:        {PLOTOVERB,PplotoverB,-4},
1.29      saito     123:        {MEMORY_IFPLOT,Pmemory_ifplot,-7},
1.26      saito     124:        {MEMORY_CONPLOT,Pmemory_conplot,-7},
1.29      saito     125:        {MEMORY_PLOT,Pmemory_plot,-7},
1.28      ohara     126:        {DRAWCIRCLE,Pdrawcircle,6},
1.26      saito     127:        {OPEN_CANVAS,Popen_canvas,-3},
                    128:        {CLEAR_CANVAS,Pclear_canvas,2},
1.28      ohara     129:        {DRAW_OBJ,Pdraw_obj,-4},
                    130:        {DRAW_STRING,Pdraw_string,-5},
1.1       noro      131:        {0,0,0},
                    132: };
1.26      saito     133: char *pfn[]={
                    134:        IFPLOT,CONPLOT,PLOT,INTERACTIVE,POLARPLOT,PLOTOVER,
                    135:        IFPLOTD,IFPLOTQ,IFPLOTB,INEQND,INEQNQ,INEQNB,
                    136:        INEQNDAND,INEQNQAND,INEQNBAND,
                    137:        INEQNDOR,INEQNQOR,INEQNBOR,
                    138:        INEQNDXOR,INEQNQXOR,INEQNBXOR,
                    139:        CONPLOTD,CONPLOTQ,CONPLOTB,ITVIFPLOT,
                    140:        PLOTOVERD,PLOTOVERQ,PLOTOVERB,
                    141:        MEMORY_IFPLOT,MEMORY_CONPLOT,MEMORY_PLOT,ARRAYPLOT,OPEN_CANVAS,
1.29      saito     142:        DRAWCIRCLE,DRAW_OBJ,DRAW_STRING,OBJ_CP,CLEAR_CANVAS,POLARPLOTD};
1.26      saito     143: /*
                    144:        IFPLOT:0,CONPLOT:1,PLOT:2,INTERACTIVE:3,POLARPLOT:4,PLOTOVER:5,
                    145:        IFPLOTD:6,IFPLOTQ:7,IFPLOTB:8,INEQND:9,INEQNQ:10,INEQNB:11,
                    146:        INEQNDAND:12,INEQNQAND:13,INEQNBAND:14,
                    147:        INEQNDOR:15,INEQNQOR:16,INEQNBOR:17,
                    148:        INEQNDXOR:18,INEQNQXOR:19,INEQNBXOR:20,
                    149:        CONPLOTD:21,CONPLOTQ:22,CONPLOTB:23,ITVIFPLOT:24,
                    150:        PLOTOVERD:25,PLOTOVERQ:26,PLOTOVERB:27,
                    151:        MEMORY_IFPLOT:28,MEMORY_CONPLOT:29,MEMORY_PLOT:30,ARRAYPLOT:31,
                    152:        OPEN_CANVAS:32,DRAWCIRCLE:33,DRAW_OBJ:34,DRAW_STRING:35,OBJ_CP:36,
1.29      saito     153:        CLEAR_CANVAS:37,POLARPLOTD:38
1.26      saito     154: */
                    155: int modeNO(char *fn){
                    156:        int i;
                    157:        char **z;
                    158:        for(i=0,z=pfn;*z!=NULL;z++,i++)if(!strcmp(fn,*z))return i;
                    159:        return -1;
                    160: }
1.1       noro      161:
1.24      saito     162: void Popen_canvas(NODE arg,Obj *rp){
1.9       noro      163:        Q w300,s_id;
1.6       noro      164:        LIST geom;
1.11      noro      165:        int stream;
1.6       noro      166:        NODE n,n0;
                    167:        STRING fname,wname;
                    168:
1.24      saito     169:        geom=0;wname=0;stream=-1;
                    170:        for(;arg;arg=NEXT(arg))
                    171:                if(!BDY(arg)) stream=0;
                    172:                else switch (OID(BDY(arg))){
                    173:                        case O_LIST:
                    174:                                geom=(LIST)BDY(arg);
                    175:                                break;
                    176:                        case O_N:
                    177:                                stream=QTOS((Q)BDY(arg));
                    178:                                break;
                    179:                        case O_STR:
                    180:                                wname=(STRING)BDY(arg);
                    181:                                break;
                    182:                        default:
                    183:                                error("open_canvas : invalid argument");
                    184:                                break;
1.6       noro      185:                }
1.24      saito     186:        stream=validate_ox_plot_stream(stream);
1.9       noro      187:        STOQ(stream,s_id);
1.24      saito     188:        if(!geom){
1.6       noro      189:                STOQ(300,w300);
1.24      saito     190:                MKNODE(n0,w300,0);
                    191:                MKNODE(n,w300,n0);
                    192:                MKLIST(geom,n);
1.6       noro      193:        }
1.26      saito     194:        MKSTR(fname,OPEN_CANVAS);
1.24      saito     195:        arg=mknode(4,s_id,fname,geom,wname);
1.6       noro      196:        Pox_cmo_rpc(arg,rp);
1.24      saito     197:        *rp=(Obj)s_id;
1.6       noro      198: }
                    199:
1.26      saito     200: void Pifplot(NODE arg,Obj *rp){ifplot_main(arg,0,IFPLOT,rp);}
                    201: void Pmemory_ifplot(NODE arg,Obj *rp){ifplot_main(arg,1,IFPLOT,rp);}
1.18      noro      202:
1.26      saito     203: void ifplot_main(NODE arg,int is_memory,char *fn,Obj *rp){
1.9       noro      204:        Q m2,p2,w300,s_id;
1.1       noro      205:        NODE defrange;
1.26      saito     206:        LIST xrange,yrange,zrange,range[2],list,geom;
1.1       noro      207:        VL vl,vl0;
                    208:        V v[2],av[2];
1.22      saito     209:        int stream,ri,i,sign;
1.32      noro      210:   Obj poly;
                    211:        P var;
1.22      saito     212:        NODE n,n0;
                    213:        STRING fname,wname;
                    214:        Obj t;
1.32      noro      215:   int found_f;
1.22      saito     216:
1.24      saito     217:        STOQ(-2,m2);STOQ(2,p2);MKNODE(n,p2,0);MKNODE(defrange,m2,n);
1.26      saito     218:        poly=0;vl=0;geom=0;wname=0;stream=-1;ri=0;xrange=0;yrange=0;zrange=0;
1.24      saito     219:        v[0]=v[1]=0;
1.32      noro      220:   found_f = 0;
1.24      saito     221:        for(;arg;arg=NEXT(arg))
1.32      noro      222:                if(!BDY(arg)){
                    223:       if ( !found_f ) {
                    224:         poly = 0;
                    225:         found_f = 1;
                    226:       } else stream=0;
                    227:                } else
1.24      saito     228:                switch(OID(BDY(arg))){
1.22      saito     229:                case O_P:
1.32      noro      230:                        poly=(Obj)BDY(arg);
1.22      saito     231:                        get_vars_recursive((Obj)poly,&vl);
1.26      saito     232:                        for(vl0=vl,i=0;vl0;vl0=NEXT(vl0)){
                    233:                                if(vl0->v->attr==(pointer)V_IND){
1.24      saito     234:                                        if(i>=2)error("ifplot : invalid argument");
                    235:                                        else v[i++]=vl0->v;
1.26      saito     236:                                }
                    237:                        }
1.32      noro      238:       found_f = 1;
1.22      saito     239:                        break;
                    240:                case O_LIST:
1.24      saito     241:                        list=(LIST)BDY(arg);
                    242:                        if(OID(BDY(BDY(list)))==O_P)
                    243:                                if(ri>1) error("ifplot : invalid argument");
                    244:                                else range[ri++]=list;
                    245:                        else geom=list;
1.22      saito     246:                        break;
                    247:                case O_N:
1.32      noro      248:       if ( !found_f ) {
                    249:         poly = (Obj)BDY(arg);
                    250:         found_f = 1;
                    251:       } else stream=QTOS((Q)BDY(arg));
                    252:       break;
1.22      saito     253:                case O_STR:
1.24      saito     254:                        wname=(STRING)BDY(arg);break;
1.22      saito     255:                default:
1.24      saito     256:                        error("ifplot : invalid argument");break;
1.22      saito     257:                }
1.32      noro      258:        if(!found_f) error("ifplot : invalid argument");
1.24      saito     259:        switch(ri){
1.22      saito     260:        case 0:
1.24      saito     261:                if(!v[1]) error("ifplot : please specify all variables");
                    262:                MKV(v[0],var);MKNODE(n,var,defrange);MKLIST(xrange,n);
                    263:                MKV(v[1],var);MKNODE(n,var,defrange);MKLIST(yrange,n);
1.22      saito     264:                break;
                    265:        case 1:
1.24      saito     266:                if(!v[1]) error("ifplot : please specify all variables");
                    267:                av[0]=VR((P)BDY(BDY(range[0])));
1.32      noro      268:                if(!poly || NUM(poly) || v[0]==av[0]){
1.24      saito     269:                        xrange=range[0];
                    270:                        MKV(v[1],var);MKNODE(n,var,defrange);MKLIST(yrange,n);
                    271:                } else if(v[1]==av[0]){
                    272:                        MKV(v[0],var);MKNODE(n,var,defrange);MKLIST(xrange,n);
                    273:                        yrange=range[0];
1.22      saito     274:                } else error("ifplot : invalid argument");
                    275:                break;
                    276:        case 2:
1.24      saito     277:                av[0]=VR((P)BDY(BDY(range[0])));
                    278:                av[1]=VR((P)BDY(BDY(range[1])));
1.32      noro      279:                if(!poly || NUM(poly) || (((v[0]==av[0])&&(!v[1]||v[1]==av[1]))||
                    280:                        ((v[0]==av[1])&&(!v[1]||v[1]==av[0])))){
1.24      saito     281:                        xrange=range[0];yrange=range[1];
1.22      saito     282:                } else error("ifplot : invalid argument");
                    283:                break;
                    284:        default:
1.24      saito     285:                error("ifplot : cannot happen");break;
1.22      saito     286:        }
                    287:        /* ifplot in ox_plot requires
                    288:                [s_id (Q),
                    289:                formula (Obj),
                    290:                xrange=[x,xmin,xmax] (LIST),
                    291:                yrange=[y,ymin,ymax] (LIST),
                    292:                zrange=0,
                    293:                geom=[xsize,ysize] (LIST),
                    294:                wname=name (STRING)]
                    295:        */
1.24      saito     296:        stream=validate_ox_plot_stream(stream);
1.22      saito     297:        STOQ(stream,s_id);
1.24      saito     298:        if(!geom){
                    299:                STOQ(300,w300);MKNODE(n0,w300,0);MKNODE(n,w300,n0);MKLIST(geom,n);
1.22      saito     300:        }
1.24      saito     301:        if(is_memory){
1.26      saito     302:                MKSTR(fname,MEMORY_PLOT);
                    303:                arg=mknode(8,s_id,fname,poly,xrange,yrange,zrange,geom);
1.22      saito     304:                Pox_rpc(arg,&t);
1.24      saito     305:                arg=mknode(1,s_id);
1.22      saito     306:                Pox_pop_cmo(arg,rp);
                    307:        } else {
1.26      saito     308:                MKSTR(fname,fn);
                    309:                arg=mknode(8,s_id,fname,poly,xrange,yrange,zrange,geom,wname);
1.22      saito     310:                Pox_rpc(arg,&t);
1.24      saito     311:                *rp=(Obj)s_id;
1.22      saito     312:        }
                    313: }
                    314:
1.24      saito     315: void Pconplot(NODE arg,Obj *rp){conplot_main(arg, 0, rp);}
                    316: void Pmemory_conplot(NODE arg,Obj *rp){conplot_main(arg,1,rp);}
1.22      saito     317:
1.24      saito     318: void conplot_main(NODE arg,int is_memory,Obj *rp){
1.29      saito     319:        Q m2,p2,w300,s_id;
                    320:        NODE defrange;
1.24      saito     321:        LIST xrange,yrange,zrange,range[3],list,geom;
1.22      saito     322:        VL vl,vl0;
                    323:        V v[2],av[2];
1.29      saito     324:        int stream,ri,i;
                    325:        P poly;
                    326:        P var;
                    327:        NODE n,n0;
1.22      saito     328:        STRING fname,wname;
                    329:        Obj t;
                    330:
1.29      saito     331:        STOQ(-2,m2); STOQ(2,p2);
                    332:        MKNODE(n,p2,0); MKNODE(defrange,m2,n);
                    333:        poly = 0; vl = 0; geom = 0; wname = 0; stream = -1; ri = 0;
                    334:        v[0] = v[1] = 0;
                    335:        for ( ; arg; arg = NEXT(arg) )
                    336:                if ( !BDY(arg) )
                    337:                        stream = 0;
                    338:                else
                    339:                switch ( OID(BDY(arg)) ) {
1.22      saito     340:                        case O_P:
1.29      saito     341:                                poly = (P)BDY(arg);
1.22      saito     342:                                get_vars_recursive((Obj)poly,&vl);
1.29      saito     343:                                for ( vl0 = vl, i = 0; vl0; vl0 = NEXT(vl0) )
                    344:                                        if ( vl0->v->attr == (pointer)V_IND )
                    345:                                                if ( i >= 2 )
                    346:                                                        error("ifplot : invalid argument");
                    347:                                                else
                    348:                                                        v[i++] = vl0->v;
1.22      saito     349:                                break;
                    350:                        case O_LIST:
1.29      saito     351:                                list = (LIST)BDY(arg);
                    352:                                if ( OID(BDY(BDY(list))) == O_P )
                    353:                                        if ( ri > 2 )
                    354:                                                error("ifplot : invalid argument");
                    355:                                        else
                    356:                                                range[ri++] = list;
                    357:                                else
                    358:                                        geom = list;
1.22      saito     359:                                break;
                    360:                        case O_N:
1.29      saito     361:                                stream = QTOS((Q)BDY(arg)); break;
1.22      saito     362:                        case O_STR:
1.29      saito     363:                                wname = (STRING)BDY(arg); break;
1.1       noro      364:                        default:
1.29      saito     365:                                error("ifplot : invalid argument"); break;
1.1       noro      366:                }
1.29      saito     367:        if ( !poly )
                    368:                error("ifplot : invalid argument");
                    369:        switch ( ri ) {
1.1       noro      370:                case 0:
1.29      saito     371:                        if ( !v[1] )
                    372:                                error("ifplot : please specify all variables");
                    373:                        MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
                    374:                        MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
                    375:                        MKNODE(n,0,defrange); MKLIST(zrange,n);
1.1       noro      376:                        break;
                    377:                case 1:
1.29      saito     378:                        if ( !v[1] )
                    379:                                error("ifplot : please specify all variables");
                    380:                        av[0] = VR((P)BDY(BDY(range[0])));
                    381:                        if ( v[0] == av[0] ) {
                    382:                                xrange = range[0];
                    383:                                MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
                    384:                                MKNODE(n,0,defrange); MKLIST(zrange,n);
                    385:                        } else if ( v[1] == av[0] ) {
                    386:                                MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
                    387:                                yrange = range[0];
                    388:                                MKNODE(n,0,defrange); MKLIST(zrange,n);
1.1       noro      389:                        } else {
1.29      saito     390:                                MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
                    391:                                MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
                    392:                                zrange = range[0];
1.1       noro      393:                        }
                    394:                        break;
1.29      saito     395:                case 2: case 3:
                    396:                        av[0] = VR((P)BDY(BDY(range[0])));
                    397:                        av[1] = VR((P)BDY(BDY(range[1])));
                    398:                        if ( ((v[0] == av[0]) && (!v[1] || v[1] == av[1])) ||
                    399:                                 ((v[0] == av[1]) && (!v[1] || v[1] == av[0])) ) {
                    400:                                xrange = range[0]; yrange = range[1];
                    401:                                if ( ri == 3 )
                    402:                                        zrange = range[2];
1.1       noro      403:                                else {
1.29      saito     404:                                        MKNODE(n,0,defrange); MKLIST(zrange,n);
1.1       noro      405:                                }
1.29      saito     406:                        } else
                    407:                                error("ifplot : invalid argument");
1.1       noro      408:                        break;
                    409:                default:
1.29      saito     410:                        error("ifplot : cannot happen"); break;
1.1       noro      411:        }
                    412:        /* conplot in ox_plot requires
1.9       noro      413:           [s_id (Q),
1.1       noro      414:                formula (Obj),
                    415:                xrange=[x,xmin,xmax] (LIST),
                    416:                yrange=[y,ymin,ymax] (LIST),
1.29      saito     417:                zrange=[z,zmin,zmax] (LIST),
1.1       noro      418:                geom=[xsize,ysize] (LIST),
                    419:                wname=name (STRING)]
                    420:        */
1.29      saito     421:
                    422:        stream = validate_ox_plot_stream(stream);
1.9       noro      423:        STOQ(stream,s_id);
1.29      saito     424:        if ( !geom ) {
1.1       noro      425:                STOQ(300,w300);
1.29      saito     426:                MKNODE(n0,w300,0); MKNODE(n,w300,n0); MKLIST(geom,n);
1.1       noro      427:        }
1.29      saito     428:        if ( is_memory ) {
                    429:                MKSTR(fname,"memory_plot");
                    430:                arg = mknode(7,s_id,fname,poly,xrange,yrange,zrange,geom);
1.18      noro      431:                Pox_rpc(arg,&t);
1.29      saito     432:                arg = mknode(1,s_id);
1.18      noro      433:                Pox_pop_cmo(arg,rp);
                    434:        } else {
1.26      saito     435:                MKSTR(fname,CONPLOT);
1.29      saito     436:                arg = mknode(8,s_id,fname,poly,xrange,yrange,zrange,geom,wname);
1.18      noro      437:                Pox_rpc(arg,&t);
1.29      saito     438:                *rp = (Obj)s_id;
1.18      noro      439:        }
                    440: }
                    441:
1.26      saito     442: void Pplot(NODE arg,Obj *rp){plot_main(arg,0,PLOT,rp);}
                    443: void Pmemory_plot(NODE arg,Obj *rp){plot_main(arg,1,PLOT,rp);}
1.1       noro      444:
1.33    ! noro      445: int plot_by_bigfloat;
        !           446:
1.26      saito     447: void plot_main(NODE arg,int is_memory,char *fn,Obj *rp){
1.9       noro      448:        Q m2,p2,w300,s_id;
1.1       noro      449:        NODE defrange;
                    450:        LIST xrange,range[1],list,geom;
                    451:        VL vl,vl0;
                    452:        V v[1],av[1];
1.31      noro      453:        int stream,ri,i,found_f;
1.32      noro      454:        Obj func;
1.1       noro      455:        P var;
                    456:        NODE n,n0;
                    457:        STRING fname,wname;
1.13      noro      458:        Obj t;
1.33    ! noro      459:   Q prec;
1.1       noro      460:
1.24      saito     461:        STOQ(-2,m2);STOQ(2,p2);
                    462:        MKNODE(n,p2,0);MKNODE(defrange,m2,n);
1.32      noro      463:        func=0;vl=0;geom=0;wname=0;stream=-1;ri=0;
1.24      saito     464:        v[0]=0;
1.31      noro      465:   found_f = 0;
1.32      noro      466:        for(;arg;arg=NEXT(arg) ) {
1.24      saito     467:                if(!BDY(arg) )
1.32      noro      468:       if ( !found_f ) {
                    469:         makevar("x",&var);
                    470:         v[0] = VR(var);
                    471:         found_f = 1;
                    472:       } else
                    473:                          stream=0;
1.1       noro      474:                else
1.24      saito     475:                switch ( OID(BDY(arg)) ){
1.1       noro      476:                        case O_P: case O_R:
1.32      noro      477:         func = (Obj)BDY(arg);
                    478:                                get_vars_recursive(func,&vl);
1.26      saito     479:                                for(vl0=vl, i=0;vl0;vl0=NEXT(vl0) ){
                    480:                                        if(vl0->v->attr==(pointer)V_IND ){
1.32      noro      481:                                                if(i >= 1 ) error("plot : function must be univariate");
1.26      saito     482:                                                else v[i++]=vl0->v;
                    483:                                        }
                    484:                                }
1.31      noro      485:         found_f = 1;
1.1       noro      486:                                break;
                    487:                        case O_LIST:
1.24      saito     488:                                list=(LIST)BDY(arg);
1.26      saito     489:                                if(OID(BDY(BDY(list)))==O_P ){
1.32      noro      490:                                        if(ri > 0 ) error("plot : too many intervals");
1.26      saito     491:                                        else range[ri++]=list;
                    492:                                } else geom=list;
1.1       noro      493:                                break;
                    494:                        case O_N:
1.31      noro      495:         if ( !found_f ) {
1.32      noro      496:           func = (Obj)BDY(arg);
1.31      noro      497:           makevar("x",&var);
                    498:           v[0] = VR(var);
1.32      noro      499:           found_f = 1;
1.31      noro      500:         } else
                    501:                                  stream=QTOS((Q)BDY(arg));
                    502:         break;
1.1       noro      503:                        case O_STR:
1.24      saito     504:                                wname=(STRING)BDY(arg);break;
1.1       noro      505:                        default:
1.24      saito     506:                                error("plot : invalid argument");break;
1.1       noro      507:                }
1.32      noro      508:   }
                    509:        if(!found_f )
1.1       noro      510:                error("plot : invalid argument");
1.24      saito     511:        switch ( ri ){
1.1       noro      512:                case 0:
1.24      saito     513:                        MKV(v[0],var);MKNODE(n,var,defrange);MKLIST(xrange,n);
1.1       noro      514:                        break;
                    515:                case 1:
1.24      saito     516:                        av[0]=VR((P)BDY(BDY(range[0])));
1.32      noro      517:                        if(!func || NUM(func) || v[0]==av[0] )
1.24      saito     518:                                xrange=range[0];
1.1       noro      519:                        else
                    520:                                error("plot : invalid argument");
                    521:                        break;
                    522:                default:
1.24      saito     523:                        error("plot : cannot happen");break;
1.1       noro      524:        }
                    525:        /* conplot in ox_plot requires
1.9       noro      526:           [s_id (Q),
1.1       noro      527:                formula (Obj),
                    528:                xrange=[x,xmin,xmax] (LIST),
                    529:                yrange=0,
                    530:                zrange=0,
                    531:                geom=[xsize,ysize] (LIST),
                    532:                wname=name (STRING)]
                    533:        */
1.24      saito     534:        stream=validate_ox_plot_stream(stream);
1.9       noro      535:        STOQ(stream,s_id);
1.24      saito     536:        if(!geom ){
1.1       noro      537:                STOQ(300,w300);
1.24      saito     538:                MKNODE(n0,w300,0);MKNODE(n,w300,n0);MKLIST(geom,n);
1.1       noro      539:        }
1.33    ! noro      540:   if(plot_by_bigfloat)
        !           541:     STOQ(plot_by_bigfloat,prec);
        !           542:   else
        !           543:     prec = 0;
1.24      saito     544:        if(is_memory ){
1.26      saito     545:                MKSTR(fname,MEMORY_PLOT);
1.33    ! noro      546:                arg=mknode(8,s_id,fname,func,xrange,NULLP,NULLP,geom,prec);
1.18      noro      547:                Pox_rpc(arg,&t);
1.24      saito     548:                arg=mknode(1,s_id);
1.18      noro      549:                Pox_pop_cmo(arg,rp);
                    550:        } else {
1.26      saito     551:                MKSTR(fname,fn);
1.33    ! noro      552:                arg=mknode(9,s_id,fname,func,xrange,NULLP,NULLP,geom,wname,prec);
1.18      noro      553:                Pox_rpc(arg,&t);
1.24      saito     554:                *rp=(Obj)s_id;
1.18      noro      555:        }
1.15      noro      556: }
                    557:
                    558: #define Pi 3.14159265358979323846264
                    559:
1.24      saito     560: void Ppolarplot(NODE arg,Obj *rp){
1.29      saito     561:        Q m2,p2,w300,s_id;
                    562:        NODE defrange,n,n0;
                    563:        LIST zrange,range[1],geom,list;
1.15      noro      564:        VL vl,vl0;
1.29      saito     565:        V v[1],av[1];
                    566:        int stream,ri,i;
1.26      saito     567:        P poly,var;
1.15      noro      568:        STRING fname,wname;
                    569:        Real pi2;
1.29      saito     570:        Obj t;
1.15      noro      571:
1.29      saito     572:        MKReal(2*Pi,pi2);MKNODE(n,pi2,0); MKNODE(defrange,0,n);
                    573:        poly=0;vl=0;geom=0;wname=0;stream=-1;ri=0;v[0]=0;
1.26      saito     574:        for(;arg;arg=NEXT(arg)){
1.29      saito     575:                if(!BDY(arg)) stream=0;
1.26      saito     576:                else switch(OID(BDY(arg))){
1.32      noro      577:                case O_P: case O_R://formula
1.26      saito     578:                        poly=(P)BDY(arg);
                    579:                        get_vars_recursive((Obj)poly,&vl);
1.29      saito     580:                        for(vl0=vl,i=0;vl0;vl0=NEXT(vl0))
                    581:                                if(vl0->v->attr==(pointer)V_IND)
                    582:                                        if(i>=1)error("polarplot : invalid argument");
                    583:                                else v[i++]=vl0->v;
                    584:                        if(i!=1)error("polarplot : invalid argument");
1.26      saito     585:                        break;
1.29      saito     586:                case O_LIST://range,geomerty
                    587:                        list=(LIST)BDY(arg);
                    588:                        if(OID(BDY(BDY(list)))==O_P)
                    589:                                if(ri>0)error("polarplot : invalid argument");
                    590:                                else range[ri++]=list;
                    591:                        else geom=list;
1.26      saito     592:                        break;
1.29      saito     593:                case O_N:
                    594:                        stream=QTOS((Q)BDY(arg));
1.15      noro      595:                        break;
1.26      saito     596:                case O_STR://wname
                    597:                        wname=(STRING)BDY(arg);
1.15      noro      598:                        break;
                    599:                default:
1.29      saito     600:                        error("polarplot : invalid argument");
1.26      saito     601:                        break;
                    602:                }
                    603:        }
                    604:        //formular check
1.29      saito     605:        if(!poly)error("polarplot : invalid argument");
                    606:        switch (ri){
                    607:        case 0:
                    608:                MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(zrange,n);
                    609:                break;
                    610:        case 1:
                    611:                av[0]=VR((P)BDY(BDY(range[0])));
                    612:                if(v[0]==av[0]) zrange = range[0];
                    613:                else error("polarplot : invalid argument");
                    614:                break;
                    615:        default:
                    616:                error("polarplot : cannot happen");
                    617:                break;
1.26      saito     618:        }
1.29      saito     619:        stream=validate_ox_plot_stream(stream);
                    620:        STOQ(stream,s_id);
1.26      saito     621:        if(!geom){
1.29      saito     622:                STOQ(300,w300);
                    623:                MKNODE(n0,w300,0); MKNODE(n,w300,n0); MKLIST(geom,n);
1.15      noro      624:        }
1.26      saito     625:        MKSTR(fname,POLARPLOT);
1.29      saito     626:        arg=mknode(8,s_id,fname,poly,NULLP,NULLP,zrange,geom,wname);
1.13      noro      627:        Pox_rpc(arg,&t);
1.29      saito     628:        *rp=s_id;
1.1       noro      629: }
                    630:
1.24      saito     631: void Pplotover(NODE arg,Obj *rp){
                    632:        Q s_id,w_id,color;
1.1       noro      633:        P poly;
                    634:        STRING fname;
1.13      noro      635:        Obj t;
1.24      saito     636:        poly=(P)ARG0(arg);
                    637:        s_id=(Q)ARG1(arg);
                    638:        w_id=(Q)ARG2(arg);
                    639:        if(argc(arg)==4)color=(Q)ARG3(arg);
                    640:        else color=0;
1.26      saito     641:        MKSTR(fname,PLOTOVER);
1.24      saito     642:        arg=mknode(5,s_id,fname,w_id,poly,color);
1.13      noro      643:        Pox_rpc(arg,&t);
1.24      saito     644:        *rp=(Obj)s_id;
1.1       noro      645: }
                    646:
1.24      saito     647: void Pdrawcircle(NODE arg,Obj *rp){
1.9       noro      648:        Q s_id,index;
1.24      saito     649:        Obj x,y,r,c,t;
1.1       noro      650:        STRING fname;
                    651:        NODE n;
                    652:        LIST pos;
                    653:
1.24      saito     654:        x=(Obj)ARG0(arg);
                    655:        y=(Obj)ARG1(arg);
                    656:        r=(Obj)ARG2(arg);
                    657:        c=(Obj)ARG3(arg);
                    658:        s_id=(Q)ARG4(arg);
                    659:        index=(Q)ARG5(arg);
1.26      saito     660:        MKSTR(fname,DRAWCIRCLE);
1.24      saito     661:        n=mknode(3,x,y,r,c);
                    662:        MKLIST(pos,n);
                    663:        arg=mknode(5,s_id,fname,index,pos,c);
1.13      noro      664:        Pox_rpc(arg,&t);
1.24      saito     665:        *rp=(Obj)s_id;
1.6       noro      666: }
                    667:
1.24      saito     668: void Pdraw_obj(NODE arg,Obj *rp){
1.6       noro      669:        static STRING fname;
1.9       noro      670:        Q s_id,index;
1.6       noro      671:        LIST obj;
1.13      noro      672:        Obj t;
1.6       noro      673:
1.26      saito     674:        if(!fname)MKSTR(fname,DRAW_OBJ);
1.24      saito     675:        s_id=(Q)ARG0(arg);
                    676:        index=(Q)ARG1(arg);
                    677:        obj=(LIST)ARG2(arg);
                    678:        // ARG3(arg)=color
                    679:        if(argc(arg)==4) arg=mknode(5,s_id,fname,index,obj,ARG3(arg));
                    680:        else arg=mknode(4,s_id,fname,index,obj);
1.13      noro      681:        Pox_cmo_rpc(arg,&t);
1.24      saito     682:        *rp=(Obj)s_id;
1.12      noro      683: }
                    684:
1.24      saito     685: void Pdraw_string(NODE arg,Obj *rp){
1.12      noro      686:        static STRING fname;
                    687:        STRING str;
                    688:        Q s_id,index;
                    689:        LIST pos;
1.13      noro      690:        Obj t;
1.12      noro      691:
1.26      saito     692:        if(!fname)MKSTR(fname,DRAW_STRING);
1.24      saito     693:        s_id=(Q)ARG0(arg);
                    694:        index=(Q)ARG1(arg);
                    695:        pos=(LIST)ARG2(arg);
                    696:        str=(STRING)ARG3(arg);
                    697:        // ARG4(arg)=color
                    698:        if(argc(arg)==5) arg=mknode(6,s_id,fname,index,pos,str,ARG4(arg));
                    699:        else arg=mknode(5,s_id,fname,index,pos,str);
1.13      noro      700:        Pox_cmo_rpc(arg,&t);
1.24      saito     701:        *rp=(Obj)s_id;
1.6       noro      702: }
                    703:
1.24      saito     704: void Pclear_canvas(NODE arg,Obj *rp){
1.6       noro      705:        static STRING fname;
1.9       noro      706:        Q s_id,index;
1.13      noro      707:        Obj t;
1.6       noro      708:
1.26      saito     709:        if(!fname) MKSTR(fname,CLEAR_CANVAS);
1.24      saito     710:        s_id=(Q)ARG0(arg);
                    711:        index=(Q)ARG1(arg);
                    712:        arg=mknode(3,s_id,fname,index);
                    713:        Pox_cmo_rpc(arg,&t);
                    714:        *rp=(Obj)s_id;
                    715: }
                    716: //****************************ifplotNG
                    717: /*
                    718:  * name ifplot,ineqn,ineqnor,ineqnand,ineqnxor,conplot
                    719:  * type
                    720:  *  D:sign character using double
                    721:  *  Q:sign character use rational
                    722:  *  B:Boundary character use sturm theorem
                    723:  */
                    724: void ListCheck(char * head,LIST list){
                    725:        int i;
                    726:        NODE n;
                    727:        if(!list){
1.26      saito     728:                printf("%s zero \n",head);
1.24      saito     729:                return;
                    730:        }
1.26      saito     731:        for(i=0,n=(NODE)BDY(list);n;i++,n=NEXT(n));
                    732:        printf("%s length %d\n",head,i);
1.24      saito     733:        for(i=0,n=(NODE)BDY(list);n;i++,n=NEXT(n)){
                    734:                if(!BDY(n))printf("%d 0\n",i);
                    735:                else if(OID(BDY(n))==O_P) printf("%d poly\n",i);
1.26      saito     736:                else if(OID(BDY(n))==O_R) printf("%d real\n",i);
                    737:                else if(OID(BDY(n))==O_N) printf("%d %d\n",i,QTOS((Q)BDY(n)));
1.6       noro      738:        }
1.1       noro      739: }
                    740:
1.26      saito     741: void PifplotD(NODE arg,Obj *rp){ifplot_mainNG(arg,IFPLOTD,rp);}
                    742: void PifplotQ(NODE arg,Obj *rp){ifplot_mainNG(arg,IFPLOTQ,rp);}
                    743: void PifplotB(NODE arg,Obj *rp){ifplot_mainNG(arg,IFPLOTB,rp);}
1.24      saito     744:
1.26      saito     745: void PconplotD(NODE arg,Obj *rp){ifplot_mainNG(arg,CONPLOTD,rp);}
                    746: void PconplotQ(NODE arg,Obj *rp){ifplot_mainNG(arg,CONPLOTQ,rp);}
                    747: void PconplotB(NODE arg,Obj *rp){ifplot_mainNG(arg,CONPLOTB,rp);}
1.24      saito     748:
1.26      saito     749: void PineqnD(NODE arg,Obj *rp){ifplot_mainNG(arg,INEQND,rp);}
                    750: void PineqnQ(NODE arg,Obj *rp){ifplot_mainNG(arg,INEQNQ,rp);}
                    751: void PineqnB(NODE arg,Obj *rp){ifplot_mainNG(arg,INEQNB,rp);}
1.24      saito     752:
                    753: #if defined(INTERVAL)
1.26      saito     754: void Pitvifplot(NODE arg,Obj *rp){ifplot_mainNG(arg,ITVIFPLOT,rp);}
1.24      saito     755: #endif
                    756:
1.26      saito     757: void PineqnorD(NODE arg,Obj *rp){plotover_mainNG(arg,INEQNDOR,rp);}
                    758: void PineqnorQ(NODE arg,Obj *rp){plotover_mainNG(arg,INEQNQOR,rp);}
                    759: void PineqnorB(NODE arg,Obj *rp){plotover_mainNG(arg,INEQNBOR,rp);}
                    760:
                    761: void PineqnandD(NODE arg,Obj *rp){plotover_mainNG(arg,INEQNDAND,rp);}
                    762: void PineqnandQ(NODE arg,Obj *rp){plotover_mainNG(arg,INEQNQAND,rp);}
                    763: void PineqnandB(NODE arg,Obj *rp){plotover_mainNG(arg,INEQNBAND,rp);}
                    764:
                    765: void PineqnxorD(NODE arg,Obj *rp){plotover_mainNG(arg,INEQNDXOR,rp);}
                    766: void PineqnxorQ(NODE arg,Obj *rp){plotover_mainNG(arg,INEQNQXOR,rp);}
                    767: void PineqnxorB(NODE arg,Obj *rp){plotover_mainNG(arg,INEQNBXOR,rp);}
                    768:
                    769: void PplotoverD(NODE arg,Obj *rp){plotover_mainNG(arg,PLOTOVERD,rp);}
                    770: void PplotoverQ(NODE arg,Obj *rp){plotover_mainNG(arg,PLOTOVERQ,rp);}
                    771: void PplotoverB(NODE arg,Obj *rp){plotover_mainNG(arg,PLOTOVERB,rp);}
1.24      saito     772:
1.29      saito     773: void Pobj_cp(NODE arg,Obj *rp){
                    774:        //copy canvas
                    775:        //1:and,3:copy,6:xor,7:or
                    776:        Q sysid,index_A,index_B,op_code;
                    777:        STRING fname;
                    778:        Obj t;
                    779:        sysid=(Q)ARG0(arg);
                    780:        index_A=(Q)ARG1(arg);
                    781:        index_B=(Q)ARG2(arg);
                    782:        op_code=(Q)ARG3(arg);
                    783:        MKSTR(fname,OBJ_CP);
                    784:        arg=mknode(5,sysid,fname,index_A,index_B,op_code);
                    785:        Pox_rpc(arg,&t);
                    786:        *rp=(Obj)sysid;
                    787: }
                    788:
                    789: void PpolarplotD(NODE arg,Obj *rp){
                    790:        Q m2,p2,w300,defstep,s_id,color;
                    791:        NODE defrange,n,n0,n1,n2;
                    792:        LIST range,geom,list[2];
                    793:        VL vl,vl0;
                    794:        V v[1],av;
                    795:        int stream,ri,i,len,iNo,lNo,vNo,sNo,pfine,findG;
                    796:        P poly,var;
                    797:        STRING fname,wname;
                    798:        Real pi2;
                    799:        Obj t,frst,sec,thr;
                    800:        char ebuf[BUFSIZ];
                    801:
                    802:        iNo=lNo=sNo=findG=0;pfine=TRUE;
                    803:        poly=0;vl=0;geom=0;wname=0;color=0;stream=-1;ri=0;v[0]=0;
                    804:        for(;arg;arg=NEXT(arg)){
                    805:                if(!BDY(arg)) iNo++;
                    806:                else switch(OID(BDY(arg))){
                    807:                case O_P: case O_R://formular
                    808:                        poly=(P)BDY(arg);
                    809:                        get_vars_recursive((Obj)poly,&vl);
                    810:                        for(vl0=vl,vNo=0;vl0;vl0=NEXT(vl0)){
                    811:                                if(vl0->v->attr==(pointer)V_IND){
                    812:                                        if(vNo>=1){
                    813:                                                sprintf(ebuf,"%s : invalaid argument",POLARPLOT);
                    814:                                                error(ebuf);
                    815:                                        } else v[vNo++]=vl0->v;
                    816:                                }
                    817:                        }
                    818:                        if(vNo!=1){
                    819:                                sprintf(ebuf,"%s : only uni-variate formular",POLARPLOT);
                    820:                                error(ebuf);
                    821:                        }
                    822:                        break;
                    823:                case O_N://color,id,idx,division
                    824:                        switch (iNo){
                    825:                        case 0://color arg
                    826:                                color=(Q)BDY(arg);
                    827:                                iNo++;
                    828:                                break;
                    829:                        case 1://stream arg
                    830:                                stream=QTOS((Q)BDY(arg));
                    831:                                iNo++;
                    832:                                break;
                    833:                        default://error
                    834:                                sprintf(ebuf,"%s : invalid number arguments",POLARPLOT);
                    835:                                error(ebuf);
                    836:                                break;
                    837:                        }
                    838:                        break;
                    839:                case O_LIST://range,geomerty
                    840:                        if(lNo<2)list[lNo++]=(LIST)BDY(arg);
                    841:                        else {
                    842:                                sprintf(ebuf,"%s : invalid list argument",POLARPLOT);
                    843:                                error(ebuf);
                    844:                        }
                    845:                        break;
                    846:                case O_STR://wname
                    847:                        wname=(STRING)BDY(arg);
                    848:                        sNo++;
                    849:                        break;
                    850:                default:
                    851:                        break;
                    852:                }
                    853:        }
                    854:        //formular check
                    855:        if(!poly){
1.30      saito     856:                sprintf(ebuf,"%s : invalid plot argument",POLARPLOT);
1.29      saito     857:                error(ebuf);
                    858:        }
                    859:        //vars check
                    860:        get_vars_recursive((Obj)poly,&vl);
                    861:        for(vl0=vl,vNo=0;vl0;vNo++,vl0=NEXT(vl0)){
                    862:                if(vl0->v->attr==(pointer)V_IND){
                    863:                        if(vNo>=2){
1.30      saito     864:                                sprintf(ebuf,"%s : invalid plot argument",POLARPLOT);
1.29      saito     865:                                error(ebuf);
                    866:                        } else v[vNo]=vl0->v;
                    867:                }
                    868:        }
                    869:        //list check
                    870:        for(i=0;i<lNo;i++){
                    871:                if(OID(BDY(BDY(list[i])))!=O_P){
                    872:                        // list first value is number (geometry)
                    873:                        for(len=0,n=(NODE)BDY(list[i]);n;len++,n=NEXT(n)){
                    874:                                if(len==0) frst=BDY(n);
                    875:                                else if(len==1) sec=BDY(n);
                    876:                                else {
                    877:                                        sprintf(ebuf,"%s : geometry list too long",POLARPLOT);
                    878:                                        error(ebuf);
                    879:                                }
                    880:                        }
                    881:                        if(len!=2){
                    882:                                sprintf(ebuf,"%s : geometry requierd 2 numbers", POLARPLOT);
                    883:                                error(ebuf);
                    884:                        } else geom=list[i];
                    885:                } else {
                    886:                        //list first value is var (range)
                    887:                        av=VR((P)BDY(BDY(list[i])));
                    888:                        if(v[0]==av)range=list[i];
                    889:                        else {
                    890:                                sprintf(ebuf,"%s : invalid list length",POLARPLOT);
                    891:                                error(ebuf);
                    892:                        }
                    893:                }
                    894:        }
                    895:        // set default
                    896:        if(!range){
                    897:                STOQ(DEFAULTPOLARSTEP,defstep);MKReal(2*Pi,pi2);MKV(v[0],var);
                    898:                MKNODE(n,defstep,0);MKNODE(n1,pi2,n);MKNODE(n2,0,n1);
                    899:                MKNODE(defrange,var,n2);MKLIST(range,defrange);
                    900:        }
                    901:        if(!geom){
                    902:                STOQ(300,w300);MKNODE(n0,w300,0);MKNODE(n,w300,n0);MKLIST(geom,n);
                    903:        }
                    904:        stream=validate_ox_plot_stream(stream);
                    905:        STOQ(stream,s_id);
                    906:        MKSTR(fname,POLARPLOTD);
                    907:        arg=mknode(7,s_id,fname,poly,color,range,geom,wname);
                    908:        Pox_rpc(arg,&t);
                    909:        *rp=(Obj)s_id;
                    910: }
                    911:
1.26      saito     912: void ifplot_mainNG(NODE arg,char *fn,Obj *rp){
                    913:        Q m2,p2,w300,mxgc,s_id,color;
1.24      saito     914:        NODE defrange,n,n0,n1,n2;
                    915:        P poly,var;
                    916:        VL vl,vl0;
                    917:        V v[2],av;
                    918:        LIST xrange,yrange,zrange,geom,range[2],list[4];
                    919:        int stream,ri,i,j,sign,llen,len,iNo,lNo,vNo,sNo,pfine,findG;
                    920:        STRING fname,wname;
                    921:        Obj t,frst,sec,thr;
                    922:        char ebuf[BUFSIZ];
                    923:
                    924:        iNo=lNo=sNo=findG=0;pfine=TRUE;
1.26      saito     925:        poly=0;stream=-1;wname=0;color=0;stream=0;
1.24      saito     926:        STOQ(-2,m2);STOQ(2,p2);MKNODE(n,p2,0);MKNODE(defrange,m2,n);
                    927:        STOQ(MAXGC,mxgc);
                    928:        for(;arg;arg=NEXT(arg)){
                    929:                if(!BDY(arg)) iNo++;
                    930:                else switch(OID(BDY(arg))){
                    931:                case O_P://formular
                    932:                        if(pfine){
                    933:                                poly=(P)BDY(arg);
                    934:                                pfine=FALSE;
                    935:                        } else {
1.30      saito     936:                                sprintf(ebuf,"%s : to many plot arguments",fn);
1.24      saito     937:                                error(ebuf);
                    938:                        }
                    939:                        break;
                    940:                case O_N://color,id,idx,division
                    941:                        switch (iNo){
                    942:                        case 0: //color arg
                    943:                                color=(Q)BDY(arg);
                    944:                                iNo++;
                    945:                                break;
                    946:                        case 1: //stream arg
                    947:                                stream=QTOS((Q)BDY(arg));
                    948:                                iNo++;
                    949:                                break;
1.26      saito     950:                        default:
                    951:                                sprintf(ebuf,"%s : invalid number arguments",fn);
1.24      saito     952:                                error(ebuf);
                    953:                                break;
                    954:                        }
                    955:                        break;
                    956:                case O_LIST://xrange,yrange,zrange,geometry
                    957:                        if(lNo<4) list[lNo++]=(LIST)BDY(arg);
                    958:                        else {
1.26      saito     959:                                sprintf(ebuf,"%s : invalid list argument",fn);
1.24      saito     960:                                error(ebuf);
                    961:                        }
                    962:                        break;
                    963:                case O_STR://wname
                    964:                        wname=(STRING)BDY(arg);
                    965:                        sNo++;
                    966:                        break;
                    967:                default:
                    968:                        break;
                    969:                }
                    970:        }
                    971:        // formular check
                    972:        if(!poly){
1.30      saito     973:                sprintf(ebuf,"%s : invalid plot argument",fn);
1.24      saito     974:                error(ebuf);
                    975:        }
                    976:        // vars check
                    977:        get_vars_recursive((Obj)poly,&vl);
1.26      saito     978:        for(vl0=vl,vNo=0;vl0;vl0=NEXT(vl0)){
                    979:                if(vl0->v->attr==(pointer)V_IND){
1.24      saito     980:                        if(vNo>=2){
1.30      saito     981:                                sprintf(ebuf,"%s : invalid plot argument",fn);
1.24      saito     982:                                error(ebuf);
                    983:                        } else v[vNo++]=vl0->v;
1.26      saito     984:                }
                    985:        }
1.24      saito     986:        //list check
                    987:        xrange=yrange=zrange=geom=0;frst=sec=thr=0;
                    988:        for(i=0;i<lNo;i++){
                    989:                for(llen=0,n=(NODE)BDY(list[i]);n;llen++,n=NEXT(n));
                    990:                if(llen>4){
1.26      saito     991:                        sprintf(ebuf,"%s : invalid list length",fn);
1.24      saito     992:                        error(ebuf);
                    993:                }
                    994:                if(OID(BDY(BDY(list[i])))!=O_P){
                    995:                        // First list value is number
                    996:                        for(len=0,n=(NODE)BDY(list[i]);n;len++,n=NEXT(n)){
                    997:                                if(len==0)frst=BDY(n);
                    998:                                else if(len==1)sec=BDY(n);
                    999:                                else thr=BDY(n);
                   1000:                        }
                   1001:                        switch(len){
                   1002:                        case 2:
1.26      saito    1003:                                if(!strcmp(fn,CONPLOT)){
1.24      saito    1004:                                        if(thr==0)thr=(Obj)mxgc;
                   1005:                                        MKNODE(n,thr,0);MKNODE(n1,sec,n);MKNODE(n2,frst,n1);MKLIST(zrange,n2);
                   1006:                                } else geom=list[i];
                   1007:                                break;
                   1008:                        case 3:
                   1009:                                zrange=list[i];
                   1010:                                break;
                   1011:                        case 0:
                   1012:                        case 1:
                   1013:                        default:
1.26      saito    1014:                                sprintf(ebuf,"%s : invalid list length",fn);
1.24      saito    1015:                                error(ebuf);
                   1016:                                break;
                   1017:                        }
                   1018:                } else {
                   1019:                        //xrange,yrange
                   1020:                        av=VR((P)BDY(BDY(list[i])));
                   1021:                        if(v[0]==av)xrange=list[i];
                   1022:                        else if(v[1]==av)yrange=list[i];
                   1023:                        else {
                   1024:                                MKLIST(zrange,NEXT(BDY(list[i])));
                   1025:                        }
                   1026:                }
                   1027:        }
                   1028:        //set default
                   1029:        if(!xrange){
                   1030:                MKV(v[0],var);MKNODE(n,var,defrange);MKLIST(xrange,n);
                   1031:        }
                   1032:        if(!yrange){
                   1033:                MKV(v[1],var);MKNODE(n,var,defrange);MKLIST(yrange,n);
                   1034:        }
                   1035:        if(!geom){
                   1036:                STOQ(300,w300);MKNODE(n0,w300,0);MKNODE(n,w300,n0);MKLIST(geom,n);
                   1037:        }
1.26      saito    1038:        if(!(strcmp(fn,CONPLOTD)&strcmp(fn,CONPLOTQ)&strcmp(fn,CONPLOTB))&!zrange){
1.24      saito    1039:                MKNODE(n,mxgc,0);MKNODE(n1,m2,n);MKNODE(n2,m2,n1);MKLIST(zrange,n2);
                   1040:        }
                   1041:        /*new ifplot in ox_plot requires
                   1042:                [s_id (Q),
                   1043:                formula (Obj),
                   1044:                color (Q),
                   1045:                geom=[xsize,ysize] (LIST optional),
                   1046:                xrange=[x,xmin,xmax] (LIST optional),
                   1047:                yrange=[y,ymin,ymax] (LIST optional),
                   1048:                zrange=[zmin,zmax,zstep] (LIST optional),
                   1049:                wname=name (STRING optional)],
1.26      saito    1050:                itvstep (Q) if ITVIFPLOT */
1.24      saito    1051:        stream=validate_ox_plot_stream(stream);
                   1052:        STOQ(stream,s_id);
1.26      saito    1053:        MKSTR(fname,fn);
                   1054:        arg=mknode(9,s_id,fname,poly,color,xrange,yrange,zrange,geom,wname);
1.24      saito    1055:        Pox_rpc(arg,&t);
                   1056:        *rp=(Obj)s_id;
                   1057: }
                   1058:
1.26      saito    1059: void plotover_mainNG(NODE arg,char *fn,Obj *rp){
1.24      saito    1060:        Q s_id,w_id,color;
                   1061:        P poly;
                   1062:        STRING fname;
                   1063:        Obj t;
                   1064:        int iNo,pfine,sfine;
                   1065:        char ebuf[BUFSIZ];
                   1066:
                   1067:        pfine=sfine=TRUE;
                   1068:        iNo=0;poly=0;color=s_id=w_id=0;
                   1069:        for(;arg;arg=NEXT(arg)){
                   1070:                if(!BDY(arg)) iNo++;
                   1071:                else switch(OID(BDY(arg))){
                   1072:                case O_P://formular
                   1073:                        if(pfine){
                   1074:                                poly=(P)BDY(arg);
                   1075:                                pfine=FALSE;
                   1076:                        } else {
1.30      saito    1077:                                sprintf(ebuf,"%s : to many plot arguments",fn);
1.24      saito    1078:                                error(ebuf);
                   1079:                        }
                   1080:                        break;
                   1081:                case O_N://color,s_id,w_id
                   1082:                        switch(iNo){
                   1083:                        case 0://color arg
                   1084:                                color=(Q)BDY(arg);
                   1085:                                iNo++;
                   1086:                                break;
                   1087:                        case 1://stream arg
                   1088:                                s_id=(Q)BDY(arg);
                   1089:                                iNo++;
                   1090:                                break;
                   1091:                        case 2://window arg
                   1092:                                w_id=(Q)BDY(arg);
                   1093:                                iNo++;
                   1094:                                break;
                   1095:                        default://error
1.26      saito    1096:                                sprintf(ebuf,"%s : to many numbers",fn);
1.24      saito    1097:                                error(ebuf);
                   1098:                                break;
                   1099:                        }
                   1100:                        break;
                   1101:                default:
1.26      saito    1102:                        sprintf(ebuf,"%s : arguments type miss match",fn);
1.24      saito    1103:                        error(ebuf);
                   1104:                }
                   1105:        }
1.26      saito    1106:        MKSTR(fname,fn);
1.29      saito    1107:        //[s_id (Q), w_id (Q), formula (Obj), color (Q)]
1.24      saito    1108:        arg=mknode(5,s_id,fname,w_id,poly,color);
                   1109:        Pox_rpc(arg,&t);
                   1110:        *rp=(Obj)s_id;
1.1       noro     1111: }

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