Annotation of OpenXM_contrib2/windows/engine2000/ox_plot_win.c, Revision 1.5
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.5 ! noro 48: * $OpenXM: OpenXM_contrib2/windows/engine2000/ox_plot_win.c,v 1.4 2002/07/30 03:48:34 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;
! 95:
1.2 noro 96: void create_canvas(struct canvas *can)
1.1 noro 97: {
98: alloc_pixmap(can);
99: can->real_can = can;
1.5 ! noro 100: while ( !MainThread );
! 101: canvas_created = 0;
1.1 noro 102: PostThreadMessage(MainThread,WM_APP,can->index,0);
1.5 ! noro 103: while ( !canvas_created );
1.1 noro 104: }
105:
1.2 noro 106: void destroy_canvas(struct canvas *can)
1.1 noro 107: {
108: if ( can == current_can ) {
109: reset_busy(can); current_can = 0;
110: }
1.4 noro 111: can->window = 0;
112: DeleteObject(can->pix);
113: closed_canvas[can->index] = can;
114: canvas[can->index] = 0;
1.1 noro 115: }
116:
1.2 noro 117: void clear_pixmap(struct canvas *can)
1.1 noro 118: {
119: RECT rect;
120:
121: create_brushes();
122: rect.left = 0; rect.top = 0;
123: rect.right = can->width; rect.bottom = can->height;
124: FillRect(can->pix,&rect,ClearBrush);
125: }
126:
1.2 noro 127: void alloc_pixmap(struct canvas *can)
1.1 noro 128: {
129: HDC pix;
130: HBITMAP bm;
131: int bpp,np;
132: BITMAP bmobj;
133: void *bits;
134:
135: can->pix = pix = CreateCompatibleDC(NULL);
136: bpp = GetDeviceCaps(pix,BITSPIXEL);
137: np = GetDeviceCaps(pix,PLANES);
138:
139: // XXX: CreateCompatibleBitmap() creates a monochrome bitmap
140: // bm = CreateCompatibleBitmap(pix,can->width,can->height);
141: bits = (void *)calloc(((bpp*can->width+31)/32)*can->height*np,4);
142: bm = CreateBitmap(can->width,can->height,np,bpp,bits);
143:
144: SelectObject(pix,bm);
145: clear_pixmap(can);
146: current_can = can;
147: }
148:
1.2 noro 149: void copy_to_canvas(struct canvas *can)
1.1 noro 150: {
151: PostThreadMessage(MainThread,WM_APP,can->index,0);
1.3 noro 152: }
153:
154: void popup_canvas(int index)
155: {
1.4 noro 156: create_canvas(canvas[index]);
1.1 noro 157: }
158:
1.2 noro 159: void copy_subimage(struct canvas *subcan,struct canvas *can,POINT pos)
1.1 noro 160: {
161: BitBlt(can->pix,pos.x,pos.y,subcan->width,subcan->height,subcan->pix,0,0,SRCCOPY);
162: }
163:
1.2 noro 164: void draw_wideframe(struct canvas *can,DRAWABLE d)
1.1 noro 165: {
166: struct canvas fakecan;
167: double xmid,ymid,dx,dy;
168: POINT s,e;
169: RECT rect;
170:
171: fakecan = *can;
172: dx = 10*(can->xmax-can->xmin); dy = 10*(can->ymax-can->ymin);
173: xmid = (can->xmax+can->xmin)/2; ymid = (can->ymax+can->ymin)/2;
174:
175: fakecan.xmin = xmid-dx/2; fakecan.xmax = xmid+dx/2;
176: fakecan.ymin = ymid-dy/2; fakecan.ymax = ymid+dy/2;
177:
178: rect.left = 0; rect.top = 0;
179: rect.right = can->width; rect.bottom = can->height;
180: create_brushes();
181: FillRect(d,&rect,ClearBrush);
182: pline(display,&fakecan,d);
183: XC(s) = can->width*9/20; YC(s) = can->height*9/20;
184: XC(e) = can->width*11/20; YC(e) = can->height*11/20;
185: draw_frame0(d,s,e);
186: }
187:
188: void create_brushes()
189: {
190: if ( !ClearBrush )
191: ClearBrush = CreateSolidBrush(0xffffff);
192: if ( !DrawBrush )
193: DrawBrush = CreateSolidBrush(0);
194: }
195:
1.2 noro 196: void draw_frame0(DRAWABLE d,POINT spos,POINT epos)
1.1 noro 197: {
198: RECT rect;
199: int ulx,uly,w,h;
200:
201: ulx = MIN(XC(spos),XC(epos)); uly = MIN(YC(spos),YC(epos));
202: w = ABS(XC(spos)-XC(epos)); h = ABS(YC(spos)-YC(epos));
203: if ( !w || !h )
204: return;
205: rect.left = spos.x; rect.top = spos.y;
206: rect.right = epos.x; rect.bottom = epos.y;
207: FrameRect(d,&rect,DrawBrush);
208: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>