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

Diff for /OpenXM_contrib2/asir2000/plot/if.c between version 1.1 and 1.23

version 1.1, 1999/12/03 07:39:13 version 1.23, 2011/08/11 06:25:06
Line 1 
Line 1 
 /* $OpenXM: OpenXM/src/asir99/plot/if.c,v 1.1.1.1 1999/11/10 08:12:34 noro Exp $ */  /*
    * Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED
    * All rights reserved.
    *
    * FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited,
    * non-exclusive and royalty-free license to use, copy, modify and
    * redistribute, solely for non-commercial and non-profit purposes, the
    * computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and
    * conditions of this Agreement. For the avoidance of doubt, you acquire
    * only a limited right to use the SOFTWARE hereunder, and FLL or any
    * third party developer retains all rights, including but not limited to
    * copyrights, in and to the SOFTWARE.
    *
    * (1) FLL does not grant you a license in any way for commercial
    * purposes. You may use the SOFTWARE only for non-commercial and
    * non-profit purposes only, such as academic, research and internal
    * business use.
    * (2) The SOFTWARE is protected by the Copyright Law of Japan and
    * international copyright treaties. If you make copies of the SOFTWARE,
    * with or without modification, as permitted hereunder, you shall affix
    * to all such copies of the SOFTWARE the above copyright notice.
    * (3) An explicit reference to this SOFTWARE and its copyright owner
    * shall be made on your publication or presentation in any form of the
    * results obtained by use of the SOFTWARE.
    * (4) In the event that you modify the SOFTWARE, you shall notify FLL by
    * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
    * for such modification or the source code of the modified part of the
    * SOFTWARE.
    *
    * THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL
    * MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND
    * EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS
    * FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES'
    * RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY
    * MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY.
    * UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT,
    * OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY
    * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL
    * DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES
    * ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES
    * FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY
    * DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF
    * SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART
    * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY
    * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
    * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
    *
    * $OpenXM: OpenXM_contrib2/asir2000/plot/if.c,v 1.22 2011/08/10 04:51:58 saito Exp $
   */
 #include "ca.h"  #include "ca.h"
 #include "parse.h"  #include "parse.h"
 #include "ox.h"  #include "ox.h"
 #include "ifplot.h"  #include "ifplot.h"
   
 extern jmp_buf ox_env;  #if defined(INTERVAL)
   /* Time message and func*/
   #include <sys/types.h>
   #include <sys/resource.h>
   #include <sys/time.h>
   
   static struct oEGT ltime;
   static double r0;
   double get_rtime();
   #if defined(ITV_TIME_CHECK)
   void tstart()
   {
           get_eg(&ltime);
           r0 = get_rtime();
   }
   
   void tstop(struct canvas *can)
   {
           struct oEGT egt1;
           double e, g, r;
           char ts[100];
           void popdown_warning();
           Widget warnshell,warndialog;
   
           get_eg(&egt1);
           e = egt1.exectime - ltime.exectime;
           g = egt1.gctime - ltime.gctime;
           r = get_rtime() - r0;
           sprintf(ts,"(%8.6f + gc %8.6f) total %8.6f \n",e,g,r);
           create_popup(can->shell,"Message",&ts,&warnshell,&warndialog);
           XawDialogAddButton(warndialog,"OK",popdown_warning,warnshell);
           XtPopup(warnshell,XtGrabNone);
           SetWM_Proto(warnshell);
   }
   #else
   #define tstart()
   #define tstop(a)
   #endif
   #endif
   
   extern JMP_BUF ox_env;
   
   int open_canvas(NODE arg)
   {
           int id;
           struct canvas *can;
           LIST wsize;
           STRING wname;
   
           wsize = (LIST)ARG0(arg);
           wname = (STRING)ARG1(arg);
   
           can = canvas[id = search_canvas()];
           can->mode = MODE_INTERACTIVE;
           if ( !wsize ) {
                   can->width = DEFAULTWIDTH; can->height = DEFAULTHEIGHT;
           } else {
                   can->width = QTOS((Q)BDY(BDY(wsize)));
                   can->height = QTOS((Q)BDY(NEXT(BDY(wsize))));
           }
           if ( wname )
                   can->wname = BDY(wname);
           else
                   can->wname = "";
           create_canvas(can);
           return id;
   }
   
 int plot(NODE arg)  int plot(NODE arg)
 {  {
         int id;          int id;
Line 14  int plot(NODE arg)
Line 128  int plot(NODE arg)
         P formula;          P formula;
         LIST xrange,yrange,zrange,wsize;          LIST xrange,yrange,zrange,wsize;
         STRING wname;          STRING wname;
           V v;
   
         formula = (P)ARG0(arg);          formula = (P)ARG0(arg);
         xrange = (LIST)ARG1(arg);          xrange = (LIST)ARG1(arg);
Line 23  int plot(NODE arg)
Line 138  int plot(NODE arg)
         wname = (STRING)ARG5(arg);          wname = (STRING)ARG5(arg);
   
         can = canvas[id = search_canvas()];          can = canvas[id = search_canvas()];
           if ( xrange ) {
                   n = BDY(xrange); can->vx = VR((P)BDY(n)); n = NEXT(n);
                   can->qxmin = (Q)BDY(n); n = NEXT(n); can->qxmax = (Q)BDY(n);
                   can->xmin = ToReal(can->qxmin); can->xmax = ToReal(can->qxmax);
           }
           if ( yrange ) {
                   n = BDY(yrange); can->vy = VR((P)BDY(n)); n = NEXT(n);
                   can->qymin = (Q)BDY(n); n = NEXT(n); can->qymax = (Q)BDY(n);
                   can->ymin = ToReal(can->qymin); can->ymax = ToReal(can->qymax);
           }
           if ( xrange && yrange )
                   can->mode = zrange ? MODE_CONPLOT : MODE_IFPLOT;
           else
                   can->mode = xrange ? MODE_PLOT : MODE_POLARPLOT;
   
           if ( zrange ) {
                   n = NEXT(BDY(zrange));
                   can->zmin = ToReal(BDY(n));
                   n = NEXT(n); can->zmax = ToReal(BDY(n));
                   n = NEXT(n);
                   if ( can->mode == MODE_CONPLOT )
                           can->nzstep = n ? QTOS((Q)BDY(n)) : MAXGC;
                   else {
                           /* XXX */
                           can->vx = VR((P)BDY(BDY(zrange)));
                           can->nzstep = n ? QTOS((Q)BDY(n)) : DEFAULTPOLARSTEP;
                   }
           }
   
           if ( !wsize ) {
                   can->width = DEFAULTWIDTH; can->height = DEFAULTHEIGHT;
           } else {
                   can->width = QTOS((Q)BDY(BDY(wsize)));
                   can->height = QTOS((Q)BDY(NEXT(BDY(wsize))));
           }
           if ( wname )
                   can->wname = BDY(wname);
           else
                   can->wname = "";
           can->formula = formula;
           if ( can->mode == MODE_PLOT ) {
                   plotcalc(can);
                   create_canvas(can);
                   plot_print(display,can);
           } else if ( can->mode == MODE_POLARPLOT ) {
                   polarplotcalc(can);
                   create_canvas(can);
                   plot_print(display,can);
           } else {
                   create_canvas(can);
                   ifplotmain(can);
           }
           copy_to_canvas(can);
           return id;
   }
   
   int memory_plot(NODE arg,LIST *bytes)
   {
           NODE n;
           struct canvas tmp_can;
           struct canvas *can;
           P formula;
           LIST xrange,yrange,zrange,wsize;
           int width,height;
           double **tabe;
           int i;
           BYTEARRAY barray;
           Q qw,qh;
   
           formula = (P)ARG0(arg);
           xrange = (LIST)ARG1(arg);
           yrange = (LIST)ARG2(arg);
           zrange = (LIST)ARG3(arg);
           wsize = (LIST)ARG4(arg);
   
           bzero((char *)&tmp_can,sizeof(tmp_can));
           can = &tmp_can;
         n = BDY(xrange); can->vx = VR((P)BDY(n)); n = NEXT(n);          n = BDY(xrange); can->vx = VR((P)BDY(n)); n = NEXT(n);
         can->qxmin = (Q)BDY(n); n = NEXT(n); can->qxmax = (Q)BDY(n);          can->qxmin = (Q)BDY(n); n = NEXT(n); can->qxmax = (Q)BDY(n);
         can->xmin = ToReal(can->qxmin); can->xmax = ToReal(can->qxmax);          can->xmin = ToReal(can->qxmin); can->xmax = ToReal(can->qxmax);
Line 48  int plot(NODE arg)
Line 240  int plot(NODE arg)
                 can->width = QTOS((Q)BDY(BDY(wsize)));                  can->width = QTOS((Q)BDY(BDY(wsize)));
                 can->height = QTOS((Q)BDY(NEXT(BDY(wsize))));                  can->height = QTOS((Q)BDY(NEXT(BDY(wsize))));
         }          }
         if ( wname )          can->wname = "";
                 can->wname = BDY(wname);  
         else  
                 can->wname = "";  
         can->formula = formula;          can->formula = formula;
         create_canvas(can);  
         if ( can->mode == MODE_PLOT ) {          if ( can->mode == MODE_PLOT ) {
                 plotcalc(can);                  plotcalc(can);
                 plot_print(display,can);                  memory_print(can,&barray);
         } else                  STOQ(can->width,qw); STOQ(can->height,qh);
                 ifplotmain(can);                  n = mknode(3,qw,qh,barray);
         copy_to_canvas(can);                  MKLIST(*bytes,n);
         return id;          } else {
                   width = can->width; height = can->height;
                   tabe = (double **)ALLOCA(width*sizeof(double *));
                   for ( i = 0; i < width; i++ )
                           tabe[i] = (double *)ALLOCA(height*sizeof(double));
                   calc(tabe,can,1);
                   memory_if_print(tabe,can,&barray);
                   STOQ(width,qw); STOQ(height,qh);
                   n = mknode(3,qw,qh,barray);
                   MKLIST(*bytes,n);
           }
 }  }
   
 int plotover(NODE arg)  int plotover(NODE arg)
 {  {
         int index;          int index, color;
         P formula;          P formula;
         struct canvas *can;          struct canvas *can;
         struct canvas fakecan;  
         VL vl,vl0;          VL vl,vl0;
   
         index = QTOS((Q)ARG0(arg));          index = QTOS((Q)ARG0(arg));
         formula = (P)ARG1(arg);          formula = (P)ARG1(arg);
         can = canvas[index];          can = canvas[index];
           color = can->color;
         if ( !can->window )          if ( !can->window )
                 return -1;                  return -1;
         get_vars_recursive(formula,&vl);          get_vars_recursive((Obj)formula,&vl);
         for ( vl0 = vl; vl0; vl0 = NEXT(vl0) )          for ( vl0 = vl; vl0; vl0 = NEXT(vl0) )
                 if ( vl0->v->attr == V_IND )                  if ( vl0->v->attr == (pointer)V_IND )
                         if ( vl->v != can->vx && vl->v != can->vy )                          if ( vl->v != can->vx && vl->v != can->vy )
                                 return -1;                                  return -1;
           if ( argc(arg) == 3 )
                   can->color = QTOS((Q)ARG2(arg));
           else
                   can->color = 0;
   #if !defined(VISUAL)
           set_drawcolor(can->color);
   #endif
         current_can = can;          current_can = can;
         fakecan = *can; fakecan.formula = formula;          can->formula = formula;
         if ( can->mode == MODE_PLOT ) {          if ( can->mode == MODE_PLOT ) {
                 plotcalc(&fakecan);                  plotcalc(can);
                 plot_print(display,&fakecan);                  plot_print(display,can);
         } else          } else
                 ifplotmain(&fakecan);                  ifplotmain(can);
         copy_to_canvas(&fakecan);          copy_to_canvas(can);
           can->color = color;
   #if !defined(VISUAL)
           set_drawcolor(can->color);
   #endif
         return index;          return index;
 }  }
   
 int drawcircle(NODE arg)  int drawcircle(NODE arg)
 {  {
   #if !defined(VISUAL)
         int id;          int id;
         int index;          int index;
         pointer ptr;          pointer ptr;
         Q ret;          Q ret;
         LIST xyr;          LIST xyr;
         Obj x,y,r;          Obj x,y,r;
         int wx,wy,wr;          int wx,wy,wr,c;
         struct canvas *can;          struct canvas *can;
         struct canvas fakecan;  
   
         index = QTOS((Q)ARG0(arg));          index = QTOS((Q)ARG0(arg));
         xyr = (LIST)ARG1(arg);          xyr = (LIST)ARG1(arg);
         x = (Obj)ARG0(BDY(xyr)); y = (Obj)ARG1(BDY(xyr)); r = (Obj)ARG2(BDY(xyr));          x = (Obj)ARG0(BDY(xyr)); y = (Obj)ARG1(BDY(xyr)); r = (Obj)ARG2(BDY(xyr));
           c = QTOS((Q)ARG2(arg));
         can = canvas[index];          can = canvas[index];
         if ( !can->window )          if ( !can->window )
                 return -1;                  return -1;
         else {          else {
                 current_can = can;                  current_can = can;
                   set_drawcolor(c);
                 wx = (ToReal(x)-can->xmin)*can->width/(can->xmax-can->xmin);                  wx = (ToReal(x)-can->xmin)*can->width/(can->xmax-can->xmin);
                 wy = (can->ymax-ToReal(y))*can->height/(can->ymax-can->ymin);                  wy = (can->ymax-ToReal(y))*can->height/(can->ymax-can->ymin);
                 wr = ToReal(r);                  wr = ToReal(r);
                 XFillArc(display,can->pix,colorGC,wx-wr/2,wy-wr/2,wr,wr,0,360*64);                  XFillArc(display,can->pix,cdrawGC,wx-wr/2,wy-wr/2,wr,wr,0,360*64);
                 copy_to_canvas(can);                  copy_to_canvas(can);
                   set_drawcolor(can->color);
                 return index;                  return index;
         }          }
   #endif
 }  }
   
   int draw_obj(NODE arg)
   {
           int index;
           int x,y,u,v,len,r;
           NODE obj,n;
           RealVect *vect;
           struct canvas *can;
           int color;
   
           index = QTOS((Q)ARG0(arg));
           can = canvas[index];
           if ( !can && closed_canvas[index] ) {
                   canvas[index] = closed_canvas[index];
                   closed_canvas[index] = 0;
                   can = canvas[index];
                   popup_canvas(index);
                   current_can = can;
           } else if ( !can || (can && !can->window) ) {
                   set_lasterror("draw_obj : canvas does not exist");
                   return -1;
           }
   
           obj = BDY((LIST)ARG1(arg));
           if ( argc(arg) == 3 )
                   color = QTOS((Q)ARG2(arg));
           else
                   color = 0; /* black */
           switch ( len = length(obj) ) {
                   case 2: /* point */
                           x = (int)ToReal((Q)ARG0(obj)); y = (int)ToReal((Q)ARG1(obj));
                           draw_point(display,can,x,y,color);
                           MKRVECT3(vect,x,y,color); MKNODE(n,vect,can->history);
                           can->history = n;
                           break;
                   case 3: /* circle */
                           x = (int)ToReal((Q)ARG0(obj)); y = (int)ToReal((Q)ARG1(obj));
                           r = (int)ToReal((Q)ARG2(obj));
                           MKRVECT4(vect,x,y,r,color); MKNODE(n,vect,can->history);
                           can->history = n;
                           break;
                   case 4: /* line */
                           x = (int)ToReal((Q)ARG0(obj)); y = (int)ToReal((Q)ARG1(obj));
                           u = (int)ToReal((Q)ARG2(obj)); v = (int)ToReal((Q)ARG3(obj));
                           draw_line(display,can,x,y,u,v,color);
                           MKRVECT5(vect,x,y,u,v,color); MKNODE(n,vect,can->history);
                           can->history = n;
                           break;
                   default:
                           set_lasterror("draw_obj : invalid request");
                           return -1;
           }
   #if !defined(VISUAL)
           set_drawcolor(can->color);
   #endif
           return 0;
   }
   
   int draw_string(NODE arg)
   {
           int index,x,y;
           char *str;
           NODE pos;
           struct canvas *can;
           int color;
   
           index = QTOS((Q)ARG0(arg));
           can = canvas[index];
           if ( !can && closed_canvas[index] ) {
                   canvas[index] = closed_canvas[index];
                   closed_canvas[index] = 0;
                   can = canvas[index];
                   popup_canvas(index);
                   current_can = can;
           } else if ( !can || (can && !can->window) ) {
                   set_lasterror("draw_obj : canvas does not exist");
                   return -1;
           }
   
           pos = BDY((LIST)ARG1(arg));
           str = BDY((STRING)ARG2(arg));
           if ( argc(arg) == 4 )
                   color = QTOS((Q)ARG3(arg));
           else
                   color = 0; /* black */
           x = (int)ToReal((Q)ARG0(pos));
           y = (int)ToReal((Q)ARG1(pos));
           draw_character_string(display,can,x,y,str,color);
   #if !defined(VISUAL)
           set_drawcolor(can->color);
   #endif
           return 0;
   }
   
   int clear_canvas(NODE arg)
   {
           int index;
           struct canvas *can;
   
           index = QTOS((Q)ARG0(arg));
           can = canvas[index];
           if ( !can || !can->window )
                   return -1;
           clear_pixmap(can);
           copy_to_canvas(can);
           /* clear the history */
           can->history = 0;
   }
   
 #define RealtoDbl(r) ((r)?BDY(r):0.0)  #define RealtoDbl(r) ((r)?BDY(r):0.0)
   
 int arrayplot(NODE arg)  int arrayplot(NODE arg)
Line 130  int arrayplot(NODE arg)
Line 451  int arrayplot(NODE arg)
         LIST xrange,wsize;          LIST xrange,wsize;
         char *wname;          char *wname;
         NODE n;          NODE n;
         Q ret;  
         double ymax,ymin,dy,xstep;          double ymax,ymin,dy,xstep;
         Real *tab;          Real *tab;
         struct canvas *can;          struct canvas *can;
Line 182  int arrayplot(NODE arg)
Line 502  int arrayplot(NODE arg)
                 else if ( t < -MAXSHORT )                  else if ( t < -MAXSHORT )
                         pa[ix].y = -MAXSHORT;                          pa[ix].y = -MAXSHORT;
                 else                  else
                         pa[ix].y = t;                          pa[ix].y = (long)t;
         }          }
         plot_print(display,can);          plot_print(display,can);
         copy_to_canvas(can);          copy_to_canvas(can);
         return id;          return id;
 }  }
   
 ifplot_resize(can,spos,epos)  void ifplot_resize(struct canvas *can,POINT spos,POINT epos)
 struct canvas *can;  
 POINT spos,epos;  
 {  {
         struct canvas *ncan;          struct canvas *ncan;
         struct canvas fakecan;          struct canvas fakecan;
Line 200  POINT spos,epos;
Line 518  POINT spos,epos;
         Q s,t;          Q s,t;
         int new;          int new;
         int w,h,m;          int w,h,m;
         Q ret;  
   
         if ( XC(spos) < XC(epos) && YC(spos) < YC(epos) ) {          if ( XC(spos) < XC(epos) && YC(spos) < YC(epos) ) {
                 if ( can->precise && !can->wide ) {                  if ( can->precise && !can->wide ) {
Line 249  POINT spos,epos;
Line 566  POINT spos,epos;
                 if ( can->precise && !can->wide ) {                  if ( can->precise && !can->wide ) {
                         current_can = can;                          current_can = can;
                         alloc_pixmap(ncan);                          alloc_pixmap(ncan);
   #if defined(VISUAL)
                           ncan->real_can = can;
   #endif
                         qifplotmain(ncan);                          qifplotmain(ncan);
                         copy_subimage(ncan,can,spos);                          copy_subimage(ncan,can,spos);
                         copy_to_canvas(can);                          copy_to_canvas(can);
Line 263  POINT spos,epos;
Line 583  POINT spos,epos;
         }          }
 }  }
   
 plot_resize(can,spos,epos)  void plot_resize(struct canvas *can,POINT spos,POINT epos)
 struct canvas *can;  
 POINT spos,epos;  
 {  {
         struct canvas *ncan;          struct canvas *ncan;
         Q dx,dx2,xmin,xmax,xmid;          Q dx,dx2,xmin,xmax,xmid;
         double dy,dy2,ymin,ymax,ymid;          double dy,ymin,ymax,ymid;
         Q sx,ex,cw,ten,two;          Q sx,ex,cw,ten,two;
         double sy,ey;  
         Q s,t;          Q s,t;
         int new;          int new;
         int w,h,m;          int w,h,m;
Line 323  POINT spos,epos;
Line 640  POINT spos,epos;
         }          }
 }  }
   
 ifplotmain(can)  void ifplotmain(struct canvas *can)
 struct canvas *can;  
 {  {
         int width,height;          int width,height;
         double **tabe,*tabeb;          double **tabe;
         int i;          int i;
   
   #if defined(INTERVAL)
           tstart();
   #endif
         width = can->width; height = can->height;          width = can->width; height = can->height;
         tabe = (double **)ALLOCA(width*sizeof(double *));          tabe = (double **)ALLOCA((width+1)*sizeof(double *));
         for ( i = 0; i < width; i++ )          for ( i = 0; i < width; i++ )
                 tabe[i] = (double *)ALLOCA(height*sizeof(double));                  tabe[i] = (double *)ALLOCA((height+1)*sizeof(double));
         define_cursor(can->window,runningcur);          define_cursor(can->window,runningcur);
         set_busy(can); set_selection();          set_busy(can); set_selection();
         calc(tabe,can); if_print(display,tabe,can);          calc(tabe,can,0); if_print(display,tabe,can);
         reset_selection(); reset_busy(can);          reset_selection(); reset_busy(can);
         define_cursor(can->window,normalcur);          define_cursor(can->window,normalcur);
   #if defined(INTERVAL)
           tstop(can);
   #endif
 }  }
   
 qifplotmain(can)  void qifplotmain(struct canvas *can)
 struct canvas *can;  
 {  {
         int width,height;          int width,height;
         char **tabe,*tabeb;          char **tabe,*tabeb;
Line 350  struct canvas *can;
Line 671  struct canvas *can;
   
         width = can->width; height = can->height;          width = can->width; height = can->height;
         tabe = (char **)ALLOCA(width*sizeof(char *)+width*height*sizeof(char));          tabe = (char **)ALLOCA(width*sizeof(char *)+width*height*sizeof(char));
         bzero(tabe,width*sizeof(char *)+width*height*sizeof(char));          bzero((void *)tabe,width*sizeof(char *)+width*height*sizeof(char));
         for ( i = 0, tabeb = (char *)(tabe+width); i < width; i++ )          for ( i = 0, tabeb = (char *)(tabe+width); i < width; i++ )
                 tabe[i] = tabeb + height*i;                  tabe[i] = tabeb + height*i;
         define_cursor(can->window,runningcur);          define_cursor(can->window,runningcur);
Line 359  struct canvas *can;
Line 680  struct canvas *can;
         reset_selection(); reset_busy(can);          reset_selection(); reset_busy(can);
         define_cursor(can->window,normalcur);          define_cursor(can->window,normalcur);
 }  }
   
   #if defined(INTERVAL)
   int objcp(NODE arg)
   {
           int idsrc, idtrg, op_code;
           struct canvas *cansrc, *cantrg;
   
           idsrc = QTOS((Q)ARG0(arg));
           idtrg = QTOS((Q)ARG1(arg));
           op_code = QTOS((Q)ARG2(arg));
           cansrc = canvas[idsrc];
           cantrg = canvas[idtrg];
           obj_op(cansrc, cantrg, op_code);
           return idsrc;
   }
   
   void obj_op(struct canvas *cansrc, struct canvas *cantrg, int op)
   {
           XImage *imgsrc, *imgtrg;
           int width, height, i, j;
           unsigned long src, trg, black, white;
   
           width = cansrc->width; height = cansrc->height;
           imgsrc = XGetImage(display, cansrc->pix, 0, 0, width, height, -1, ZPixmap);
           imgtrg = XGetImage(display, cantrg->pix, 0, 0, width, height, -1, ZPixmap);
           black=GetColor(display, "black");
           white=GetColor(display, "white");
           flush();
           define_cursor(cantrg->window,runningcur);
           set_busy(cantrg); set_selection();
           cantrg->precise = cansrc->precise;
           cantrg->noaxis = cansrc->noaxis;
           cantrg->noaxisb = cansrc->noaxisb;
           cantrg->vx = cansrc->vx;
           cantrg->vy = cansrc->vy;
           cantrg->formula = cansrc->formula;
           cantrg->width = cansrc->width;
           cantrg->height = cansrc->height;
           cantrg->xmin = cansrc->xmin;
           cantrg->xmax = cansrc->xmax;
           cantrg->ymin = cansrc->ymin;
           cantrg->ymax = cansrc->ymax;
           cantrg->zmin = cansrc->zmin;
           cantrg->zmax = cansrc->zmax;
           cantrg->nzstep = cansrc->nzstep;
           cantrg->qxmin = cansrc->qxmin;
           cantrg->qxmax = cansrc->qxmax;
           cantrg->qymin = cansrc->qymin;
           cantrg->qymax = cansrc->qymax;
           cantrg->pa = cansrc->pa;
           switch (op) {
                   case 1:/* and case */
                           for(i=0;i<width;i++)for(j=0;j<height;j++){
                                   src = XGetPixel(imgsrc,i,j);
                                   trg = XGetPixel(imgtrg,i,j);
                                   if ( (src == black) || (trg == black) )
                                           XPutPixel(imgtrg,i,j,black);
                                   else if ( (src == white) || (trg == white) )
                                           XPutPixel(imgtrg,i,j,white);
                                   else XPutPixel(imgtrg,i,j,(src & trg));
                           }
                           break;
                   case 3:/* copy case */
                           imgtrg->data = imgsrc->data;
                           break;
                   case 6:/* xor case */
                           for(i=0;i<width;i++)for(j=0;j<height;j++){
                                   src = XGetPixel(imgsrc,i,j);
                                   trg = XGetPixel(imgtrg,i,j);
                                   if ( (src == black) || (trg == black) )
                                           XPutPixel(imgtrg,i,j,black);
                                   else if ( (src == white) && (trg == white) )
                                           XPutPixel(imgtrg,i,j,trg|src);
                                   else if ( (src != white) && (trg != white) )
                                           XPutPixel(imgtrg,i,j,white);
                                   else if ( src == white )
                                           XPutPixel(imgtrg,i,j,src);
                           }
                           break;
                   case 7:/* or case */
                           for(i=0;i<width;i++)for(j=0;j<height;j++){
                                   src = XGetPixel(imgsrc,i,j);
                                   trg = XGetPixel(imgtrg,i,j);
                                   if ( (src == black) || (trg == black) )
                                           XPutPixel(imgtrg,i,j,black);
                                   else if (src == white)
                                           XPutPixel(imgtrg,i,j,trg);
                                   else if (trg == white)
                                           XPutPixel(imgtrg,i,j,src);
                           }
                           break;
                   default:
                           break;
           }
           XPutImage(display, cantrg->pix, drawGC, imgtrg, 0, 0, 0, 0, width, height);
           reset_selection(); reset_busy(cantrg);
           define_cursor(cantrg->window,normalcur);
           copy_to_canvas(cantrg);
           count_and_flush();
           flush();
   }
   
   int ineqn(NODE arg)
   {
           int id, op_code, orgcolor;
           struct canvas *can;
           LIST xrange, yrange, geom;
           NODE n;
           STRING wname;
           double **tbl;
   
           can = canvas[id = search_canvas()];
           orgcolor = can->color;
           can->formula = (P)ARG0(arg);
           can->color = QTOS((Q)ARG1(arg));
           xrange = (LIST)ARG2(arg);
           yrange = (LIST)ARG3(arg);
           geom   = (LIST)ARG4(arg);
           wname  = (STRING)ARG5(arg);
           op_code = 3;
           /* set canvas data */
           can->mode = MODE_INEQNP;
           can->width = QTOS((Q)BDY(BDY(geom)));
           can->height = QTOS((Q)BDY(NEXT(BDY(geom))));
           n = BDY(xrange); can->vx = VR((P)BDY(n)); n = NEXT(n);
           can->qxmin = (Q)BDY(n); n = NEXT(n); can->qxmax = (Q)BDY(n);
           can->xmin = ToReal(can->qxmin); can->xmax = ToReal(can->qxmax);
           n = BDY(yrange); can->vy = VR((P)BDY(n)); n = NEXT(n);
           can->qymin = (Q)BDY(n); n = NEXT(n); can->qymax = (Q)BDY(n);
           can->ymin = ToReal(can->qymin); can->ymax = ToReal(can->qymax);
           can->mode = MODE_INEQNP;
           if ( wname )
                   can->wname = BDY(wname);
           else
                   can->wname = "";
           create_canvas(can);
           ineqnmain(can, orgcolor, op_code);
           return id;
   }
   
   int ineqnover(NODE arg)
   {
           int id;
           struct canvas *can;
           int orgcolor, op_code;
   
           id = QTOS((Q)ARG0(arg));
           can = canvas[id];
           orgcolor = can->color;
           can->formula = (P)ARG1(arg);
           can->color   = QTOS((Q)ARG2(arg));
           op_code      = QTOS((Q)ARG3(arg));
           can->mode    = MODE_INEQNP;
           ineqnmain(can, orgcolor, op_code);
           return id;
   }
   
   void ineqnmain(struct canvas *can, int orgcolor, int op_code)
   {
           int **mask;
           double **tbl;
           int i,j;
   
           current_can = can;
           tbl = (double **)ALLOCA((can->height+1)*sizeof(double *));
           for ( i = 0; i <= can->height; i++ )
                   tbl[i] = (double *)ALLOCA((can->width+1)*sizeof(double));
           mask = (int **)ALLOCA(can->height*sizeof(int *));
           for ( i = 0; i < can->height; i++)
                   mask[i] = (int *)ALLOCA(can->width*sizeof(int));
   
           define_cursor(can->window,runningcur);
           set_busy(can); set_selection();
           ineqncalc(tbl, can, 1);
           for (j = 0; j < can->height; j++){
                   for (i = 0; i < can->width; i++){
                           if ( tbl[j][i] >= 0 ){
                                   if ( (tbl[j+1][i] <= 0 ) ||
                                           (tbl[j][i+1] <= 0) ||
                                           (tbl[j+1][i+1] <= 0) ) mask[j][i] = 0;
                                   else mask[j][i] = 1;
                           } else {
                                   if( (tbl[j+1][i] >= 0) ||
                                           (tbl[j][i+1] >= 0) ||
                                           (tbl[j+1][i+1] >= 0) ) mask[j][i] = 0;
                                   else mask[j][i] = -1;
                           }
                   }
           }
           area_print(display, mask, can, op_code);
           reset_selection();
           reset_busy(can);
           define_cursor(can->window,normalcur);
   #if !defined(VISUAL)
           set_drawcolor(orgcolor);
           can->color = orgcolor;
   #endif
           copy_to_canvas(can);
   }
   
   int itvifplot(NODE arg)
   {
           int id, op_code, orgcolor;
           struct canvas *can;
           LIST xrange, yrange, zrange, geom;
           NODE n;
           STRING wname;
           double **tbl;
           int itvsize;
   
           can = canvas[id = search_canvas()];
           orgcolor = can->color;
           can->formula = (P)ARG0(arg);
           xrange = (LIST)ARG1(arg);
           yrange = (LIST)ARG2(arg);
           zrange = (LIST)ARG3(arg);
           geom   = (LIST)ARG4(arg);
           wname  = (STRING)ARG5(arg);
           itvsize = QTOS((Q)ARG6(arg));
           /* set canvas data */
           can->mode = MODE_INEQNP;
           can->width = QTOS((Q)BDY(BDY(geom)));
           can->height = QTOS((Q)BDY(NEXT(BDY(geom))));
           n = BDY(xrange); can->vx = VR((P)BDY(n)); n = NEXT(n);
           can->qxmin = (Q)BDY(n); n = NEXT(n); can->qxmax = (Q)BDY(n);
           can->xmin = ToReal(can->qxmin); can->xmax = ToReal(can->qxmax);
           n = BDY(yrange); can->vy = VR((P)BDY(n)); n = NEXT(n);
           can->qymin = (Q)BDY(n); n = NEXT(n); can->qymax = (Q)BDY(n);
           can->ymin = ToReal(can->qymin); can->ymax = ToReal(can->qymax);
           can->mode = MODE_INEQNP;
           if ( wname )
                   can->wname = BDY(wname);
           else
                   can->wname = "";
           create_canvas(can);
           itvplotmain(can, itvsize);
   #if !defined(VISUAL)
           set_drawcolor(orgcolor);
           can->color = orgcolor;
   #endif
           copy_to_canvas(can);
           return id;
   }
   
   void itvplotmain(struct canvas *can, int itvsize)
   {
           int **mask;
           double **tbl;
           int i,j;
           int op_code;
           pointer *prp;
   
           tstart(); /* time calc */
           op_code=3;
           current_can = can;
           can->color=0xff00;
           mask = (int **)ALLOCA(can->height*sizeof(int *));
           for ( i = 0; i < can->height; i++){
                   mask[i] = (int *)ALLOCA(can->width*sizeof(int));
                   for (j = 0; j< can->width; j++) mask[i][j] = -1;
           }
           define_cursor(can->window,runningcur);
           set_busy(can); set_selection();
           itvcalc(mask, can, 1, itvsize);
           area_print(display, mask, can, op_code);
           reset_selection();
           reset_busy(can);
           define_cursor(can->window,normalcur);
           tstop(can); /* time calc */
   }
   
   // NORMAL type
   int itvplot1(NODE arg)
   {
           int id, op_code, orgcolor;
           struct canvas *can;
           LIST xrange, yrange, zrange, geom;
           NODE n;
           STRING wname;
           double **tbl;
   
           can = canvas[id = search_canvas()];
           orgcolor = can->color;
           can->formula = (P)ARG0(arg);
           xrange = (LIST)ARG1(arg);
           yrange = (LIST)ARG2(arg);
           zrange = (LIST)ARG3(arg);
           geom   = (LIST)ARG4(arg);
           wname  = (STRING)ARG5(arg);
           /* set canvas data */
           can->mode = MODE_INEQNP;
           can->width = QTOS((Q)BDY(BDY(geom)));
           can->height = QTOS((Q)BDY(NEXT(BDY(geom))));
           n = BDY(xrange); can->vx = VR((P)BDY(n)); n = NEXT(n);
           can->qxmin = (Q)BDY(n); n = NEXT(n); can->qxmax = (Q)BDY(n);
           can->xmin = ToReal(can->qxmin); can->xmax = ToReal(can->qxmax);
           n = BDY(yrange); can->vy = VR((P)BDY(n)); n = NEXT(n);
           can->qymin = (Q)BDY(n); n = NEXT(n); can->qymax = (Q)BDY(n);
           can->ymin = ToReal(can->qymin); can->ymax = ToReal(can->qymax);
           can->mode = MODE_INEQNP;
           if ( wname )
                   can->wname = BDY(wname);
           else
                   can->wname = "";
           create_canvas(can);
           itvplotmain1(can);
   #if !defined(VISUAL)
           set_drawcolor(orgcolor);
           can->color = orgcolor;
   #endif
           copy_to_canvas(can);
           return id;
   }
   
   void itvplotmain1(struct canvas *can)
   {
           int **mask;
           double **tbl;
           int i,j;
           int op_code;
   
           op_code=3;
           current_can = can;
           mask = (int **)ALLOCA(can->height*sizeof(int *));
           for ( i = 0; i < can->height; i++){
                   mask[i] = (int *)ALLOCA(can->width*sizeof(int));
                   for (j = 0; j< can->width; j++) mask[i][j] = -1;
           }
   
           define_cursor(can->window,runningcur);
           set_busy(can); set_selection();
           itvcalc1(mask, can, 1);
           area_print(display, mask, can, op_code);
           reset_selection();
           reset_busy(can);
           define_cursor(can->window,normalcur);
   }
   
   // TRANSFER type
   int itvplot2(NODE arg)
   {
           int id, op_code, orgcolor;
           struct canvas *can;
           LIST xrange, yrange, zrange, geom;
           NODE n;
           STRING wname;
           double **tbl;
   
           can = canvas[id = search_canvas()];
           orgcolor = can->color;
           can->formula = (P)ARG0(arg);
           xrange = (LIST)ARG1(arg);
           yrange = (LIST)ARG2(arg);
           zrange = (LIST)ARG3(arg);
           geom   = (LIST)ARG4(arg);
           wname  = (STRING)ARG5(arg);
           /* set canvas data */
           can->mode = MODE_INEQNP;
           can->width = QTOS((Q)BDY(BDY(geom)));
           can->height = QTOS((Q)BDY(NEXT(BDY(geom))));
           n = BDY(xrange); can->vx = VR((P)BDY(n)); n = NEXT(n);
           can->qxmin = (Q)BDY(n); n = NEXT(n); can->qxmax = (Q)BDY(n);
           can->xmin = ToReal(can->qxmin); can->xmax = ToReal(can->qxmax);
           n = BDY(yrange); can->vy = VR((P)BDY(n)); n = NEXT(n);
           can->qymin = (Q)BDY(n); n = NEXT(n); can->qymax = (Q)BDY(n);
           can->ymin = ToReal(can->qymin); can->ymax = ToReal(can->qymax);
           can->mode = MODE_INEQNP;
           if ( wname )
                   can->wname = BDY(wname);
           else
                   can->wname = "";
           create_canvas(can);
           itvplotmain2(can);
   #if !defined(VISUAL)
           set_drawcolor(orgcolor);
           can->color = orgcolor;
   #endif
           copy_to_canvas(can);
           return id;
   }
   
   void itvplotmain2(struct canvas *can)
   {
           int **mask;
           double **tbl;
           int i,j;
           int op_code;
   
           op_code=3;
           current_can = can;
   
           mask = (int **)ALLOCA(can->height*sizeof(int *));
           for ( i = 0; i < can->height; i++){
                   mask[i] = (int *)ALLOCA(can->width*sizeof(int));
                   for (j = 0; j< can->width; j++) mask[i][j] = -1;
           }
   
           define_cursor(can->window,runningcur);
           set_busy(can); set_selection();
           itvcalc2(mask, can, 1);
           area_print(display, mask, can, op_code);
           reset_selection();
           reset_busy(can);
           define_cursor(can->window,normalcur);
   }
   
   // RECURSION type
   int itvplot3(NODE arg)
   {
           int id, op_code, orgcolor;
           struct canvas *can;
           LIST xrange, yrange, zrange, geom;
           NODE n;
           STRING wname;
           double **tbl;
           int itvsize;
   
           can = canvas[id = search_canvas()];
           orgcolor = can->color;
           can->formula = (P)ARG0(arg);
           xrange = (LIST)ARG1(arg);
           yrange = (LIST)ARG2(arg);
           zrange = (LIST)ARG3(arg);
           geom   = (LIST)ARG4(arg);
           wname  = (STRING)ARG5(arg);
           itvsize = QTOS((Q)ARG6(arg));
           /* set canvas data */
           can->mode = MODE_INEQNP;
           can->width = QTOS((Q)BDY(BDY(geom)));
           can->height = QTOS((Q)BDY(NEXT(BDY(geom))));
           n = BDY(xrange); can->vx = VR((P)BDY(n)); n = NEXT(n);
           can->qxmin = (Q)BDY(n); n = NEXT(n); can->qxmax = (Q)BDY(n);
           can->xmin = ToReal(can->qxmin); can->xmax = ToReal(can->qxmax);
           n = BDY(yrange); can->vy = VR((P)BDY(n)); n = NEXT(n);
           can->qymin = (Q)BDY(n); n = NEXT(n); can->qymax = (Q)BDY(n);
           can->ymin = ToReal(can->qymin); can->ymax = ToReal(can->qymax);
           can->mode = MODE_INEQNP;
           if ( wname )
                   can->wname = BDY(wname);
           else
                   can->wname = "";
           create_canvas(can);
           itvplotmain3(can, itvsize);
   #if !defined(VISUAL)
           set_drawcolor(orgcolor);
           can->color = orgcolor;
   #endif
           copy_to_canvas(can);
           return id;
   }
   
   void itvplotmain3(struct canvas *can, int itvsize)
   {
           int **mask;
           double **tbl;
           int i,j;
           int op_code;
   
           op_code=3;
           current_can = can;
   
           mask = (int **)ALLOCA(can->height*sizeof(int *));
           for ( i = 0; i < can->height; i++)
                   mask[i] = (int *)ALLOCA(can->width*sizeof(int));
   
           define_cursor(can->window,runningcur);
           set_busy(can); set_selection();
           itvcalc3(mask, can, 1, itvsize);
           area_print(display, mask, can, op_code);
           reset_selection();
           reset_busy(can);
           define_cursor(can->window,normalcur);
   }
   
   // RECURSION and TRANSFER type
   int itvplot4(NODE arg)
   {
           int id, op_code, orgcolor;
           struct canvas *can;
           LIST xrange, yrange, zrange, geom;
           NODE n;
           STRING wname;
           double **tbl;
           int itvsize;
   
           can = canvas[id = search_canvas()];
           orgcolor = can->color;
           can->formula = (P)ARG0(arg);
           xrange = (LIST)ARG1(arg);
           yrange = (LIST)ARG2(arg);
           zrange = (LIST)ARG3(arg);
           geom   = (LIST)ARG4(arg);
           wname  = (STRING)ARG5(arg);
           itvsize = QTOS((Q)ARG6(arg));
           /* set canvas data */
           can->mode = MODE_INEQNP;
           can->width = QTOS((Q)BDY(BDY(geom)));
           can->height = QTOS((Q)BDY(NEXT(BDY(geom))));
           n = BDY(xrange); can->vx = VR((P)BDY(n)); n = NEXT(n);
           can->qxmin = (Q)BDY(n); n = NEXT(n); can->qxmax = (Q)BDY(n);
           can->xmin = ToReal(can->qxmin); can->xmax = ToReal(can->qxmax);
           n = BDY(yrange); can->vy = VR((P)BDY(n)); n = NEXT(n);
           can->qymin = (Q)BDY(n); n = NEXT(n); can->qymax = (Q)BDY(n);
           can->ymin = ToReal(can->qymin); can->ymax = ToReal(can->qymax);
           can->mode = MODE_INEQNP;
           if ( wname )
                   can->wname = BDY(wname);
           else
                   can->wname = "";
           create_canvas(can);
           itvplotmain4(can, itvsize);
   #if !defined(VISUAL)
           set_drawcolor(orgcolor);
           can->color = orgcolor;
   #endif
           copy_to_canvas(can);
           return id;
   }
   
   void itvplotmain4(struct canvas *can, int itvsize)
   {
           int **mask;
           double **tbl;
           int i,j;
           int op_code;
   
           tstart();/* time calc */
           op_code=3;
           current_can = can;
   
           mask = (int **)ALLOCA(can->height*sizeof(int *));
           for ( i = 0; i < can->height; i++){
                   mask[i] = (int *)ALLOCA(can->width*sizeof(int));
                   for (j = 0; j< can->width; j++) mask[i][j] = -1;
           }
   
           define_cursor(can->window,runningcur);
           set_busy(can); set_selection();
           itvcalc4(mask, can, 1, itvsize);
           area_print(display, mask, can, op_code);
           reset_selection();
           reset_busy(can);
           define_cursor(can->window,normalcur);
           tstop(can); /* time calc */
   }
   #endif

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.23

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