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

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

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