[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.23

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

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