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

Annotation of OpenXM_contrib2/asir2000/plot/plotp.c, Revision 1.11

1.3       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.4       noro       26:  * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
1.3       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.11    ! noro       48:  * $OpenXM: OpenXM_contrib2/asir2000/plot/plotp.c,v 1.10 2002/07/10 05:29:36 noro Exp $
1.3       noro       49: */
1.1       noro       50: #include "ca.h"
                     51: #include "parse.h"
                     52: #include "ox.h"
                     53: #include "ifplot.h"
1.2       noro       54: #include <math.h>
1.1       noro       55:
                     56: #if defined(sun) && !defined(__svr4__)
                     57: #define EXP10(a) exp10(a)
                     58: #else
                     59: #define EXP10(a) pow(10.0,a)
                     60: #endif
                     61:
1.5       noro       62: #if defined(VISUAL)
                     63: static POINT oldpos;
                     64: #endif
                     65:
1.9       noro       66: void if_print(DISPLAY *display,double **tab,struct canvas *can)
1.1       noro       67: {
                     68:        int ix,iy,width,height;
                     69:        double *px,*px1,*px2;
                     70:        DRAWABLE pix;
                     71:
                     72:        if ( can->mode == MODE_CONPLOT ) {
                     73:                con_print(display,tab,can); return;
                     74:        }
                     75:        flush();
                     76:        width = can->width; height = can->height; pix = can->pix;
                     77:        for( ix=0; ix<width-1; ix++ )
                     78:                for(iy=0, px=tab[ix], px1 = tab[ix+1], px2 = px+1;
                     79:                        iy<height-1 ;iy++, px++, px1++, px2++ )
                     80:                        if ( ((*px >= 0) && ((*px1 <= 0) || (*px2 <= 0))) ||
                     81:                                 ((*px <= 0) && ((*px1 >= 0) || (*px2 >= 0))) ) {
                     82:                                DRAWPOINT(display,pix,drawGC,ix,height-iy-1);
                     83:                                count_and_flush();
                     84:                        }
                     85:        flush();
                     86: }
                     87:
1.8       noro       88: #define MEMORY_DRAWPOINT(a,len,x,y) (((a)[(len)*(y)+((x)>>3)]) |= (1<<((x)&7)))
                     89:
1.9       noro       90: void memory_if_print(double **tab,struct canvas *can,BYTEARRAY *bytes)
1.8       noro       91: {
                     92:        int ix,iy,width,height;
                     93:        double *px,*px1,*px2;
                     94:        unsigned char *array;
                     95:        int scan_len;
                     96:
                     97:        if ( can->mode == MODE_CONPLOT ) {
                     98:                memory_con_print(tab,can,bytes); return;
                     99:        }
                    100:        width = can->width; height = can->height;
                    101:
                    102:        /* scan_len = byte length of the scan line */
                    103:        scan_len = (width+7)/8;
                    104:        MKBYTEARRAY(*bytes,scan_len*height);
                    105:        array = BDY(*bytes);
                    106:        for( ix=0; ix<width-1; ix++ )
                    107:                for(iy=0, px=tab[ix], px1 = tab[ix+1], px2 = px+1;
                    108:                        iy<height-1 ;iy++, px++, px1++, px2++ )
                    109:                        if ( ((*px >= 0) && ((*px1 <= 0) || (*px2 <= 0))) ||
                    110:                                 ((*px <= 0) && ((*px1 >= 0) || (*px2 >= 0))) ) {
                    111:                                MEMORY_DRAWPOINT(array,scan_len,ix,height-iy-1);
                    112:                        }
                    113: }
                    114:
1.9       noro      115: void con_print(DISPLAY *display,double **tab,struct canvas *can)
1.1       noro      116: {
                    117:        int ix,iy,iz,width,height,pas,pai,len;
                    118:        double zstep,z;
                    119:        double *px,*px1,*px2;
                    120:        DRAWABLE pix;
                    121:        POINT *pa,*pa1;
                    122:        struct pa *parray;
                    123:
                    124:
                    125:        width = can->width; height = can->height; pix = can->pix;
                    126:        zstep = (can->zmax-can->zmin)/can->nzstep;
                    127:        can->pa = (struct pa *)MALLOC((can->nzstep+1)*sizeof(struct pa));
                    128:        pas = width;
                    129:        pa = (POINT *)ALLOCA(pas*sizeof(POINT));
                    130:        initmarker(can,"Drawing...");
                    131:        for ( z = can->zmin, iz = 0; z <= can->zmax; z += zstep, iz++ ) {
                    132:                marker(can,DIR_Z,iz);
                    133:                pai = 0;
                    134:                for( ix=0; ix<width-1; ix++ )
                    135:                        for(iy=0, px=tab[ix], px1 = tab[ix+1], px2 = px+1;
                    136:                                iy<height-1 ;iy++, px++, px1++, px2++ )
                    137:                                if ( ((*px >= z) && ((*px1 <= z) || (*px2 <= z))) ||
                    138:                                         ((*px <= z) && ((*px1 >= z) || (*px2 >= z))) ) {
                    139:                                        if ( pai == pas ) {
                    140:                                                pa1 = (POINT *)ALLOCA(2*pas*sizeof(POINT));
                    141:                                                bcopy((char *)pa,(char *)pa1,pas*sizeof(POINT)); pa = pa1;
                    142:                                                pas += pas;
                    143:                                        }
                    144:                                        XC(pa[pai]) = ix; YC(pa[pai]) = height-iy-1; pai++;
                    145:                                }
                    146:                can->pa[iz].length = pai;
                    147:                if ( pai ) {
                    148:                        pa1 = (POINT *)MALLOC(pai*sizeof(POINT));
                    149:                        bcopy((char *)pa,(char *)pa1,pai*sizeof(POINT));
                    150:                        can->pa[iz].pos = pa1;
                    151:                }
                    152:        }
                    153:        flush();
                    154:        for ( parray = can->pa, iz = 0; iz <= can->nzstep; iz++, parray++ )
                    155:                for ( pa = parray->pos, len = parray->length, ix = 0; ix < len; ix++ ) {
                    156:                        DRAWPOINT(display,pix,drawGC,XC(pa[ix]),YC(pa[ix]));
                    157:                        count_and_flush();
                    158:                }
                    159:        flush();
1.8       noro      160: }
                    161:
1.9       noro      162: void memory_con_print(double **tab,struct canvas *can,BYTEARRAY *bytes)
1.8       noro      163: {
                    164:        int ix,iy,iz,width,height,pas,pai,len;
                    165:        double zstep,z;
                    166:        double *px,*px1,*px2;
                    167:        POINT *pa,*pa1;
                    168:        struct pa *parray;
                    169:        unsigned char *array;
                    170:        int scan_len;
                    171:
                    172:        width = can->width; height = can->height;
                    173:        zstep = (can->zmax-can->zmin)/can->nzstep;
                    174:        can->pa = (struct pa *)MALLOC((can->nzstep+1)*sizeof(struct pa));
                    175:        pas = width;
                    176:        pa = (POINT *)ALLOCA(pas*sizeof(POINT));
                    177:        for ( z = can->zmin, iz = 0; z <= can->zmax; z += zstep, iz++ ) {
                    178:                pai = 0;
                    179:                for( ix=0; ix<width-1; ix++ )
                    180:                        for(iy=0, px=tab[ix], px1 = tab[ix+1], px2 = px+1;
                    181:                                iy<height-1 ;iy++, px++, px1++, px2++ )
                    182:                                if ( ((*px >= z) && ((*px1 <= z) || (*px2 <= z))) ||
                    183:                                         ((*px <= z) && ((*px1 >= z) || (*px2 >= z))) ) {
                    184:                                        if ( pai == pas ) {
                    185:                                                pa1 = (POINT *)ALLOCA(2*pas*sizeof(POINT));
                    186:                                                bcopy((char *)pa,(char *)pa1,pas*sizeof(POINT)); pa = pa1;
                    187:                                                pas += pas;
                    188:                                        }
                    189:                                        XC(pa[pai]) = ix; YC(pa[pai]) = height-iy-1; pai++;
                    190:                                }
                    191:                can->pa[iz].length = pai;
                    192:                if ( pai ) {
                    193:                        pa1 = (POINT *)MALLOC(pai*sizeof(POINT));
                    194:                        bcopy((char *)pa,(char *)pa1,pai*sizeof(POINT));
                    195:                        can->pa[iz].pos = pa1;
                    196:                }
                    197:        }
                    198:        /* scan_len = byte length of the scan line */
                    199:        scan_len = (width+7)/8;
                    200:        MKBYTEARRAY(*bytes,scan_len*height);
                    201:        array = BDY(*bytes);
                    202:        for ( parray = can->pa, iz = 0; iz <= can->nzstep; iz++, parray++ )
                    203:                for ( pa = parray->pos, len = parray->length, ix = 0; ix < len; ix++ ) {
                    204:                        MEMORY_DRAWPOINT(array,scan_len,XC(pa[ix]),YC(pa[ix]));
                    205:                }
1.1       noro      206: }
                    207:
1.9       noro      208: void qif_print(DISPLAY *display,char **tab,struct canvas *can)
1.1       noro      209: {
                    210:        int ix,iy,width,height;
                    211:        char *px;
                    212:        DRAWABLE pix;
                    213:
                    214:        flush();
                    215:        width = can->width; height = can->height; pix = can->pix;
                    216:        for( ix = 0; ix < width; ix++ )
                    217:                for(iy = 0, px = tab[ix]; iy < height ;iy++, px++ )
                    218:                        if ( *px ) {
                    219:                                DRAWPOINT(display,pix,drawGC,ix,height-iy-1);
                    220:                                count_and_flush();
                    221:                        }
                    222:        flush();
                    223: }
                    224:
1.9       noro      225: void plot_print(DISPLAY *display,struct canvas *can)
1.1       noro      226: {
1.9       noro      227:        int len;
1.1       noro      228:        POINT *pa;
1.5       noro      229:
                    230: #if defined(VISUAL)
                    231:        len = can->pa[0].length;
                    232:        pa = can->pa[0].pos;
1.6       noro      233:
                    234:        Polyline(can->pix,pa,len);
                    235: //     for ( i = 0; i < len-1; i++ ) {
                    236: //             DRAWLINE(display,can->pix,drawGC,pa[i].x,pa[i].y,pa[i+1].x,pa[i+1].y);
                    237: //     }
1.5       noro      238: #else
1.1       noro      239:        XDrawLines(display,can->pix,drawGC,
                    240:                can->pa[0].pos,can->pa[0].length,CoordModeOrigin);
                    241:        XFlush(display);
1.5       noro      242: #endif
                    243: }
                    244:
1.9       noro      245: void draw_point(DISPLAY *display,struct canvas *can,int x,int y,int color)
1.5       noro      246: {
                    247: #if defined(VISUAL)
                    248:        HDC dc;
                    249:
1.6       noro      250:        SetPixel(can->pix,x,y,(COLORREF)color);
1.5       noro      251:        dc = GetDC(can->hwnd);
1.6       noro      252:        SetPixel(dc,x,y,(COLORREF)color);
1.5       noro      253:        ReleaseDC(can->hwnd,dc);
                    254: #else
1.7       noro      255:        if ( color ) {
                    256:                set_drawcolor(color);
                    257:                DRAWPOINT(display,can->pix,cdrawGC,x,y);
                    258:                DRAWPOINT(display,can->window,cdrawGC,x,y);
                    259:        } else {
                    260:                DRAWPOINT(display,can->pix,drawGC,x,y);
                    261:                DRAWPOINT(display,can->window,drawGC,x,y);
                    262:        }
1.5       noro      263:        XFlush(display);
                    264: #endif
                    265: }
                    266:
1.9       noro      267: void draw_line(DISPLAY *display,struct canvas *can,int x,int y,int u,int v,int color)
1.5       noro      268: {
                    269: #if defined(VISUAL)
                    270:        HDC dc;
1.6       noro      271:        HPEN pen,oldpen;
1.5       noro      272:
1.6       noro      273:        if ( color ) {
                    274:                pen = CreatePen(PS_SOLID,1,color);
                    275:                oldpen = SelectObject(can->pix,pen);
                    276:                DRAWLINE(display,can->pix,drawGC,x,y,u,v);
                    277:                SelectObject(can->pix,oldpen);
                    278:
                    279:                dc = GetDC(can->hwnd);
                    280:                oldpen = SelectObject(dc,pen);
                    281:                DRAWLINE(display,dc,drawGC,x,y,u,v);
                    282:                SelectObject(dc,oldpen);
                    283:                ReleaseDC(can->hwnd,dc);
                    284:
                    285:                DeleteObject(pen);
                    286:        } else {
                    287:                DRAWLINE(display,can->pix,drawGC,x,y,u,v);
                    288:                dc = GetDC(can->hwnd);
                    289:                DRAWLINE(display,dc,drawGC,x,y,u,v);
                    290:                ReleaseDC(can->hwnd,dc);
                    291:        }
1.5       noro      292: #else
1.7       noro      293:        if ( color ) {
                    294:                set_drawcolor(color);
                    295:                DRAWLINE(display,can->pix,cdrawGC,x,y,u,v);
                    296:                DRAWLINE(display,can->window,cdrawGC,x,y,u,v);
                    297:        } else {
                    298:                DRAWLINE(display,can->pix,drawGC,x,y,u,v);
                    299:                DRAWLINE(display,can->window,drawGC,x,y,u,v);
1.10      noro      300:        }
                    301:        XFlush(display);
                    302: #endif
                    303: }
                    304:
                    305: void draw_character_string(DISPLAY *display,struct canvas *can,int x,int y,char *str,int color)
                    306: {
                    307: #if defined(VISUAL)
                    308:        HDC dc;
1.11    ! noro      309:        COLORREF oldcolor;
1.10      noro      310:
                    311:        if ( color ) {
1.11    ! noro      312:                oldcolor = SetTextColor(can->pix,color);
1.10      noro      313:                DRAWSTRING(display,can->pix,drawGC,x,y,str,strlen(str));
1.11    ! noro      314:                SetTextColor(can->pix,oldcolor);
1.10      noro      315:
                    316:                dc = GetDC(can->hwnd);
1.11    ! noro      317:                oldcolor = SetTextColor(dc,color);
1.10      noro      318:                DRAWSTRING(display,dc,drawGC,x,y,str,strlen(str));
1.11    ! noro      319:                SetTextColor(dc,oldcolor);
1.10      noro      320:                ReleaseDC(can->hwnd,dc);
                    321:        } else {
                    322:                DRAWSTRING(display,can->pix,drawGC,x,y,str,strlen(str));
                    323:                dc = GetDC(can->hwnd);
                    324:                DRAWSTRING(display,dc,drawGC,x,y,str,strlen(str));
                    325:                ReleaseDC(can->hwnd,dc);
                    326:        }
                    327: #else
                    328:        if ( color ) {
                    329:                set_drawcolor(color);
                    330:                DRAWSTRING(display,can->pix,cdrawGC,x,y,str,strlen(str));
                    331:                DRAWSTRING(display,can->window,cdrawGC,x,y,str,strlen(str));
                    332:        } else {
                    333:                DRAWSTRING(display,can->pix,drawGC,x,y,str,strlen(str));
                    334:                DRAWSTRING(display,can->window,drawGC,x,y,str,strlen(str));
1.7       noro      335:        }
1.5       noro      336:        XFlush(display);
                    337: #endif
1.1       noro      338: }
                    339:
                    340: #define D 5
                    341:
1.9       noro      342: void pline(DISPLAY *display,struct canvas *can,DRAWABLE d)
1.1       noro      343: {
1.9       noro      344:        double w,w1,e,n;
1.1       noro      345:        int x0,y0,x,y,xadj,yadj;
                    346:        char buf[BUFSIZ];
                    347:        double adjust_scale();
                    348:
1.5       noro      349:        /* XXX : should be cleaned up */
                    350:        if ( can->noaxis || (can->mode == MODE_PLOT && !can->pa) )
                    351:                return;
                    352:        if ( can->mode == MODE_INTERACTIVE )
1.1       noro      353:                return;
                    354:
                    355:        xadj = yadj = 0;
                    356:        if ( (can->xmin < 0) && (can->xmax > 0) ) {
1.6       noro      357:                x0 = (int)((can->width)*(-can->xmin/(can->xmax-can->xmin)));
1.1       noro      358:                DRAWLINE(display,d,dashGC,x0,0,x0,can->height);
                    359:        } else if ( can->xmin >= 0 )
                    360:                x0 = 0;
                    361:        else
1.6       noro      362:                x0 = can->width-D;
1.1       noro      363:        if ( (can->ymin < 0) && (can->ymax > 0) ) {
1.6       noro      364:                y0 = (int)((can->height)*(can->ymax/(can->ymax-can->ymin)));
1.1       noro      365:                DRAWLINE(display,d,dashGC,0,y0,can->width,y0);
                    366:        } else if ( can->ymin >= 0 )
1.6       noro      367:                y0 = can->height;
1.1       noro      368:        else
                    369:                y0 = D;
1.6       noro      370:
                    371:        /* scale on x-axis */
1.1       noro      372:        w = can->xmax-can->xmin;
                    373:        w1 = w * DEFAULTWIDTH/can->width;
                    374:        e = adjust_scale(EXP10(floor(log10(w1))),w1);
                    375:        for ( n = ceil(can->xmin/e); n*e<= can->xmax; n++ ) {
1.9       noro      376:                x = (int)(can->width*(n*e-can->xmin)/w);
1.1       noro      377:                DRAWLINE(display,d,drawGC,x,y0,x,y0-D);
                    378:                sprintf(buf,"%g",n*e);
1.6       noro      379:                DRAWSTRING(display,d,scaleGC,x+2,y0+2,buf,strlen(buf));
1.1       noro      380:        }
1.6       noro      381:
                    382:        /* scale on y-axis */
1.1       noro      383:        w = can->ymax-can->ymin;
                    384:        w1 = w * DEFAULTHEIGHT/can->height;
                    385:        e = adjust_scale(EXP10(floor(log10(w1))),w1);
                    386:        for ( n = ceil(can->ymin/e); n*e<= can->ymax; n++ ) {
1.9       noro      387:                y = (int)(can->height*(1-(n*e-can->ymin)/w));
1.1       noro      388:                DRAWLINE(display,d,drawGC,x0,y,x0+D,y);
                    389:                sprintf(buf,"%g",n*e);
1.6       noro      390:                if ( can->xmax <= 0 ) {
                    391: #if !defined(VISUAL)
1.1       noro      392:                        xadj = TEXTWIDTH(sffs,buf,strlen(buf));
1.6       noro      393: #else
                    394:                        SIZE size;
                    395:
                    396:                        GetTextExtentPoint32(d,buf,strlen(buf),&size);
                    397:                        xadj = size.cx;
                    398: #endif
                    399:                }
                    400:                DRAWSTRING(display,d,scaleGC,x0+2-xadj,y+2,buf,strlen(buf));
1.1       noro      401:        }
                    402: }
                    403:
1.9       noro      404: double adjust_scale(double e,double w)
1.1       noro      405: {
                    406:        switch ( (int)floor(w/e) ) {
                    407:                case 1:
                    408:                        return e/4; break;
                    409:                case 2: case 3:
                    410:                        return e/2; break;
                    411:                case 4: case 5: case 6: case 7:
                    412:                        return e; break;
                    413:                        break;
                    414:                case 8: case 9: case 10: default:
                    415:                        return 2*e; break;
                    416:        }
                    417: }
                    418:
1.9       noro      419: void initmarker(struct canvas *can,char *message)
1.1       noro      420: {
1.5       noro      421: #if defined(VISUAL)
                    422:        can->real_can->percentage = 0;
                    423:        can->real_can->prefix = message;
                    424: #else
1.1       noro      425:        XawScrollbarSetThumb(can->xdone,0.0,0.0);
                    426:        XawScrollbarSetThumb(can->ydone,1.0,0.0);
                    427:        XFlush(display);
1.5       noro      428: #endif
1.1       noro      429: }
                    430:
1.9       noro      431: void marker(struct canvas *can,int dir,int p)
1.1       noro      432: {
1.5       noro      433: #if defined(VISUAL)
                    434:        if ( dir == DIR_X )
1.9       noro      435:                can->real_can->percentage = (int)ceil((float)p/(float)can->real_can->width*100);
1.5       noro      436:        else if ( dir == DIR_Y )
1.9       noro      437:                can->real_can->percentage = (int)ceil((float)p/(float)can->real_can->height*100);
1.5       noro      438:        else
1.9       noro      439:                can->real_can->percentage = (int)ceil((float)p/(float)can->real_can->nzstep*100);
1.5       noro      440: #else
1.1       noro      441:        if ( dir == DIR_X ) {
                    442:                XawScrollbarSetThumb(can->xdone,(float)p/(float)can->width,0.05);
                    443:                count_and_flush();
                    444:        } else if ( dir == DIR_Y ) {
                    445:                XawScrollbarSetThumb(can->ydone,1.0-(float)p/(float)can->height,0.05);
                    446:                count_and_flush();
                    447:        } else {
                    448:                XawScrollbarSetThumb(can->ydone,1.0-(float)p/(float)can->nzstep,0.05);
                    449:                flush();
                    450:        }
1.5       noro      451: #endif
1.1       noro      452: }
                    453:
1.9       noro      454: void define_cursor(WINDOW w,CURSOR cur)
1.1       noro      455: {
1.5       noro      456: #if !defined(VISUAL)
1.1       noro      457:        XDefineCursor(display,w,cur); flush();
1.5       noro      458: #endif
1.1       noro      459: }
                    460:
                    461: static int flush_count;
                    462: #if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__)
                    463: #define MAX_COUNT 64
                    464: #else
                    465: #define MAX_COUNT 32
                    466: #endif
                    467:
1.9       noro      468: void count_and_flush() {
1.5       noro      469: #if !defined(VISUAL)
1.1       noro      470:        if ( ++flush_count == MAX_COUNT )
                    471:                flush();
1.5       noro      472: #endif
1.1       noro      473: }
                    474:
1.9       noro      475: void flush() {
1.5       noro      476: #if !defined(VISUAL)
1.1       noro      477:        flush_count = 0;
                    478:        XFlush(display);
1.5       noro      479: #endif
1.1       noro      480: }

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