[BACK]Return to ox_plot_win.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / windows / engine2000

Annotation of OpenXM_contrib2/windows/engine2000/ox_plot_win.c, Revision 1.7

1.1       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
                     26:  * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
                     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     ! ohara      48:  * $OpenXM: OpenXM_contrib2/windows/engine2000/ox_plot_win.c,v 1.6 2002/10/03 03:05:44 noro Exp $
1.1       noro       49: */
                     50: #include "ca.h"
                     51: #include "parse.h"
                     52: #include "ox.h"
                     53: #include "ifplot.h"
                     54:
                     55: #ifdef ABS
                     56: #undef ABS
                     57: #define ABS(a) ((a)>0?(a):-(a))
                     58: #endif
                     59:
                     60: static char *dname;
                     61: static int remotes;
                     62: static int depth,scrn;
                     63:
                     64: extern jmp_buf ox_env;
                     65:
                     66: static int busy;
                     67:
                     68: HBRUSH ClearBrush,DrawBrush;
                     69:
                     70: #define LABELWIDTH 150
                     71:
                     72: int search_canvas()
                     73: {
                     74:        int i;
                     75:
                     76:        for ( i = 0; i < MAXCANVAS; i++ )
                     77:                if ( !canvas[i] ) {
                     78:                        canvas[i] = (struct canvas *)MALLOC(sizeof(struct canvas));
                     79:                        canvas[i]->index = i; return i;
                     80:                }
                     81: }
                     82:
                     83: int search_active_canvas()
                     84: {
                     85:        int i;
                     86:
                     87:        for ( i = 0; i < MAXCANVAS; i++ )
                     88:                if ( canvas[i] )
                     89:                        return i;
                     90:        return -1;
                     91: }
                     92:
1.5       noro       93: volatile DWORD MainThread;
                     94: volatile int canvas_created;
1.6       noro       95: extern HANDLE hMainThreadReady,hCanvasCreated;
1.5       noro       96:
1.2       noro       97: void create_canvas(struct canvas *can)
1.1       noro       98: {
                     99:        alloc_pixmap(can);
                    100:        can->real_can = can;
1.6       noro      101:        WaitForSingleObject(hMainThreadReady,(DWORD)-1);
                    102:        ResetEvent(hCanvasCreated);
1.1       noro      103:        PostThreadMessage(MainThread,WM_APP,can->index,0);
1.6       noro      104:        WaitForSingleObject(hCanvasCreated,(DWORD)-1);
1.1       noro      105: }
                    106:
1.2       noro      107: void destroy_canvas(struct canvas *can)
1.1       noro      108: {
                    109:        if ( can == current_can ) {
                    110:                reset_busy(can); current_can = 0;
                    111:        }
1.4       noro      112:        can->window = 0;
                    113:        DeleteObject(can->pix);
                    114:        closed_canvas[can->index] = can;
                    115:        canvas[can->index] = 0;
1.1       noro      116: }
                    117:
1.2       noro      118: void clear_pixmap(struct canvas *can)
1.1       noro      119: {
                    120:        RECT rect;
                    121:
                    122:        create_brushes();
                    123:        rect.left = 0; rect.top = 0;
                    124:        rect.right = can->width; rect.bottom = can->height;
                    125:        FillRect(can->pix,&rect,ClearBrush);
                    126: }
                    127:
1.2       noro      128: void alloc_pixmap(struct canvas *can)
1.1       noro      129: {
                    130:        HDC pix;
                    131:        HBITMAP bm;
                    132:        int bpp,np;
                    133:        BITMAP bmobj;
                    134:        void *bits;
                    135:
                    136:        can->pix = pix = CreateCompatibleDC(NULL);
                    137:        bpp = GetDeviceCaps(pix,BITSPIXEL);
                    138:        np = GetDeviceCaps(pix,PLANES);
                    139:
                    140: // XXX: CreateCompatibleBitmap() creates a monochrome bitmap
                    141: //     bm = CreateCompatibleBitmap(pix,can->width,can->height);
                    142:        bits = (void *)calloc(((bpp*can->width+31)/32)*can->height*np,4);
                    143:        bm = CreateBitmap(can->width,can->height,np,bpp,bits);
                    144:
                    145:        SelectObject(pix,bm);
                    146:        clear_pixmap(can);
                    147:        current_can = can;
                    148: }
                    149:
1.2       noro      150: void copy_to_canvas(struct canvas *can)
1.1       noro      151: {
                    152:        PostThreadMessage(MainThread,WM_APP,can->index,0);
1.3       noro      153: }
                    154:
                    155: void popup_canvas(int index)
                    156: {
1.4       noro      157:        create_canvas(canvas[index]);
1.1       noro      158: }
                    159:
1.2       noro      160: void copy_subimage(struct canvas *subcan,struct canvas *can,POINT pos)
1.1       noro      161: {
                    162:        BitBlt(can->pix,pos.x,pos.y,subcan->width,subcan->height,subcan->pix,0,0,SRCCOPY);
                    163: }
                    164:
1.2       noro      165: void draw_wideframe(struct canvas *can,DRAWABLE d)
1.1       noro      166: {
                    167:        struct canvas fakecan;
                    168:        double xmid,ymid,dx,dy;
                    169:        POINT s,e;
                    170:        RECT rect;
                    171:
                    172:        fakecan = *can;
                    173:        dx = 10*(can->xmax-can->xmin); dy = 10*(can->ymax-can->ymin);
                    174:        xmid = (can->xmax+can->xmin)/2; ymid = (can->ymax+can->ymin)/2;
                    175:
                    176:        fakecan.xmin = xmid-dx/2; fakecan.xmax = xmid+dx/2;
                    177:        fakecan.ymin = ymid-dy/2; fakecan.ymax = ymid+dy/2;
                    178:
                    179:        rect.left = 0; rect.top = 0;
                    180:        rect.right = can->width; rect.bottom = can->height;
                    181:        create_brushes();
                    182:        FillRect(d,&rect,ClearBrush);
                    183:        pline(display,&fakecan,d);
                    184:        XC(s) = can->width*9/20; YC(s) = can->height*9/20;
                    185:        XC(e) = can->width*11/20; YC(e) = can->height*11/20;
                    186:        draw_frame0(d,s,e);
                    187: }
                    188:
                    189: void create_brushes()
                    190: {
                    191:        if ( !ClearBrush )
                    192:                ClearBrush = CreateSolidBrush(0xffffff);
                    193:        if ( !DrawBrush )
                    194:                DrawBrush = CreateSolidBrush(0);
                    195: }
                    196:
1.2       noro      197: void draw_frame0(DRAWABLE d,POINT spos,POINT epos)
1.1       noro      198: {
                    199:        RECT rect;
                    200:        int ulx,uly,w,h;
                    201:
                    202:        ulx = MIN(XC(spos),XC(epos)); uly = MIN(YC(spos),YC(epos));
                    203:        w = ABS(XC(spos)-XC(epos)); h = ABS(YC(spos)-YC(epos));
                    204:        if ( !w || !h )
                    205:                return;
                    206:        rect.left = spos.x; rect.top = spos.y;
                    207:        rect.right = epos.x; rect.bottom = epos.y;
                    208:        FrameRect(d,&rect,DrawBrush);
                    209: }
1.7     ! ohara     210:
        !           211: /* dummy function */
        !           212: void set_drawcolor(unsigned int c)
        !           213: {
        !           214: }

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