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

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

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