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