Annotation of OpenXM_contrib2/asir2000/plot/plotf.c, Revision 1.22
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.22 ! saito 48: * $OpenXM: OpenXM_contrib2/asir2000/plot/plotf.c,v 1.21 2011/06/16 08:17:15 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.22 ! saito 55: void Pifplot(NODE, Obj *), Pconplot(NODE, Obj *), Pplotover(NODE, Q *);
! 56: void Pplot(NODE, Obj *), Parrayplot(NODE, Q *), Pdrawcircle(NODE, Q *);
! 57: #if defined(INTERVAL)
! 58: void Pitvplot1(NODE, Obj *), itvplot_main1(NODE, Obj *); //NORMAL
! 59: void Pitvplot2(NODE, Obj *), itvplot_main2(NODE, Obj *); //TRANSFER
! 60: void Pitvplot3(NODE, Obj *), itvplot_main3(NODE, Obj *); //RECURSION
! 61: void Pitvplot4(NODE, Obj *), itvplot_main4(NODE, Obj *); //RECURSION+TRANSFER
! 62: void Pitvplot(NODE, Obj *), itvplot_main(NODE, Obj *); //NEWTYPE
! 63: void Pobj_cp(NODE, Obj *);
! 64: void Pineqn(NODE, Obj *), Pineqnor(NODE, Obj *), Pineqnand(NODE, Obj *);
! 65: void Pineqnxor(NODE, Obj *), Pmemory_ineqn(NODE, Obj *);
! 66: void ineqn_main(NODE, int, Obj *);
! 67: void ineqn_main_op(NODE, int, int, Obj *);
! 68: #endif
! 69: void Ppolarplot(NODE, Q *);
! 70: void Pmemory_ifplot(NODE, Obj *), Pmemory_conplot(NODE, Obj *);
! 71: void Pmemory_plot(NODE, Obj *);
! 72: void Popen_canvas(NODE, Q *), Pclear_canvas(NODE, Q *), Pdraw_obj(NODE, Q *);
! 73: void Pdraw_string(NODE, Q *);
! 74: void Pox_rpc(), Pox_cmo_rpc();
! 75: void ifplot_main(NODE, int, Obj *);
! 76: void conplot_main(NODE, int, Obj *);
! 77: void plot_main(NODE, int, Obj *);
1.1 noro 78:
79: struct ftab plot_tab[] = {
80: {"ifplot",Pifplot,-7},
1.18 noro 81: {"memory_ifplot",Pmemory_ifplot,-6},
1.22 ! saito 82: #if defined(INTERVAL)
! 83: {"itvplot1",Pitvplot1,-7},
! 84: {"itvplot2",Pitvplot2,-7},
! 85: {"itvplot3",Pitvplot3,-7},
! 86: {"itvplot4",Pitvplot4,-7},
! 87: {"itvplot",Pitvplot,-7},
! 88: {"ineqn",Pineqn,-8},
! 89: {"ineqnor",Pineqnor,-7},
! 90: {"ineqnand",Pineqnand,-7},
! 91: {"ineqnxor",Pineqnxor,-7},
! 92: {"memory_ineqn",Pmemory_ineqn,-6},
! 93: {"obj_cp",Pobj_cp,4},
! 94: #endif
1.1 noro 95: {"conplot",Pconplot,-8},
1.18 noro 96: {"memory_conplot",Pmemory_conplot,-7},
1.1 noro 97: {"plot",Pplot,-6},
1.18 noro 98: {"memory_plot",Pmemory_plot,-5},
1.15 noro 99: {"polarplot",Ppolarplot,-6},
1.17 noro 100: {"plotover",Pplotover,-4},
1.19 saito 101: {"drawcircle",Pdrawcircle,6},
1.6 noro 102: {"open_canvas",Popen_canvas,-3},
103: {"clear_canvas",Pclear_canvas,2},
1.7 noro 104: {"draw_obj",Pdraw_obj,-4},
1.12 noro 105: {"draw_string",Pdraw_string,-5},
1.1 noro 106: {0,0,0},
107: };
108:
1.16 noro 109: void Popen_canvas(NODE arg,Q *rp)
1.6 noro 110: {
1.9 noro 111: Q w300,s_id;
1.6 noro 112: LIST geom;
1.11 noro 113: int stream;
1.6 noro 114: NODE n,n0;
115: STRING fname,wname;
116:
117: geom = 0; wname = 0; stream = -1;
118: for ( ; arg; arg = NEXT(arg) )
119: if ( !BDY(arg) )
120: stream = 0;
121: else
122: switch ( OID(BDY(arg)) ) {
1.22 ! saito 123: case O_LIST:
! 124: geom = (LIST)BDY(arg);
! 125: break;
! 126: case O_N:
! 127: stream = QTOS((Q)BDY(arg)); break;
! 128: case O_STR:
! 129: wname = (STRING)BDY(arg); break;
! 130: default:
! 131: error("open_canvas : invalid argument"); break;
1.6 noro 132: }
1.13 noro 133: stream = validate_ox_plot_stream(stream);
1.9 noro 134: STOQ(stream,s_id);
1.6 noro 135: if ( !geom ) {
136: STOQ(300,w300);
137: MKNODE(n0,w300,0); MKNODE(n,w300,n0); MKLIST(geom,n);
138: }
139: MKSTR(fname,"open_canvas");
1.9 noro 140: arg = mknode(4,s_id,fname,geom,wname);
1.6 noro 141: Pox_cmo_rpc(arg,rp);
1.16 noro 142: *rp = s_id;
1.6 noro 143: }
144:
1.18 noro 145: void Pifplot(NODE arg,Obj *rp)
146: {
147: ifplot_main(arg,0,rp);
148: }
149:
150: void Pmemory_ifplot(NODE arg,Obj *rp)
151: {
152: ifplot_main(arg,1,rp);
153: }
154:
155: void ifplot_main(NODE arg,int is_memory, Obj *rp)
1.1 noro 156: {
1.9 noro 157: Q m2,p2,w300,s_id;
1.1 noro 158: NODE defrange;
159: LIST xrange,yrange,range[2],list,geom;
160: VL vl,vl0;
161: V v[2],av[2];
1.22 ! saito 162: int stream,ri,i,sign;
! 163: P poly;
! 164: P var;
! 165: NODE n,n0;
! 166: STRING fname,wname;
! 167: Obj t;
! 168:
! 169: STOQ(-2,m2); STOQ(2,p2);
! 170: MKNODE(n,p2,0); MKNODE(defrange,m2,n);
! 171: poly = 0; vl = 0; geom = 0; wname = 0; stream = -1; ri = 0;
! 172: v[0] = v[1] = 0;
! 173: for ( ; arg; arg = NEXT(arg) )
! 174: if ( !BDY(arg) ) stream = 0;
! 175: else
! 176: switch ( OID(BDY(arg)) ) {
! 177: case O_P:
! 178: poly = (P)BDY(arg);
! 179: get_vars_recursive((Obj)poly,&vl);
! 180: for ( vl0 = vl, i = 0; vl0; vl0 = NEXT(vl0) )
! 181: if ( vl0->v->attr == (pointer)V_IND )
! 182: if ( i >= 2 ) error("ifplot : invalid argument");
! 183: else v[i++] = vl0->v;
! 184: break;
! 185: case O_LIST:
! 186: list = (LIST)BDY(arg);
! 187: if ( OID(BDY(BDY(list))) == O_P )
! 188: if ( ri > 1 ) error("ifplot : invalid argument");
! 189: else range[ri++] = list;
! 190: else geom = list;
! 191: break;
! 192: case O_N:
! 193: stream = QTOS((Q)BDY(arg)); break;
! 194: case O_STR:
! 195: wname = (STRING)BDY(arg); break;
! 196: default:
! 197: error("ifplot : invalid argument"); break;
! 198: }
! 199: if ( !poly ) error("ifplot : invalid argument");
! 200: switch ( ri ) {
! 201: case 0:
! 202: if ( !v[1] ) error("ifplot : please specify all variables");
! 203: MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
! 204: MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
! 205: break;
! 206: case 1:
! 207: if ( !v[1] ) error("ifplot : please specify all variables");
! 208: av[0] = VR((P)BDY(BDY(range[0])));
! 209: if ( v[0] == av[0] ) {
! 210: xrange = range[0];
! 211: MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
! 212: } else if ( v[1] == av[0] ) {
! 213: MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
! 214: yrange = range[0];
! 215: } else error("ifplot : invalid argument");
! 216: break;
! 217: case 2:
! 218: av[0] = VR((P)BDY(BDY(range[0])));
! 219: av[1] = VR((P)BDY(BDY(range[1])));
! 220: if ( ((v[0] == av[0]) && (!v[1] || v[1] == av[1])) ||
! 221: ((v[0] == av[1]) && (!v[1] || v[1] == av[0])) ) {
! 222: xrange = range[0]; yrange = range[1];
! 223: } else error("ifplot : invalid argument");
! 224: break;
! 225: default:
! 226: error("ifplot : cannot happen"); break;
! 227: }
! 228: /* ifplot in ox_plot requires
! 229: [s_id (Q),
! 230: formula (Obj),
! 231: xrange=[x,xmin,xmax] (LIST),
! 232: yrange=[y,ymin,ymax] (LIST),
! 233: zrange=0,
! 234: geom=[xsize,ysize] (LIST),
! 235: wname=name (STRING)]
! 236: */
! 237:
! 238: stream = validate_ox_plot_stream(stream);
! 239: STOQ(stream,s_id);
! 240: if ( !geom ) {
! 241: STOQ(300,w300);
! 242: MKNODE(n0,w300,0); MKNODE(n,w300,n0); MKLIST(geom,n);
! 243: }
! 244: if ( is_memory ) {
! 245: MKSTR(fname,"memory_plot");
! 246: arg = mknode(8,s_id,fname,poly,xrange,yrange,0,geom);
! 247: Pox_rpc(arg,&t);
! 248: arg = mknode(1,s_id);
! 249: Pox_pop_cmo(arg,rp);
! 250: } else {
! 251: MKSTR(fname,"plot");
! 252: arg = mknode(8,s_id,fname,poly,xrange,yrange,0,geom,wname);
! 253: Pox_rpc(arg,&t);
! 254: *rp = (Obj)s_id;
! 255: }
! 256: }
! 257:
! 258: #if defined(INTERVAL)
! 259: void Pitvplot(NODE arg, Obj *rp)
! 260: {
! 261: itvplot_main(arg, rp);
! 262: }
! 263:
! 264: void itvplot_main(NODE arg, Obj *rp)
! 265: {
! 266: Q m2,p2,w300,s_id, itvsize;
! 267: NODE defrange;
! 268: LIST xrange,yrange,range[2],list,geom;
! 269: VL vl,vl0;
! 270: V v[2],av[2];
! 271: int stream,ri,i,sign;
! 272: P poly;
! 273: P var;
! 274: NODE n,n0;
! 275: STRING fname,wname;
! 276: Obj t;
! 277:
! 278: STOQ(-2,m2); STOQ(2,p2);
! 279: MKNODE(n,p2,0); MKNODE(defrange,m2,n);
! 280: poly = 0; vl = 0; geom = 0; wname = 0; stream = -1; ri = 0;
! 281: v[0] = v[1] = 0;
! 282: for ( ; arg; arg = NEXT(arg) )
! 283: if ( !BDY(arg) ) stream = 0;
! 284: else
! 285: switch ( OID(BDY(arg)) ) {
! 286: case O_P:
! 287: poly = (P)BDY(arg);
! 288: get_vars_recursive((Obj)poly,&vl);
! 289: for ( vl0 = vl, i = 0; vl0; vl0 = NEXT(vl0) )
! 290: if ( vl0->v->attr == (pointer)V_IND )
! 291: if ( i >= 2 ) error("itvplot : invalid argument");
! 292: else v[i++] = vl0->v;
! 293: break;
! 294: case O_LIST:
! 295: list = (LIST)BDY(arg);
! 296: if ( OID(BDY(BDY(list))) == O_P )
! 297: if ( ri > 1 ) error("itvplot : invalid argument");
! 298: else range[ri++] = list;
! 299: else geom = list;
! 300: break;
! 301: case O_N:
! 302: stream = QTOS((Q)BDY(arg)); break;
! 303: case O_STR:
! 304: wname = (STRING)BDY(arg); break;
! 305: default:
! 306: error("itvplot : invalid argument"); break;
! 307: }
! 308: if ( !poly ) error("itvplot : invalid argument");
! 309: switch ( ri ) {
! 310: case 0:
! 311: if ( !v[1] ) error("itvplot : please specify all variables");
! 312: MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
! 313: MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
! 314: break;
! 315: case 1:
! 316: if ( !v[1] ) error("itvplot : please specify all variables");
! 317: av[0] = VR((P)BDY(BDY(range[0])));
! 318: if ( v[0] == av[0] ) {
! 319: xrange = range[0];
! 320: MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
! 321: } else if ( v[1] == av[0] ) {
! 322: MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
! 323: yrange = range[0];
! 324: } else error("itvplot : invalid argument");
! 325: break;
! 326: case 2:
! 327: av[0] = VR((P)BDY(BDY(range[0])));
! 328: av[1] = VR((P)BDY(BDY(range[1])));
! 329: if ( ((v[0] == av[0]) && (!v[1] || v[1] == av[1])) ||
! 330: ((v[0] == av[1]) && (!v[1] || v[1] == av[0])) ) {
! 331: xrange = range[0]; yrange = range[1];
! 332: } else error("itvplot : invalid argument");
! 333: break;
! 334: default:
! 335: error("itvplot : cannot happen"); break;
! 336: }
! 337: /* itvplot in ox_plot requires
! 338: [s_id (Q),
! 339: formula (Obj),
! 340: xrange=[x,xmin,xmax] (LIST),
! 341: yrange=[y,ymin,ymax] (LIST),
! 342: zrange=0,
! 343: geom=[xsize,ysize] (LIST),
! 344: wname=name (STRING)]
! 345: */
! 346: stream = validate_ox_plot_stream(stream);
! 347: STOQ(stream,s_id);
! 348: if ( !geom ) {
! 349: STOQ(300,w300);
! 350: MKNODE(n0,w300,0); MKNODE(n,w300,n0); MKLIST(geom,n);
! 351: }
! 352: MKSTR(fname,"itvifplot");
! 353: STOQ(Itvplot, itvsize);
! 354: arg = mknode(9,s_id,fname,poly,xrange,yrange,0,geom,wname,itvsize);
! 355: Pox_rpc(arg,&t);
! 356: *rp = (Obj)s_id;
! 357: }
! 358:
! 359: void Pitvplot1(NODE arg, Obj *rp)
! 360: {
! 361: itvplot_main1(arg, rp);
! 362: }
! 363:
! 364: void Pitvplot2(NODE arg, Obj *rp)
! 365: {
! 366: itvplot_main2(arg, rp);
! 367: }
! 368:
! 369: void Pitvplot3(NODE arg, Obj *rp)
! 370: {
! 371: itvplot_main3(arg, rp);
! 372: }
! 373:
! 374: void Pitvplot4(NODE arg, Obj *rp)
! 375: {
! 376: itvplot_main4(arg, rp);
! 377: }
! 378:
! 379: // NORMAL type
! 380: void itvplot_main1(NODE arg, Obj *rp)
! 381: {
! 382: Q m2,p2,w300,s_id;
! 383: NODE defrange;
! 384: LIST xrange,yrange,range[2],list,geom;
! 385: VL vl,vl0;
! 386: V v[2],av[2];
! 387: int stream,ri,i,sign;
! 388: P poly;
! 389: P var;
! 390: NODE n,n0;
! 391: STRING fname,wname;
! 392: Obj t;
! 393:
! 394: STOQ(-2,m2); STOQ(2,p2);
! 395: MKNODE(n,p2,0); MKNODE(defrange,m2,n);
! 396: poly = 0; vl = 0; geom = 0; wname = 0; stream = -1; ri = 0;
! 397: v[0] = v[1] = 0;
! 398: for ( ; arg; arg = NEXT(arg) )
! 399: if ( !BDY(arg) ) stream = 0;
! 400: else
! 401: switch ( OID(BDY(arg)) ) {
! 402: case O_P:
! 403: poly = (P)BDY(arg);
! 404: get_vars_recursive((Obj)poly,&vl);
! 405: for ( vl0 = vl, i = 0; vl0; vl0 = NEXT(vl0) )
! 406: if ( vl0->v->attr == (pointer)V_IND )
! 407: if ( i >= 2 ) error("itvplot : invalid argument");
! 408: else v[i++] = vl0->v;
! 409: break;
! 410: case O_LIST:
! 411: list = (LIST)BDY(arg);
! 412: if ( OID(BDY(BDY(list))) == O_P )
! 413: if ( ri > 1 ) error("itvplot : invalid argument");
! 414: else range[ri++] = list;
! 415: else geom = list;
! 416: break;
! 417: case O_N:
! 418: stream = QTOS((Q)BDY(arg)); break;
! 419: case O_STR:
! 420: wname = (STRING)BDY(arg); break;
! 421: default:
! 422: error("itvplot : invalid argument"); break;
! 423: }
! 424: if ( !poly ) error("itvplot : invalid argument");
! 425: switch ( ri ) {
! 426: case 0:
! 427: if ( !v[1] ) error("itvplot : please specify all variables");
! 428: MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
! 429: MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
! 430: break;
! 431: case 1:
! 432: if ( !v[1] ) error("itvplot : please specify all variables");
! 433: av[0] = VR((P)BDY(BDY(range[0])));
! 434: if ( v[0] == av[0] ) {
! 435: xrange = range[0];
! 436: MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
! 437: } else if ( v[1] == av[0] ) {
! 438: MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
! 439: yrange = range[0];
! 440: } else error("itvplot : invalid argument");
! 441: break;
! 442: case 2:
! 443: av[0] = VR((P)BDY(BDY(range[0])));
! 444: av[1] = VR((P)BDY(BDY(range[1])));
! 445: if ( ((v[0] == av[0]) && (!v[1] || v[1] == av[1])) ||
! 446: ((v[0] == av[1]) && (!v[1] || v[1] == av[0])) ) {
! 447: xrange = range[0]; yrange = range[1];
! 448: } else error("itvplot : invalid argument");
! 449: break;
! 450: default:
! 451: error("itvplot : cannot happen"); break;
! 452: }
! 453: stream = validate_ox_plot_stream(stream);
! 454: STOQ(stream,s_id);
! 455: if ( !geom ) {
! 456: STOQ(300,w300);
! 457: MKNODE(n0,w300,0); MKNODE(n,w300,n0); MKLIST(geom,n);
! 458: }
! 459: MKSTR(fname,"itvplot1");
! 460: arg = mknode(8,s_id,fname,poly,xrange,yrange,0,geom,wname);
! 461: Pox_rpc(arg,&t);
! 462: *rp = (Obj)s_id;
! 463: }
! 464:
! 465: // TRANSFER TYPE
! 466: void itvplot_main2(NODE arg, Obj *rp)
! 467: {
! 468: Q m2,p2,w300,s_id;
! 469: NODE defrange;
! 470: LIST xrange,yrange,range[2],list,geom;
! 471: VL vl,vl0;
! 472: V v[2],av[2];
! 473: int stream,ri,i,sign;
! 474: P poly;
! 475: P var;
! 476: NODE n,n0;
! 477: STRING fname,wname;
! 478: Obj t;
! 479:
! 480: STOQ(-2,m2); STOQ(2,p2);
! 481: MKNODE(n,p2,0); MKNODE(defrange,m2,n);
! 482: poly = 0; vl = 0; geom = 0; wname = 0; stream = -1; ri = 0;
! 483: v[0] = v[1] = 0;
! 484: for ( ; arg; arg = NEXT(arg) )
! 485: if ( !BDY(arg) )
! 486: stream = 0;
! 487: else
! 488: switch ( OID(BDY(arg)) ) {
! 489: case O_P:
! 490: poly = (P)BDY(arg);
! 491: get_vars_recursive((Obj)poly,&vl);
! 492: for ( vl0 = vl, i = 0; vl0; vl0 = NEXT(vl0) )
! 493: if ( vl0->v->attr == (pointer)V_IND )
! 494: if ( i >= 2 )
! 495: error("itvplot : invalid argument");
! 496: else
! 497: v[i++] = vl0->v;
! 498: break;
! 499: case O_LIST:
! 500: list = (LIST)BDY(arg);
! 501: if ( OID(BDY(BDY(list))) == O_P )
! 502: if ( ri > 1 )
! 503: error("itvplot : invalid argument");
! 504: else
! 505: range[ri++] = list;
! 506: else
! 507: geom = list;
! 508: break;
! 509: case O_N:
! 510: stream = QTOS((Q)BDY(arg)); break;
! 511: case O_STR:
! 512: wname = (STRING)BDY(arg); break;
! 513: default:
! 514: error("itvplot : invalid argument"); break;
! 515: }
! 516: if ( !poly )
! 517: error("itvplot : invalid argument");
! 518: switch ( ri ) {
! 519: case 0:
! 520: if ( !v[1] )
! 521: error("itvplot : please specify all variables");
! 522: MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
! 523: MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
! 524: break;
! 525: case 1:
! 526: if ( !v[1] )
! 527: error("itvplot : please specify all variables");
! 528: av[0] = VR((P)BDY(BDY(range[0])));
! 529: if ( v[0] == av[0] ) {
! 530: xrange = range[0];
! 531: MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
! 532: } else if ( v[1] == av[0] ) {
! 533: MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
! 534: yrange = range[0];
! 535: } else
! 536: error("itvplot : invalid argument");
! 537: break;
! 538: case 2:
! 539: av[0] = VR((P)BDY(BDY(range[0])));
! 540: av[1] = VR((P)BDY(BDY(range[1])));
! 541: if ( ((v[0] == av[0]) && (!v[1] || v[1] == av[1])) ||
! 542: ((v[0] == av[1]) && (!v[1] || v[1] == av[0])) ) {
! 543: xrange = range[0]; yrange = range[1];
! 544: } else
! 545: error("itvplot : invalid argument");
! 546: break;
! 547: default:
! 548: error("itvplot : cannot happen"); break;
! 549: }
! 550: stream = validate_ox_plot_stream(stream);
! 551: STOQ(stream,s_id);
! 552: if ( !geom ) {
! 553: STOQ(300,w300);
! 554: MKNODE(n0,w300,0); MKNODE(n,w300,n0); MKLIST(geom,n);
! 555: }
! 556: MKSTR(fname,"itvplot2");
! 557: arg = mknode(8,s_id,fname,poly,xrange,yrange,0,geom,wname);
! 558: Pox_rpc(arg,&t);
! 559: *rp = (Obj)s_id;
! 560: }
! 561: // RECURSION TYPE
! 562: void itvplot_main3(NODE arg, Obj *rp)
! 563: {
! 564: Q m2,p2,w300,s_id, itvsize;
! 565: NODE defrange;
! 566: LIST xrange,yrange,range[2],list,geom;
! 567: VL vl,vl0;
! 568: V v[2],av[2];
! 569: int stream,ri,i,sign;
! 570: P poly;
! 571: P var;
! 572: NODE n,n0;
! 573: STRING fname,wname;
! 574: Obj t;
! 575:
! 576: STOQ(-2,m2); STOQ(2,p2);
! 577: MKNODE(n,p2,0); MKNODE(defrange,m2,n);
! 578: poly = 0; vl = 0; geom = 0; wname = 0; stream = -1; ri = 0;
! 579: v[0] = v[1] = 0;
! 580: for ( ; arg; arg = NEXT(arg) )
! 581: if ( !BDY(arg) )
! 582: stream = 0;
! 583: else
! 584: switch ( OID(BDY(arg)) ) {
! 585: case O_P:
! 586: poly = (P)BDY(arg);
! 587: get_vars_recursive((Obj)poly,&vl);
! 588: for ( vl0 = vl, i = 0; vl0; vl0 = NEXT(vl0) )
! 589: if ( vl0->v->attr == (pointer)V_IND )
! 590: if ( i >= 2 )
! 591: error("itvplot : invalid argument");
! 592: else
! 593: v[i++] = vl0->v;
! 594: break;
! 595: case O_LIST:
! 596: list = (LIST)BDY(arg);
! 597: if ( OID(BDY(BDY(list))) == O_P )
! 598: if ( ri > 1 )
! 599: error("itvplot : invalid argument");
! 600: else
! 601: range[ri++] = list;
! 602: else
! 603: geom = list;
! 604: break;
! 605: case O_N:
! 606: stream = QTOS((Q)BDY(arg)); break;
! 607: case O_STR:
! 608: wname = (STRING)BDY(arg); break;
! 609: default:
! 610: error("itvplot : invalid argument"); break;
! 611: }
! 612: if ( !poly )
! 613: error("itvplot : invalid argument");
! 614: switch ( ri ) {
! 615: case 0:
! 616: if ( !v[1] )
! 617: error("itvplot : please specify all variables");
! 618: MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
! 619: MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
! 620: break;
! 621: case 1:
! 622: if ( !v[1] )
! 623: error("itvplot : please specify all variables");
! 624: av[0] = VR((P)BDY(BDY(range[0])));
! 625: if ( v[0] == av[0] ) {
! 626: xrange = range[0];
! 627: MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
! 628: } else if ( v[1] == av[0] ) {
! 629: MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
! 630: yrange = range[0];
! 631: } else
! 632: error("itvplot : invalid argument");
! 633: break;
! 634: case 2:
! 635: av[0] = VR((P)BDY(BDY(range[0])));
! 636: av[1] = VR((P)BDY(BDY(range[1])));
! 637: if ( ((v[0] == av[0]) && (!v[1] || v[1] == av[1])) ||
! 638: ((v[0] == av[1]) && (!v[1] || v[1] == av[0])) ) {
! 639: xrange = range[0]; yrange = range[1];
! 640: } else
! 641: error("itvplot : invalid argument");
! 642: break;
! 643: default:
! 644: error("itvplot : cannot happen"); break;
! 645: }
! 646: stream = validate_ox_plot_stream(stream);
! 647: STOQ(stream,s_id);
! 648: if ( !geom ) {
! 649: STOQ(300,w300);
! 650: MKNODE(n0,w300,0); MKNODE(n,w300,n0); MKLIST(geom,n);
! 651: }
! 652: MKSTR(fname,"itvplot3");
! 653: STOQ(Itvplot, itvsize);
! 654: arg = mknode(9,s_id,fname,poly,xrange,yrange,0,geom,wname,itvsize);
! 655: Pox_rpc(arg,&t);
! 656: *rp = (Obj)s_id;
! 657: }
! 658: // RECURSION and TRANSFER TYPE
! 659: void itvplot_main4(NODE arg, Obj *rp)
! 660: {
! 661: Q m2,p2,w300,s_id,itvsize;
! 662: NODE defrange;
! 663: LIST xrange,yrange,range[2],list,geom;
! 664: VL vl,vl0;
! 665: V v[2],av[2];
! 666: int stream,ri,i,sign;
1.1 noro 667: P poly;
668: P var;
669: NODE n,n0;
670: STRING fname,wname;
1.13 noro 671: Obj t;
1.1 noro 672:
673: STOQ(-2,m2); STOQ(2,p2);
674: MKNODE(n,p2,0); MKNODE(defrange,m2,n);
675: poly = 0; vl = 0; geom = 0; wname = 0; stream = -1; ri = 0;
1.14 noro 676: v[0] = v[1] = 0;
1.1 noro 677: for ( ; arg; arg = NEXT(arg) )
678: if ( !BDY(arg) )
679: stream = 0;
680: else
681: switch ( OID(BDY(arg)) ) {
682: case O_P:
683: poly = (P)BDY(arg);
1.11 noro 684: get_vars_recursive((Obj)poly,&vl);
1.1 noro 685: for ( vl0 = vl, i = 0; vl0; vl0 = NEXT(vl0) )
1.11 noro 686: if ( vl0->v->attr == (pointer)V_IND )
1.1 noro 687: if ( i >= 2 )
1.22 ! saito 688: error("itvplot : invalid argument");
1.1 noro 689: else
690: v[i++] = vl0->v;
691: break;
692: case O_LIST:
693: list = (LIST)BDY(arg);
694: if ( OID(BDY(BDY(list))) == O_P )
695: if ( ri > 1 )
1.22 ! saito 696: error("itvplot : invalid argument");
1.1 noro 697: else
698: range[ri++] = list;
699: else
700: geom = list;
701: break;
702: case O_N:
703: stream = QTOS((Q)BDY(arg)); break;
704: case O_STR:
705: wname = (STRING)BDY(arg); break;
706: default:
1.22 ! saito 707: error("itvplot : invalid argument"); break;
1.1 noro 708: }
709: if ( !poly )
1.22 ! saito 710: error("itvplot : invalid argument");
1.1 noro 711: switch ( ri ) {
712: case 0:
713: if ( !v[1] )
1.22 ! saito 714: error("itvplot : please specify all variables");
1.1 noro 715: MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
716: MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
717: break;
718: case 1:
719: if ( !v[1] )
1.22 ! saito 720: error("itvplot : please specify all variables");
1.1 noro 721: av[0] = VR((P)BDY(BDY(range[0])));
722: if ( v[0] == av[0] ) {
723: xrange = range[0];
724: MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
725: } else if ( v[1] == av[0] ) {
726: MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
727: yrange = range[0];
728: } else
1.22 ! saito 729: error("itvplot : invalid argument");
1.1 noro 730: break;
731: case 2:
732: av[0] = VR((P)BDY(BDY(range[0])));
733: av[1] = VR((P)BDY(BDY(range[1])));
734: if ( ((v[0] == av[0]) && (!v[1] || v[1] == av[1])) ||
735: ((v[0] == av[1]) && (!v[1] || v[1] == av[0])) ) {
736: xrange = range[0]; yrange = range[1];
737: } else
1.22 ! saito 738: error("itvplot : invalid argument");
1.1 noro 739: break;
740: default:
1.22 ! saito 741: error("itvplot : cannot happen"); break;
1.1 noro 742: }
1.22 ! saito 743: /* itvplot in ox_plot requires
1.9 noro 744: [s_id (Q),
1.1 noro 745: formula (Obj),
746: xrange=[x,xmin,xmax] (LIST),
747: yrange=[y,ymin,ymax] (LIST),
748: zrange=0,
749: geom=[xsize,ysize] (LIST),
750: wname=name (STRING)]
751: */
752:
1.13 noro 753: stream = validate_ox_plot_stream(stream);
1.9 noro 754: STOQ(stream,s_id);
1.1 noro 755: if ( !geom ) {
756: STOQ(300,w300);
757: MKNODE(n0,w300,0); MKNODE(n,w300,n0); MKLIST(geom,n);
758: }
1.22 ! saito 759: MKSTR(fname,"itvplot4");
! 760: STOQ(Itvplot, itvsize);
! 761: arg = mknode(9,s_id,fname,poly,xrange,yrange,0,geom,wname,itvsize);
! 762: Pox_rpc(arg,&t);
! 763: *rp = (Obj)s_id;
! 764: }
! 765:
! 766: void Pineqn(NODE arg, Obj *rp)
! 767: {
! 768: ineqn_main(arg, 1, rp);
! 769: }
! 770:
! 771: void ineqn_main(NODE arg,int is_memory, Obj *rp)
! 772: {
! 773: Q s_id, m2, p2, w300, color;
! 774: NODE defrange, n, n0;
! 775: P poly, var;
! 776: VL vl, vl0;
! 777: V v[2], av[2];
! 778: LIST xrange, yrange, range[2], list, geom;
! 779: int stream, ri, i,sign;
! 780: STRING fname,wname;
! 781:
! 782: STOQ(-2,m2); STOQ(2,p2);
! 783: MKNODE(n,p2,0); MKNODE(defrange,m2,n);
! 784: poly = 0; vl = 0; geom = 0; wname = 0; stream = -1; ri = 0;
! 785: v[0] = v[1] = 0;
! 786: /* get polynomial */
! 787: if ( !(OID(BDY(arg)) == O_P || (OID(BDY(arg)) ==O_R)) )
! 788: error("ineqn : first argument must be a polynormial");
! 789: else {
! 790: poly = (P)BDY(arg);
! 791: /* get vars */
! 792: get_vars_recursive((Obj)poly,&vl);
! 793: for ( vl0 = vl, i = 0; vl0; vl0 = NEXT(vl0) )
! 794: if ( vl0->v->attr == (pointer)V_IND )
! 795: if ( i >= 2 )
! 796: error(
! 797: "ineqn : first argument must be a univariate or bivariate polynormial");
! 798: else
! 799: v[i++] = vl0->v;
! 800: }
! 801: /* get color */
! 802: arg = NEXT(arg);
! 803: if ( OID(BDY(arg)) != O_N )
! 804: error("ineqn : second argument must be color code");
! 805: else
! 806: color = (Q)BDY(arg);
! 807: /* other argument is optional */
! 808: arg = NEXT(arg);
! 809: for ( ; arg; arg = NEXT(arg) )
! 810: if ( !BDY(arg) )
! 811: stream = 0;
! 812: else
! 813: switch ( OID(BDY(arg)) ) {
! 814: case O_LIST:
! 815: list = (LIST)BDY(arg);
! 816: if ( OID(BDY(BDY(list))) == O_P )
! 817: if ( ri > 1 )
! 818: error("ineqn : invalid list argument");
! 819: else
! 820: range[ri++] = list;
! 821: else
! 822: geom = list;
! 823: break;
! 824: case O_N:
! 825: stream = QTOS((Q)BDY(arg)); break;
! 826: case O_STR:
! 827: wname = (STRING)BDY(arg); break;
! 828: default:
! 829: error("ineqn : invalid argument"); break;
! 830: }
! 831: switch ( ri ) {
! 832: case 0:
! 833: if ( !v[1] ) error("ineqn : please specify all variables");
! 834: MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
! 835: MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
! 836: break;
! 837: case 1:
! 838: if ( !v[1] ) error("ineqn : please specify all variables");
! 839: av[0] = VR((P)BDY(BDY(range[0])));
! 840: if ( v[0] == av[0] ) {
! 841: xrange = range[0];
! 842: MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
! 843: } else if ( v[1] == av[0] ) {
! 844: MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
! 845: yrange = range[0];
! 846: } else error("ineqn : invalid argument");
! 847: break;
! 848: case 2:
! 849: av[0] = VR((P)BDY(BDY(range[0])));
! 850: av[1] = VR((P)BDY(BDY(range[1])));
! 851: if ( ((v[0] == av[0]) && (!v[1] || v[1] == av[1])) ||
! 852: ((v[0] == av[1]) && (!v[1] || v[1] == av[0])) ) {
! 853: xrange = range[0]; yrange = range[1];
! 854: } else error("ineqn : invalid argument");
! 855: break;
! 856: default:
! 857: error("ineqn : cannot happen"); break;
! 858: }
! 859:
! 860: stream = validate_ox_plot_stream(stream);
! 861: STOQ(stream,s_id);
! 862: if ( !geom ) {
! 863: STOQ(300,w300);
! 864: MKNODE(n0,w300,0); MKNODE(n,w300,n0); MKLIST(geom,n);
1.18 noro 865: }
1.22 ! saito 866: MKSTR(fname, "ineqn");
! 867: arg = mknode(8, s_id, fname, poly, color, xrange, yrange, geom, wname);
! 868: Pox_cmo_rpc(arg,rp);
! 869: }
! 870:
! 871: void Pineqnor(NODE arg, Obj *rp)
! 872: {
! 873: ineqn_main_op(arg, 7, 0, rp);
1.10 noro 874: }
875:
1.22 ! saito 876: void Pineqnand(NODE arg, Obj *rp)
! 877: {
! 878: ineqn_main_op(arg, 1, 0, rp);
! 879: }
! 880:
! 881: void Pineqnxor(NODE arg, Obj *rp)
! 882: {
! 883: ineqn_main_op(arg, 6, 0, rp);
! 884: }
! 885:
! 886: void Pmemory_ineqn(NODE arg, Obj *rp)
! 887: {
! 888: ineqn_main(arg, 1, rp);
! 889: }
! 890:
! 891: void ineqn_main_op(NODE arg, int op, int is_memory, Obj *rp)
! 892: {
! 893: Q s_id, index, color, op_code;
! 894: P poly;
! 895: STRING fname;
! 896: Obj t;
! 897:
! 898: poly = (P)ARG0(arg);
! 899: color = (Q)ARG1(arg);
! 900: s_id = (Q)ARG2(arg);
! 901: index = (Q)ARG3(arg);
! 902: STOQ( op, op_code);
! 903: MKSTR(fname, "ineqnover");
! 904: arg = mknode(6, s_id, fname, index, poly, color, op_code);
! 905: Pox_rpc(arg, &t);
! 906: *rp = (Obj)s_id;
! 907: }
! 908:
! 909: void Pobj_cp(NODE arg, Obj *rp)
! 910: {
! 911: Q sysid, index_A, index_B, op_code;
! 912: STRING fname;
! 913: Obj t;
! 914:
! 915: sysid = (Q)ARG0(arg);
! 916: index_A = (Q)ARG1(arg);
! 917: index_B = (Q)ARG2(arg);
! 918: op_code = (Q)ARG3(arg);
! 919: MKSTR(fname, "objcp");
! 920: arg = mknode(5, sysid, fname, index_A, index_B, op_code);
! 921: Pox_rpc(arg, &t);
! 922: *rp = (Obj)sysid;
! 923: }
! 924: #endif
1.18 noro 925:
926: void Pconplot(NODE arg,Obj *rp)
1.10 noro 927: {
1.22 ! saito 928: conplot_main(arg, 0, rp);
1.18 noro 929: }
1.10 noro 930:
1.18 noro 931: void Pmemory_conplot(NODE arg,Obj *rp)
932: {
933: conplot_main(arg,1,rp);
1.1 noro 934: }
935:
1.18 noro 936: void conplot_main(NODE arg,int is_memory,Obj *rp)
1.1 noro 937: {
1.9 noro 938: Q m2,p2,w300,s_id;
1.1 noro 939: NODE defrange;
940: LIST xrange,yrange,zrange,range[3],list,geom;
941: VL vl,vl0;
942: V v[2],av[2];
1.11 noro 943: int stream,ri,i;
1.1 noro 944: P poly;
945: P var;
946: NODE n,n0;
947: STRING fname,wname;
1.13 noro 948: Obj t;
1.1 noro 949:
950: STOQ(-2,m2); STOQ(2,p2);
951: MKNODE(n,p2,0); MKNODE(defrange,m2,n);
952: poly = 0; vl = 0; geom = 0; wname = 0; stream = -1; ri = 0;
1.14 noro 953: v[0] = v[1] = 0;
1.1 noro 954: for ( ; arg; arg = NEXT(arg) )
955: if ( !BDY(arg) )
956: stream = 0;
957: else
958: switch ( OID(BDY(arg)) ) {
959: case O_P:
960: poly = (P)BDY(arg);
1.11 noro 961: get_vars_recursive((Obj)poly,&vl);
1.1 noro 962: for ( vl0 = vl, i = 0; vl0; vl0 = NEXT(vl0) )
1.11 noro 963: if ( vl0->v->attr == (pointer)V_IND )
1.1 noro 964: if ( i >= 2 )
965: error("ifplot : invalid argument");
966: else
967: v[i++] = vl0->v;
968: break;
969: case O_LIST:
970: list = (LIST)BDY(arg);
971: if ( OID(BDY(BDY(list))) == O_P )
972: if ( ri > 2 )
973: error("ifplot : invalid argument");
974: else
975: range[ri++] = list;
976: else
977: geom = list;
978: break;
979: case O_N:
980: stream = QTOS((Q)BDY(arg)); break;
981: case O_STR:
982: wname = (STRING)BDY(arg); break;
983: default:
984: error("ifplot : invalid argument"); break;
985: }
986: if ( !poly )
987: error("ifplot : invalid argument");
988: switch ( ri ) {
989: case 0:
990: if ( !v[1] )
991: error("ifplot : please specify all variables");
992: MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
993: MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
994: MKNODE(n,0,defrange); MKLIST(zrange,n);
995: break;
996: case 1:
997: if ( !v[1] )
998: error("ifplot : please specify all variables");
999: av[0] = VR((P)BDY(BDY(range[0])));
1000: if ( v[0] == av[0] ) {
1001: xrange = range[0];
1002: MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
1003: MKNODE(n,0,defrange); MKLIST(zrange,n);
1004: } else if ( v[1] == av[0] ) {
1005: MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
1006: yrange = range[0];
1007: MKNODE(n,0,defrange); MKLIST(zrange,n);
1008: } else {
1009: MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
1010: MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
1011: zrange = range[0];
1012: }
1013: break;
1014: case 2: case 3:
1015: av[0] = VR((P)BDY(BDY(range[0])));
1016: av[1] = VR((P)BDY(BDY(range[1])));
1017: if ( ((v[0] == av[0]) && (!v[1] || v[1] == av[1])) ||
1018: ((v[0] == av[1]) && (!v[1] || v[1] == av[0])) ) {
1019: xrange = range[0]; yrange = range[1];
1020: if ( ri == 3 )
1021: zrange = range[2];
1022: else {
1023: MKNODE(n,0,defrange); MKLIST(zrange,n);
1024: }
1025: } else
1026: error("ifplot : invalid argument");
1027: break;
1028: default:
1029: error("ifplot : cannot happen"); break;
1030: }
1031: /* conplot in ox_plot requires
1.9 noro 1032: [s_id (Q),
1.1 noro 1033: formula (Obj),
1034: xrange=[x,xmin,xmax] (LIST),
1035: yrange=[y,ymin,ymax] (LIST),
1036: zrange=[z,zmin,zmax] (LIST),
1037: geom=[xsize,ysize] (LIST),
1038: wname=name (STRING)]
1039: */
1040:
1.13 noro 1041: stream = validate_ox_plot_stream(stream);
1.9 noro 1042: STOQ(stream,s_id);
1.1 noro 1043: if ( !geom ) {
1044: STOQ(300,w300);
1045: MKNODE(n0,w300,0); MKNODE(n,w300,n0); MKLIST(geom,n);
1046: }
1.18 noro 1047: if ( is_memory ) {
1048: MKSTR(fname,"memory_plot");
1049: arg = mknode(7,s_id,fname,poly,xrange,yrange,zrange,geom);
1050: Pox_rpc(arg,&t);
1051: arg = mknode(1,s_id);
1052: Pox_pop_cmo(arg,rp);
1053: } else {
1054: MKSTR(fname,"plot");
1055: arg = mknode(8,s_id,fname,poly,xrange,yrange,zrange,geom,wname);
1056: Pox_rpc(arg,&t);
1057: *rp = (Obj)s_id;
1058: }
1059: }
1060:
1061: void Pplot(NODE arg,Obj *rp)
1062: {
1063: plot_main(arg,0,rp);
1064: }
1065:
1066: void Pmemory_plot(NODE arg,Obj *rp)
1067: {
1068: plot_main(arg,1,rp);
1.1 noro 1069: }
1070:
1.18 noro 1071: void plot_main(NODE arg,int is_memory,Obj *rp)
1.1 noro 1072: {
1.9 noro 1073: Q m2,p2,w300,s_id;
1.1 noro 1074: NODE defrange;
1075: LIST xrange,range[1],list,geom;
1076: VL vl,vl0;
1077: V v[1],av[1];
1.11 noro 1078: int stream,ri,i;
1.1 noro 1079: P poly;
1080: P var;
1081: NODE n,n0;
1082: STRING fname,wname;
1.13 noro 1083: Obj t;
1.1 noro 1084:
1085: STOQ(-2,m2); STOQ(2,p2);
1086: MKNODE(n,p2,0); MKNODE(defrange,m2,n);
1087: poly = 0; vl = 0; geom = 0; wname = 0; stream = -1; ri = 0;
1.14 noro 1088: v[0] = 0;
1.1 noro 1089: for ( ; arg; arg = NEXT(arg) )
1090: if ( !BDY(arg) )
1091: stream = 0;
1092: else
1093: switch ( OID(BDY(arg)) ) {
1094: case O_P: case O_R:
1095: poly = (P)BDY(arg);
1.11 noro 1096: get_vars_recursive((Obj)poly,&vl);
1.1 noro 1097: for ( vl0 = vl, i = 0; vl0; vl0 = NEXT(vl0) )
1.11 noro 1098: if ( vl0->v->attr == (pointer)V_IND )
1.1 noro 1099: if ( i >= 1 )
1100: error("ifplot : invalid argument");
1101: else
1102: v[i++] = vl0->v;
1.8 noro 1103: if ( i != 1 )
1104: error("ifplot : invalid argument");
1.1 noro 1105: break;
1106: case O_LIST:
1107: list = (LIST)BDY(arg);
1108: if ( OID(BDY(BDY(list))) == O_P )
1109: if ( ri > 0 )
1110: error("plot : invalid argument");
1111: else
1112: range[ri++] = list;
1113: else
1114: geom = list;
1115: break;
1116: case O_N:
1117: stream = QTOS((Q)BDY(arg)); break;
1118: case O_STR:
1119: wname = (STRING)BDY(arg); break;
1120: default:
1121: error("plot : invalid argument"); break;
1122: }
1123: if ( !poly )
1124: error("plot : invalid argument");
1125: switch ( ri ) {
1126: case 0:
1127: MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
1128: break;
1129: case 1:
1130: av[0] = VR((P)BDY(BDY(range[0])));
1131: if ( v[0] == av[0] )
1132: xrange = range[0];
1133: else
1134: error("plot : invalid argument");
1135: break;
1136: default:
1137: error("plot : cannot happen"); break;
1138: }
1139: /* conplot in ox_plot requires
1.9 noro 1140: [s_id (Q),
1.1 noro 1141: formula (Obj),
1142: xrange=[x,xmin,xmax] (LIST),
1143: yrange=0,
1144: zrange=0,
1145: geom=[xsize,ysize] (LIST),
1146: wname=name (STRING)]
1147: */
1.13 noro 1148: stream = validate_ox_plot_stream(stream);
1.9 noro 1149: STOQ(stream,s_id);
1.1 noro 1150: if ( !geom ) {
1151: STOQ(300,w300);
1152: MKNODE(n0,w300,0); MKNODE(n,w300,n0); MKLIST(geom,n);
1153: }
1.18 noro 1154: if ( is_memory ) {
1155: MKSTR(fname,"memory_plot");
1.21 noro 1156: arg = mknode(7,s_id,fname,poly,xrange,NULLP,NULLP,geom);
1.18 noro 1157: Pox_rpc(arg,&t);
1158: arg = mknode(1,s_id);
1159: Pox_pop_cmo(arg,rp);
1160: } else {
1161: MKSTR(fname,"plot");
1.21 noro 1162: arg = mknode(8,s_id,fname,poly,xrange,NULLP,NULLP,geom,wname);
1.18 noro 1163: Pox_rpc(arg,&t);
1164: *rp = (Obj)s_id;
1165: }
1.15 noro 1166: }
1167:
1168: #define Pi 3.14159265358979323846264
1169:
1170: void Ppolarplot(NODE arg,Q *rp)
1171: {
1172: Q m2,p2,w300,s_id;
1173: NODE defrange;
1174: LIST zrange,range[1],list,geom;
1175: VL vl,vl0;
1176: V v[1],av[1];
1177: int stream,ri,i;
1178: P poly;
1179: P var;
1180: NODE n,n0;
1181: STRING fname,wname;
1182: Real pi2;
1183: Obj t;
1184:
1185: MKReal(2*Pi,pi2);
1186: MKNODE(n,pi2,0); MKNODE(defrange,0,n);
1187: poly = 0; vl = 0; geom = 0; wname = 0; stream = -1; ri = 0;
1188: v[0] = 0;
1189: for ( ; arg; arg = NEXT(arg) )
1190: if ( !BDY(arg) )
1191: stream = 0;
1192: else
1193: switch ( OID(BDY(arg)) ) {
1194: case O_P: case O_R:
1195: poly = (P)BDY(arg);
1196: get_vars_recursive((Obj)poly,&vl);
1197: for ( vl0 = vl, i = 0; vl0; vl0 = NEXT(vl0) )
1198: if ( vl0->v->attr == (pointer)V_IND )
1199: if ( i >= 1 )
1200: error("polarplot : invalid argument");
1201: else
1202: v[i++] = vl0->v;
1203: if ( i != 1 )
1204: error("polarplot : invalid argument");
1205: break;
1206: case O_LIST:
1207: list = (LIST)BDY(arg);
1208: if ( OID(BDY(BDY(list))) == O_P )
1209: if ( ri > 0 )
1210: error("polarplot : invalid argument");
1211: else
1212: range[ri++] = list;
1213: else
1214: geom = list;
1215: break;
1216: case O_N:
1217: stream = QTOS((Q)BDY(arg)); break;
1218: case O_STR:
1219: wname = (STRING)BDY(arg); break;
1220: default:
1221: error("polarplot : invalid argument"); break;
1222: }
1223: if ( !poly )
1224: error("polarplot : invalid argument");
1225: switch ( ri ) {
1226: case 0:
1227: MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(zrange,n);
1228: break;
1229: case 1:
1230: av[0] = VR((P)BDY(BDY(range[0])));
1231: if ( v[0] == av[0] )
1232: zrange = range[0];
1233: else
1234: error("polarplot : invalid argument");
1235: break;
1236: default:
1237: error("polarplot : cannot happen"); break;
1238: }
1239: stream = validate_ox_plot_stream(stream);
1240: STOQ(stream,s_id);
1241: if ( !geom ) {
1242: STOQ(300,w300);
1243: MKNODE(n0,w300,0); MKNODE(n,w300,n0); MKLIST(geom,n);
1244: }
1245: MKSTR(fname,"plot");
1.21 noro 1246: arg = mknode(8,s_id,fname,poly,NULLP,NULLP,zrange,geom,wname);
1.13 noro 1247: Pox_rpc(arg,&t);
1248: *rp = s_id;
1.1 noro 1249: }
1250:
1.13 noro 1251: void Pplotover(NODE arg,Q *rp)
1.1 noro 1252: {
1.9 noro 1253: Q s_id,index;
1.1 noro 1254: P poly;
1255: STRING fname;
1.13 noro 1256: Obj t;
1.1 noro 1257:
1258: poly = (P)ARG0(arg);
1.9 noro 1259: s_id = (Q)ARG1(arg);
1.1 noro 1260: index = (Q)ARG2(arg);
1261: MKSTR(fname,"plotover");
1.17 noro 1262: if ( argc(arg) == 4 )
1263: arg = mknode(5,s_id,fname,index,poly,(Q)ARG3(arg));
1264: else
1265: arg = mknode(4,s_id,fname,index,poly);
1.13 noro 1266: Pox_rpc(arg,&t);
1267: *rp = s_id;
1.1 noro 1268: }
1269:
1.22 ! saito 1270: /* arg = [x,y,r,s_id,index] */
1.1 noro 1271:
1.13 noro 1272: void Pdrawcircle(NODE arg,Q *rp)
1.1 noro 1273: {
1.9 noro 1274: Q s_id,index;
1.20 noro 1275: Obj x,y,r,c;
1.1 noro 1276: STRING fname;
1277: NODE n;
1278: LIST pos;
1.13 noro 1279: Obj t;
1.1 noro 1280:
1281: x = (Obj)ARG0(arg);
1282: y = (Obj)ARG1(arg);
1283: r = (Obj)ARG2(arg);
1.19 saito 1284: c = (Obj)ARG3(arg);
1285: s_id = (Q)ARG4(arg);
1286: index = (Q)ARG5(arg);
1.1 noro 1287: MKSTR(fname,"drawcircle");
1.22 ! saito 1288: n = mknode(3,x,y,r,c); MKLIST(pos,n);
1.19 saito 1289: arg = mknode(5,s_id,fname,index,pos,c);
1.13 noro 1290: Pox_rpc(arg,&t);
1291: *rp = s_id;
1.6 noro 1292: }
1293:
1.9 noro 1294: /* draw_obj(s_id,cindex,point|line); point = [x,y], line = [xa,ya,xb,yb] */
1.13 noro 1295: void Pdraw_obj(NODE arg,Q *rp)
1.6 noro 1296: {
1297: static STRING fname;
1.9 noro 1298: Q s_id,index;
1.6 noro 1299: LIST obj;
1.13 noro 1300: Obj t;
1.6 noro 1301:
1302: if ( !fname ) {
1303: MKSTR(fname,"draw_obj");
1304: }
1.9 noro 1305: s_id = (Q)ARG0(arg);
1.6 noro 1306: index = (Q)ARG1(arg);
1307: obj = (LIST)ARG2(arg);
1.7 noro 1308: /* ARG3(arg) = color */
1309: if ( argc(arg) == 4 )
1.9 noro 1310: arg = mknode(5,s_id,fname,index,obj,ARG3(arg));
1.7 noro 1311: else
1.9 noro 1312: arg = mknode(4,s_id,fname,index,obj);
1.13 noro 1313: Pox_cmo_rpc(arg,&t);
1314: *rp = s_id;
1.12 noro 1315: }
1316:
1317: /* draw_string(s_id,cindex,pos,string,[,color]); pos=[x,y] */
1.13 noro 1318: void Pdraw_string(NODE arg,Q *rp)
1.12 noro 1319: {
1320: static STRING fname;
1321: STRING str;
1322: Q s_id,index;
1323: LIST pos;
1.13 noro 1324: Obj t;
1.12 noro 1325:
1326: if ( !fname ) {
1327: MKSTR(fname,"draw_string");
1328: }
1329: s_id = (Q)ARG0(arg);
1330: index = (Q)ARG1(arg);
1331: pos = (LIST)ARG2(arg);
1332: str = (STRING)ARG3(arg);
1333: /* ARG4(arg) = color */
1334: if ( argc(arg) == 5 )
1335: arg = mknode(6,s_id,fname,index,pos,str,ARG4(arg));
1336: else
1337: arg = mknode(5,s_id,fname,index,pos,str);
1.13 noro 1338: Pox_cmo_rpc(arg,&t);
1339: *rp = s_id;
1.6 noro 1340: }
1341:
1.13 noro 1342: void Pclear_canvas(NODE arg,Q *rp)
1.6 noro 1343: {
1344: static STRING fname;
1.9 noro 1345: Q s_id,index;
1.13 noro 1346: Obj t;
1.6 noro 1347:
1348: if ( !fname ) {
1349: MKSTR(fname,"clear_canvas");
1350: }
1.9 noro 1351: s_id = (Q)ARG0(arg);
1.6 noro 1352: index = (Q)ARG1(arg);
1.9 noro 1353: arg = mknode(3,s_id,fname,index);
1.13 noro 1354: Pox_cmo_rpc(arg,&t);
1355: *rp = s_id;
1.1 noro 1356: }
1357:
1358: #if 0
1.11 noro 1359: void Parrayplot(NODE arg,Obj *rp)
1.1 noro 1360: {
1361: int s;
1362: int id;
1363:
1364: if ( ID((Obj)ARG0(arg)) == O_VECT && ID((Obj)ARG1(arg)) == O_LIST ) {
1365: s = current_s;
1366: gensend(s,C_APLOT,0);
1367: gensend(s,C_OBJ,ARG0(arg)); gensend(s,C_OBJ,ARG1(arg)); genflush(s);
1368: }
1369: genrecv(s,&id,rp);
1370: }
1371: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>