Annotation of OpenXM_contrib2/asir2000/plot/plotf.c, Revision 1.6
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.6 ! noro 48: * $OpenXM: OpenXM_contrib2/asir2000/plot/plotf.c,v 1.5 2000/08/22 05:04:32 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:
55: void Pifplot(), Pconplot(), Pplotover(), Pplot(), Parrayplot(), Pdrawcircle();
1.6 ! noro 56: void Popen_canvas(), Pclear_canvas(), Pdraw_obj();
1.1 noro 57:
58: struct ftab plot_tab[] = {
59: {"ifplot",Pifplot,-7},
60: {"conplot",Pconplot,-8},
61: {"plot",Pplot,-6},
62: {"plotover",Pplotover,3},
63: {"drawcircle",Pdrawcircle,5},
1.6 ! noro 64: {"open_canvas",Popen_canvas,-3},
! 65: {"clear_canvas",Pclear_canvas,2},
! 66: {"draw_obj",Pdraw_obj,3},
1.1 noro 67: /*
68: {"arrayplot",Parrayplot,2},
69: */
70: {0,0,0},
71: };
72:
73: int current_s;
74:
1.6 ! noro 75: void Popen_canvas(arg,rp)
! 76: NODE arg;
! 77: Obj *rp;
! 78: {
! 79: Q w300,sid;
! 80: LIST geom;
! 81: int stream,id,i;
! 82: NODE n,n0;
! 83: STRING fname,wname;
! 84:
! 85: geom = 0; wname = 0; stream = -1;
! 86: for ( ; arg; arg = NEXT(arg) )
! 87: if ( !BDY(arg) )
! 88: stream = 0;
! 89: else
! 90: switch ( OID(BDY(arg)) ) {
! 91: case O_LIST:
! 92: geom = (LIST)BDY(arg);
! 93: break;
! 94: case O_N:
! 95: stream = QTOS((Q)BDY(arg)); break;
! 96: case O_STR:
! 97: wname = (STRING)BDY(arg); break;
! 98: default:
! 99: error("open_canvas : invalid argument"); break;
! 100: }
! 101: /* open_canvas in ox_plot requires
! 102: [sid (Q),
! 103: geom=[xsize,ysize] (LIST),
! 104: wname=name (STRING)]
! 105: */
! 106:
! 107: if ( stream < 0 )
! 108: stream = current_s;
! 109: else
! 110: current_s = stream;
! 111: STOQ(stream,sid);
! 112: if ( !geom ) {
! 113: STOQ(300,w300);
! 114: MKNODE(n0,w300,0); MKNODE(n,w300,n0); MKLIST(geom,n);
! 115: }
! 116: MKSTR(fname,"open_canvas");
! 117: arg = mknode(4,sid,fname,geom,wname);
! 118: Pox_cmo_rpc(arg,rp);
! 119: }
! 120:
1.1 noro 121: void Pifplot(arg,rp)
122: NODE arg;
123: Obj *rp;
124: {
125: Q m2,p2,w300,sid;
126: NODE defrange;
127: LIST xrange,yrange,range[2],list,geom;
128: VL vl,vl0;
129: V v[2],av[2];
130: int stream,ri,id,i;
131: P poly;
132: P var;
133: NODE n,n0;
134: STRING fname,wname;
135:
136: STOQ(-2,m2); STOQ(2,p2);
137: MKNODE(n,p2,0); MKNODE(defrange,m2,n);
138: poly = 0; vl = 0; geom = 0; wname = 0; stream = -1; ri = 0;
139: for ( ; arg; arg = NEXT(arg) )
140: if ( !BDY(arg) )
141: stream = 0;
142: else
143: switch ( OID(BDY(arg)) ) {
144: case O_P:
145: poly = (P)BDY(arg);
146: get_vars_recursive(poly,&vl);
147: for ( vl0 = vl, i = 0; vl0; vl0 = NEXT(vl0) )
148: if ( vl0->v->attr == V_IND )
149: if ( i >= 2 )
150: error("ifplot : invalid argument");
151: else
152: v[i++] = vl0->v;
153: break;
154: case O_LIST:
155: list = (LIST)BDY(arg);
156: if ( OID(BDY(BDY(list))) == O_P )
157: if ( ri > 1 )
158: error("ifplot : invalid argument");
159: else
160: range[ri++] = list;
161: else
162: geom = list;
163: break;
164: case O_N:
165: stream = QTOS((Q)BDY(arg)); break;
166: case O_STR:
167: wname = (STRING)BDY(arg); break;
168: default:
169: error("ifplot : invalid argument"); break;
170: }
171: if ( !poly )
172: error("ifplot : invalid argument");
173: switch ( ri ) {
174: case 0:
175: if ( !v[1] )
176: error("ifplot : please specify all variables");
177: MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
178: MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
179: break;
180: case 1:
181: if ( !v[1] )
182: error("ifplot : please specify all variables");
183: av[0] = VR((P)BDY(BDY(range[0])));
184: if ( v[0] == av[0] ) {
185: xrange = range[0];
186: MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
187: } else if ( v[1] == av[0] ) {
188: MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
189: yrange = range[0];
190: } else
191: error("ifplot : invalid argument");
192: break;
193: case 2:
194: av[0] = VR((P)BDY(BDY(range[0])));
195: av[1] = VR((P)BDY(BDY(range[1])));
196: if ( ((v[0] == av[0]) && (!v[1] || v[1] == av[1])) ||
197: ((v[0] == av[1]) && (!v[1] || v[1] == av[0])) ) {
198: xrange = range[0]; yrange = range[1];
199: } else
200: error("ifplot : invalid argument");
201: break;
202: default:
203: error("ifplot : cannot happen"); break;
204: }
205: /* ifplot in ox_plot requires
206: [sid (Q),
207: formula (Obj),
208: xrange=[x,xmin,xmax] (LIST),
209: yrange=[y,ymin,ymax] (LIST),
210: zrange=0,
211: geom=[xsize,ysize] (LIST),
212: wname=name (STRING)]
213: */
214:
215: if ( stream < 0 )
216: stream = current_s;
217: else
218: current_s = stream;
219: STOQ(stream,sid);
220: if ( !geom ) {
221: STOQ(300,w300);
222: MKNODE(n0,w300,0); MKNODE(n,w300,n0); MKLIST(geom,n);
223: }
224: MKSTR(fname,"plot");
225: arg = mknode(8,sid,fname,poly,xrange,yrange,0,geom,wname);
1.3 noro 226: Pox_rpc(arg,rp);
1.1 noro 227: }
228:
229: void Pconplot(arg,rp)
230: NODE arg;
231: Obj *rp;
232: {
233: Q m2,p2,w300,sid;
234: NODE defrange;
235: LIST xrange,yrange,zrange,range[3],list,geom;
236: VL vl,vl0;
237: V v[2],av[2];
238: int stream,ri,id,i;
239: P poly;
240: P var;
241: NODE n,n0;
242: STRING fname,wname;
243:
244: STOQ(-2,m2); STOQ(2,p2);
245: MKNODE(n,p2,0); MKNODE(defrange,m2,n);
246: poly = 0; vl = 0; geom = 0; wname = 0; stream = -1; ri = 0;
247: for ( ; arg; arg = NEXT(arg) )
248: if ( !BDY(arg) )
249: stream = 0;
250: else
251: switch ( OID(BDY(arg)) ) {
252: case O_P:
253: poly = (P)BDY(arg);
254: get_vars_recursive(poly,&vl);
255: for ( vl0 = vl, i = 0; vl0; vl0 = NEXT(vl0) )
256: if ( vl0->v->attr == V_IND )
257: if ( i >= 2 )
258: error("ifplot : invalid argument");
259: else
260: v[i++] = vl0->v;
261: break;
262: case O_LIST:
263: list = (LIST)BDY(arg);
264: if ( OID(BDY(BDY(list))) == O_P )
265: if ( ri > 2 )
266: error("ifplot : invalid argument");
267: else
268: range[ri++] = list;
269: else
270: geom = list;
271: break;
272: case O_N:
273: stream = QTOS((Q)BDY(arg)); break;
274: case O_STR:
275: wname = (STRING)BDY(arg); break;
276: default:
277: error("ifplot : invalid argument"); break;
278: }
279: if ( !poly )
280: error("ifplot : invalid argument");
281: switch ( ri ) {
282: case 0:
283: if ( !v[1] )
284: error("ifplot : please specify all variables");
285: MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
286: MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
287: MKNODE(n,0,defrange); MKLIST(zrange,n);
288: break;
289: case 1:
290: if ( !v[1] )
291: error("ifplot : please specify all variables");
292: av[0] = VR((P)BDY(BDY(range[0])));
293: if ( v[0] == av[0] ) {
294: xrange = range[0];
295: MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
296: MKNODE(n,0,defrange); MKLIST(zrange,n);
297: } else if ( v[1] == av[0] ) {
298: MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
299: yrange = range[0];
300: MKNODE(n,0,defrange); MKLIST(zrange,n);
301: } else {
302: MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
303: MKV(v[1],var); MKNODE(n,var,defrange); MKLIST(yrange,n);
304: zrange = range[0];
305: }
306: break;
307: case 2: case 3:
308: av[0] = VR((P)BDY(BDY(range[0])));
309: av[1] = VR((P)BDY(BDY(range[1])));
310: if ( ((v[0] == av[0]) && (!v[1] || v[1] == av[1])) ||
311: ((v[0] == av[1]) && (!v[1] || v[1] == av[0])) ) {
312: xrange = range[0]; yrange = range[1];
313: if ( ri == 3 )
314: zrange = range[2];
315: else {
316: MKNODE(n,0,defrange); MKLIST(zrange,n);
317: }
318: } else
319: error("ifplot : invalid argument");
320: break;
321: default:
322: error("ifplot : cannot happen"); break;
323: }
324: if ( stream < 0 )
325: stream = current_s;
326: else
327: current_s = stream;
328:
329: /* conplot in ox_plot requires
330: [sid (Q),
331: formula (Obj),
332: xrange=[x,xmin,xmax] (LIST),
333: yrange=[y,ymin,ymax] (LIST),
334: zrange=[z,zmin,zmax] (LIST),
335: geom=[xsize,ysize] (LIST),
336: wname=name (STRING)]
337: */
338:
339: if ( stream < 0 )
340: stream = current_s;
341: else
342: current_s = stream;
343: STOQ(stream,sid);
344: if ( !geom ) {
345: STOQ(300,w300);
346: MKNODE(n0,w300,0); MKNODE(n,w300,n0); MKLIST(geom,n);
347: }
348: MKSTR(fname,"plot");
349: arg = mknode(8,sid,fname,poly,xrange,yrange,zrange,geom,wname);
1.3 noro 350: Pox_rpc(arg,rp);
1.1 noro 351: }
352:
353: void Pplot(arg,rp)
354: NODE arg;
355: Obj *rp;
356: {
357: Q m2,p2,w300,sid;
358: NODE defrange;
359: LIST xrange,range[1],list,geom;
360: VL vl,vl0;
361: V v[1],av[1];
362: int stream,ri,id,i;
363: P poly;
364: P var;
365: NODE n,n0;
366: STRING fname,wname;
367:
368: STOQ(-2,m2); STOQ(2,p2);
369: MKNODE(n,p2,0); MKNODE(defrange,m2,n);
370: poly = 0; vl = 0; geom = 0; wname = 0; stream = -1; ri = 0;
371: for ( ; arg; arg = NEXT(arg) )
372: if ( !BDY(arg) )
373: stream = 0;
374: else
375: switch ( OID(BDY(arg)) ) {
376: case O_P: case O_R:
377: poly = (P)BDY(arg);
378: get_vars_recursive(poly,&vl);
379: for ( vl0 = vl, i = 0; vl0; vl0 = NEXT(vl0) )
380: if ( vl0->v->attr == V_IND )
381: if ( i >= 1 )
382: error("ifplot : invalid argument");
383: else
384: v[i++] = vl0->v;
385: break;
386: case O_LIST:
387: list = (LIST)BDY(arg);
388: if ( OID(BDY(BDY(list))) == O_P )
389: if ( ri > 0 )
390: error("plot : invalid argument");
391: else
392: range[ri++] = list;
393: else
394: geom = list;
395: break;
396: case O_N:
397: stream = QTOS((Q)BDY(arg)); break;
398: case O_STR:
399: wname = (STRING)BDY(arg); break;
400: default:
401: error("plot : invalid argument"); break;
402: }
403: if ( !poly )
404: error("plot : invalid argument");
405: switch ( ri ) {
406: case 0:
407: MKV(v[0],var); MKNODE(n,var,defrange); MKLIST(xrange,n);
408: break;
409: case 1:
410: av[0] = VR((P)BDY(BDY(range[0])));
411: if ( v[0] == av[0] )
412: xrange = range[0];
413: else
414: error("plot : invalid argument");
415: break;
416: default:
417: error("plot : cannot happen"); break;
418: }
419: /* conplot in ox_plot requires
420: [sid (Q),
421: formula (Obj),
422: xrange=[x,xmin,xmax] (LIST),
423: yrange=0,
424: zrange=0,
425: geom=[xsize,ysize] (LIST),
426: wname=name (STRING)]
427: */
428: if ( stream < 0 )
429: stream = current_s;
430: else
431: current_s = stream;
432: STOQ(stream,sid);
433: if ( !geom ) {
434: STOQ(300,w300);
435: MKNODE(n0,w300,0); MKNODE(n,w300,n0); MKLIST(geom,n);
436: }
437: MKSTR(fname,"plot");
438: arg = mknode(8,sid,fname,poly,xrange,0,0,geom,wname);
1.3 noro 439: Pox_rpc(arg,rp);
1.1 noro 440: }
441:
442: void Pplotover(arg,rp)
443: NODE arg;
444: Obj *rp;
445: {
446: Q sid,index;
447: P poly;
448: STRING fname;
449:
450: poly = (P)ARG0(arg);
451: sid = (Q)ARG1(arg);
452: index = (Q)ARG2(arg);
453: MKSTR(fname,"plotover");
454: arg = mknode(4,sid,fname,index,poly);
1.3 noro 455: Pox_rpc(arg,rp);
1.1 noro 456: }
457:
458: /* arg = [x,y,r,sid,index] */
459:
460: void Pdrawcircle(arg,rp)
461: NODE arg;
462: Obj *rp;
463: {
464: Q sid,index;
465: Obj x,y,r;
466: STRING fname;
467: NODE n;
468: LIST pos;
469:
470: x = (Obj)ARG0(arg);
471: y = (Obj)ARG1(arg);
472: r = (Obj)ARG2(arg);
473: sid = (Q)ARG3(arg);
474: index = (Q)ARG4(arg);
475: MKSTR(fname,"drawcircle");
476: n = mknode(3,x,y,r); MKLIST(pos,n);
477: arg = mknode(4,sid,fname,index,pos);
1.3 noro 478: Pox_rpc(arg,rp);
1.6 ! noro 479: }
! 480:
! 481: /* draw_obj(sid,cindex,point|line); point = [x,y], line = [xa,ya,xb,yb] */
! 482: void Pdraw_obj(arg,rp)
! 483: NODE arg;
! 484: Obj *rp;
! 485: {
! 486: static STRING fname;
! 487: Q sid,index;
! 488: LIST obj;
! 489:
! 490: if ( !fname ) {
! 491: MKSTR(fname,"draw_obj");
! 492: }
! 493: sid = (Q)ARG0(arg);
! 494: index = (Q)ARG1(arg);
! 495: obj = (LIST)ARG2(arg);
! 496: arg = mknode(4,sid,fname,index,obj);
! 497: Pox_cmo_rpc(arg,rp);
! 498: }
! 499:
! 500: void Pclear_canvas(arg,rp)
! 501: NODE arg;
! 502: Obj *rp;
! 503: {
! 504: static STRING fname;
! 505: Q sid,index;
! 506: LIST obj;
! 507:
! 508: if ( !fname ) {
! 509: MKSTR(fname,"clear_canvas");
! 510: }
! 511: sid = (Q)ARG0(arg);
! 512: index = (Q)ARG1(arg);
! 513: arg = mknode(3,sid,fname,index);
! 514: Pox_cmo_rpc(arg,rp);
1.1 noro 515: }
516:
517: #if 0
518: void Parrayplot(arg,rp)
519: NODE arg;
520: Obj *rp;
521: {
522: int s;
523: int id;
524:
525: if ( ID((Obj)ARG0(arg)) == O_VECT && ID((Obj)ARG1(arg)) == O_LIST ) {
526: s = current_s;
527: gensend(s,C_APLOT,0);
528: gensend(s,C_OBJ,ARG0(arg)); gensend(s,C_OBJ,ARG1(arg)); genflush(s);
529: }
530: genrecv(s,&id,rp);
531: }
532: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>