1 /*------------------------------------------------------------\
2 | |
3 | This file is part of the Alliance CAD System Copyright |
4 | (C) Laboratoire LIP6 - D�partement ASIM Universite P&M Curie|
5 | |
6 | Home page : http://www-asim.lip6.fr/alliance/ |
7 | E-mail : mailto:alliance-users@asim.lip6.fr |
8 | |
9 | This progam is free software; you can redistribute it |
10 | and/or modify it under the terms of the GNU General Public |
11 | License as published by the Free Software Foundation; |
12 | either version 2 of the License, or (at your option) any |
13 | later version. |
14 | |
15 | Alliance VLSI CAD System is distributed in the hope that |
16 | it will be useful, but WITHOUT ANY WARRANTY; |
17 | without even the implied warranty of MERCHANTABILITY or |
18 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
19 | Public License for more details. |
20 | |
21 | You should have received a copy of the GNU General Public |
22 | License along with the GNU C Library; see the file COPYING. |
23 | If not, write to the Free Software Foundation, Inc., |
24 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
25 | |
26 \------------------------------------------------------------*/
27
28 /*------------------------------------------------------------\
29 | |
30 | Tool : GRAAL |
31 | |
32 | File : Graphic.c |
33 | |
34 | Author : Jacomme Ludovic |
35 | |
36 | Date : 28.03.95 |
37 | |
38 \------------------------------------------------------------*/
39
40 /*------------------------------------------------------------\
41 | |
42 | Include Files |
43 | |
44 \------------------------------------------------------------*/
45
46 # include <stdio.h>
47 # include <Xm/Xm.h>
48 # include <Xm/Form.h>
49 # include <Xm/Frame.h>
50 # include <Xm/DrawingA.h>
51
52 # include "mut.h"
53 # include "mph.h"
54 # include "rds.h"
55 # include "rpr.h"
56 # include "GSB.h"
57 # include "GTB.h"
58 # include "GMX.h"
59
60 # include "GMX_graphic.h"
61 # include "GMX_view.h"
62 # include "GMX_grid.h"
63
64 /*------------------------------------------------------------\
65 | |
66 | Constants |
67 | |
68 \------------------------------------------------------------*/
69 /*------------------------------------------------------------\
70 | |
71 | Types |
72 | |
73 \------------------------------------------------------------*/
74 /*------------------------------------------------------------\
75 | |
76 | Variables |
77 | |
78 \------------------------------------------------------------*/
79
80 Widget GraalGraphicFrame;
81 Widget GraalGraphicWindow;
82 Display *GraalGraphicDisplay = (Display *)NULL;
83
84 Dimension GraalGraphicDx = 0;
85 Dimension GraalGraphicDy = 0;
86 Dimension GraalOldGraphicDx = 0;
87 Dimension GraalOldGraphicDy = 0;
88
89 Pixmap GraalGraphicPixmap = (Pixmap)NULL;
90
91 /*------------------------------------------------------------\
92 | |
93 | Functions |
94 | |
95 \------------------------------------------------------------*/
96 /*------------------------------------------------------------\
97 | |
98 | GraalInitializeGraphicWindow |
99 | |
100 \------------------------------------------------------------*/
101
GraalInitializeGraphicWindow()102 void GraalInitializeGraphicWindow()
103
104 {
105 rdsbegin();
106
107 XtVaGetValues( GraalGraphicWindow,
108 XmNwidth, &GraalGraphicDx,
109 XmNheight, &GraalGraphicDy,
110 NULL
111 );
112
113 GraalOldGraphicDx = GraalGraphicDx;
114 GraalOldGraphicDy = GraalGraphicDy;
115
116 GraalGraphicPixmap =
117
118 XCreatePixmap ( GraalGraphicDisplay,
119 RootWindowOfScreen( XtScreen ( GraalGraphicWindow ) ),
120 GraalGraphicDx,
121 GraalGraphicDy,
122 DefaultDepthOfScreen ( XtScreen ( GraalGraphicWindow ) )
123 );
124
125 GraalClearGraphicWindow( 0, 0, GraalGraphicDx, GraalGraphicDy );
126 GraalInitializeLambdaGrid();
127
128 GraalSetMouseCursor( GraalGraphicWindow, GRAAL_NORMAL_CURSOR );
129
130 rdsend();
131 }
132
133 /*------------------------------------------------------------\
134 | |
135 | GraalClearGraphicWindow |
136 | |
137 \------------------------------------------------------------*/
138
GraalClearGraphicWindow(GraphicX,GraphicY,GraphicDx,GraphicDy)139 void GraalClearGraphicWindow( GraphicX, GraphicY, GraphicDx, GraphicDy )
140
141 long GraphicX;
142 long GraphicY;
143 long GraphicDx;
144 long GraphicDy;
145 {
146 XFillRectangle( GraalGraphicDisplay,
147 GraalGraphicPixmap,
148 GraalBackgroundGC,
149 GraphicX, GraphicY,
150 GraphicDx,
151 GraphicDy );
152 }
153
154 /*------------------------------------------------------------\
155 | |
156 | GraalRefreshGraphicWindow |
157 | |
158 \------------------------------------------------------------*/
159
GraalRefreshGraphicWindow(GraphicX,GraphicY,GraphicDx,GraphicDy)160 void GraalRefreshGraphicWindow( GraphicX, GraphicY, GraphicDx, GraphicDy )
161
162 Dimension GraphicX;
163 Dimension GraphicY;
164 Dimension GraphicDx;
165 Dimension GraphicDy;
166 {
167 rdsbegin();
168
169 GraalUndisplayCursor();
170
171 XCopyArea( GraalGraphicDisplay,
172 GraalGraphicPixmap,
173 XtWindow ( GraalGraphicWindow ),
174 GraalBackgroundGC,
175 GraphicX, GraphicY,
176 GraphicDx, GraphicDy,
177 GraphicX, GraphicY
178 );
179
180 GraalDisplayLambdaGrid( GraphicX, GraphicY,
181 GraphicX + GraphicDx,
182 GraphicY + GraphicDy );
183 GraalUndisplayCursor();
184
185 rdsend();
186 }
187
188
189 /*------------------------------------------------------------\
190 | |
191 | GraalResizeGraphicWindow |
192 | |
193 \------------------------------------------------------------*/
194
GraalResizeGraphicWindow()195 void GraalResizeGraphicWindow()
196
197 {
198 Pixmap OldPixmap;
199 Dimension SourceY;
200 Dimension TargetY;
201 Dimension TargetDx;
202 Dimension TargetDy;
203
204 rdsbegin();
205
206 GraalOldGraphicDx = GraalGraphicDx;
207 GraalOldGraphicDy = GraalGraphicDy;
208
209 XtVaGetValues( GraalGraphicWindow,
210 XmNwidth, &GraalGraphicDx,
211 XmNheight, &GraalGraphicDy,
212 NULL
213 );
214
215 if ( ( GraalOldGraphicDx != GraalGraphicDx ) ||
216 ( GraalOldGraphicDy != GraalGraphicDy ) )
217 {
218 OldPixmap = GraalGraphicPixmap;
219
220 GraalGraphicPixmap =
221
222 XCreatePixmap ( GraalGraphicDisplay,
223 RootWindowOfScreen( XtScreen ( GraalGraphicWindow ) ),
224 GraalGraphicDx,
225 GraalGraphicDy,
226 DefaultDepthOfScreen ( XtScreen ( GraalGraphicWindow ) )
227 );
228
229 GraalClearGraphicWindow( 0, 0, GraalGraphicDx, GraalGraphicDy );
230
231 GraalResizeLambdaGrid();
232
233 if ( GraalOldGraphicDx < GraalGraphicDx )
234 {
235 TargetDx = GraalOldGraphicDx;
236
237 GraalDisplayFigure( TargetDx, 0,
238 GraalGraphicDx, GraalGraphicDy );
239 }
240 else
241 {
242 TargetDx = GraalGraphicDx;
243 }
244
245 if ( GraalOldGraphicDy < GraalGraphicDy )
246 {
247 SourceY = 0;
248 TargetDy = GraalOldGraphicDy;
249 TargetY = GraalGraphicDy - GraalOldGraphicDy;
250
251 GraalDisplayFigure( 0, TargetDy,
252 TargetDx, GraalGraphicDy );
253 }
254 else
255 {
256 TargetDy = GraalGraphicDy;
257 TargetY = 0;
258 SourceY = GraalOldGraphicDy - GraalGraphicDy;
259 }
260
261 XCopyArea( GraalGraphicDisplay,
262 OldPixmap,
263 GraalGraphicPixmap,
264 GraalBackgroundGC,
265 0, SourceY,
266 TargetDx, TargetDy,
267 0, TargetY
268 );
269
270 XFreePixmap( GraalGraphicDisplay, OldPixmap );
271 }
272
273 rdsend();
274 }
275
276 /*------------------------------------------------------------\
277 | |
278 | GraalInitializeGraphic |
279 | |
280 \------------------------------------------------------------*/
281
GraalInitializeGraphic()282 void GraalInitializeGraphic()
283
284 {
285 rdsbegin();
286
287 GraalGraphicFrame = XtVaCreateManagedWidget( "GraalGraphicFrame",
288 xmFrameWidgetClass,
289 GraalMainForm,
290 XmNshadowType , XmSHADOW_ETCHED_IN,
291 XmNtopAttachment , XmATTACH_POSITION,
292 XmNtopPosition , 1,
293 XmNbottomAttachment , XmATTACH_POSITION,
294 XmNbottomPosition , 191,
295 XmNleftAttachment , XmATTACH_POSITION,
296 XmNleftPosition , 1,
297 XmNrightAttachment , XmATTACH_POSITION,
298 XmNrightPosition , 199,
299 NULL );
300
301 GraalGraphicWindow = XtVaCreateManagedWidget(
302 "GraalGraphicWindow",
303 xmDrawingAreaWidgetClass,
304 GraalGraphicFrame,
305 XmNtopAttachment, XmATTACH_FORM,
306 XmNrightAttachment, XmATTACH_FORM,
307 XmNbottomAttachment, XmATTACH_FORM,
308 XmNleftAttachment, XmATTACH_FORM,
309 XmNbackground, 1,
310 XmNforeground, 0,
311 NULL
312 );
313
314 GraalGraphicDisplay = XtDisplay( GraalGraphicWindow );
315
316 rdsend();
317 }
318