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