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

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.7     ! noro       48:  * $OpenXM: OpenXM_contrib2/asir2000/plot/if.c,v 1.6 2001/08/22 09:19:21 noro Exp $
1.2       noro       49: */
1.1       noro       50: #include "ca.h"
                     51: #include "parse.h"
                     52: #include "ox.h"
                     53: #include "ifplot.h"
                     54:
                     55: extern jmp_buf ox_env;
                     56:
1.4       noro       57: int open_canvas(NODE arg)
                     58: {
                     59:        int id;
                     60:        struct canvas *can;
                     61:        LIST wsize;
                     62:        STRING wname;
                     63:
                     64:        wsize = (LIST)ARG0(arg);
                     65:        wname = (STRING)ARG1(arg);
                     66:
                     67:        can = canvas[id = search_canvas()];
                     68:        can->mode = MODE_INTERACTIVE;
                     69:        if ( !wsize ) {
                     70:                can->width = DEFAULTWIDTH; can->height = DEFAULTHEIGHT;
                     71:        } else {
                     72:                can->width = QTOS((Q)BDY(BDY(wsize)));
                     73:                can->height = QTOS((Q)BDY(NEXT(BDY(wsize))));
                     74:        }
                     75:        if ( wname )
                     76:                can->wname = BDY(wname);
                     77:        else
                     78:                can->wname = "";
                     79:        create_canvas(can);
                     80:        return id;
                     81: }
                     82:
1.1       noro       83: int plot(NODE arg)
                     84: {
                     85:        int id;
                     86:        NODE n;
                     87:        struct canvas *can;
                     88:        P formula;
                     89:        LIST xrange,yrange,zrange,wsize;
                     90:        STRING wname;
                     91:
                     92:        formula = (P)ARG0(arg);
                     93:        xrange = (LIST)ARG1(arg);
                     94:        yrange = (LIST)ARG2(arg);
                     95:        zrange = (LIST)ARG3(arg);
                     96:        wsize = (LIST)ARG4(arg);
                     97:        wname = (STRING)ARG5(arg);
                     98:
                     99:        can = canvas[id = search_canvas()];
                    100:        n = BDY(xrange); can->vx = VR((P)BDY(n)); n = NEXT(n);
                    101:        can->qxmin = (Q)BDY(n); n = NEXT(n); can->qxmax = (Q)BDY(n);
                    102:        can->xmin = ToReal(can->qxmin); can->xmax = ToReal(can->qxmax);
                    103:        if ( yrange ) {
                    104:                n = BDY(yrange); can->vy = VR((P)BDY(n)); n = NEXT(n);
                    105:                can->qymin = (Q)BDY(n); n = NEXT(n); can->qymax = (Q)BDY(n);
                    106:                can->ymin = ToReal(can->qymin); can->ymax = ToReal(can->qymax);
                    107:                if ( zrange ) {
                    108:                        n = NEXT(BDY(zrange));
                    109:                        can->zmin = ToReal(BDY(n)); n = NEXT(n); can->zmax = ToReal(BDY(n));
                    110:                        if ( n = NEXT(n) )
                    111:                                can->nzstep = QTOS((Q)BDY(n));
                    112:                        else
                    113:                                can->nzstep = MAXGC;
                    114:                        can->mode = MODE_CONPLOT;
                    115:                } else
                    116:                        can->mode = MODE_IFPLOT;
                    117:        } else
                    118:                can->mode = MODE_PLOT;
                    119:        if ( !wsize ) {
                    120:                can->width = DEFAULTWIDTH; can->height = DEFAULTHEIGHT;
                    121:        } else {
                    122:                can->width = QTOS((Q)BDY(BDY(wsize)));
                    123:                can->height = QTOS((Q)BDY(NEXT(BDY(wsize))));
                    124:        }
                    125:        if ( wname )
                    126:                can->wname = BDY(wname);
                    127:        else
                    128:                can->wname = "";
                    129:        can->formula = formula;
                    130:        create_canvas(can);
                    131:        if ( can->mode == MODE_PLOT ) {
                    132:                plotcalc(can);
                    133:                plot_print(display,can);
                    134:        } else
                    135:                ifplotmain(can);
                    136:        copy_to_canvas(can);
                    137:        return id;
                    138: }
                    139:
1.6       noro      140: int memory_plot(NODE arg,LIST *bytes)
                    141: {
                    142:        NODE n;
                    143:        struct canvas tmp_can;
                    144:        struct canvas *can;
                    145:        P formula;
                    146:        LIST xrange,yrange,zrange,wsize;
                    147:        int width,height;
                    148:        double **tabe;
                    149:        int i;
                    150:        BYTEARRAY barray;
                    151:        Q qw,qh;
                    152:
                    153:        formula = (P)ARG0(arg);
                    154:        xrange = (LIST)ARG1(arg);
                    155:        yrange = (LIST)ARG2(arg);
                    156:        zrange = (LIST)ARG3(arg);
                    157:        wsize = (LIST)ARG4(arg);
                    158:
                    159:        can = &tmp_can;
                    160:        n = BDY(xrange); can->vx = VR((P)BDY(n)); n = NEXT(n);
                    161:        can->qxmin = (Q)BDY(n); n = NEXT(n); can->qxmax = (Q)BDY(n);
                    162:        can->xmin = ToReal(can->qxmin); can->xmax = ToReal(can->qxmax);
                    163:        if ( yrange ) {
                    164:                n = BDY(yrange); can->vy = VR((P)BDY(n)); n = NEXT(n);
                    165:                can->qymin = (Q)BDY(n); n = NEXT(n); can->qymax = (Q)BDY(n);
                    166:                can->ymin = ToReal(can->qymin); can->ymax = ToReal(can->qymax);
                    167:                if ( zrange ) {
                    168:                        n = NEXT(BDY(zrange));
                    169:                        can->zmin = ToReal(BDY(n)); n = NEXT(n); can->zmax = ToReal(BDY(n));
                    170:                        if ( n = NEXT(n) )
                    171:                                can->nzstep = QTOS((Q)BDY(n));
                    172:                        else
                    173:                                can->nzstep = MAXGC;
                    174:                        can->mode = MODE_CONPLOT;
                    175:                } else
                    176:                        can->mode = MODE_IFPLOT;
                    177:        } else
                    178:                can->mode = MODE_PLOT;
                    179:        if ( !wsize ) {
                    180:                can->width = DEFAULTWIDTH; can->height = DEFAULTHEIGHT;
                    181:        } else {
                    182:                can->width = QTOS((Q)BDY(BDY(wsize)));
                    183:                can->height = QTOS((Q)BDY(NEXT(BDY(wsize))));
                    184:        }
                    185:        can->wname = "";
                    186:        can->formula = formula;
                    187:        if ( can->mode == MODE_PLOT )
                    188:                plotcalc(can);
                    189:        else {
                    190:                width = can->width; height = can->height;
                    191:                tabe = (double **)ALLOCA(width*sizeof(double *));
                    192:                for ( i = 0; i < width; i++ )
                    193:                        tabe[i] = (double *)ALLOCA(height*sizeof(double));
                    194:                calc(tabe,can,1);
                    195:                memory_if_print(tabe,can,&barray);
                    196:                STOQ(width,qw); STOQ(height,qh);
                    197:                n = mknode(3,qw,qh,barray);
                    198:                MKLIST(*bytes,n);
                    199:        }
                    200: }
                    201:
1.1       noro      202: int plotover(NODE arg)
                    203: {
                    204:        int index;
                    205:        P formula;
                    206:        struct canvas *can;
                    207:        struct canvas fakecan;
                    208:        VL vl,vl0;
                    209:
                    210:        index = QTOS((Q)ARG0(arg));
                    211:        formula = (P)ARG1(arg);
                    212:        can = canvas[index];
                    213:        if ( !can->window )
                    214:                return -1;
1.7     ! noro      215:        get_vars_recursive((Obj)formula,&vl);
1.1       noro      216:        for ( vl0 = vl; vl0; vl0 = NEXT(vl0) )
1.7     ! noro      217:                if ( vl0->v->attr == (pointer)V_IND )
1.1       noro      218:                        if ( vl->v != can->vx && vl->v != can->vy )
                    219:                                return -1;
                    220:        current_can = can;
                    221:        fakecan = *can; fakecan.formula = formula;
                    222:        if ( can->mode == MODE_PLOT ) {
                    223:                plotcalc(&fakecan);
                    224:                plot_print(display,&fakecan);
                    225:        } else
                    226:                ifplotmain(&fakecan);
                    227:        copy_to_canvas(&fakecan);
                    228:        return index;
                    229: }
                    230:
                    231: int drawcircle(NODE arg)
                    232: {
1.4       noro      233: #if !defined(VISUAL)
1.1       noro      234:        int id;
                    235:        int index;
                    236:        pointer ptr;
                    237:        Q ret;
                    238:        LIST xyr;
                    239:        Obj x,y,r;
                    240:        int wx,wy,wr;
                    241:        struct canvas *can;
                    242:        struct canvas fakecan;
                    243:
                    244:        index = QTOS((Q)ARG0(arg));
                    245:        xyr = (LIST)ARG1(arg);
                    246:        x = (Obj)ARG0(BDY(xyr)); y = (Obj)ARG1(BDY(xyr)); r = (Obj)ARG2(BDY(xyr));
                    247:        can = canvas[index];
                    248:        if ( !can->window )
                    249:                return -1;
                    250:        else {
                    251:                current_can = can;
                    252:                wx = (ToReal(x)-can->xmin)*can->width/(can->xmax-can->xmin);
                    253:                wy = (can->ymax-ToReal(y))*can->height/(can->ymax-can->ymin);
                    254:                wr = ToReal(r);
                    255:                XFillArc(display,can->pix,colorGC,wx-wr/2,wy-wr/2,wr,wr,0,360*64);
                    256:                copy_to_canvas(can);
                    257:                return index;
                    258:        }
1.4       noro      259: #endif
                    260: }
                    261:
                    262: int draw_obj(NODE arg)
                    263: {
                    264:        int index;
1.5       noro      265:        int x,y,u,v,len,r;
1.4       noro      266:        NODE obj,n;
                    267:        RealVect *vect;
                    268:        struct canvas *can;
1.5       noro      269:        int color;
1.4       noro      270:
                    271:        index = QTOS((Q)ARG0(arg));
                    272:        can = canvas[index];
1.5       noro      273:        if ( !can || !can->window ) {
                    274:                set_lasterror("draw_obj : canvas does not exist");
1.4       noro      275:                return -1;
1.5       noro      276:        }
1.4       noro      277:
                    278:        obj = BDY((LIST)ARG1(arg));
1.5       noro      279:        if ( argc(arg) == 3 )
                    280:                color = QTOS((Q)ARG2(arg));
                    281:        else
                    282:                color = 0; /* black */
                    283:        switch ( len = length(obj) ) {
1.4       noro      284:                case 2: /* point */
                    285:                        x = (int)ToReal((Q)ARG0(obj)); y = (int)ToReal((Q)ARG1(obj));
1.5       noro      286:                        draw_point(display,can,x,y,color);
                    287:                        MKRVECT2(vect,x,y); MKNODE(n,vect,can->history); can->history = n;
                    288:                        break;
                    289:                case 3: /* circle */
                    290:                        x = (int)ToReal((Q)ARG0(obj)); y = (int)ToReal((Q)ARG1(obj));
                    291:                        r = (int)ToReal((Q)ARG2(obj));
                    292:                        MKRVECT3(vect,x,y,r); MKNODE(n,vect,can->history); can->history = n;
1.4       noro      293:                        break;
                    294:                case 4: /* line */
                    295:                        x = (int)ToReal((Q)ARG0(obj)); y = (int)ToReal((Q)ARG1(obj));
                    296:                        u = (int)ToReal((Q)ARG2(obj)); v = (int)ToReal((Q)ARG3(obj));
1.5       noro      297:                        draw_line(display,can,x,y,u,v,color);
1.4       noro      298:                        MKRVECT4(vect,x,y,u,v); MKNODE(n,vect,can->history); can->history = n;
                    299:                        break;
                    300:                default:
1.5       noro      301:                        set_lasterror("draw_obj : invalid request");
1.4       noro      302:                        return -1;
                    303:        }
                    304:        return 0;
                    305: }
                    306:
                    307: int clear_canvas(NODE arg)
                    308: {
                    309:        int index;
                    310:        struct canvas *can;
                    311:
                    312:        index = QTOS((Q)ARG0(arg));
                    313:        can = canvas[index];
                    314:        if ( !can || !can->window )
                    315:                return -1;
                    316:        clear_pixmap(can);
                    317:        copy_to_canvas(can);
                    318:        /* clear the history */
                    319:        can->history = 0;
1.1       noro      320: }
                    321:
                    322: #define RealtoDbl(r) ((r)?BDY(r):0.0)
                    323:
                    324: int arrayplot(NODE arg)
                    325: {
                    326:        int id,ix,w,h;
                    327:        VECT array;
                    328:        LIST xrange,wsize;
                    329:        char *wname;
                    330:        NODE n;
                    331:        double ymax,ymin,dy,xstep;
                    332:        Real *tab;
                    333:        struct canvas *can;
                    334:        POINT *pa;
                    335:
                    336:        array = (VECT)ARG0(arg);
                    337:        xrange = (LIST)ARG1(arg);
                    338:        can = canvas[id = search_canvas()];
                    339:        n = BDY(xrange); can->vx = VR((P)BDY(n)); n = NEXT(n);
                    340:        can->qxmin = (Q)BDY(n); n = NEXT(n); can->qxmax = (Q)BDY(n);
                    341:        can->xmin = ToReal(can->qxmin); can->xmax = ToReal(can->qxmax);
                    342:        if ( !wsize ) {
                    343:                can->width = DEFAULTWIDTH; can->height = DEFAULTHEIGHT;
                    344:        } else {
                    345:                can->width = QTOS((Q)BDY(BDY(wsize)));
                    346:                can->height = QTOS((Q)BDY(NEXT(BDY(wsize))));
                    347:        }
                    348:        can->wname = wname; can->formula = 0; can->mode = MODE_PLOT;
                    349:        create_canvas(can);
                    350:        w = array->len;
                    351:        h = can->height;
                    352:        tab = (Real *)BDY(array);
                    353:        if ( can->ymax == can->ymin ) {
                    354:                for ( ymax = ymin = RealtoDbl(tab[0]), ix = 1; ix < w; ix++ ) {
                    355:                        if ( RealtoDbl(tab[ix]) > ymax )
                    356:                                ymax = RealtoDbl(tab[ix]);
                    357:                        if ( RealtoDbl(tab[ix]) < ymin )
                    358:                                ymin = RealtoDbl(tab[ix]);
                    359:                }
                    360:                can->ymax = ymax; can->ymin = ymin;
                    361:        } else {
                    362:                ymax = can->ymax; ymin = can->ymin;
                    363:        }
                    364:        dy = ymax-ymin;
                    365:        can->pa = (struct pa *)MALLOC(sizeof(struct pa));
                    366:        can->pa[0].length = w;
                    367:        can->pa[0].pos = pa = (POINT *)MALLOC(w*sizeof(POINT));
                    368:        xstep = (double)can->width/(double)(w-1);
                    369:        for ( ix = 0; ix < w; ix++ ) {
                    370: #ifndef MAXSHORT
                    371: #define MAXSHORT ((short)0x7fff)
                    372: #endif
                    373:                double t;
                    374:
                    375:                pa[ix].x = (int)(ix*xstep);
                    376:                t = (h - 1)*(ymax - RealtoDbl(tab[ix]))/dy;
                    377:                if ( t > MAXSHORT )
                    378:                        pa[ix].y = MAXSHORT;
                    379:                else if ( t < -MAXSHORT )
                    380:                        pa[ix].y = -MAXSHORT;
                    381:                else
1.7     ! noro      382:                        pa[ix].y = (long)t;
1.1       noro      383:        }
                    384:        plot_print(display,can);
                    385:        copy_to_canvas(can);
                    386:        return id;
                    387: }
                    388:
1.7     ! noro      389: void ifplot_resize(struct canvas *can,POINT spos,POINT epos)
1.1       noro      390: {
                    391:        struct canvas *ncan;
                    392:        struct canvas fakecan;
                    393:        Q dx,dy,dx2,dy2,xmin,xmax,ymin,ymax,xmid,ymid;
                    394:        Q sx,sy,ex,ey,cw,ch,ten,two;
                    395:        Q s,t;
                    396:        int new;
                    397:        int w,h,m;
                    398:
                    399:        if ( XC(spos) < XC(epos) && YC(spos) < YC(epos) ) {
                    400:                if ( can->precise && !can->wide ) {
                    401:                        fakecan = *can; ncan = &fakecan;
                    402:                } else {
                    403:                        new = search_canvas(); ncan = canvas[new];
                    404:                }
                    405:                ncan->mode = can->mode;
                    406:                ncan->zmin = can->zmin; ncan->zmax = can->zmax;
                    407:                ncan->nzstep = can->nzstep;
                    408:                ncan->wname = can->wname;
                    409:                ncan->vx = can->vx; ncan->vy = can->vy;
                    410:                ncan->formula = can->formula;
                    411:                w = XC(epos)-XC(spos);
                    412:                h = YC(epos)-YC(spos);
                    413:                m = MAX(can->width,can->height);
                    414:                if ( can->precise ) {
                    415:                        ncan->width = w; ncan->height = h;
                    416:                } else if ( w > h ) {
                    417:                        ncan->width = m; ncan->height = m * h/w;
                    418:                } else {
                    419:                        ncan->width = m * w/h; ncan->height = m;
                    420:                }
                    421:                if ( can->wide ) {
                    422:                        STOQ(10,ten); STOQ(2,two);
                    423:                        subq(can->qxmax,can->qxmin,&t); mulq(t,ten,&dx);
                    424:                        subq(can->qymax,can->qymin,&t); mulq(t,ten,&dy);
                    425:                        addq(can->qxmax,can->qxmin,&t); divq(t,two,&xmid);
                    426:                        addq(can->qymax,can->qymin,&t); divq(t,two,&ymid);
                    427:                        divq(dx,two,&dx2); divq(dy,two,&dy2);
                    428:                        subq(xmid,dx2,&xmin); addq(xmid,dx2,&xmax);
                    429:                        subq(ymid,dy2,&ymin); addq(ymid,dy2,&ymax);
                    430:                } else {
                    431:                        subq(can->qxmax,can->qxmin,&dx); subq(can->qymax,can->qymin,&dy);
                    432:                        xmin = can->qxmin; xmax = can->qxmax;
                    433:                        ymin = can->qymin; ymax = can->qymax;
                    434:                }
                    435:                STOQ(XC(spos),sx); STOQ(YC(spos),sy); STOQ(XC(epos),ex); STOQ(YC(epos),ey);
                    436:                STOQ(can->width,cw); STOQ(can->height,ch);
                    437:                mulq(sx,dx,&t); divq(t,cw,&s); addq(xmin,s,&ncan->qxmin);
                    438:                mulq(ex,dx,&t); divq(t,cw,&s); addq(xmin,s,&ncan->qxmax);
                    439:                mulq(ey,dy,&t); divq(t,ch,&s); subq(ymax,s,&ncan->qymin);
                    440:                mulq(sy,dy,&t); divq(t,ch,&s); subq(ymax,s,&ncan->qymax);
                    441:                ncan->xmin = ToReal(ncan->qxmin); ncan->xmax = ToReal(ncan->qxmax);
                    442:                ncan->ymin = ToReal(ncan->qymin); ncan->ymax = ToReal(ncan->qymax);
                    443:                if ( can->precise && !can->wide ) {
                    444:                        current_can = can;
                    445:                        alloc_pixmap(ncan);
1.4       noro      446: #if defined(VISUAL)
                    447:                        ncan->real_can = can;
                    448: #endif
1.1       noro      449:                        qifplotmain(ncan);
                    450:                        copy_subimage(ncan,can,spos);
                    451:                        copy_to_canvas(can);
                    452:                } else {
                    453:                        create_canvas(ncan);
                    454:                        if ( can->precise )
                    455:                                qifplotmain(ncan);
                    456:                        else
                    457:                                ifplotmain(ncan);
                    458:                        copy_to_canvas(ncan);
                    459:                }
                    460:        }
                    461: }
                    462:
1.7     ! noro      463: void plot_resize(struct canvas *can,POINT spos,POINT epos)
1.1       noro      464: {
                    465:        struct canvas *ncan;
                    466:        Q dx,dx2,xmin,xmax,xmid;
1.7     ! noro      467:        double dy,ymin,ymax,ymid;
1.1       noro      468:        Q sx,ex,cw,ten,two;
                    469:        Q s,t;
                    470:        int new;
                    471:        int w,h,m;
                    472:
                    473:        if ( XC(spos) < XC(epos) && YC(spos) < YC(epos) ) {
                    474:                new = search_canvas(); ncan = canvas[new];
                    475:                ncan->mode = can->mode;
                    476:                ncan->zmin = can->zmin; ncan->zmax = can->zmax;
                    477:                ncan->nzstep = can->nzstep;
                    478:                ncan->wname = can->wname;
                    479:                ncan->vx = can->vx; ncan->vy = can->vy;
                    480:                ncan->formula = can->formula;
                    481:                w = XC(epos)-XC(spos);
                    482:                h = YC(epos)-YC(spos);
                    483:                m = MAX(can->width,can->height);
                    484:                if ( w > h ) {
                    485:                        ncan->width = m; ncan->height = m * h/w;
                    486:                } else {
                    487:                        ncan->width = m * w/h; ncan->height = m;
                    488:                }
                    489:                if ( can->wide ) {
                    490:                        STOQ(10,ten); STOQ(2,two);
                    491:                        subq(can->qxmax,can->qxmin,&t); mulq(t,ten,&dx);
                    492:                        addq(can->qxmax,can->qxmin,&t); divq(t,two,&xmid);
                    493:                        divq(dx,two,&dx2); subq(xmid,dx2,&xmin); addq(xmid,dx2,&xmax);
                    494:
                    495:                        dy = (can->ymax-can->ymin)*10;
                    496:                        ymid = (can->ymax+can->ymin)/2;
                    497:                        ymin = ymid-dy/2; ymax = ymid+dy/2;
                    498:                } else {
                    499:                        subq(can->qxmax,can->qxmin,&dx);
                    500:                        xmin = can->qxmin; xmax = can->qxmax;
                    501:
                    502:                        dy = can->ymax-can->ymin;
                    503:                        ymin = can->ymin; ymax = can->ymax;
                    504:                }
                    505:                STOQ(XC(spos),sx); STOQ(XC(epos),ex); STOQ(can->width,cw);
                    506:                mulq(sx,dx,&t); divq(t,cw,&s); addq(xmin,s,&ncan->qxmin);
                    507:                mulq(ex,dx,&t); divq(t,cw,&s); addq(xmin,s,&ncan->qxmax);
                    508:                ncan->xmin = ToReal(ncan->qxmin); ncan->xmax = ToReal(ncan->qxmax);
                    509:
                    510:                ncan->ymin = ymax-YC(epos)*dy/can->height;
                    511:                ncan->ymax = ymax-YC(spos)*dy/can->height;
                    512:
                    513:                create_canvas(ncan);
                    514:                plotcalc(ncan);
                    515:                plot_print(display,ncan);
                    516:                copy_to_canvas(ncan);
                    517:        }
                    518: }
                    519:
1.7     ! noro      520: void ifplotmain(struct canvas *can)
1.1       noro      521: {
                    522:        int width,height;
1.7     ! noro      523:        double **tabe;
1.1       noro      524:        int i;
                    525:
                    526:        width = can->width; height = can->height;
                    527:        tabe = (double **)ALLOCA(width*sizeof(double *));
                    528:        for ( i = 0; i < width; i++ )
                    529:                tabe[i] = (double *)ALLOCA(height*sizeof(double));
                    530:        define_cursor(can->window,runningcur);
                    531:        set_busy(can); set_selection();
1.6       noro      532:        calc(tabe,can,0); if_print(display,tabe,can);
1.1       noro      533:        reset_selection(); reset_busy(can);
                    534:        define_cursor(can->window,normalcur);
                    535: }
                    536:
1.7     ! noro      537: void qifplotmain(struct canvas *can)
1.1       noro      538: {
                    539:        int width,height;
                    540:        char **tabe,*tabeb;
                    541:        int i;
                    542:
                    543:        width = can->width; height = can->height;
                    544:        tabe = (char **)ALLOCA(width*sizeof(char *)+width*height*sizeof(char));
                    545:        bzero(tabe,width*sizeof(char *)+width*height*sizeof(char));
                    546:        for ( i = 0, tabeb = (char *)(tabe+width); i < width; i++ )
                    547:                tabe[i] = tabeb + height*i;
                    548:        define_cursor(can->window,runningcur);
                    549:        set_busy(can); set_selection();
                    550:        qcalc(tabe,can); qif_print(display,tabe,can);
                    551:        reset_selection(); reset_busy(can);
                    552:        define_cursor(can->window,normalcur);
                    553: }

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