[BACK]Return to if.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / plot

Annotation of OpenXM_contrib2/asir2000/plot/if.c, Revision 1.37

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>