Annotation of OpenXM_contrib2/asir2000/plot/if.c, Revision 1.24
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.24 ! saito 48: * $OpenXM: OpenXM_contrib2/asir2000/plot/if.c,v 1.23 2011/08/11 06:25:06 saito 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.22 saito 55: #if defined(INTERVAL)
1.24 ! saito 56: // Time message and func
1.22 saito 57: #include <sys/types.h>
58: #include <sys/resource.h>
59: #include <sys/time.h>
60:
61: static struct oEGT ltime;
62: static double r0;
63: double get_rtime();
64: #if defined(ITV_TIME_CHECK)
65: void tstart()
66: {
67: get_eg(<ime);
1.24 ! saito 68: r0=get_rtime();
1.22 saito 69: }
70:
71: void tstop(struct canvas *can)
72: {
73: struct oEGT egt1;
74: double e, g, r;
75: char ts[100];
76: void popdown_warning();
77: Widget warnshell,warndialog;
78:
79: get_eg(&egt1);
1.24 ! saito 80: e=egt1.exectime - ltime.exectime;
! 81: g=egt1.gctime - ltime.gctime;
! 82: r=get_rtime() - r0;
1.22 saito 83: sprintf(ts,"(%8.6f + gc %8.6f) total %8.6f \n",e,g,r);
84: create_popup(can->shell,"Message",&ts,&warnshell,&warndialog);
85: XawDialogAddButton(warndialog,"OK",popdown_warning,warnshell);
86: XtPopup(warnshell,XtGrabNone);
87: SetWM_Proto(warnshell);
88: }
89: #else
90: #define tstart()
91: #define tstop(a)
92: #endif
93: #endif
94:
1.8 noro 95: extern JMP_BUF ox_env;
1.1 noro 96:
1.24 ! saito 97: int open_canvas(NODE arg){
1.4 noro 98: int id;
99: struct canvas *can;
100: LIST wsize;
101: STRING wname;
102:
1.24 ! saito 103: wsize=(LIST)ARG0(arg);
! 104: wname=(STRING)ARG1(arg);
! 105: can=canvas[id=search_canvas()];
! 106: can->mode=MODE_INTERACTIVE;
! 107: if(!wsize){
! 108: can->width=DEFAULTWIDTH;
! 109: can->height=DEFAULTHEIGHT;
1.4 noro 110: } else {
1.24 ! saito 111: can->width=QTOS((Q)BDY(BDY(wsize)));
! 112: can->height=QTOS((Q)BDY(NEXT(BDY(wsize))));
1.4 noro 113: }
1.24 ! saito 114: if(wname)can->wname=BDY(wname);
! 115: else can->wname="";
1.4 noro 116: create_canvas(can);
117: return id;
118: }
119:
1.24 ! saito 120:
! 121: int plot(NODE arg,int fn){
1.1 noro 122: int id;
123: NODE n;
124: struct canvas *can;
125: P formula;
126: LIST xrange,yrange,zrange,wsize;
127: STRING wname;
1.12 noro 128: V v;
1.1 noro 129:
1.24 ! saito 130: formula=(P)ARG0(arg);
! 131: xrange=(LIST)ARG1(arg);
! 132: yrange=(LIST)ARG2(arg);
! 133: zrange=(LIST)ARG3(arg);
! 134: wsize=(LIST)ARG4(arg);
! 135: wname=(STRING)ARG5(arg);
! 136: can=canvas[id=search_canvas()];
! 137: if(xrange){
! 138: n=BDY(xrange);can->vx=VR((P)BDY(n));n=NEXT(n);
! 139: can->qxmin=(Q)BDY(n);n=NEXT(n);can->qxmax=(Q)BDY(n);
! 140: can->xmin=ToReal(can->qxmin);can->xmax=ToReal(can->qxmax);
! 141: }
! 142: if(yrange){
! 143: n=BDY(yrange);can->vy=VR((P)BDY(n));n=NEXT(n);
! 144: can->qymin=(Q)BDY(n);n=NEXT(n);can->qymax=(Q)BDY(n);
! 145: can->ymin=ToReal(can->qymin);can->ymax=ToReal(can->qymax);
! 146: }
! 147: can->mode=fn;
! 148: if(zrange){
! 149: n=BDY(zrange); can->zmin=ToReal(BDY(n));
! 150: n=NEXT(n);can->zmax=ToReal(BDY(n));
! 151: n=NEXT(n);
! 152: if(can->mode==MODE_CONPLOT)can->nzstep=QTOS((Q)BDY(n));
1.12 noro 153: else {
1.24 ! saito 154: can->vx=VR((P)BDY(BDY(zrange)));
! 155: can->nzstep=QTOS((Q)BDY(n));
1.12 noro 156: }
157: }
1.24 ! saito 158: if(!wsize){
! 159: can->width=DEFAULTWIDTH;
! 160: can->height=DEFAULTHEIGHT;
1.1 noro 161: } else {
1.24 ! saito 162: can->width=QTOS((Q)BDY(BDY(wsize)));
! 163: can->height=QTOS((Q)BDY(NEXT(BDY(wsize))));
1.1 noro 164: }
1.24 ! saito 165: if(wname) can->wname = BDY(wname);
! 166: else can->wname="";
! 167: can->formula=formula;
! 168: if(can->mode==MODE_PLOT){
! 169: //plot
1.1 noro 170: plotcalc(can);
1.14 noro 171: create_canvas(can);
1.1 noro 172: plot_print(display,can);
1.24 ! saito 173: } else if(can->mode==MODE_POLARPLOT){
! 174: //polarplot
1.12 noro 175: polarplotcalc(can);
1.14 noro 176: create_canvas(can);
1.12 noro 177: plot_print(display,can);
1.14 noro 178: } else {
1.24 ! saito 179: //ifplot,conplot
1.14 noro 180: create_canvas(can);
1.24 ! saito 181: ifplotmainOld(can);
1.12 noro 182: }
1.1 noro 183: copy_to_canvas(can);
184: return id;
185: }
186:
1.24 ! saito 187: void ifplotmainOld(struct canvas *can){
! 188: int i,width,height;
! 189: double ** tabe;
! 190:
! 191: width=can->width;height=can->height;
! 192: tabe=(double **)ALLOCA((width+1)*sizeof(double *));
! 193: for(i=0;i<width;i++)tabe[i]=(double *)ALLOCA((height+1)*sizeof(double));
! 194: define_cursor(can->window,runningcur);
! 195: set_busy(can); set_selection();
! 196: calc(tabe,can,0);
! 197: if_printOld(display,tabe,can);
! 198: reset_selection(); reset_busy(can);
! 199: define_cursor(can->window,normalcur);
! 200: }
! 201:
! 202: int memory_plot(NODE arg,LIST *bytes){
1.6 noro 203: NODE n;
204: struct canvas tmp_can;
205: struct canvas *can;
206: P formula;
207: LIST xrange,yrange,zrange,wsize;
208: int width,height;
209: double **tabe;
210: int i;
211: BYTEARRAY barray;
212: Q qw,qh;
213:
1.24 ! saito 214: formula=(P)ARG0(arg);
! 215: xrange=(LIST)ARG1(arg);
! 216: yrange=(LIST)ARG2(arg);
! 217: zrange=(LIST)ARG3(arg);
! 218: wsize=(LIST)ARG4(arg);
1.6 noro 219:
1.19 noro 220: bzero((char *)&tmp_can,sizeof(tmp_can));
1.24 ! saito 221: can=&tmp_can;
! 222: n=BDY(xrange); can->vx=VR((P)BDY(n)); n=NEXT(n);
! 223: can->qxmin=(Q)BDY(n); n=NEXT(n); can->qxmax=(Q)BDY(n);
! 224: can->xmin=ToReal(can->qxmin); can->xmax=ToReal(can->qxmax);
! 225: if( yrange ){
! 226: n=BDY(yrange); can->vy=VR((P)BDY(n)); n=NEXT(n);
! 227: can->qymin=(Q)BDY(n); n=NEXT(n); can->qymax=(Q)BDY(n);
! 228: can->ymin=ToReal(can->qymin); can->ymax=ToReal(can->qymax);
! 229: if( zrange ){
! 230: n=NEXT(BDY(zrange));
! 231: can->zmin=ToReal(BDY(n)); n=NEXT(n); can->zmax=ToReal(BDY(n));
! 232: if(n=NEXT(n)) can->nzstep=QTOS((Q)BDY(n));
! 233: else can->nzstep=MAXGC;
! 234: can->mode=MODE_CONPLOT;
1.6 noro 235: } else
1.24 ! saito 236: can->mode=MODE_IFPLOT;
1.6 noro 237: } else
1.24 ! saito 238: can->mode=MODE_PLOT;
! 239: if( !wsize ){
! 240: can->width=DEFAULTWIDTH; can->height=DEFAULTHEIGHT;
1.6 noro 241: } else {
1.24 ! saito 242: can->width=QTOS((Q)BDY(BDY(wsize)));
! 243: can->height=QTOS((Q)BDY(NEXT(BDY(wsize))));
1.6 noro 244: }
1.24 ! saito 245: can->wname="";
! 246: can->formula=formula;
! 247: if( can->mode == MODE_PLOT ){
1.6 noro 248: plotcalc(can);
1.19 noro 249: memory_print(can,&barray);
250: STOQ(can->width,qw); STOQ(can->height,qh);
1.24 ! saito 251: n=mknode(3,qw,qh,barray);
1.19 noro 252: MKLIST(*bytes,n);
253: } else {
1.24 ! saito 254: width=can->width; height=can->height;
! 255: tabe=(double **)ALLOCA(width*sizeof(double *));
! 256: for( i=0; i<width; i++ )
! 257: tabe[i]=(double *)ALLOCA(height*sizeof(double));
1.6 noro 258: calc(tabe,can,1);
259: memory_if_print(tabe,can,&barray);
260: STOQ(width,qw); STOQ(height,qh);
1.24 ! saito 261: n=mknode(3,qw,qh,barray);
1.6 noro 262: MKLIST(*bytes,n);
263: }
264: }
265:
1.24 ! saito 266: int plotover(NODE arg){
! 267: int id,orgcolor,color;
1.1 noro 268: P formula;
269: struct canvas *can;
270: VL vl,vl0;
271:
1.24 ! saito 272: id=QTOS((Q)ARG0(arg));
! 273: formula=(P)ARG1(arg);
! 274: color=QTOS((Q)ARG2(arg));
! 275:
! 276: can=canvas[id];
! 277: orgcolor=can->color;
! 278: can->color=color;
1.7 noro 279: get_vars_recursive((Obj)formula,&vl);
1.24 ! saito 280: for(vl0=vl;vl0;vl0=NEXT(vl0))
! 281: if(vl0->v->attr==(pointer)V_IND)
! 282: if(vl->v!=can->vx && vl->v!=can->vy)return -1;
! 283: if(argc(arg)==3) can->color=QTOS((Q)ARG2(arg));
! 284: else can->color=0;
1.18 noro 285: #if !defined(VISUAL)
1.17 noro 286: set_drawcolor(can->color);
1.18 noro 287: #endif
1.24 ! saito 288: current_can=can;
! 289: can->formula=formula;
! 290: if(can->mode==MODE_PLOT){
1.21 saito 291: plotcalc(can);
292: plot_print(display,can);
1.24 ! saito 293: } else ifplotmainOld(can);
1.21 saito 294: copy_to_canvas(can);
1.24 ! saito 295: can->color=color;
1.21 saito 296: #if !defined(VISUAL)
297: set_drawcolor(can->color);
298: #endif
1.1 noro 299: return index;
300: }
301:
1.24 ! saito 302: int drawcircle(NODE arg){
1.4 noro 303: #if !defined(VISUAL)
1.24 ! saito 304: int id,index,wx,wy,wr,c;
1.1 noro 305: pointer ptr;
306: Q ret;
307: LIST xyr;
308: Obj x,y,r;
309: struct canvas *can;
310:
1.24 ! saito 311: index=QTOS((Q)ARG0(arg));
! 312: xyr=(LIST)ARG1(arg);
! 313: x=(Obj)ARG0(BDY(xyr)); y=(Obj)ARG1(BDY(xyr)); r=(Obj)ARG2(BDY(xyr));
! 314: c=QTOS((Q)ARG2(arg));
! 315: can=canvas[index];
! 316: if(!can->window)return -1;
1.1 noro 317: else {
1.24 ! saito 318: current_can=can;
1.21 saito 319: set_drawcolor(c);
1.24 ! saito 320: wx=(ToReal(x)-can->xmin)*can->width/(can->xmax-can->xmin);
! 321: wy=(can->ymax-ToReal(y))*can->height/(can->ymax-can->ymin);
! 322: wr=ToReal(r);
1.21 saito 323: XFillArc(display,can->pix,cdrawGC,wx-wr/2,wy-wr/2,wr,wr,0,360*64);
1.1 noro 324: copy_to_canvas(can);
1.21 saito 325: set_drawcolor(can->color);
1.1 noro 326: return index;
327: }
1.4 noro 328: #endif
329: }
330:
1.24 ! saito 331: int draw_obj(NODE arg){
! 332: int index,color,x,y,u,v,len,r;
1.4 noro 333: NODE obj,n;
334: RealVect *vect;
335: struct canvas *can;
336:
1.24 ! saito 337: index=QTOS((Q)ARG0(arg));
! 338: can=canvas[index];
! 339: if(!can && closed_canvas[index]){
! 340: canvas[index]=closed_canvas[index];
! 341: closed_canvas[index]=0;
! 342: can=canvas[index];
1.10 noro 343: popup_canvas(index);
1.24 ! saito 344: current_can=can;
! 345: } else if(!can||(can && !can->window)){
1.5 noro 346: set_lasterror("draw_obj : canvas does not exist");
1.4 noro 347: return -1;
1.5 noro 348: }
1.4 noro 349:
1.24 ! saito 350: obj=BDY((LIST)ARG1(arg));
! 351: if(argc(arg)== 3) color=QTOS((Q)ARG2(arg));
! 352: else color=0; // black
! 353: switch(len=length(obj)){
! 354: case 2: // point
! 355: x=(int)ToReal((Q)ARG0(obj)); y=(int)ToReal((Q)ARG1(obj));
1.5 noro 356: draw_point(display,can,x,y,color);
1.16 noro 357: MKRVECT3(vect,x,y,color); MKNODE(n,vect,can->history);
1.24 ! saito 358: can->history=n;
1.5 noro 359: break;
1.24 ! saito 360: case 3: // circle
! 361: x=(int)ToReal((Q)ARG0(obj)); y=(int)ToReal((Q)ARG1(obj));
! 362: r=(int)ToReal((Q)ARG2(obj));
1.16 noro 363: MKRVECT4(vect,x,y,r,color); MKNODE(n,vect,can->history);
1.24 ! saito 364: can->history=n;
1.4 noro 365: break;
1.24 ! saito 366: case 4: // line
! 367: x=(int)ToReal((Q)ARG0(obj)); y=(int)ToReal((Q)ARG1(obj));
! 368: u=(int)ToReal((Q)ARG2(obj)); v=(int)ToReal((Q)ARG3(obj));
1.5 noro 369: draw_line(display,can,x,y,u,v,color);
1.16 noro 370: MKRVECT5(vect,x,y,u,v,color); MKNODE(n,vect,can->history);
1.24 ! saito 371: can->history=n;
1.4 noro 372: break;
373: default:
1.5 noro 374: set_lasterror("draw_obj : invalid request");
1.4 noro 375: return -1;
376: }
1.21 saito 377: #if !defined(VISUAL)
378: set_drawcolor(can->color);
379: #endif
1.9 noro 380: return 0;
381: }
382:
1.24 ! saito 383: int draw_string(NODE arg){
! 384: int index,x,y,color;
1.9 noro 385: char *str;
386: NODE pos;
387: struct canvas *can;
388:
1.24 ! saito 389: index=QTOS((Q)ARG0(arg));
! 390: can=canvas[index];
! 391: if(!can && closed_canvas[index]){
! 392: canvas[index]=closed_canvas[index];
! 393: closed_canvas[index]=0;
! 394: can=canvas[index];
1.11 noro 395: popup_canvas(index);
1.24 ! saito 396: current_can=can;
! 397: } else if(!can||(can && !can->window)){
1.11 noro 398: set_lasterror("draw_obj : canvas does not exist");
1.9 noro 399: return -1;
400: }
401:
1.24 ! saito 402: pos=BDY((LIST)ARG1(arg));
! 403: str=BDY((STRING)ARG2(arg));
! 404: if(argc(arg)==4)color=QTOS((Q)ARG3(arg));
! 405: else color=0; // black
! 406: x=(int)ToReal((Q)ARG0(pos));
! 407: y=(int)ToReal((Q)ARG1(pos));
1.9 noro 408: draw_character_string(display,can,x,y,str,color);
1.21 saito 409: #if !defined(VISUAL)
410: set_drawcolor(can->color);
411: #endif
1.4 noro 412: return 0;
413: }
414:
1.24 ! saito 415: int clear_canvas(NODE arg){
1.4 noro 416: int index;
417: struct canvas *can;
418:
1.24 ! saito 419: index=QTOS((Q)ARG0(arg));
! 420: can=canvas[index];
! 421: if(!can||!can->window) return -1;
1.4 noro 422: clear_pixmap(can);
423: copy_to_canvas(can);
1.24 ! saito 424: // clear the history
! 425: can->history=0;
1.1 noro 426: }
427:
428: #define RealtoDbl(r) ((r)?BDY(r):0.0)
429:
1.24 ! saito 430: int arrayplot(NODE arg){
1.1 noro 431: int id,ix,w,h;
432: VECT array;
433: LIST xrange,wsize;
434: char *wname;
435: NODE n;
436: double ymax,ymin,dy,xstep;
437: Real *tab;
438: struct canvas *can;
439: POINT *pa;
440:
1.24 ! saito 441: array=(VECT)ARG0(arg);
! 442: xrange=(LIST)ARG1(arg);
! 443: can=canvas[id=search_canvas()];
! 444: n=BDY(xrange); can->vx=VR((P)BDY(n)); n=NEXT(n);
! 445: can->qxmin=(Q)BDY(n); n=NEXT(n); can->qxmax=(Q)BDY(n);
! 446: can->xmin=ToReal(can->qxmin); can->xmax=ToReal(can->qxmax);
! 447: if(!wsize){
! 448: can->width=DEFAULTWIDTH;
! 449: can->height=DEFAULTHEIGHT;
1.1 noro 450: } else {
1.24 ! saito 451: can->width=QTOS((Q)BDY(BDY(wsize)));
! 452: can->height=QTOS((Q)BDY(NEXT(BDY(wsize))));
1.1 noro 453: }
1.24 ! saito 454: can->wname=wname; can->formula=0; can->mode=MODE_PLOT;
1.1 noro 455: create_canvas(can);
1.24 ! saito 456: w=array->len;
! 457: h=can->height;
! 458: tab=(Real *)BDY(array);
! 459: if(can->ymax==can->ymin){
! 460: for(ymax=ymin=RealtoDbl(tab[0]),ix=1; ix<w; ix++){
! 461: if(RealtoDbl(tab[ix])>ymax)ymax=RealtoDbl(tab[ix]);
! 462: if(RealtoDbl(tab[ix])<ymin)ymin=RealtoDbl(tab[ix]);
1.1 noro 463: }
1.24 ! saito 464: can->ymax=ymax;
! 465: can->ymin=ymin;
1.1 noro 466: } else {
1.24 ! saito 467: ymax=can->ymax;
! 468: ymin=can->ymin;
1.1 noro 469: }
1.24 ! saito 470: dy=ymax-ymin;
! 471: can->pa=(struct pa *)MALLOC(sizeof(struct pa));
! 472: can->pa[0].length=w;
! 473: can->pa[0].pos=pa=(POINT *)MALLOC(w*sizeof(POINT));
! 474: xstep=(double)can->width/(double)(w-1);
! 475: for(ix=0;ix<w;ix++){
1.1 noro 476: #ifndef MAXSHORT
477: #define MAXSHORT ((short)0x7fff)
478: #endif
479: double t;
480:
1.24 ! saito 481: pa[ix].x=(int)(ix*xstep);
! 482: t=(h - 1)*(ymax - RealtoDbl(tab[ix]))/dy;
! 483: if(t>MAXSHORT)pa[ix].y=MAXSHORT;
! 484: else if(t<-MAXSHORT)pa[ix].y=-MAXSHORT;
! 485: else pa[ix].y=(long)t;
1.1 noro 486: }
487: plot_print(display,can);
488: copy_to_canvas(can);
489: return id;
490: }
491:
1.24 ! saito 492: void ifplot_resize(struct canvas *can,POINT spos,POINT epos){
1.1 noro 493: struct canvas *ncan;
494: struct canvas fakecan;
495: Q dx,dy,dx2,dy2,xmin,xmax,ymin,ymax,xmid,ymid;
496: Q sx,sy,ex,ey,cw,ch,ten,two;
497: Q s,t;
498: int new;
499: int w,h,m;
500:
1.24 ! saito 501: if(XC(spos)<XC(epos) && YC(spos)<YC(epos)){
! 502: if(can->precise && !can->wide){
! 503: fakecan=*can;
! 504: ncan=&fakecan;
1.1 noro 505: } else {
1.24 ! saito 506: new=search_canvas();
! 507: ncan=canvas[new];
1.1 noro 508: }
1.24 ! saito 509: ncan->mode=can->mode;
! 510: ncan->zmin=can->zmin; ncan->zmax=can->zmax;
! 511: ncan->nzstep=can->nzstep;
! 512: ncan->wname=can->wname;
! 513: ncan->vx=can->vx; ncan->vy=can->vy;
! 514: ncan->formula=can->formula;
! 515: w=XC(epos)-XC(spos);
! 516: h=YC(epos)-YC(spos);
! 517: m=MAX(can->width,can->height);
! 518: if(can->precise){
! 519: ncan->width=w;
! 520: ncan->height=h;
! 521: } else if(w>h){
! 522: ncan->width=m;
! 523: ncan->height=m*h/w;
1.1 noro 524: } else {
1.24 ! saito 525: ncan->width=m*w/h;
! 526: ncan->height=m;
1.1 noro 527: }
1.24 ! saito 528: if(can->wide){
! 529: STOQ(10,ten);
! 530: STOQ(2,two);
! 531: subq(can->qxmax,can->qxmin,&t);
! 532: mulq(t,ten,&dx);
! 533: subq(can->qymax,can->qymin,&t);
! 534: mulq(t,ten,&dy);
! 535: addq(can->qxmax,can->qxmin,&t);
! 536: divq(t,two,&xmid);
! 537: addq(can->qymax,can->qymin,&t);
! 538: divq(t,two,&ymid);
! 539: divq(dx,two,&dx2);
! 540: divq(dy,two,&dy2);
! 541: subq(xmid,dx2,&xmin);
! 542: addq(xmid,dx2,&xmax);
! 543: subq(ymid,dy2,&ymin);
! 544: addq(ymid,dy2,&ymax);
1.1 noro 545: } else {
1.24 ! saito 546: subq(can->qxmax,can->qxmin,&dx);
! 547: subq(can->qymax,can->qymin,&dy);
! 548: xmin=can->qxmin;
! 549: xmax=can->qxmax;
! 550: ymin=can->qymin;
! 551: ymax=can->qymax;
1.1 noro 552: }
553: STOQ(XC(spos),sx); STOQ(YC(spos),sy); STOQ(XC(epos),ex); STOQ(YC(epos),ey);
554: STOQ(can->width,cw); STOQ(can->height,ch);
555: mulq(sx,dx,&t); divq(t,cw,&s); addq(xmin,s,&ncan->qxmin);
556: mulq(ex,dx,&t); divq(t,cw,&s); addq(xmin,s,&ncan->qxmax);
557: mulq(ey,dy,&t); divq(t,ch,&s); subq(ymax,s,&ncan->qymin);
558: mulq(sy,dy,&t); divq(t,ch,&s); subq(ymax,s,&ncan->qymax);
1.24 ! saito 559: ncan->xmin=ToReal(ncan->qxmin); ncan->xmax=ToReal(ncan->qxmax);
! 560: ncan->ymin=ToReal(ncan->qymin); ncan->ymax=ToReal(ncan->qymax);
! 561: if(can->precise && !can->wide){
! 562: current_can=can;
1.1 noro 563: alloc_pixmap(ncan);
1.4 noro 564: #if defined(VISUAL)
1.24 ! saito 565: ncan->real_can=can;
1.4 noro 566: #endif
1.1 noro 567: qifplotmain(ncan);
568: copy_subimage(ncan,can,spos);
569: copy_to_canvas(can);
570: } else {
571: create_canvas(ncan);
1.24 ! saito 572: if( can->precise ) qifplotmain(ncan);
! 573: else ifplotmain(ncan);
1.1 noro 574: copy_to_canvas(ncan);
575: }
576: }
577: }
578:
1.24 ! saito 579: void plot_resize(struct canvas *can,POINT spos,POINT epos){
1.1 noro 580: struct canvas *ncan;
581: Q dx,dx2,xmin,xmax,xmid;
1.7 noro 582: double dy,ymin,ymax,ymid;
1.1 noro 583: Q sx,ex,cw,ten,two;
584: Q s,t;
585: int new;
586: int w,h,m;
587:
1.24 ! saito 588: if( XC(spos)<XC(epos) && YC(spos)<YC(epos) ){
! 589: new=search_canvas(); ncan=canvas[new];
! 590: ncan->mode=can->mode;
! 591: ncan->zmin=can->zmin; ncan->zmax=can->zmax;
! 592: ncan->nzstep=can->nzstep;
! 593: ncan->wname=can->wname;
! 594: ncan->vx=can->vx; ncan->vy=can->vy;
! 595: ncan->formula=can->formula;
! 596: w=XC(epos)-XC(spos);
! 597: h=YC(epos)-YC(spos);
! 598: m=MAX(can->width,can->height);
! 599: if( w>h ){
! 600: ncan->width=m; ncan->height=m * h/w;
1.1 noro 601: } else {
1.24 ! saito 602: ncan->width=m * w/h; ncan->height=m;
1.1 noro 603: }
1.24 ! saito 604: if( can->wide ){
1.1 noro 605: STOQ(10,ten); STOQ(2,two);
606: subq(can->qxmax,can->qxmin,&t); mulq(t,ten,&dx);
607: addq(can->qxmax,can->qxmin,&t); divq(t,two,&xmid);
608: divq(dx,two,&dx2); subq(xmid,dx2,&xmin); addq(xmid,dx2,&xmax);
609:
1.24 ! saito 610: dy=(can->ymax-can->ymin)*10;
! 611: ymid=(can->ymax+can->ymin)/2;
! 612: ymin=ymid-dy/2; ymax=ymid+dy/2;
1.1 noro 613: } else {
614: subq(can->qxmax,can->qxmin,&dx);
1.24 ! saito 615: xmin=can->qxmin; xmax=can->qxmax;
1.1 noro 616:
1.24 ! saito 617: dy=can->ymax-can->ymin;
! 618: ymin=can->ymin; ymax=can->ymax;
1.1 noro 619: }
620: STOQ(XC(spos),sx); STOQ(XC(epos),ex); STOQ(can->width,cw);
621: mulq(sx,dx,&t); divq(t,cw,&s); addq(xmin,s,&ncan->qxmin);
622: mulq(ex,dx,&t); divq(t,cw,&s); addq(xmin,s,&ncan->qxmax);
1.24 ! saito 623: ncan->xmin=ToReal(ncan->qxmin); ncan->xmax=ToReal(ncan->qxmax);
1.1 noro 624:
1.24 ! saito 625: ncan->ymin=ymax-YC(epos)*dy/can->height;
! 626: ncan->ymax=ymax-YC(spos)*dy/can->height;
1.1 noro 627:
628: create_canvas(ncan);
629: plotcalc(ncan);
630: plot_print(display,ncan);
631: copy_to_canvas(ncan);
632: }
633: }
634:
1.24 ! saito 635: void qifplotmain(struct canvas *can)
1.1 noro 636: {
637: int width,height;
1.24 ! saito 638: char **tabe,*tabeb;
1.1 noro 639: int i;
640:
1.24 ! saito 641: width=can->width; height=can->height;
! 642: tabe=(char **)ALLOCA(width*sizeof(char *)+width*height*sizeof(char));
! 643: bzero((void *)tabe,width*sizeof(char *)+width*height*sizeof(char));
! 644: for( i=0, tabeb=(char *)(tabe+width); i<width; i++ )
! 645: tabe[i]=tabeb + height*i;
1.1 noro 646: define_cursor(can->window,runningcur);
647: set_busy(can); set_selection();
1.24 ! saito 648: qcalc(tabe,can); qif_print(display,tabe,can);
1.1 noro 649: reset_selection(); reset_busy(can);
650: define_cursor(can->window,normalcur);
651: }
652:
1.24 ! saito 653: //*******************ifplotNG
! 654: int ifplotNG(NODE arg,char *func){
! 655: int id,orgcolor,color,op_code;
! 656: NODE n;
! 657: struct canvas *can;
! 658: P formula;
! 659: LIST xrange,yrange,zrange,wsize;
! 660: STRING wname;
! 661:
! 662: formula=(P)ARG0(arg);
! 663: color=QTOS((Q)ARG1(arg));
! 664: xrange=(LIST)ARG2(arg);
! 665: yrange=(LIST)ARG3(arg);
! 666: zrange=(LIST)ARG4(arg);
! 667: wsize=(LIST)ARG5(arg);
! 668: wname=(STRING)ARG6(arg);
! 669:
! 670: can=canvas[id=search_canvas()];
! 671: orgcolor=can->color;
! 672: can->color=color;
! 673: can->division=0;
! 674: // set canvas data
! 675: if(xrange){
! 676: n=BDY(xrange); can->vx=VR((P)BDY(n)); n=NEXT(n);
! 677: can->qxmin=(Q)BDY(n); n=NEXT(n); can->qxmax=(Q)BDY(n);
! 678: can->xmin=ToReal(can->qxmin); can->xmax=ToReal(can->qxmax);
! 679: }
! 680: if(yrange){
! 681: n=BDY(yrange); can->vy=VR((P)BDY(n)); n=NEXT(n);
! 682: can->qymin=(Q)BDY(n); n=NEXT(n); can->qymax=(Q)BDY(n);
! 683: can->ymin=ToReal(can->qymin); can->ymax=ToReal(can->qymax);
! 684: }
! 685: if(zrange){
! 686: n=BDY(zrange); can->zmin=ToReal(BDY(n));
! 687: n=NEXT(n); can->zmax=ToReal(BDY(n));
! 688: n=NEXT(n); can->nzstep=QTOS((Q)BDY(n));
! 689: }
! 690: if(!wsize){
! 691: can->width=DEFAULTWIDTH;
! 692: can->height=DEFAULTHEIGHT;
! 693: } else {
! 694: can->width=QTOS((Q)BDY(BDY(wsize)));
! 695: can->height=QTOS((Q)BDY(NEXT(BDY(wsize))));
! 696: }
! 697: if(wname) can->wname=BDY(wname);
! 698: else can->wname="";
! 699: can->formula=formula;
! 700: set_drawcolor(color);
! 701: if(!strcmp(func,"ifplot"))can->mode=MODE_IFPLOT;
! 702: else if(!strcmp(func,"ifplotD"))can->mode=MODE_IFPLOTD;
! 703: else if(!strcmp(func,"ifplotQ"))can->mode=MODE_IFPLOTQ;
! 704: else if(!strcmp(func,"ifplotB"))can->mode=MODE_IFPLOTB;
! 705: else if(!strcmp(func,"ineqnD"))can->mode=MODE_INEQND;
! 706: else if(!strcmp(func,"ineqnQ"))can->mode=MODE_INEQNQ;
! 707: else if(!strcmp(func,"ineqnB"))can->mode=MODE_INEQNB;
! 708: else if(!strcmp(func,"conplotD"))can->mode=MODE_CONPLOTD;
! 709: else if(!strcmp(func,"conplotQ"))can->mode=MODE_CONPLOTQ;
! 710: else if(!strcmp(func,"conplotB"))can->mode=MODE_CONPLOTB;
! 711: else if(!strcmp(func,"itvifplot")){
! 712: can->mode=MODE_ITVIFPLOT;
! 713: can->division=QTOS((Q)ARG7(arg));
! 714: }
! 715: else can->mode=MODE_IFPLOTD;
! 716: create_canvas(can);
! 717: ifplotmain(can);
! 718: set_drawcolor(orgcolor);
! 719: copy_to_canvas(can);
! 720: can->color=orgcolor;
! 721: return id;
! 722: }
! 723:
! 724: int ifplotOP(NODE arg,char *func){
! 725: //ineqnor[D,Q,B],ineqnand[D,Q,B],ineqnxor[D,Q,b]
! 726: int index,orgcolor,color,op_code;
! 727: NODE n;
! 728: struct canvas *can;
! 729: P formula;
! 730: //s_id,fname,w_id,poly,color
! 731: index=QTOS((Q)ARG0(arg));
! 732: formula=(P)ARG1(arg);
! 733: color=QTOS((Q)ARG2(arg));
! 734: can=canvas[index];
! 735: orgcolor=can->color;
! 736: can->color=color;
! 737: // set canvas data
! 738: can->formula=formula;
! 739: if(!strcmp(func,"ineqnandD"))can->mode=MODE_INEQNANDD;
! 740: else if(!strcmp(func,"ineqnandQ"))can->mode=MODE_INEQNANDQ;
! 741: else if(!strcmp(func,"ineqnandB"))can->mode=MODE_INEQNANDB;
! 742: else if(!strcmp(func,"ineqnorD"))can->mode=MODE_INEQNORD;
! 743: else if(!strcmp(func,"ineqnorQ"))can->mode=MODE_INEQNORQ;
! 744: else if(!strcmp(func,"ineqnorB"))can->mode=MODE_INEQNORB;
! 745: else if(!strcmp(func,"ineqnxorD"))can->mode=MODE_INEQNXORD;
! 746: else if(!strcmp(func,"ineqnxorQ"))can->mode=MODE_INEQNXORQ;
! 747: else if(!strcmp(func,"ineqnxorB"))can->mode=MODE_INEQNXORB;
! 748: else if(!strcmp(func,"plotoverD"))can->mode=MODE_PLOTOVERD;
! 749: else if(!strcmp(func,"plotoverQ"))can->mode=MODE_PLOTOVERQ;
! 750: else if(!strcmp(func,"plotoverB"))can->mode=MODE_PLOTOVERB;
! 751: else can->mode=MODE_IFPLOTD;
! 752: set_drawcolor(color);
! 753: ifplotmain(can);
! 754: set_drawcolor(orgcolor);
! 755: copy_to_canvas(can);
! 756: can->color=orgcolor;
! 757: return index;
! 758: }
! 759:
! 760: void ifplotmain(struct canvas *can){
! 761: int width,height,i,j,ix,iy,**mask;
! 762: double **tabe;
1.1 noro 763:
1.24 ! saito 764: width=can->width; height=can->height;
! 765: tabe=(double **)ALLOCA((width+1)*sizeof(double *));
! 766: for(i=0;i<width;i++)tabe[i]=(double *)ALLOCA((height+1)*sizeof(double));
1.1 noro 767: define_cursor(can->window,runningcur);
768: set_busy(can); set_selection();
1.24 ! saito 769: set_drawcolor(can->color);
! 770: switch(can->mode){
! 771: case MODE_IFPLOTD:
! 772: calc(tabe,can,0);
! 773: if_print(display,tabe,can,1);
! 774: break;
! 775: case MODE_IFPLOTQ:
! 776: calcq(tabe,can,0);
! 777: if_print(display,tabe,can,1);
! 778: break;
! 779: case MODE_IFPLOTB:
! 780: calcb(tabe,can,0);
! 781: if_print(display,tabe,can,0);
! 782: break;
! 783: case MODE_INEQND:
! 784: calc(tabe,can,0);
! 785: area_print(display,tabe,can,0);
! 786: break;
! 787: case MODE_INEQNQ:
! 788: calcq(tabe,can,0);
! 789: area_print(display,tabe,can,0);
! 790: break;
! 791: case MODE_INEQNB:
! 792: calcb(tabe,can,0);
! 793: area_print(display,tabe,can,0);
! 794: break;
! 795: case MODE_INEQNANDD:
! 796: calc(tabe,can,0);
! 797: area_print(display,tabe,can,0);
! 798: break;
! 799: case MODE_INEQNANDQ:
! 800: calcq(tabe,can,0);
! 801: area_print(display,tabe,can,2);
! 802: break;
! 803: case MODE_INEQNANDB:
! 804: calcb(tabe,can,0);
! 805: area_print(display,tabe,can,2);
! 806: break;
! 807: case MODE_INEQNORD:
! 808: calc(tabe,can,0);
! 809: area_print(display,tabe,can,3);
! 810: break;
! 811: case MODE_INEQNORQ:
! 812: calcq(tabe,can,0);
! 813: area_print(display,tabe,can,3);
! 814: break;
! 815: case MODE_INEQNORB:
! 816: calcb(tabe,can,0);
! 817: area_print(display,tabe,can,3);
! 818: break;
! 819: case MODE_INEQNXORD:
! 820: calc(tabe,can,0);
! 821: area_print(display,tabe,can,4);
! 822: break;
! 823: case MODE_INEQNXORQ:
! 824: calcq(tabe,can,0);
! 825: area_print(display,tabe,can,4);
! 826: break;
! 827: case MODE_INEQNXORB:
! 828: calcb(tabe,can,0);
! 829: area_print(display,tabe,can,4);
! 830: break;
! 831: case MODE_CONPLOTD:
! 832: calc(tabe,can,0);
! 833: con_print(display,tabe,can);
! 834: break;
! 835: case MODE_CONPLOTB:
! 836: calcb(tabe,can,0);
! 837: con_print(display,tabe,can);
! 838: break;
! 839: case MODE_CONPLOTQ:
! 840: calcq(tabe,can,0);
! 841: con_print(display,tabe,can);
! 842: break;
! 843: case MODE_PLOTOVERD:
! 844: calc(tabe,can,0);
! 845: over_print(display,tabe,can,0);
! 846: break;
! 847: case MODE_PLOTOVERQ:
! 848: calcq(tabe,can,0);
! 849: over_print(display,tabe,can,0);
! 850: break;
! 851: case MODE_PLOTOVERB:
! 852: calcb(tabe,can,0);
! 853: over_print(display,tabe,can,0);
! 854: break;
! 855: #if defined(INTERVAL)
! 856: case MODE_ITVIFPLOT:
! 857: itvcalc(tabe,can,1);
! 858: if_print(display,tabe,can,1);
! 859: break;
! 860: #endif
! 861: }
! 862: set_drawcolor(can->color);
1.1 noro 863: reset_selection(); reset_busy(can);
864: define_cursor(can->window,normalcur);
865: }
1.22 saito 866:
1.24 ! saito 867: int objcp(NODE arg){
1.22 saito 868: int idsrc, idtrg, op_code;
869: struct canvas *cansrc, *cantrg;
870:
1.24 ! saito 871: idsrc=QTOS((Q)ARG0(arg));
! 872: idtrg=QTOS((Q)ARG1(arg));
! 873: op_code=QTOS((Q)ARG2(arg));
! 874: cansrc=canvas[idsrc];
! 875: cantrg=canvas[idtrg];
1.22 saito 876: obj_op(cansrc, cantrg, op_code);
877: return idsrc;
878: }
879:
1.24 ! saito 880: void obj_op(struct canvas *cansrc, struct canvas *cantrg, int op){
1.22 saito 881: XImage *imgsrc, *imgtrg;
882: int width, height, i, j;
883: unsigned long src, trg, black, white;
884:
1.24 ! saito 885: width=cansrc->width; height=cansrc->height;
! 886: imgsrc=XGetImage(display, cansrc->pix, 0, 0, width, height, -1, ZPixmap);
! 887: imgtrg=XGetImage(display, cantrg->pix, 0, 0, width, height, -1, ZPixmap);
1.22 saito 888: black=GetColor(display, "black");
889: white=GetColor(display, "white");
890: flush();
891: define_cursor(cantrg->window,runningcur);
892: set_busy(cantrg); set_selection();
1.24 ! saito 893: cantrg->precise=cansrc->precise;
! 894: cantrg->noaxis=cansrc->noaxis;
! 895: cantrg->noaxisb=cansrc->noaxisb;
! 896: cantrg->vx=cansrc->vx;
! 897: cantrg->vy=cansrc->vy;
! 898: cantrg->formula=cansrc->formula;
! 899: cantrg->width=cansrc->width;
! 900: cantrg->height=cansrc->height;
! 901: cantrg->xmin=cansrc->xmin;
! 902: cantrg->xmax=cansrc->xmax;
! 903: cantrg->ymin=cansrc->ymin;
! 904: cantrg->ymax=cansrc->ymax;
! 905: cantrg->zmin=cansrc->zmin;
! 906: cantrg->zmax=cansrc->zmax;
! 907: cantrg->nzstep=cansrc->nzstep;
! 908: cantrg->qxmin=cansrc->qxmin;
! 909: cantrg->qxmax=cansrc->qxmax;
! 910: cantrg->qymin=cansrc->qymin;
! 911: cantrg->qymax=cansrc->qymax;
! 912: cantrg->pa=cansrc->pa;
! 913: switch(op){
1.22 saito 914: case 1:/* and case */
915: for(i=0;i<width;i++)for(j=0;j<height;j++){
1.24 ! saito 916: src=XGetPixel(imgsrc,i,j);
! 917: trg=XGetPixel(imgtrg,i,j);
! 918: if( (src == black) || (trg == black) )
1.22 saito 919: XPutPixel(imgtrg,i,j,black);
1.24 ! saito 920: else if( (src == white) || (trg == white) )
1.22 saito 921: XPutPixel(imgtrg,i,j,white);
922: else XPutPixel(imgtrg,i,j,(src & trg));
923: }
924: break;
925: case 3:/* copy case */
1.24 ! saito 926: imgtrg->data=imgsrc->data;
1.22 saito 927: break;
928: case 6:/* xor case */
929: for(i=0;i<width;i++)for(j=0;j<height;j++){
1.24 ! saito 930: src=XGetPixel(imgsrc,i,j);
! 931: trg=XGetPixel(imgtrg,i,j);
! 932: if( (src == black) || (trg == black) )
1.22 saito 933: XPutPixel(imgtrg,i,j,black);
1.24 ! saito 934: else if( (src == white) && (trg == white) )
1.22 saito 935: XPutPixel(imgtrg,i,j,trg|src);
1.24 ! saito 936: else if( (src != white) && (trg != white) )
1.22 saito 937: XPutPixel(imgtrg,i,j,white);
1.24 ! saito 938: else if( src == white )
1.22 saito 939: XPutPixel(imgtrg,i,j,src);
940: }
941: break;
942: case 7:/* or case */
943: for(i=0;i<width;i++)for(j=0;j<height;j++){
1.24 ! saito 944: src=XGetPixel(imgsrc,i,j);
! 945: trg=XGetPixel(imgtrg,i,j);
! 946: if( (src == black) || (trg == black) )
1.22 saito 947: XPutPixel(imgtrg,i,j,black);
1.24 ! saito 948: else if(src == white)
1.22 saito 949: XPutPixel(imgtrg,i,j,trg);
1.24 ! saito 950: else if(trg == white)
1.22 saito 951: XPutPixel(imgtrg,i,j,src);
952: }
953: break;
954: default:
955: break;
956: }
957: XPutImage(display, cantrg->pix, drawGC, imgtrg, 0, 0, 0, 0, width, height);
958: reset_selection(); reset_busy(cantrg);
959: define_cursor(cantrg->window,normalcur);
960: copy_to_canvas(cantrg);
961: count_and_flush();
962: flush();
963: }
964:
1.24 ! saito 965: //ifplotNG
! 966: /*
1.22 saito 967: int ineqnover(NODE arg)
968: {
1.24 ! saito 969: int id;
! 970: struct canvas *can;
! 971: int orgcolor, op_code;
! 972:
! 973: id = QTOS((Q)ARG0(arg));
! 974: can = canvas[id];
! 975: orgcolor = can->color;
! 976: can->formula = (P)ARG1(arg);
! 977: can->color = QTOS((Q)ARG2(arg));
! 978: op_code = QTOS((Q)ARG3(arg));
! 979: can->mode = MODE_INEQNP;
! 980: ineqnmain(can, orgcolor, op_code);
! 981: return id;
1.22 saito 982: }
983: void ineqnmain(struct canvas *can, int orgcolor, int op_code)
984: {
1.24 ! saito 985: int **mask;
! 986: double **tbl;
! 987: int i,j;
! 988:
! 989: current_can = can;
! 990: tbl = (double **)ALLOCA((can->height+1)*sizeof(double *));
! 991: for ( i = 0; i <= can->height; i++ )
! 992: tbl[i] = (double *)ALLOCA((can->width+1)*sizeof(double));
! 993: mask = (int **)ALLOCA(can->height*sizeof(int *));
! 994: for ( i = 0; i < can->height; i++)
! 995: mask[i] = (int *)ALLOCA(can->width*sizeof(int));
! 996:
! 997: define_cursor(can->window,runningcur);
! 998: set_busy(can); set_selection();
! 999: // ineqncalc(tbl, can, 1);
! 1000: calc(tab,can,1);
! 1001: for (j = 0; j < can->height; j++){
! 1002: for (i = 0; i < can->width; i++){
! 1003: if ( tbl[j][i] >= 0 ){
! 1004: if ( (tbl[j+1][i] <= 0 ) ||
! 1005: (tbl[j][i+1] <= 0) ||
! 1006: (tbl[j+1][i+1] <= 0) ) mask[j][i] = 0;
! 1007: else mask[j][i] = 1;
! 1008: } else {
! 1009: if( (tbl[j+1][i] >= 0) ||
! 1010: (tbl[j][i+1] >= 0) ||
! 1011: (tbl[j+1][i+1] >= 0) ) mask[j][i] = 0;
! 1012: else mask[j][i] = -1;
! 1013: }
! 1014: }
! 1015: }
! 1016: area_print(display, mask, can, op_code);
! 1017: reset_selection();
! 1018: reset_busy(can);
! 1019: define_cursor(can->window,normalcur);
1.22 saito 1020: #if !defined(VISUAL)
1.24 ! saito 1021: set_drawcolor(orgcolor);
! 1022: can->color = orgcolor;
1.22 saito 1023: #endif
1.24 ! saito 1024: copy_to_canvas(can);
1.22 saito 1025: }
1.24 ! saito 1026: */
! 1027: int polarplotNG(NODE arg){
! 1028: int id,color,orgcolor;
1.22 saito 1029: NODE n;
1030: struct canvas *can;
1.24 ! saito 1031: P formula;
! 1032: LIST xrange,wsize;
1.22 saito 1033: STRING wname;
1.24 ! saito 1034: V v;
1.22 saito 1035:
1.24 ! saito 1036: formula=(P)ARG0(arg);
! 1037: xrange=(LIST)ARG1(arg);
! 1038: color=QTOS((Q)ARG2(arg));
! 1039: wsize=(LIST)ARG3(arg);
! 1040: wname=(STRING)ARG4(arg);
! 1041:
! 1042: can=canvas[id=search_canvas()];
! 1043: if(xrange){
! 1044: n=BDY(xrange); can->vx=VR((P)BDY(n)); n=NEXT(n);
! 1045: can->qxmin=(Q)BDY(n); n=NEXT(n); can->qxmax=(Q)BDY(n);
! 1046: can->xmin=ToReal(can->qxmin); can->xmax=ToReal(can->qxmax);
! 1047: }
! 1048: can->mode=MODE_POLARPLOT;
! 1049: if(!wsize){
! 1050: can->width=DEFAULTWIDTH;
! 1051: can->height=DEFAULTHEIGHT;
! 1052: } else {
! 1053: can->width=QTOS((Q)BDY(BDY(wsize)));
! 1054: can->height=QTOS((Q)BDY(NEXT(BDY(wsize))));
1.22 saito 1055: }
1.24 ! saito 1056: if(wname)can->wname=BDY(wname);
! 1057: else can->wname="";
! 1058: can->formula=formula;
! 1059: orgcolor=can->color;
! 1060: can->color=color;
! 1061: polarplotcalc(can);
1.22 saito 1062: create_canvas(can);
1.24 ! saito 1063: plot_print(display,can);
! 1064: can->color=orgcolor;
1.22 saito 1065: copy_to_canvas(can);
1066: return id;
1067: }
1068:
1.24 ! saito 1069: int plotoverD(NODE arg){
! 1070: int index, color;
! 1071: P formula;
1.22 saito 1072: struct canvas *can;
1.24 ! saito 1073: VL vl,vl0;
1.22 saito 1074:
1.24 ! saito 1075: index=QTOS((Q)ARG0(arg));
! 1076: formula=(P)ARG1(arg);
! 1077: can=canvas[index];
! 1078: color=can->color;
! 1079: if(!can->window)return -1;
! 1080: get_vars_recursive((Obj)formula,&vl);
! 1081: for(vl0=vl;vl0;vl0=NEXT(vl0))
! 1082: if(vl0->v->attr==(pointer)V_IND)
! 1083: if(vl->v!=can->vx && vl->v!=can->vy) return -1;
! 1084: if(argc(arg)== 3)can->color=QTOS((Q)ARG2(arg));
! 1085: else can->color=0;
1.22 saito 1086: #if !defined(VISUAL)
1.24 ! saito 1087: set_drawcolor(can->color);
1.22 saito 1088: #endif
1.24 ! saito 1089: current_can=can;
! 1090: can->formula=formula;
! 1091: if(can->mode==MODE_PLOT){
! 1092: calcq(can);
! 1093: plot_print(display,can);
! 1094: } else ifplotmain(can);
1.22 saito 1095: copy_to_canvas(can);
1.24 ! saito 1096: can->color=color;
1.22 saito 1097: #if !defined(VISUAL)
1.24 ! saito 1098: set_drawcolor(can->color);
1.22 saito 1099: #endif
1.24 ! saito 1100: return index;
1.22 saito 1101: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>