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

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.22    ! saito      48:  * $OpenXM: OpenXM_contrib2/asir2000/plot/if.c,v 1.21 2006/11/09 15:54:35 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: #if defined(INTERVAL)
        !           884: int itvifplot(NODE arg)
        !           885: {
        !           886:        int id, op_code, orgcolor;
        !           887:        struct canvas *can;
        !           888:        LIST xrange, yrange, zrange, geom;
        !           889:        NODE n;
        !           890:        STRING wname;
        !           891:        double **tbl;
        !           892:        int itvsize;
        !           893:
        !           894:        can = canvas[id = search_canvas()];
        !           895:        orgcolor = can->color;
        !           896:        can->formula = (P)ARG0(arg);
        !           897:        xrange = (LIST)ARG1(arg);
        !           898:        yrange = (LIST)ARG2(arg);
        !           899:        zrange = (LIST)ARG3(arg);
        !           900:        geom   = (LIST)ARG4(arg);
        !           901:        wname  = (STRING)ARG5(arg);
        !           902:        itvsize = QTOS((Q)ARG6(arg));
        !           903:        /* set canvas data */
        !           904:        can->mode = MODE_INEQNP;
        !           905:        can->width = QTOS((Q)BDY(BDY(geom)));
        !           906:        can->height = QTOS((Q)BDY(NEXT(BDY(geom))));
        !           907:        n = BDY(xrange); can->vx = VR((P)BDY(n)); n = NEXT(n);
        !           908:        can->qxmin = (Q)BDY(n); n = NEXT(n); can->qxmax = (Q)BDY(n);
        !           909:        can->xmin = ToReal(can->qxmin); can->xmax = ToReal(can->qxmax);
        !           910:        n = BDY(yrange); can->vy = VR((P)BDY(n)); n = NEXT(n);
        !           911:        can->qymin = (Q)BDY(n); n = NEXT(n); can->qymax = (Q)BDY(n);
        !           912:        can->ymin = ToReal(can->qymin); can->ymax = ToReal(can->qymax);
        !           913:        can->mode = MODE_INEQNP;
        !           914:        if ( wname )
        !           915:                can->wname = BDY(wname);
        !           916:        else
        !           917:                can->wname = "";
        !           918:        create_canvas(can);
        !           919:        itvplotmain(can, itvsize);
        !           920: #if !defined(VISUAL)
        !           921:        set_drawcolor(orgcolor);
        !           922:        can->color = orgcolor;
        !           923: #endif
        !           924:        copy_to_canvas(can);
        !           925:        return id;
        !           926: }
        !           927:
        !           928: void itvplotmain(struct canvas *can, int itvsize)
        !           929: {
        !           930:        int **mask;
        !           931:        double **tbl;
        !           932:        int i,j;
        !           933:        int op_code;
        !           934:        pointer *prp;
        !           935:
        !           936:        tstart(); /* time calc */
        !           937:        op_code=3;
        !           938:        current_can = can;
        !           939:        can->color=0xff00;
        !           940:        mask = (int **)ALLOCA(can->height*sizeof(int *));
        !           941:        for ( i = 0; i < can->height; i++){
        !           942:                mask[i] = (int *)ALLOCA(can->width*sizeof(int));
        !           943:                for (j = 0; j< can->width; j++) mask[i][j] = -1;
        !           944:        }
        !           945:        define_cursor(can->window,runningcur);
        !           946:        set_busy(can); set_selection();
        !           947:        itvcalc(mask, can, 1, itvsize);
        !           948:        area_print(display, mask, can, op_code);
        !           949:        reset_selection();
        !           950:        reset_busy(can);
        !           951:        define_cursor(can->window,normalcur);
        !           952:        tstop(can); /* time calc */
        !           953: }
        !           954:
        !           955: // NORMAL type
        !           956: int itvplot1(NODE arg)
        !           957: {
        !           958:        int id, op_code, orgcolor;
        !           959:        struct canvas *can;
        !           960:        LIST xrange, yrange, zrange, geom;
        !           961:        NODE n;
        !           962:        STRING wname;
        !           963:        double **tbl;
        !           964:
        !           965:        can = canvas[id = search_canvas()];
        !           966:        orgcolor = can->color;
        !           967:        can->formula = (P)ARG0(arg);
        !           968:        xrange = (LIST)ARG1(arg);
        !           969:        yrange = (LIST)ARG2(arg);
        !           970:        zrange = (LIST)ARG3(arg);
        !           971:        geom   = (LIST)ARG4(arg);
        !           972:        wname  = (STRING)ARG5(arg);
        !           973:        /* set canvas data */
        !           974:        can->mode = MODE_INEQNP;
        !           975:        can->width = QTOS((Q)BDY(BDY(geom)));
        !           976:        can->height = QTOS((Q)BDY(NEXT(BDY(geom))));
        !           977:        n = BDY(xrange); can->vx = VR((P)BDY(n)); n = NEXT(n);
        !           978:        can->qxmin = (Q)BDY(n); n = NEXT(n); can->qxmax = (Q)BDY(n);
        !           979:        can->xmin = ToReal(can->qxmin); can->xmax = ToReal(can->qxmax);
        !           980:        n = BDY(yrange); can->vy = VR((P)BDY(n)); n = NEXT(n);
        !           981:        can->qymin = (Q)BDY(n); n = NEXT(n); can->qymax = (Q)BDY(n);
        !           982:        can->ymin = ToReal(can->qymin); can->ymax = ToReal(can->qymax);
        !           983:        can->mode = MODE_INEQNP;
        !           984:        if ( wname )
        !           985:                can->wname = BDY(wname);
        !           986:        else
        !           987:                can->wname = "";
        !           988:        create_canvas(can);
        !           989:        itvplotmain1(can);
        !           990: #if !defined(VISUAL)
        !           991:        set_drawcolor(orgcolor);
        !           992:        can->color = orgcolor;
        !           993: #endif
        !           994:        copy_to_canvas(can);
        !           995:        return id;
        !           996: }
        !           997:
        !           998: void itvplotmain1(struct canvas *can)
        !           999: {
        !          1000:        int **mask;
        !          1001:        double **tbl;
        !          1002:        int i,j;
        !          1003:        int op_code;
        !          1004:
        !          1005:        op_code=3;
        !          1006:        current_can = can;
        !          1007:        mask = (int **)ALLOCA(can->height*sizeof(int *));
        !          1008:        for ( i = 0; i < can->height; i++){
        !          1009:                mask[i] = (int *)ALLOCA(can->width*sizeof(int));
        !          1010:                for (j = 0; j< can->width; j++) mask[i][j] = -1;
        !          1011:        }
        !          1012:
        !          1013:        define_cursor(can->window,runningcur);
        !          1014:        set_busy(can); set_selection();
        !          1015:        itvcalc1(mask, can, 1);
        !          1016:        area_print(display, mask, can, op_code);
        !          1017:        reset_selection();
        !          1018:        reset_busy(can);
        !          1019:        define_cursor(can->window,normalcur);
        !          1020: }
        !          1021:
        !          1022: // TRANSFER type
        !          1023: int itvplot2(NODE arg)
        !          1024: {
        !          1025:        int id, op_code, orgcolor;
        !          1026:        struct canvas *can;
        !          1027:        LIST xrange, yrange, zrange, geom;
        !          1028:        NODE n;
        !          1029:        STRING wname;
        !          1030:        double **tbl;
        !          1031:
        !          1032:        can = canvas[id = search_canvas()];
        !          1033:        orgcolor = can->color;
        !          1034:        can->formula = (P)ARG0(arg);
        !          1035:        xrange = (LIST)ARG1(arg);
        !          1036:        yrange = (LIST)ARG2(arg);
        !          1037:        zrange = (LIST)ARG3(arg);
        !          1038:        geom   = (LIST)ARG4(arg);
        !          1039:        wname  = (STRING)ARG5(arg);
        !          1040:        /* set canvas data */
        !          1041:        can->mode = MODE_INEQNP;
        !          1042:        can->width = QTOS((Q)BDY(BDY(geom)));
        !          1043:        can->height = QTOS((Q)BDY(NEXT(BDY(geom))));
        !          1044:        n = BDY(xrange); can->vx = VR((P)BDY(n)); n = NEXT(n);
        !          1045:        can->qxmin = (Q)BDY(n); n = NEXT(n); can->qxmax = (Q)BDY(n);
        !          1046:        can->xmin = ToReal(can->qxmin); can->xmax = ToReal(can->qxmax);
        !          1047:        n = BDY(yrange); can->vy = VR((P)BDY(n)); n = NEXT(n);
        !          1048:        can->qymin = (Q)BDY(n); n = NEXT(n); can->qymax = (Q)BDY(n);
        !          1049:        can->ymin = ToReal(can->qymin); can->ymax = ToReal(can->qymax);
        !          1050:        can->mode = MODE_INEQNP;
        !          1051:        if ( wname )
        !          1052:                can->wname = BDY(wname);
        !          1053:        else
        !          1054:                can->wname = "";
        !          1055:        create_canvas(can);
        !          1056:        itvplotmain2(can);
        !          1057: #if !defined(VISUAL)
        !          1058:        set_drawcolor(orgcolor);
        !          1059:        can->color = orgcolor;
        !          1060: #endif
        !          1061:        copy_to_canvas(can);
        !          1062:        return id;
        !          1063: }
        !          1064:
        !          1065: void itvplotmain2(struct canvas *can)
        !          1066: {
        !          1067:        int **mask;
        !          1068:        double **tbl;
        !          1069:        int i,j;
        !          1070:        int op_code;
        !          1071:
        !          1072:        op_code=3;
        !          1073:        current_can = can;
        !          1074:
        !          1075:        mask = (int **)ALLOCA(can->height*sizeof(int *));
        !          1076:        for ( i = 0; i < can->height; i++){
        !          1077:                mask[i] = (int *)ALLOCA(can->width*sizeof(int));
        !          1078:                for (j = 0; j< can->width; j++) mask[i][j] = -1;
        !          1079:        }
        !          1080:
        !          1081:        define_cursor(can->window,runningcur);
        !          1082:        set_busy(can); set_selection();
        !          1083:        itvcalc2(mask, can, 1);
        !          1084:        area_print(display, mask, can, op_code);
        !          1085:        reset_selection();
        !          1086:        reset_busy(can);
        !          1087:        define_cursor(can->window,normalcur);
        !          1088: }
        !          1089:
        !          1090: // RECURSION type
        !          1091: int itvplot3(NODE arg)
        !          1092: {
        !          1093:        int id, op_code, orgcolor;
        !          1094:        struct canvas *can;
        !          1095:        LIST xrange, yrange, zrange, geom;
        !          1096:        NODE n;
        !          1097:        STRING wname;
        !          1098:        double **tbl;
        !          1099:        int itvsize;
        !          1100:
        !          1101:        can = canvas[id = search_canvas()];
        !          1102:        orgcolor = can->color;
        !          1103:        can->formula = (P)ARG0(arg);
        !          1104:        xrange = (LIST)ARG1(arg);
        !          1105:        yrange = (LIST)ARG2(arg);
        !          1106:        zrange = (LIST)ARG3(arg);
        !          1107:        geom   = (LIST)ARG4(arg);
        !          1108:        wname  = (STRING)ARG5(arg);
        !          1109:        itvsize = QTOS((Q)ARG6(arg));
        !          1110:        /* set canvas data */
        !          1111:        can->mode = MODE_INEQNP;
        !          1112:        can->width = QTOS((Q)BDY(BDY(geom)));
        !          1113:        can->height = QTOS((Q)BDY(NEXT(BDY(geom))));
        !          1114:        n = BDY(xrange); can->vx = VR((P)BDY(n)); n = NEXT(n);
        !          1115:        can->qxmin = (Q)BDY(n); n = NEXT(n); can->qxmax = (Q)BDY(n);
        !          1116:        can->xmin = ToReal(can->qxmin); can->xmax = ToReal(can->qxmax);
        !          1117:        n = BDY(yrange); can->vy = VR((P)BDY(n)); n = NEXT(n);
        !          1118:        can->qymin = (Q)BDY(n); n = NEXT(n); can->qymax = (Q)BDY(n);
        !          1119:        can->ymin = ToReal(can->qymin); can->ymax = ToReal(can->qymax);
        !          1120:        can->mode = MODE_INEQNP;
        !          1121:        if ( wname )
        !          1122:                can->wname = BDY(wname);
        !          1123:        else
        !          1124:                can->wname = "";
        !          1125:        create_canvas(can);
        !          1126:        itvplotmain3(can, itvsize);
        !          1127: #if !defined(VISUAL)
        !          1128:        set_drawcolor(orgcolor);
        !          1129:        can->color = orgcolor;
        !          1130: #endif
        !          1131:        copy_to_canvas(can);
        !          1132:        return id;
        !          1133: }
        !          1134:
        !          1135: void itvplotmain3(struct canvas *can, int itvsize)
        !          1136: {
        !          1137:        int **mask;
        !          1138:        double **tbl;
        !          1139:        int i,j;
        !          1140:        int op_code;
        !          1141:
        !          1142:        op_code=3;
        !          1143:        current_can = can;
        !          1144:
        !          1145:        mask = (int **)ALLOCA(can->height*sizeof(int *));
        !          1146:        for ( i = 0; i < can->height; i++)
        !          1147:                mask[i] = (int *)ALLOCA(can->width*sizeof(int));
        !          1148:
        !          1149:        define_cursor(can->window,runningcur);
        !          1150:        set_busy(can); set_selection();
        !          1151:        itvcalc3(mask, can, 1, itvsize);
        !          1152:        area_print(display, mask, can, op_code);
        !          1153:        reset_selection();
        !          1154:        reset_busy(can);
        !          1155:        define_cursor(can->window,normalcur);
        !          1156: }
        !          1157:
        !          1158: // RECURSION and TRANSFER type
        !          1159: int itvplot4(NODE arg)
        !          1160: {
        !          1161:        int id, op_code, orgcolor;
        !          1162:        struct canvas *can;
        !          1163:        LIST xrange, yrange, zrange, geom;
        !          1164:        NODE n;
        !          1165:        STRING wname;
        !          1166:        double **tbl;
        !          1167:        int itvsize;
        !          1168:
        !          1169:        can = canvas[id = search_canvas()];
        !          1170:        orgcolor = can->color;
        !          1171:        can->formula = (P)ARG0(arg);
        !          1172:        xrange = (LIST)ARG1(arg);
        !          1173:        yrange = (LIST)ARG2(arg);
        !          1174:        zrange = (LIST)ARG3(arg);
        !          1175:        geom   = (LIST)ARG4(arg);
        !          1176:        wname  = (STRING)ARG5(arg);
        !          1177:        itvsize = QTOS((Q)ARG6(arg));
        !          1178:        /* set canvas data */
        !          1179:        can->mode = MODE_INEQNP;
        !          1180:        can->width = QTOS((Q)BDY(BDY(geom)));
        !          1181:        can->height = QTOS((Q)BDY(NEXT(BDY(geom))));
        !          1182:        n = BDY(xrange); can->vx = VR((P)BDY(n)); n = NEXT(n);
        !          1183:        can->qxmin = (Q)BDY(n); n = NEXT(n); can->qxmax = (Q)BDY(n);
        !          1184:        can->xmin = ToReal(can->qxmin); can->xmax = ToReal(can->qxmax);
        !          1185:        n = BDY(yrange); can->vy = VR((P)BDY(n)); n = NEXT(n);
        !          1186:        can->qymin = (Q)BDY(n); n = NEXT(n); can->qymax = (Q)BDY(n);
        !          1187:        can->ymin = ToReal(can->qymin); can->ymax = ToReal(can->qymax);
        !          1188:        can->mode = MODE_INEQNP;
        !          1189:        if ( wname )
        !          1190:                can->wname = BDY(wname);
        !          1191:        else
        !          1192:                can->wname = "";
        !          1193:        create_canvas(can);
        !          1194:        itvplotmain4(can, itvsize);
        !          1195: #if !defined(VISUAL)
        !          1196:        set_drawcolor(orgcolor);
        !          1197:        can->color = orgcolor;
        !          1198: #endif
        !          1199:        copy_to_canvas(can);
        !          1200:        return id;
        !          1201: }
        !          1202:
        !          1203: void itvplotmain4(struct canvas *can, int itvsize)
        !          1204: {
        !          1205:        int **mask;
        !          1206:        double **tbl;
        !          1207:        int i,j;
        !          1208:        int op_code;
        !          1209:
        !          1210:        tstart();/* time calc */
        !          1211:        op_code=3;
        !          1212:        current_can = can;
        !          1213:
        !          1214:        mask = (int **)ALLOCA(can->height*sizeof(int *));
        !          1215:        for ( i = 0; i < can->height; i++){
        !          1216:                mask[i] = (int *)ALLOCA(can->width*sizeof(int));
        !          1217:                for (j = 0; j< can->width; j++) mask[i][j] = -1;
        !          1218:        }
        !          1219:
        !          1220:        define_cursor(can->window,runningcur);
        !          1221:        set_busy(can); set_selection();
        !          1222:        itvcalc4(mask, can, 1, itvsize);
        !          1223:        area_print(display, mask, can, op_code);
        !          1224:        reset_selection();
        !          1225:        reset_busy(can);
        !          1226:        define_cursor(can->window,normalcur);
        !          1227:        tstop(can); /* time calc */
        !          1228: }
        !          1229: #endif
        !          1230: #endif

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