Annotation of OpenXM_contrib2/asir2000/plot/if.c, Revision 1.17
1.2 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.3 noro 26: * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
1.2 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.17 ! noro 48: * $OpenXM: OpenXM_contrib2/asir2000/plot/if.c,v 1.16 2004/03/26 08:25:37 noro Exp $
1.2 noro 49: */
1.1 noro 50: #include "ca.h"
51: #include "parse.h"
52: #include "ox.h"
53: #include "ifplot.h"
54:
1.8 noro 55: extern JMP_BUF ox_env;
1.1 noro 56:
1.4 noro 57: int open_canvas(NODE arg)
58: {
59: int id;
60: struct canvas *can;
61: LIST wsize;
62: STRING wname;
63:
64: wsize = (LIST)ARG0(arg);
65: wname = (STRING)ARG1(arg);
66:
67: can = canvas[id = search_canvas()];
68: can->mode = MODE_INTERACTIVE;
69: if ( !wsize ) {
70: can->width = DEFAULTWIDTH; can->height = DEFAULTHEIGHT;
71: } else {
72: can->width = QTOS((Q)BDY(BDY(wsize)));
73: can->height = QTOS((Q)BDY(NEXT(BDY(wsize))));
74: }
75: if ( wname )
76: can->wname = BDY(wname);
77: else
78: can->wname = "";
79: create_canvas(can);
80: return id;
81: }
82:
1.1 noro 83: int plot(NODE arg)
84: {
85: int id;
86: NODE n;
87: struct canvas *can;
88: P formula;
89: LIST xrange,yrange,zrange,wsize;
90: STRING wname;
1.12 noro 91: V v;
1.1 noro 92:
93: formula = (P)ARG0(arg);
94: xrange = (LIST)ARG1(arg);
95: yrange = (LIST)ARG2(arg);
96: zrange = (LIST)ARG3(arg);
97: wsize = (LIST)ARG4(arg);
98: wname = (STRING)ARG5(arg);
99:
100: can = canvas[id = search_canvas()];
1.12 noro 101: if ( xrange ) {
102: n = BDY(xrange); can->vx = VR((P)BDY(n)); n = NEXT(n);
103: can->qxmin = (Q)BDY(n); n = NEXT(n); can->qxmax = (Q)BDY(n);
104: can->xmin = ToReal(can->qxmin); can->xmax = ToReal(can->qxmax);
105: }
1.1 noro 106: if ( yrange ) {
107: n = BDY(yrange); can->vy = VR((P)BDY(n)); n = NEXT(n);
108: can->qymin = (Q)BDY(n); n = NEXT(n); can->qymax = (Q)BDY(n);
109: can->ymin = ToReal(can->qymin); can->ymax = ToReal(can->qymax);
1.12 noro 110: }
111: if ( xrange && yrange )
112: can->mode = zrange ? MODE_CONPLOT : MODE_IFPLOT;
113: else
114: can->mode = xrange ? MODE_PLOT : MODE_POLARPLOT;
115:
116: if ( zrange ) {
1.15 noro 117: n = NEXT(BDY(zrange));
1.12 noro 118: can->zmin = ToReal(BDY(n));
119: n = NEXT(n); can->zmax = ToReal(BDY(n));
120: n = NEXT(n);
121: if ( can->mode == MODE_CONPLOT )
122: can->nzstep = n ? QTOS((Q)BDY(n)) : MAXGC;
123: else {
124: /* XXX */
1.15 noro 125: can->vx = VR((P)BDY(BDY(zrange)));
1.12 noro 126: can->nzstep = n ? QTOS((Q)BDY(n)) : DEFAULTPOLARSTEP;
127: }
128: }
129:
1.1 noro 130: if ( !wsize ) {
131: can->width = DEFAULTWIDTH; can->height = DEFAULTHEIGHT;
132: } else {
133: can->width = QTOS((Q)BDY(BDY(wsize)));
134: can->height = QTOS((Q)BDY(NEXT(BDY(wsize))));
135: }
136: if ( wname )
137: can->wname = BDY(wname);
138: else
139: can->wname = "";
140: can->formula = formula;
141: if ( can->mode == MODE_PLOT ) {
142: plotcalc(can);
1.14 noro 143: create_canvas(can);
1.1 noro 144: plot_print(display,can);
1.12 noro 145: } else if ( can->mode == MODE_POLARPLOT ) {
146: polarplotcalc(can);
1.14 noro 147: create_canvas(can);
1.12 noro 148: plot_print(display,can);
1.14 noro 149: } else {
150: create_canvas(can);
1.1 noro 151: ifplotmain(can);
1.12 noro 152: }
1.1 noro 153: copy_to_canvas(can);
154: return id;
155: }
156:
1.6 noro 157: int memory_plot(NODE arg,LIST *bytes)
158: {
159: NODE n;
160: struct canvas tmp_can;
161: struct canvas *can;
162: P formula;
163: LIST xrange,yrange,zrange,wsize;
164: int width,height;
165: double **tabe;
166: int i;
167: BYTEARRAY barray;
168: Q qw,qh;
169:
170: formula = (P)ARG0(arg);
171: xrange = (LIST)ARG1(arg);
172: yrange = (LIST)ARG2(arg);
173: zrange = (LIST)ARG3(arg);
174: wsize = (LIST)ARG4(arg);
175:
176: can = &tmp_can;
177: n = BDY(xrange); can->vx = VR((P)BDY(n)); n = NEXT(n);
178: can->qxmin = (Q)BDY(n); n = NEXT(n); can->qxmax = (Q)BDY(n);
179: can->xmin = ToReal(can->qxmin); can->xmax = ToReal(can->qxmax);
180: if ( yrange ) {
181: n = BDY(yrange); can->vy = VR((P)BDY(n)); n = NEXT(n);
182: can->qymin = (Q)BDY(n); n = NEXT(n); can->qymax = (Q)BDY(n);
183: can->ymin = ToReal(can->qymin); can->ymax = ToReal(can->qymax);
184: if ( zrange ) {
185: n = NEXT(BDY(zrange));
186: can->zmin = ToReal(BDY(n)); n = NEXT(n); can->zmax = ToReal(BDY(n));
187: if ( n = NEXT(n) )
188: can->nzstep = QTOS((Q)BDY(n));
189: else
190: can->nzstep = MAXGC;
191: can->mode = MODE_CONPLOT;
192: } else
193: can->mode = MODE_IFPLOT;
194: } else
195: can->mode = MODE_PLOT;
196: if ( !wsize ) {
197: can->width = DEFAULTWIDTH; can->height = DEFAULTHEIGHT;
198: } else {
199: can->width = QTOS((Q)BDY(BDY(wsize)));
200: can->height = QTOS((Q)BDY(NEXT(BDY(wsize))));
201: }
202: can->wname = "";
203: can->formula = formula;
204: if ( can->mode == MODE_PLOT )
205: plotcalc(can);
206: else {
207: width = can->width; height = can->height;
208: tabe = (double **)ALLOCA(width*sizeof(double *));
209: for ( i = 0; i < width; i++ )
210: tabe[i] = (double *)ALLOCA(height*sizeof(double));
211: calc(tabe,can,1);
212: memory_if_print(tabe,can,&barray);
213: STOQ(width,qw); STOQ(height,qh);
214: n = mknode(3,qw,qh,barray);
215: MKLIST(*bytes,n);
216: }
217: }
218:
1.1 noro 219: int plotover(NODE arg)
220: {
221: int index;
222: P formula;
223: struct canvas *can;
224: struct canvas fakecan;
225: VL vl,vl0;
226:
227: index = QTOS((Q)ARG0(arg));
228: formula = (P)ARG1(arg);
229: can = canvas[index];
230: if ( !can->window )
231: return -1;
1.7 noro 232: get_vars_recursive((Obj)formula,&vl);
1.1 noro 233: for ( vl0 = vl; vl0; vl0 = NEXT(vl0) )
1.7 noro 234: if ( vl0->v->attr == (pointer)V_IND )
1.1 noro 235: if ( vl->v != can->vx && vl->v != can->vy )
236: return -1;
1.17 ! noro 237: if ( argc(arg) == 3 )
! 238: can->color = QTOS((Q)ARG2(arg));
! 239: else
! 240: can->color = 0;
! 241: set_drawcolor(can->color);
1.1 noro 242: current_can = can;
243: fakecan = *can; fakecan.formula = formula;
244: if ( can->mode == MODE_PLOT ) {
245: plotcalc(&fakecan);
246: plot_print(display,&fakecan);
247: } else
248: ifplotmain(&fakecan);
249: copy_to_canvas(&fakecan);
250: return index;
251: }
252:
253: int drawcircle(NODE arg)
254: {
1.4 noro 255: #if !defined(VISUAL)
1.1 noro 256: int id;
257: int index;
258: pointer ptr;
259: Q ret;
260: LIST xyr;
261: Obj x,y,r;
262: int wx,wy,wr;
263: struct canvas *can;
264: struct canvas fakecan;
265:
266: index = QTOS((Q)ARG0(arg));
267: xyr = (LIST)ARG1(arg);
268: x = (Obj)ARG0(BDY(xyr)); y = (Obj)ARG1(BDY(xyr)); r = (Obj)ARG2(BDY(xyr));
269: can = canvas[index];
270: if ( !can->window )
271: return -1;
272: else {
273: current_can = can;
274: wx = (ToReal(x)-can->xmin)*can->width/(can->xmax-can->xmin);
275: wy = (can->ymax-ToReal(y))*can->height/(can->ymax-can->ymin);
276: wr = ToReal(r);
277: XFillArc(display,can->pix,colorGC,wx-wr/2,wy-wr/2,wr,wr,0,360*64);
278: copy_to_canvas(can);
279: return index;
280: }
1.4 noro 281: #endif
282: }
283:
284: int draw_obj(NODE arg)
285: {
286: int index;
1.5 noro 287: int x,y,u,v,len,r;
1.4 noro 288: NODE obj,n;
289: RealVect *vect;
290: struct canvas *can;
1.5 noro 291: int color;
1.4 noro 292:
293: index = QTOS((Q)ARG0(arg));
294: can = canvas[index];
1.10 noro 295: if ( !can && closed_canvas[index] ) {
296: canvas[index] = closed_canvas[index];
297: closed_canvas[index] = 0;
298: can = canvas[index];
299: popup_canvas(index);
300: current_can = can;
301: } else if ( !can || (can && !can->window) ) {
1.5 noro 302: set_lasterror("draw_obj : canvas does not exist");
1.4 noro 303: return -1;
1.5 noro 304: }
1.4 noro 305:
306: obj = BDY((LIST)ARG1(arg));
1.5 noro 307: if ( argc(arg) == 3 )
308: color = QTOS((Q)ARG2(arg));
309: else
310: color = 0; /* black */
311: switch ( len = length(obj) ) {
1.4 noro 312: case 2: /* point */
313: x = (int)ToReal((Q)ARG0(obj)); y = (int)ToReal((Q)ARG1(obj));
1.5 noro 314: draw_point(display,can,x,y,color);
1.16 noro 315: MKRVECT3(vect,x,y,color); MKNODE(n,vect,can->history);
316: can->history = n;
1.5 noro 317: break;
318: case 3: /* circle */
319: x = (int)ToReal((Q)ARG0(obj)); y = (int)ToReal((Q)ARG1(obj));
320: r = (int)ToReal((Q)ARG2(obj));
1.16 noro 321: MKRVECT4(vect,x,y,r,color); MKNODE(n,vect,can->history);
322: can->history = n;
1.4 noro 323: break;
324: case 4: /* line */
325: x = (int)ToReal((Q)ARG0(obj)); y = (int)ToReal((Q)ARG1(obj));
326: u = (int)ToReal((Q)ARG2(obj)); v = (int)ToReal((Q)ARG3(obj));
1.5 noro 327: draw_line(display,can,x,y,u,v,color);
1.16 noro 328: MKRVECT5(vect,x,y,u,v,color); MKNODE(n,vect,can->history);
329: can->history = n;
1.4 noro 330: break;
331: default:
1.5 noro 332: set_lasterror("draw_obj : invalid request");
1.4 noro 333: return -1;
334: }
1.9 noro 335: return 0;
336: }
337:
338: int draw_string(NODE arg)
339: {
340: int index,x,y;
341: char *str;
342: NODE pos;
343: struct canvas *can;
344: int color;
345:
346: index = QTOS((Q)ARG0(arg));
347: can = canvas[index];
1.11 noro 348: if ( !can && closed_canvas[index] ) {
349: canvas[index] = closed_canvas[index];
350: closed_canvas[index] = 0;
351: can = canvas[index];
352: popup_canvas(index);
353: current_can = can;
354: } else if ( !can || (can && !can->window) ) {
355: set_lasterror("draw_obj : canvas does not exist");
1.9 noro 356: return -1;
357: }
358:
359: pos = BDY((LIST)ARG1(arg));
360: str = BDY((STRING)ARG2(arg));
361: if ( argc(arg) == 4 )
362: color = QTOS((Q)ARG3(arg));
363: else
364: color = 0; /* black */
365: x = (int)ToReal((Q)ARG0(pos));
366: y = (int)ToReal((Q)ARG1(pos));
367: draw_character_string(display,can,x,y,str,color);
1.4 noro 368: return 0;
369: }
370:
371: int clear_canvas(NODE arg)
372: {
373: int index;
374: struct canvas *can;
375:
376: index = QTOS((Q)ARG0(arg));
377: can = canvas[index];
378: if ( !can || !can->window )
379: return -1;
380: clear_pixmap(can);
381: copy_to_canvas(can);
382: /* clear the history */
383: can->history = 0;
1.1 noro 384: }
385:
386: #define RealtoDbl(r) ((r)?BDY(r):0.0)
387:
388: int arrayplot(NODE arg)
389: {
390: int id,ix,w,h;
391: VECT array;
392: LIST xrange,wsize;
393: char *wname;
394: NODE n;
395: double ymax,ymin,dy,xstep;
396: Real *tab;
397: struct canvas *can;
398: POINT *pa;
399:
400: array = (VECT)ARG0(arg);
401: xrange = (LIST)ARG1(arg);
402: can = canvas[id = search_canvas()];
403: n = BDY(xrange); can->vx = VR((P)BDY(n)); n = NEXT(n);
404: can->qxmin = (Q)BDY(n); n = NEXT(n); can->qxmax = (Q)BDY(n);
405: can->xmin = ToReal(can->qxmin); can->xmax = ToReal(can->qxmax);
406: if ( !wsize ) {
407: can->width = DEFAULTWIDTH; can->height = DEFAULTHEIGHT;
408: } else {
409: can->width = QTOS((Q)BDY(BDY(wsize)));
410: can->height = QTOS((Q)BDY(NEXT(BDY(wsize))));
411: }
412: can->wname = wname; can->formula = 0; can->mode = MODE_PLOT;
413: create_canvas(can);
414: w = array->len;
415: h = can->height;
416: tab = (Real *)BDY(array);
417: if ( can->ymax == can->ymin ) {
418: for ( ymax = ymin = RealtoDbl(tab[0]), ix = 1; ix < w; ix++ ) {
419: if ( RealtoDbl(tab[ix]) > ymax )
420: ymax = RealtoDbl(tab[ix]);
421: if ( RealtoDbl(tab[ix]) < ymin )
422: ymin = RealtoDbl(tab[ix]);
423: }
424: can->ymax = ymax; can->ymin = ymin;
425: } else {
426: ymax = can->ymax; ymin = can->ymin;
427: }
428: dy = ymax-ymin;
429: can->pa = (struct pa *)MALLOC(sizeof(struct pa));
430: can->pa[0].length = w;
431: can->pa[0].pos = pa = (POINT *)MALLOC(w*sizeof(POINT));
432: xstep = (double)can->width/(double)(w-1);
433: for ( ix = 0; ix < w; ix++ ) {
434: #ifndef MAXSHORT
435: #define MAXSHORT ((short)0x7fff)
436: #endif
437: double t;
438:
439: pa[ix].x = (int)(ix*xstep);
440: t = (h - 1)*(ymax - RealtoDbl(tab[ix]))/dy;
441: if ( t > MAXSHORT )
442: pa[ix].y = MAXSHORT;
443: else if ( t < -MAXSHORT )
444: pa[ix].y = -MAXSHORT;
445: else
1.7 noro 446: pa[ix].y = (long)t;
1.1 noro 447: }
448: plot_print(display,can);
449: copy_to_canvas(can);
450: return id;
451: }
452:
1.7 noro 453: void ifplot_resize(struct canvas *can,POINT spos,POINT epos)
1.1 noro 454: {
455: struct canvas *ncan;
456: struct canvas fakecan;
457: Q dx,dy,dx2,dy2,xmin,xmax,ymin,ymax,xmid,ymid;
458: Q sx,sy,ex,ey,cw,ch,ten,two;
459: Q s,t;
460: int new;
461: int w,h,m;
462:
463: if ( XC(spos) < XC(epos) && YC(spos) < YC(epos) ) {
464: if ( can->precise && !can->wide ) {
465: fakecan = *can; ncan = &fakecan;
466: } else {
467: new = search_canvas(); ncan = canvas[new];
468: }
469: ncan->mode = can->mode;
470: ncan->zmin = can->zmin; ncan->zmax = can->zmax;
471: ncan->nzstep = can->nzstep;
472: ncan->wname = can->wname;
473: ncan->vx = can->vx; ncan->vy = can->vy;
474: ncan->formula = can->formula;
475: w = XC(epos)-XC(spos);
476: h = YC(epos)-YC(spos);
477: m = MAX(can->width,can->height);
478: if ( can->precise ) {
479: ncan->width = w; ncan->height = h;
480: } else if ( w > h ) {
481: ncan->width = m; ncan->height = m * h/w;
482: } else {
483: ncan->width = m * w/h; ncan->height = m;
484: }
485: if ( can->wide ) {
486: STOQ(10,ten); STOQ(2,two);
487: subq(can->qxmax,can->qxmin,&t); mulq(t,ten,&dx);
488: subq(can->qymax,can->qymin,&t); mulq(t,ten,&dy);
489: addq(can->qxmax,can->qxmin,&t); divq(t,two,&xmid);
490: addq(can->qymax,can->qymin,&t); divq(t,two,&ymid);
491: divq(dx,two,&dx2); divq(dy,two,&dy2);
492: subq(xmid,dx2,&xmin); addq(xmid,dx2,&xmax);
493: subq(ymid,dy2,&ymin); addq(ymid,dy2,&ymax);
494: } else {
495: subq(can->qxmax,can->qxmin,&dx); subq(can->qymax,can->qymin,&dy);
496: xmin = can->qxmin; xmax = can->qxmax;
497: ymin = can->qymin; ymax = can->qymax;
498: }
499: STOQ(XC(spos),sx); STOQ(YC(spos),sy); STOQ(XC(epos),ex); STOQ(YC(epos),ey);
500: STOQ(can->width,cw); STOQ(can->height,ch);
501: mulq(sx,dx,&t); divq(t,cw,&s); addq(xmin,s,&ncan->qxmin);
502: mulq(ex,dx,&t); divq(t,cw,&s); addq(xmin,s,&ncan->qxmax);
503: mulq(ey,dy,&t); divq(t,ch,&s); subq(ymax,s,&ncan->qymin);
504: mulq(sy,dy,&t); divq(t,ch,&s); subq(ymax,s,&ncan->qymax);
505: ncan->xmin = ToReal(ncan->qxmin); ncan->xmax = ToReal(ncan->qxmax);
506: ncan->ymin = ToReal(ncan->qymin); ncan->ymax = ToReal(ncan->qymax);
507: if ( can->precise && !can->wide ) {
508: current_can = can;
509: alloc_pixmap(ncan);
1.4 noro 510: #if defined(VISUAL)
511: ncan->real_can = can;
512: #endif
1.1 noro 513: qifplotmain(ncan);
514: copy_subimage(ncan,can,spos);
515: copy_to_canvas(can);
516: } else {
517: create_canvas(ncan);
518: if ( can->precise )
519: qifplotmain(ncan);
520: else
521: ifplotmain(ncan);
522: copy_to_canvas(ncan);
523: }
524: }
525: }
526:
1.7 noro 527: void plot_resize(struct canvas *can,POINT spos,POINT epos)
1.1 noro 528: {
529: struct canvas *ncan;
530: Q dx,dx2,xmin,xmax,xmid;
1.7 noro 531: double dy,ymin,ymax,ymid;
1.1 noro 532: Q sx,ex,cw,ten,two;
533: Q s,t;
534: int new;
535: int w,h,m;
536:
537: if ( XC(spos) < XC(epos) && YC(spos) < YC(epos) ) {
538: new = search_canvas(); ncan = canvas[new];
539: ncan->mode = can->mode;
540: ncan->zmin = can->zmin; ncan->zmax = can->zmax;
541: ncan->nzstep = can->nzstep;
542: ncan->wname = can->wname;
543: ncan->vx = can->vx; ncan->vy = can->vy;
544: ncan->formula = can->formula;
545: w = XC(epos)-XC(spos);
546: h = YC(epos)-YC(spos);
547: m = MAX(can->width,can->height);
548: if ( w > h ) {
549: ncan->width = m; ncan->height = m * h/w;
550: } else {
551: ncan->width = m * w/h; ncan->height = m;
552: }
553: if ( can->wide ) {
554: STOQ(10,ten); STOQ(2,two);
555: subq(can->qxmax,can->qxmin,&t); mulq(t,ten,&dx);
556: addq(can->qxmax,can->qxmin,&t); divq(t,two,&xmid);
557: divq(dx,two,&dx2); subq(xmid,dx2,&xmin); addq(xmid,dx2,&xmax);
558:
559: dy = (can->ymax-can->ymin)*10;
560: ymid = (can->ymax+can->ymin)/2;
561: ymin = ymid-dy/2; ymax = ymid+dy/2;
562: } else {
563: subq(can->qxmax,can->qxmin,&dx);
564: xmin = can->qxmin; xmax = can->qxmax;
565:
566: dy = can->ymax-can->ymin;
567: ymin = can->ymin; ymax = can->ymax;
568: }
569: STOQ(XC(spos),sx); STOQ(XC(epos),ex); STOQ(can->width,cw);
570: mulq(sx,dx,&t); divq(t,cw,&s); addq(xmin,s,&ncan->qxmin);
571: mulq(ex,dx,&t); divq(t,cw,&s); addq(xmin,s,&ncan->qxmax);
572: ncan->xmin = ToReal(ncan->qxmin); ncan->xmax = ToReal(ncan->qxmax);
573:
574: ncan->ymin = ymax-YC(epos)*dy/can->height;
575: ncan->ymax = ymax-YC(spos)*dy/can->height;
576:
577: create_canvas(ncan);
578: plotcalc(ncan);
579: plot_print(display,ncan);
580: copy_to_canvas(ncan);
581: }
582: }
583:
1.7 noro 584: void ifplotmain(struct canvas *can)
1.1 noro 585: {
586: int width,height;
1.7 noro 587: double **tabe;
1.1 noro 588: int i;
589:
590: width = can->width; height = can->height;
591: tabe = (double **)ALLOCA(width*sizeof(double *));
592: for ( i = 0; i < width; i++ )
593: tabe[i] = (double *)ALLOCA(height*sizeof(double));
594: define_cursor(can->window,runningcur);
595: set_busy(can); set_selection();
1.6 noro 596: calc(tabe,can,0); if_print(display,tabe,can);
1.1 noro 597: reset_selection(); reset_busy(can);
598: define_cursor(can->window,normalcur);
599: }
600:
1.7 noro 601: void qifplotmain(struct canvas *can)
1.1 noro 602: {
603: int width,height;
604: char **tabe,*tabeb;
605: int i;
606:
607: width = can->width; height = can->height;
608: tabe = (char **)ALLOCA(width*sizeof(char *)+width*height*sizeof(char));
1.8 noro 609: bzero((void *)tabe,width*sizeof(char *)+width*height*sizeof(char));
1.1 noro 610: for ( i = 0, tabeb = (char *)(tabe+width); i < width; i++ )
611: tabe[i] = tabeb + height*i;
612: define_cursor(can->window,runningcur);
613: set_busy(can); set_selection();
614: qcalc(tabe,can); qif_print(display,tabe,can);
615: reset_selection(); reset_busy(can);
616: define_cursor(can->window,normalcur);
617: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>