Update ChangeLog
[gss-tcad.git] / src / graphic / showmesh.cc
blobc3dc2173f9024686745fdd92bfa85adb3783a00d
1 // This file is borrowed from showmesh 1.0
2 // shipped with easymesh project
3 // Author: Bojan NICENO
4 // Email: niceno@univ.trieste.it
6 #include "config.h"
7 #ifdef HAVE_X11
9 #include "bsolver.h"
10 #include "mathfunc.h"
11 #include <X11/Xlib.h>
12 #include <X11/Xutil.h>
13 #include <X11/Xos.h>
14 #include <X11/Xatom.h>
15 #include <X11/keysym.h>
16 #include <stdio.h>
17 #include <string.h>
18 #include <stdlib.h>
20 #ifndef max
21 #define max(a,b) (((a) > (b)) ? (a) : (b))
22 #endif
23 #ifndef min
24 #define min(a,b) (((a) < (b)) ? (a) : (b))
25 #endif
26 #define SMALL 1e-30
27 #define GREAT 1e+30
29 #define MAIN_WDTH 750
30 #define MAIN_HGHT 500
31 #define BUTTON_HEIGHT 18
32 #define BUTTON_WIDTH 80
33 #define ON 0
34 #define OFF -1
36 #define DELAUNAY 0
37 #define VORONOI 1
38 #define MATERIALS 2
39 #define BOUNDARY 3
40 #define ZOOM 4
41 #define MOVE 5
42 #define FIT 6
43 #define QUIT 7
44 #define NBUTTONS 8
46 #define GR_BLACK 0
47 #define GR_BLUE 1
48 #define GR_GREEN 2
49 #define GR_CYAN 3
50 #define GR_RED 4
51 #define GR_MAGENTA 5
52 #define GR_BROWN 6
53 #define GR_LIGHTGRAY 7
54 #define GR_DARKGRAY 8
55 #define GR_LIGHTBLUE 9
56 #define GR_LIGHTGREEN 10
57 #define GR_LIGHTCYAN 11
58 #define GR_LIGHTRED 12
59 #define GR_LIGHTMAGENTA 13
60 #define GR_YELLOW 14
61 #define GR_WHITE 15
63 #define Rainbow_Color_NUM 20
64 #define Rainbow_0 16
65 #define Rainbow_1 17
66 #define Rainbow_2 18
67 #define Rainbow_3 19
68 #define Rainbow_4 20
69 #define Rainbow_5 21
70 #define Rainbow_6 22
71 #define Rainbow_7 23
72 #define Rainbow_8 24
73 #define Rainbow_9 25
74 #define Rainbow_10 26
75 #define Rainbow_11 27
76 #define Rainbow_12 28
77 #define Rainbow_13 29
78 #define Rainbow_14 30
79 #define Rainbow_15 31
80 #define Rainbow_16 32
81 #define Rainbow_17 33
82 #define Rainbow_18 34
83 #define Rainbow_19 35
85 static unsigned int rc[][3] =
87 0, 0, 65535,
88 0, 29298, 65535,
89 0, 41377, 65535,
90 0, 50629, 65535,
91 0, 58596, 65535,
92 0, 65535, 65535,
93 0, 65535, 56797,
94 0, 65535, 46003,
95 0, 65535, 32639,
96 0, 65535, 0,
97 32125, 65535, 0,
98 46260, 65535, 0,
99 56540, 65535, 0,
100 65535, 65535, 0,
101 65535, 59881, 0,
102 65535, 53199, 0,
103 65535, 45746, 0,
104 65535, 38036, 0,
105 65535, 26471, 0,
106 65535, 0, 0
109 static Display *display;
110 static Window main_win;
111 static Window draw_win;
112 static XTextProperty winname, iconame;
113 static Pixmap ico_pixm, back_pixm;
114 static int draw_wdth, draw_hght;
115 static int scr_num;
116 static char *prog_name;
117 static GC gc_BoW, gc_WoB, gc_XOR, gc_THICK, gc_DASHED, gc_numb;
118 static GC gc_color[16+20];
119 static XFontStruct *text_font, *numb_font;
120 static Colormap colormap;
121 static int main_wdth=MAIN_WDTH;
122 static int main_hght=MAIN_HGHT;
123 static double scl, X0, Y0;
124 static double xmin,xmax,ymin,ymax;
125 #define Xmap(x) (int( ((x)-(xmin+xmax)/2)*scl+X0))
126 #define Ymap(y) (int(-((y)-(ymin+ymax)/2)*scl+Y0))
129 class Doping2D
131 public:
132 int n;
133 short int X,Y;
134 double doping;
135 Doping2D(int _n, short int _XX, short int _YY, double _doping):n(_n),X(_XX),Y(_YY),doping(_doping)
140 inline void swap(Doping2D &A, Doping2D &B)
142 Doping2D tmp=A;
143 A=B;
144 B=tmp;
147 struct butt_data
149 int x0, y0, hght, wdth, border;
150 const char *caption;
151 int pressed;
154 static butt_data[NBUTTONS]=
156 { MAIN_WDTH-BUTTON_WIDTH-20, 10, BUTTON_HEIGHT, BUTTON_WIDTH, 2, "Delaunay", ON},
157 { MAIN_WDTH-BUTTON_WIDTH-20, 40, BUTTON_HEIGHT, BUTTON_WIDTH, 2, "Voronoi", OFF},
158 { MAIN_WDTH-BUTTON_WIDTH-20, 70, BUTTON_HEIGHT, BUTTON_WIDTH, 2, "Materials", ON},
159 { MAIN_WDTH-BUTTON_WIDTH-20, 100, BUTTON_HEIGHT, BUTTON_WIDTH, 2, "Boundary", OFF},
160 { MAIN_WDTH-BUTTON_WIDTH-20, 130, BUTTON_HEIGHT, BUTTON_WIDTH, 2, "Zoom", OFF},
161 { MAIN_WDTH-BUTTON_WIDTH-20, 160, BUTTON_HEIGHT, BUTTON_WIDTH, 2, "Move", OFF},
162 { MAIN_WDTH-BUTTON_WIDTH-20, 190, BUTTON_HEIGHT, BUTTON_WIDTH, 2, "Fit", OFF},
163 { MAIN_WDTH-BUTTON_WIDTH-20, 250, BUTTON_HEIGHT, BUTTON_WIDTH, 2, "Exit", OFF},
166 static Window button[NBUTTONS];
168 /******************************************************************************
169 * Description: This function allocates a color.
171 void GetGCbyColorName (Window win, GC *gc, char *pszColorName )
173 unsigned long dwValueMask;
174 unsigned long dwForeground;
175 XGCValues values;
176 XColor xcolorDef;
177 XColor xcolorRGB;
179 XAllocNamedColor(display, colormap, pszColorName, &xcolorDef, &xcolorRGB);
180 dwForeground = xcolorDef.pixel;
181 dwValueMask = GCForeground | GCBackground;
182 values.foreground = dwForeground;
183 values.background = BlackPixel(display, scr_num);
184 *gc = XCreateGC(display, win, dwValueMask, &values);
185 XSetFont(display, *gc, text_font->fid);
188 /******************************************************************************
189 * Description: This function allocates a rainbow color.
191 void GetGCbyRainbow (Window win, GC *gc, unsigned short R, unsigned short G,unsigned short B)
193 unsigned long dwValueMask;
194 unsigned long dwForeground;
195 XGCValues values;
196 XColor xcolorDef;
197 XColor xcolorRGB;
198 xcolorDef.red = R;
199 xcolorDef.green = G;
200 xcolorDef.blue = B;
201 xcolorDef.flags = 0;
202 XAllocColor(display, colormap, &xcolorDef);
203 dwForeground = xcolorDef.pixel;
204 dwValueMask = GCForeground | GCBackground;
205 values.foreground = dwForeground;
206 values.background = BlackPixel(display, scr_num);
207 *gc = XCreateGC(display, win, dwValueMask, &values);
208 XSetFont(display, *gc, text_font->fid);
211 /*========================================================================*/
212 void getGC ( Window win )
214 unsigned long valuemask=0;
215 XGCValues values;
217 int dash_offset=0;
218 static char dash_list[2]={1,1};
219 int list_len=2;
221 /* Normal, thin lines */
222 gc_BoW = XCreateGC ( display, win, valuemask, &values );
223 gc_WoB = XCreateGC ( display, win, valuemask, &values );
225 XSetFont ( display, gc_BoW, text_font->fid );
226 XSetFont ( display, gc_WoB, text_font->fid );
228 XSetForeground ( display, gc_BoW, WhitePixel ( display, scr_num ) );
229 XSetForeground ( display, gc_WoB, BlackPixel ( display, scr_num ) );
231 XSetLineAttributes ( display, gc_BoW, 0, LineSolid, CapRound, JoinRound );
232 XSetLineAttributes ( display, gc_WoB, 0, LineSolid, CapRound, JoinRound );
234 /* Thick lines */
235 gc_THICK = XCreateGC ( display, win, valuemask, &values );
236 XSetForeground ( display, gc_THICK, WhitePixel ( display, scr_num ) );
237 XSetLineAttributes ( display, gc_THICK, 3, LineSolid, CapRound, JoinRound );
239 /* Dashed lines */
240 gc_DASHED = XCreateGC ( display, win, valuemask, &values );
241 XSetForeground ( display, gc_DASHED, WhitePixel ( display, scr_num ) );
242 XSetLineAttributes ( display, gc_DASHED, 0, LineOnOffDash, CapRound, JoinRound );
243 XSetDashes ( display, gc_DASHED, dash_offset, dash_list, list_len );
245 /* numbers */
246 gc_numb = XCreateGC ( display, win, valuemask, &values );
247 XSetFont ( display, gc_numb, numb_font->fid );
248 XSetForeground ( display, gc_numb, WhitePixel ( display, scr_num ) );
250 /* Invisible lines */
251 gc_XOR = XCreateGC ( display, win, 0, NULL );
252 XSetFunction ( display, gc_XOR, GXxor );
253 XSetForeground ( display, gc_XOR, WhitePixel ( display, scr_num ) );
255 /* Color GC */
256 GetGCbyColorName(win,&gc_color[0], "black"); /* black */
257 GetGCbyColorName(win,&gc_color[1], "blue"); /* blue */
258 GetGCbyColorName(win,&gc_color[2], "green"); /* green */
259 GetGCbyColorName(win,&gc_color[3], "cyan"); /* cyan */
260 GetGCbyColorName(win,&gc_color[4], "red"); /* red */
261 GetGCbyColorName(win,&gc_color[5], "magenta"); /* magenta */
262 GetGCbyColorName(win,&gc_color[6], "brown"); /* brown */
263 GetGCbyColorName(win,&gc_color[7], "gray"); /* light gray */
264 GetGCbyColorName(win,&gc_color[8], "dark slate gray"); /* dark gray */
265 GetGCbyColorName(win,&gc_color[9], "light blue"); /* light blue */
266 GetGCbyColorName(win,&gc_color[10], "lime green"); /* light green */
267 GetGCbyColorName(win,&gc_color[11], "slate blue"); /* light cyan */
268 GetGCbyColorName(win,&gc_color[12], "medium violet red"); /* light red */
269 GetGCbyColorName(win,&gc_color[13], "orange red"); /* light magenta */
270 GetGCbyColorName(win,&gc_color[14], "yellow"); /* yellow */
271 GetGCbyColorName(win,&gc_color[15], "white"); /* white */
272 for(int i = 0; i <Rainbow_Color_NUM; i++)
273 GetGCbyRainbow (win,&gc_color[16+i], rc[i][0],rc[i][1],rc[i][2]);
275 for(int i=0; i<16+Rainbow_Color_NUM; i++)
276 XSetLineAttributes ( display, gc_color[i], 3, LineSolid, CapRound, JoinRound );
281 /*========================================================================*/
282 void load_fonts()
284 if ( ( text_font = XLoadQueryFont ( display, "-*-helvetica-bold-r-normal--12-*" ) ) == NULL )
286 if ( ( text_font = XLoadQueryFont ( display, "7x14" ) ) == NULL )
288 ( void ) fprintf ( stderr, "%s: Cannot open font\n", prog_name );
289 exit ( -1 );
293 if ( ( numb_font = XLoadQueryFont ( display, "-*-helvetica-bold-r-normal--10-*" ) ) == NULL )
295 if ( ( numb_font = XLoadQueryFont ( display, "7x14" ) ) == NULL )
297 ( void ) fprintf ( stderr, "%s: Cannot open font\n", prog_name );
298 exit ( -1 );
303 /*========================================================================*/
304 void draw ( Window win, GC gc, int win_x_dim, int win_y_dim )
306 int x_0, y_0, x_dim, y_dim;
308 x_0 = win_x_dim/5;
309 y_0 = win_y_dim/5;
311 x_dim = 3*win_x_dim/5;
312 y_dim = 3*win_y_dim/5;
314 XDrawRectangle ( display, win, gc, x_0, y_0, x_dim, y_dim );
317 /*========================================================================*/
318 void place_text ( Window win, GC gc, XFontStruct *text_font,
319 int win_x_dim, int win_y_dim, char *string )
321 int width, height; /* string height and width */
323 width = XTextWidth ( text_font, string, strlen ( string ) );
324 height = text_font->ascent + text_font->descent;
326 XDrawString ( display, win, gc,
327 ( win_x_dim-width ) /2, ( win_y_dim+height ) /2,
328 string, strlen ( string ) );
332 /*========================================================================*/
333 void create_buttons ( Window parent )
335 int b;
337 unsigned long valuemask = CWWinGravity;
338 unsigned long border, background;
339 XSetWindowAttributes attr;
341 attr.win_gravity = NorthEastGravity;
343 for ( b=0; b<NBUTTONS; b++ )
345 if ( butt_data[b].pressed==OFF )
347 border =BlackPixel ( display, scr_num );
348 background=WhitePixel ( display, scr_num );
350 else
352 border =WhitePixel ( display, scr_num );
353 background=BlackPixel ( display, scr_num );
356 button[b] = XCreateSimpleWindow ( display, parent,
357 butt_data[b].x0, butt_data[b].y0,
358 butt_data[b].wdth, butt_data[b].hght,
359 butt_data[b].border,
360 border, background );
362 XSelectInput ( display, button[b], ExposureMask | ButtonPressMask );
363 XChangeWindowAttributes ( display, button[b], valuemask, &attr );
364 XMapWindow ( display, button[b] );
368 /*========================================================================*/
369 void write_on_button ( int b )
371 int width, height; /* string height and width */
373 unsigned long valuemask = CWBackPixel | CWBorderPixel;
374 XSetWindowAttributes attr;
375 GC gc;
377 height = text_font->ascent + text_font->descent;
378 width = XTextWidth ( text_font, butt_data[b].caption, strlen ( butt_data[b].caption ) );
380 if ( butt_data[b].pressed==ON )
382 attr.background_pixel = WhitePixel ( display, scr_num );
383 attr.border_pixel = BlackPixel ( display, scr_num );
386 if ( butt_data[b].pressed==OFF )
388 attr.background_pixel = BlackPixel ( display, scr_num );
389 attr.border_pixel = WhitePixel ( display, scr_num );
392 XChangeWindowAttributes ( display, button[b], valuemask, &attr );
393 XClearWindow ( display, button[b] );
394 /* XFlush(display); */
396 if ( butt_data[b].pressed==ON ) gc=gc_WoB;
397 if ( butt_data[b].pressed==OFF ) gc=gc_BoW;
399 XDrawString ( display, button[b], gc,
400 ( butt_data[b].wdth-width ) /2, ( butt_data[b].hght+height ) /2,
401 butt_data[b].caption, strlen ( butt_data[b].caption ) );
404 /*=========================================================================*/
405 void BSolver ::show_mesh_redwraw()
407 XPoint axpoint[10];
409 /***********************
410 * Draw Delaunay Mesh *
411 ***********************/
412 //draw triangle from zone level
413 for ( int z = 0; z < zone_num; z++ )
414 for ( int itri = 0; itri < zone[z].datri.size(); itri++ )
416 Tri ptri = zone[z].datri[itri];
417 int Bcolor=GR_WHITE;
418 if(zonedata[z]->material_type == Semiconductor)
420 SMCZone *pzonedata = dynamic_cast<SMCZone *> (zonedata[z]);
423 double dopingA = (pzonedata->aux[ptri.node[0]].Nd - pzonedata->aux[ptri.node[0]].Na)*1e18;
424 double dopingB = (pzonedata->aux[ptri.node[1]].Nd - pzonedata->aux[ptri.node[1]].Na)*1e18;
425 double dopingC = (pzonedata->aux[ptri.node[2]].Nd - pzonedata->aux[ptri.node[2]].Na)*1e18;
426 Doping2D A(ptri.node[0], axpoint[0].x,axpoint[0].y,dsign(dopingA)*log(1+fabs(dopingA)));
427 Doping2D B(ptri.node[1], axpoint[1].x,axpoint[1].y,dsign(dopingB)*log(1+fabs(dopingB)));
428 Doping2D C(ptri.node[2], axpoint[2].x,axpoint[2].y,dsign(dopingC)*log(1+fabs(dopingC)));
430 double dopingA = (pzonedata->aux[ptri.node[0]].Nd - pzonedata->aux[ptri.node[0]].Na);
431 double dopingB = (pzonedata->aux[ptri.node[1]].Nd - pzonedata->aux[ptri.node[1]].Na);
432 double dopingC = (pzonedata->aux[ptri.node[2]].Nd - pzonedata->aux[ptri.node[2]].Na);
433 Doping2D A(ptri.node[0], Xmap(zone[z].danode[ptri.node[0]].x),Ymap(zone[z].danode[ptri.node[0]].y),(dopingA));
434 Doping2D B(ptri.node[1], Xmap(zone[z].danode[ptri.node[1]].x),Ymap(zone[z].danode[ptri.node[1]].y),(dopingB));
435 Doping2D C(ptri.node[2], Xmap(zone[z].danode[ptri.node[2]].x),Ymap(zone[z].danode[ptri.node[2]].y),(dopingC));
437 // Sort the three points A B C in increasing doping components;
438 if (A.doping > B.doping) swap(A, B);
439 if (B.doping > C.doping)
441 if(C.doping < A.doping) swap(A, C);
442 swap(B, C);
445 if(A.doping>=0 || C.doping<=0)
447 if(A.doping>=0) Bcolor= GR_LIGHTGREEN; //the triangle is N-Type
448 if(C.doping<=0) Bcolor= Rainbow_15; //the triangle is P-Type
450 axpoint[0].x=Xmap(zone[z].danode[ptri.node[0]].x);
451 axpoint[0].y=Ymap(zone[z].danode[ptri.node[0]].y);
452 axpoint[1].x=Xmap(zone[z].danode[ptri.node[1]].x);
453 axpoint[1].y=Ymap(zone[z].danode[ptri.node[1]].y);
454 axpoint[2].x=Xmap(zone[z].danode[ptri.node[2]].x);
455 axpoint[2].y=Ymap(zone[z].danode[ptri.node[2]].y);
456 axpoint[3].x=axpoint[0].x;
457 axpoint[3].y=axpoint[0].y;
458 if ( butt_data[MATERIALS].pressed==ON )
459 XFillPolygon(display, draw_win, gc_color[Bcolor], axpoint, 4 - 1, Nonconvex, CoordModeOrigin);
461 //we must draw the metallurgic juction
462 if(A.doping<0 && B.doping>=0 && C.doping>=0)
464 // B and C above the A
465 // A<0<=B<=C
466 double factor = (0 - A.doping) / ( B.doping - A.doping);
467 int temp1x = int(A.X + (B.X - A.X) * factor);
468 int temp1y = int(A.Y + (B.Y - A.Y) * factor);
470 factor = (0 - A.doping) / (C.doping - A.doping);
471 int temp2x = int(A.X + (C.X - A.X) * factor);
472 int temp2y = int(A.Y + (C.Y - A.Y) * factor);
474 Bcolor= Rainbow_15;
475 axpoint[0].x=A.X;
476 axpoint[0].y=A.Y;
477 axpoint[1].x=temp1x;
478 axpoint[1].y=temp1y;
479 axpoint[2].x=temp2x;
480 axpoint[2].y=temp2y;
481 axpoint[3].x=axpoint[0].x;
482 axpoint[3].y=axpoint[0].y;
483 if ( butt_data[MATERIALS].pressed==ON )
484 XFillPolygon(display, draw_win, gc_color[Bcolor], axpoint, 4 - 1, Nonconvex, CoordModeOrigin);
485 //if ( butt_data[DELAUNAY].pressed==ON )
486 // XDrawLines(display, draw_win, gc_BoW, axpoint, 4, CoordModeOrigin);
488 Bcolor= GR_LIGHTGREEN;
489 axpoint[0].x=temp1x;
490 axpoint[0].y=temp1y;
491 axpoint[1].x=temp2x;
492 axpoint[1].y=temp2y;
493 axpoint[2].x=C.X;
494 axpoint[2].y=C.Y;
495 axpoint[3].x=B.X;
496 axpoint[3].y=B.Y;
497 axpoint[4].x=axpoint[0].x;
498 axpoint[4].y=axpoint[0].y;
499 if ( butt_data[MATERIALS].pressed==ON )
500 XFillPolygon(display, draw_win, gc_color[Bcolor], axpoint, 5 - 1, Nonconvex, CoordModeOrigin);
501 //if ( butt_data[DELAUNAY].pressed==ON )
502 // XDrawLines(display, draw_win, gc_BoW, axpoint, 5, CoordModeOrigin);
504 if(A.doping<0 && B.doping<0 && C.doping>=0)
506 // A and B are below C
507 // a<b<0<=c
509 double factor = (0 - A.doping) / (C.doping - A.doping);
510 int temp1x = int(A.X + (C.X - A.X) * factor);
511 int temp1y = int(A.Y + (C.Y - A.Y) * factor);
513 factor = (0 - B.doping) / (C.doping - B.doping);
514 int temp2x = int(B.X + (C.X - B.X) * factor);
515 int temp2y = int(B.Y + (C.Y - B.Y) * factor);
517 Bcolor= Rainbow_15;
518 axpoint[0].x=temp1x;
519 axpoint[0].y=temp1y;
520 axpoint[1].x=temp2x;
521 axpoint[1].y=temp2y;
522 axpoint[2].x=B.X;
523 axpoint[2].y=B.Y;
524 axpoint[3].x=A.X;
525 axpoint[3].y=A.Y;
526 axpoint[4].x=axpoint[0].x;
527 axpoint[4].y=axpoint[0].y;
528 if ( butt_data[MATERIALS].pressed==ON )
529 XFillPolygon(display, draw_win, gc_color[Bcolor], axpoint, 5 - 1, Nonconvex, CoordModeOrigin);
530 //if ( butt_data[DELAUNAY].pressed==ON )
531 // XDrawLines(display, draw_win, gc_BoW, axpoint, 5, CoordModeOrigin);
533 Bcolor= GR_LIGHTGREEN;
534 axpoint[0].x=C.X;
535 axpoint[0].y=C.Y;
536 axpoint[1].x=temp1x;
537 axpoint[1].y=temp1y;
538 axpoint[2].x=temp2x;
539 axpoint[2].y=temp2y;
540 axpoint[3].x=axpoint[0].x;
541 axpoint[3].y=axpoint[0].y;
542 if ( butt_data[MATERIALS].pressed==ON )
543 XFillPolygon(display, draw_win, gc_color[Bcolor], axpoint, 4 - 1, Nonconvex, CoordModeOrigin);
544 //if ( butt_data[DELAUNAY].pressed==ON )
545 // XDrawLines(display, draw_win, gc_BoW, axpoint, 4, CoordModeOrigin);
548 axpoint[0].x=Xmap(zone[z].danode[ptri.node[0]].x);
549 axpoint[0].y=Ymap(zone[z].danode[ptri.node[0]].y);
550 axpoint[1].x=Xmap(zone[z].danode[ptri.node[1]].x);
551 axpoint[1].y=Ymap(zone[z].danode[ptri.node[1]].y);
552 axpoint[2].x=Xmap(zone[z].danode[ptri.node[2]].x);
553 axpoint[2].y=Ymap(zone[z].danode[ptri.node[2]].y);
554 axpoint[3].x=axpoint[0].x;
555 axpoint[3].y=axpoint[0].y;
556 if ( butt_data[DELAUNAY].pressed==ON )
557 XDrawLines(display, draw_win, gc_BoW, axpoint, 4, CoordModeOrigin);
559 else //other zones
561 axpoint[0].x=Xmap(zone[z].danode[ptri.node[0]].x);
562 axpoint[0].y=Ymap(zone[z].danode[ptri.node[0]].y);
563 axpoint[1].x=Xmap(zone[z].danode[ptri.node[1]].x);
564 axpoint[1].y=Ymap(zone[z].danode[ptri.node[1]].y);
565 axpoint[2].x=Xmap(zone[z].danode[ptri.node[2]].x);
566 axpoint[2].y=Ymap(zone[z].danode[ptri.node[2]].y);
567 axpoint[3].x=axpoint[0].x;
568 axpoint[3].y=axpoint[0].y;
570 switch (zonedata[z]->material_type)
572 case Insulator:
574 if (zonedata[z]->material==SiO2)
575 Bcolor= GR_CYAN;//Rainbow_3;
576 else if (zonedata[z]->material==Nitride)
577 Bcolor= GR_MAGENTA;
578 else Bcolor= Rainbow_7;
579 break;
581 case Conductor:
582 Bcolor= GR_BLUE;
583 break;
584 case Vacuum:
585 Bcolor= GR_LIGHTCYAN;
586 break;
587 case PML:
588 Bcolor= Rainbow_3;
589 break;
592 if ( butt_data[MATERIALS].pressed==ON )
593 XFillPolygon(display, draw_win, gc_color[Bcolor], axpoint, 4 - 1, Nonconvex, CoordModeOrigin);
594 if ( butt_data[DELAUNAY].pressed==ON )
595 XDrawLines(display, draw_win, gc_BoW, axpoint, 4, CoordModeOrigin);
599 /**********************
600 * Draw Voronoi Mesh *
601 **********************/
602 if ( butt_data[VORONOI].pressed==ON )
603 for(int z = 0; z < zone_num; z++)
605 for(int i = 0; i < zone[z].davedge.size(); i++)
607 VEdge Edge = zone[z].davedge[i];
608 int sx1=Xmap(Edge.x1);
609 int sy1=Ymap(Edge.y1);
610 int sx2=Xmap(Edge.x2);
611 int sy2=Ymap(Edge.y2);
612 XDrawLine ( display, draw_win, gc_DASHED, sx1, sy1, sx2, sy2);
616 /*****************************
617 * Draw Boundary Conditions *
618 *****************************/
619 if ( butt_data[BOUNDARY].pressed==ON )
620 for(int z = 0; z < zone_num; z++)
622 for(int i=0;i<zone[z].dasegment.size();i++)
624 int color=GR_WHITE;
625 int bc_index = zone[z].dasegment[i].bc_index-1;
626 if(bc[bc_index].BCType & ContactMask) color=GR_BLUE;
627 if(bc[bc_index].BCType & InterfaceMask) color=GR_RED;
629 for(int k=0;k<zone[z].dasegment[i].edge_num;k++)
631 int p1=zone[z].dasegment[i].edge_array[k].p1;
632 int p2=zone[z].dasegment[i].edge_array[k].p2;
633 int sx1=Xmap(zone[z].danode[p1].x);
634 int sy1=Ymap(zone[z].danode[p1].y);
635 int sx2=Xmap(zone[z].danode[p2].x);
636 int sy2=Ymap(zone[z].danode[p2].y);
637 //XDrawLine ( display, draw_win, gc_THICK, sx1, sy1, sx2, sy2);
638 XDrawLine ( display, draw_win, gc_color[color], sx1, sy1, sx2, sy2);
642 XFlush(display);
644 /*-show_mesh_redwraw--------------------------------------------------------------*/
649 /*========================================================================*/
650 void show_mesh_init()
652 XWindowAttributes main_win_attr;
654 /*----------------------+
655 | Connect to X server |
656 +----------------------*/
658 char *disp_name=NULL; /* ako nije definirano od korisnika mora biti NULL */
660 if ( ( display=XOpenDisplay ( disp_name ) ) == NULL )
662 fprintf ( stderr, "%s: cannot connect to X server %s\n",
663 prog_name, XDisplayName ( disp_name ) );
664 exit ( -1 );
668 scr_num = DefaultScreen ( display );
670 /*---------------------------------------+
671 | Creating the main application window |
672 +---------------------------------------*/
673 main_win = XCreateSimpleWindow ( display, RootWindow ( display, scr_num ),
674 0, 0, MAIN_WDTH, MAIN_HGHT, 4,
675 BlackPixel ( display, scr_num ),
676 WhitePixel ( display, scr_num ) );
677 XGetWindowAttributes ( display, main_win, &main_win_attr );
678 main_wdth=main_win_attr.width;
679 main_hght=main_win_attr.height;
680 colormap = DefaultColormap(display, scr_num);
681 /* load window colors */
682 int ColorDepth = DisplayPlanes(display, scr_num);
683 Visual *visual = DefaultVisual(display, scr_num);
684 /*------------------------------------+
685 | Preparing an icon an a background |
686 +------------------------------------*/
688 #define icon_width 57
689 #define icon_height 57
690 static char icon_bits[] =
692 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
693 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00,
694 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0xe4, 0xff, 0xd7, 0xff,
695 0xaf, 0xff, 0x4f, 0x00, 0xd4, 0xff, 0xbb, 0xff, 0x77, 0xff, 0x57, 0x00,
696 0xb4, 0xff, 0xbb, 0xff, 0x7b, 0xff, 0x5b, 0x00, 0x74, 0xff, 0x7d, 0xff,
697 0xfb, 0xfe, 0x5d, 0x00, 0xf4, 0xfc, 0xfd, 0xfe, 0xfd, 0xfe, 0x5e, 0x00,
698 0xf4, 0xfb, 0xfe, 0xfe, 0xfe, 0x7d, 0x5f, 0x00, 0xf4, 0xf7, 0xfe, 0x7d,
699 0xff, 0xbd, 0x5f, 0x00, 0xf4, 0x6f, 0xff, 0x7b, 0xff, 0xdb, 0x5f, 0x00,
700 0xf4, 0x5f, 0xff, 0xbb, 0xff, 0xeb, 0x5f, 0x00, 0xf4, 0x1f, 0xfc, 0xd7,
701 0xff, 0xf0, 0x5f, 0x00, 0xf4, 0xa7, 0x03, 0xd6, 0x00, 0xc7, 0x5f, 0x00,
702 0xf4, 0x79, 0xff, 0x01, 0xff, 0xbb, 0x5f, 0x00, 0x74, 0x7e, 0xff, 0xd7,
703 0xff, 0x7b, 0x5e, 0x00, 0x94, 0x7f, 0xff, 0xbb, 0xff, 0xfb, 0x59, 0x00,
704 0xe4, 0x7f, 0xff, 0xbb, 0xff, 0xfd, 0x57, 0x00, 0xf4, 0xff, 0xfe, 0x7d,
705 0xff, 0xfd, 0x4f, 0x00, 0xe4, 0xff, 0xfe, 0xfe, 0xfe, 0xfd, 0x5f, 0x00,
706 0x94, 0xff, 0x7e, 0xff, 0xfd, 0xfe, 0x47, 0x00, 0x74, 0xfe, 0x7e, 0xff,
707 0xfd, 0xfe, 0x59, 0x00, 0xf4, 0xfd, 0xbd, 0xff, 0xfb, 0x7e, 0x5e, 0x00,
708 0xf4, 0xf3, 0xdd, 0xff, 0x77, 0x9f, 0x5f, 0x00, 0xf4, 0xcf, 0xed, 0xff,
709 0x6f, 0xe7, 0x5f, 0x00, 0xf4, 0x3f, 0xed, 0xff, 0x6f, 0xf9, 0x5f, 0x00,
710 0xf4, 0xff, 0xf0, 0xff, 0x1f, 0xfe, 0x5f, 0x00, 0xf4, 0xff, 0x03, 0x00,
711 0x80, 0xff, 0x5f, 0x00, 0xf4, 0xff, 0xf0, 0xff, 0x1f, 0xfe, 0x5f, 0x00,
712 0xf4, 0x3f, 0xf5, 0xff, 0x5f, 0xf9, 0x5f, 0x00, 0xf4, 0xcf, 0xed, 0xff,
713 0x6f, 0xe7, 0x5f, 0x00, 0xf4, 0xf3, 0xdd, 0xff, 0x77, 0xdf, 0x5f, 0x00,
714 0xf4, 0xfd, 0xbd, 0xff, 0x7b, 0x3f, 0x5f, 0x00, 0x74, 0xfe, 0xbe, 0xff,
715 0xfb, 0xfe, 0x5c, 0x00, 0x94, 0xff, 0x7e, 0xff, 0xfd, 0xfe, 0x53, 0x00,
716 0xe4, 0xff, 0xfe, 0xfe, 0xfe, 0xfe, 0x4f, 0x00, 0xf4, 0xff, 0xfe, 0xfe,
717 0xfe, 0xfe, 0x5f, 0x00, 0xe4, 0x7f, 0xff, 0x7d, 0xff, 0xfd, 0x47, 0x00,
718 0x94, 0x7f, 0xff, 0xbb, 0xff, 0xfd, 0x59, 0x00, 0x74, 0x7e, 0xff, 0xd7,
719 0xff, 0x7d, 0x5e, 0x00, 0xf4, 0x79, 0xff, 0xd7, 0xff, 0x9d, 0x5f, 0x00,
720 0xf4, 0xa7, 0x1f, 0x00, 0xf8, 0xe3, 0x5f, 0x00, 0xf4, 0x1f, 0xe0, 0xd7,
721 0x07, 0xf8, 0x5f, 0x00, 0xf4, 0x9f, 0xff, 0xbb, 0xff, 0xf3, 0x5f, 0x00,
722 0xf4, 0x6f, 0xff, 0xbb, 0xff, 0xed, 0x5f, 0x00, 0xf4, 0x77, 0xff, 0x7d,
723 0xff, 0xdd, 0x5f, 0x00, 0xf4, 0xfb, 0xfe, 0xfe, 0xfe, 0xbe, 0x5f, 0x00,
724 0xf4, 0xfc, 0x7e, 0xff, 0xfd, 0x7e, 0x5f, 0x00, 0x74, 0xff, 0x7d, 0xff,
725 0x7d, 0xff, 0x5c, 0x00, 0xb4, 0xff, 0xbd, 0xff, 0x7b, 0xff, 0x5b, 0x00,
726 0xd4, 0xff, 0xdb, 0xff, 0xb7, 0xff, 0x57, 0x00, 0xe4, 0xff, 0xeb, 0xff,
727 0xaf, 0xff, 0x4f, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
728 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00,
729 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
732 #define back_width 4
733 #define back_height 4
734 static char back_bits[] = {0x05, 0x0a, 0x05, 0x0a};
736 ico_pixm = XCreateBitmapFromData ( display, main_win,
737 icon_bits, icon_width, icon_height );
739 back_pixm = XCreatePixmapFromBitmapData ( display, main_win,
740 back_bits, back_width, back_height,
741 BlackPixel ( display, scr_num ), WhitePixel ( display, scr_num ),
742 main_win_attr.depth );
745 /*----------------------------+
746 | Set the window background |
747 +----------------------------*/
748 XSetWindowBackgroundPixmap ( display, main_win, back_pixm );
750 /*------------------------+
751 | Set window properties |
752 +------------------------*/
754 XSizeHints size_hints;
755 XWMHints wm_hints;
756 XClassHint class_hints;
758 char *win_name="Mesh Topology";
759 char *ico_name="ShowMesh";
761 size_hints.flags = PPosition | PSize | PMinSize;
762 size_hints.min_width = 50; /* 300 */
763 size_hints.min_height = NBUTTONS* ( BUTTON_HEIGHT+12 ) +10;
765 wm_hints.initial_state = NormalState; /* Normal or Iconified */
766 wm_hints.input = True; /* It needs keyboard input */
767 wm_hints.icon_pixmap = ico_pixm;
768 wm_hints.flags = StateHint | IconPixmapHint | InputHint;
770 class_hints.res_name = prog_name;
771 class_hints.res_class = "ShowMesh";
773 if ( XStringListToTextProperty ( &win_name,1,&winname ) == 0 )
775 fprintf ( stderr, "%s: structure allocation for window name failed\n",
776 prog_name );
777 exit ( -1 );
780 if ( XStringListToTextProperty ( &ico_name,1,&iconame ) == 0 )
782 fprintf ( stderr, "%s: structure allocation for icon name failed\n",
783 prog_name );
784 exit ( -1 );
787 XSetWMProperties ( display, main_win,
788 &winname, &iconame,
789 0, NULL,
790 &size_hints, &wm_hints, &class_hints );
794 /*---------------------+
795 | Select input types |
796 +---------------------*/
797 XSelectInput ( display, main_win, ExposureMask | StructureNotifyMask | KeyPressMask);
799 load_fonts();
800 getGC ( main_win );
802 /*---------------------+
803 | Display the window |
804 +---------------------*/
805 XMapWindow ( display, main_win );
807 /*--------------------+
808 | Create the button |
809 +--------------------*/
810 create_buttons ( main_win );
812 /*----------------------------+
813 | Create the drawing window |
814 +----------------------------*/
815 draw_wdth = main_wdth-BUTTON_WIDTH-40;
816 draw_hght = main_hght-20;
817 draw_win = XCreateSimpleWindow ( display, main_win,
818 10, 10, draw_wdth, draw_hght, 3,
819 WhitePixel ( display, scr_num ),
820 BlackPixel ( display, scr_num ) );
822 XSelectInput ( display, draw_win, ExposureMask | PointerMotionMask | ButtonPressMask );
823 XMapWindow ( display, draw_win );
826 /*------------------------------------------------------------------------*/
828 void show_mesh_close()
830 XFree(winname.value);
831 XFree(iconame.value);
832 XFreePixmap(display,ico_pixm);
833 XFreePixmap(display,back_pixm);
834 XUnloadFont(display, text_font->fid);
835 XUnloadFont(display, numb_font->fid);
836 XFreeGC(display, gc_WoB);
837 XFreeGC(display, gc_BoW);
838 XFreeGC(display, gc_XOR);
839 XFreeGC(display, gc_THICK);
840 XFreeGC(display, gc_DASHED);
841 XFreeGC(display, gc_numb);
842 for(int i=0;i<16+Rainbow_Color_NUM;i++)
843 XFreeGC(display, gc_color[i]);
844 XCloseDisplay(display);
847 #ifdef HAVE_TIFF
848 #include <tiffio.h>
849 int show_mesh_save_screen (const char * tiff_file, Window window, int width, int height)
851 TIFF *fout= TIFFOpen(tiff_file, "w");
852 if(!fout) return 1;
854 int sampleperpixel = 3; //RGB channel
855 XImage *ximage = XGetImage(display, window, 0, 0, width, height, AllPlanes, XYPixmap);
856 char *image=new char [width*height*sampleperpixel];
857 //it seems the XQueryColors has the limit of query size of 65535 colors.
858 XColor *color=new XColor[65535];
859 int lines=65535/width;
860 int currentlines;
861 int count = 0;
863 for (int i = 0; i < height; i+=lines)
865 if(i+lines>=height) currentlines=height-i-1;
866 else currentlines=lines;
867 for (int j = 0; j < currentlines; j++)
868 for (int k = 0; k < width; k++)
870 unsigned long c;
871 c = XGetPixel(ximage, k, i+j); /* X pixel value */
872 color[k+j*width].pixel = c;
874 XQueryColors(display, colormap, color, currentlines*width);
875 for (int j = 0; j < currentlines; j++)
876 for (int k = 0; k < width; k++)
878 char r, g, b;
879 r = color[k+j*width].red >> 8;
880 g = color[k+j*width].green >> 8;
881 b = color[k+j*width].blue >> 8;
883 image[count++] = r;
884 image[count++] = g;
885 image[count++] = b;
888 delete [] color;
890 TIFFSetField(fout, TIFFTAG_IMAGEWIDTH, width); // set the width of the image
891 TIFFSetField(fout, TIFFTAG_IMAGELENGTH, height); // set the height of the image
892 TIFFSetField(fout, TIFFTAG_SAMPLESPERPIXEL, sampleperpixel); // set number of channels per pixel
893 TIFFSetField(fout, TIFFTAG_BITSPERSAMPLE, 8); // set the size of the channels
894 TIFFSetField(fout, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); // set the origin of the image.
895 TIFFSetField(fout, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
896 TIFFSetField(fout, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
897 TIFFSetField(fout, TIFFTAG_COMPRESSION, COMPRESSION_PACKBITS);
899 tsize_t linebytes = sampleperpixel*width; // length in memory of one row of pixel in the image.
900 // We set the strip size of the file to be size of one row of pixels
901 TIFFSetField(fout, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(fout, width*sampleperpixel));
902 //Now writing image to the file one strip at a time
903 for (int row = 0; row < height; row++)
905 // check the index here, and figure out why not using h*linebytes
906 if(TIFFWriteScanline(fout, &image[row*linebytes], row, 0) < 0)
907 break;
909 TIFFClose(fout);
910 delete [] image;
911 XDestroyImage(ximage);
912 return 0;
914 #else
915 /* do nothing */
916 int show_mesh_save_screen (const char * tiff_file, Window window, int width, int height)
918 return 0;
920 #endif
922 /*========================================================================*/
923 void BSolver::show_mesh(PlotDefine &plot)
925 XEvent report;
927 /*-------------------------------+
928 | Copy the name of the program |
929 +-------------------------------*/
930 prog_name="ShowMesh";
931 show_mesh_init();
932 xmin=xMin;xmax=xMax;ymin=yMin;ymax=yMax;
933 scl =min ( ( 0.9* ( double ) draw_hght ) / ( yMax-yMin+SMALL ),
934 ( 0.9* ( double ) draw_wdth ) / ( xMax-xMin+SMALL ) );
935 X0 = ( int ) (0.5*draw_wdth);
936 Y0 = ( int ) (0.5*draw_hght);
938 /*============#
939 # MAIN LOOP #
940 #============*/
942 Window root, child; /* for XQuerryPointer */
943 unsigned int mouse_butt;
944 int b, x0=OFF, y0, x_root, y_root;
945 int x_new, y_new;
946 int x_old=int(0.45*draw_wdth), y_old=int(0.45*draw_hght);
947 double x0_fiz, y0_fiz, scl_new;
948 char buffer[10];
949 int count;
950 KeySym keysym;
951 XComposeStatus compose;
952 short int keycode;
954 while ( 1 )
956 XNextEvent ( display, &report );
957 switch ( report.type )
959 /******************
960 * Expose Window *
961 ******************/
962 case Expose:
963 while (XCheckTypedWindowEvent(display, report.xany.window, Expose, &report));
964 if ( report.xany.window == draw_win )
965 show_mesh_redwraw();
966 for ( b=0; b<NBUTTONS; b++ )
967 if ( report.xany.window==button[b] )
968 write_on_button ( b );
969 break;
971 /******************
972 * Resize Window *
973 ******************/
974 case ConfigureNotify:
975 main_wdth = report.xconfigure.width;
976 main_hght = report.xconfigure.height;
977 draw_wdth = main_wdth-BUTTON_WIDTH-40;
978 draw_hght = main_hght-20;
979 XResizeWindow ( display, draw_win, draw_wdth, draw_hght );
980 break;
982 /*****************
983 * Button Press *
984 *****************/
985 case ButtonPress:
986 if ( report.xany.window==button[QUIT] )
988 if(plot.GenerateTIFF)
989 show_mesh_save_screen(plot.TIFFFileName.c_str(),draw_win, draw_wdth, draw_hght);
990 show_mesh_close();
991 return;
994 for ( b=0; b<NBUTTONS; b++ )
996 if ( report.xany.window==button[b] )
998 if ( butt_data[b].pressed==ON )
999 {butt_data[b].pressed=OFF; write_on_button ( b );}
1000 else
1001 {butt_data[b].pressed=ON; write_on_button ( b );}
1005 if ( report.xany.window==button[MATERIALS] && butt_data[MATERIALS].pressed==ON )
1006 { write_on_button ( MATERIALS );}
1008 if ( report.xany.window==button[FIT] )
1010 butt_data[FIT].pressed=OFF;
1011 scl =min ( ( 0.9* ( double ) draw_hght ) / ( yMax-yMin+SMALL ),
1012 ( 0.9* ( double ) draw_wdth ) / ( xMax-xMin+SMALL ) );
1013 X0 = ( int ) (0.5*draw_wdth);
1014 Y0 = ( int ) (0.5*draw_hght);
1015 XClearWindow ( display, draw_win );
1016 show_mesh_redwraw();
1017 write_on_button ( FIT );
1020 if ( report.xany.window>=button[DELAUNAY] && report.xany.window<=button[BOUNDARY] )
1022 XClearWindow ( display, draw_win );
1023 show_mesh_redwraw();
1026 if ( report.xany.window==draw_win )
1028 if ( butt_data[MOVE].pressed==ON )
1030 if ( x0==OFF ) {x0=report.xmotion.x; y0=report.xmotion.y;}
1031 else
1033 butt_data[MOVE].pressed=OFF;
1034 write_on_button ( MOVE );
1035 X0+= ( x_new-x0 ); Y0+= ( y_new-y0 ); x0=OFF;
1036 XClearWindow ( display, draw_win ); show_mesh_redwraw();
1039 if ( butt_data[ZOOM].pressed==ON )
1041 if ( x0==OFF ) {x0=report.xmotion.x; y0=report.xmotion.y;}
1042 else
1044 butt_data[ZOOM].pressed=OFF;
1045 write_on_button ( ZOOM );
1046 x0_fiz = ( min ( x0, x_new )-X0 ) /scl;
1047 y0_fiz = ( min ( y0, y_new )-Y0 ) /scl;
1048 if ( x0!=x_new && y0!=y_new )
1049 scl_new= ( min ( ( double ) draw_wdth/abs ( x0-x_new ),
1050 ( double ) draw_hght/abs ( y0-y_new ) ) ) *scl;
1051 if ( max ( scl_new*xMax, scl_new*yMax ) < 32768 )
1053 scl=scl_new;
1054 X0=-x0_fiz*scl;
1055 Y0=-y0_fiz*scl;
1057 x0=OFF;
1058 XClearWindow ( display, draw_win ); show_mesh_redwraw();
1062 break;
1064 /*****************
1065 * Mouse Motion *
1066 *****************/
1067 case MotionNotify:
1068 if ( report.xany.window==draw_win )
1070 if ( butt_data[MOVE].pressed==ON )
1072 x_old=x_new; y_old=y_new;
1073 XQueryPointer ( display, report.xmotion.window,
1074 &root, &child, &x_root, &y_root, &x_new, &y_new,
1075 &mouse_butt );
1076 if ( x0!=OFF )
1078 XDrawLine ( display, draw_win, gc_XOR, x0, y0, x_old, y_old );
1079 XDrawLine ( display, draw_win, gc_XOR, x0, y0, x_new, y_new );
1083 if ( butt_data[ZOOM].pressed==ON )
1085 x_old=x_new; y_old=y_new;
1086 XQueryPointer ( display, report.xmotion.window,
1087 &root, &child, &x_root, &y_root, &x_new, &y_new,
1088 &mouse_butt );
1089 if ( x0!=OFF )
1091 XDrawRectangle ( display, draw_win, gc_XOR,
1092 min ( x0, x_old ), min ( y0, y_old ), abs ( x_old-x0 ), abs ( y_old-y0 ) );
1093 XDrawRectangle ( display, draw_win, gc_XOR,
1094 min ( x0, x_new ), min ( y0, y_new ), abs ( x_new-x0 ), abs ( y_new-y0 ) );
1099 break;
1100 /*****************
1101 * Key Press *
1102 *****************/
1103 case KeyPress:
1104 count = XLookupString(&report.xkey, buffer, sizeof(buffer),
1105 &keysym, &compose);
1106 buffer[count] = 0;
1107 keycode = (char) 0;
1110 switch (keysym)
1112 case XK_Left:
1113 X0--;XClearWindow ( display, draw_win ); show_mesh_redwraw(); break;
1114 case XK_Right:
1115 X0++;XClearWindow ( display, draw_win ); show_mesh_redwraw(); break;
1116 case XK_Up:
1117 Y0--;XClearWindow ( display, draw_win ); show_mesh_redwraw(); break;
1118 case XK_Down:
1119 Y0++;XClearWindow ( display, draw_win ); show_mesh_redwraw(); break;
1120 case XK_R:
1121 case XK_r:
1122 scl =min ( ( 0.9* ( double ) draw_hght ) / ( yMax-yMin+SMALL ),
1123 ( 0.9* ( double ) draw_wdth ) / ( xMax-xMin+SMALL ) );
1124 X0 = ( int ) (0.5*draw_wdth);
1125 Y0 = ( int ) (0.5*draw_hght);
1126 XClearWindow ( display, draw_win );
1127 show_mesh_redwraw();
1128 break;
1129 case XK_Z:
1130 x0_fiz = ( 0.5*draw_wdth-X0 ) /scl;
1131 y0_fiz = ( 0.5*draw_hght-Y0 ) /scl;
1132 scl*=2;
1133 X0+=x0_fiz*scl;
1134 Y0+=y0_fiz*scl;
1135 XClearWindow ( display, draw_win ); show_mesh_redwraw();
1136 break;
1137 case XK_z:
1138 x0_fiz = ( 0.5*draw_wdth-X0 ) /scl;
1139 y0_fiz = ( 0.5*draw_hght-Y0 ) /scl;
1140 scl/=2;
1141 X0+=x0_fiz*scl;
1142 Y0+=y0_fiz*scl;
1143 XClearWindow ( display, draw_win ); show_mesh_redwraw();
1144 break;
1145 case XK_Q:
1146 case XK_q:
1147 case XK_Escape:
1148 if(plot.GenerateTIFF)
1149 show_mesh_save_screen(plot.TIFFFileName.c_str(),draw_win, draw_wdth, draw_hght);
1150 show_mesh_close();
1151 return;
1152 case XK_BackSpace: break;
1153 default: break;
1155 keycode = report.xkey.keycode;
1157 while (keycode == 0);
1159 break;
1160 } /* end switch */
1161 } /* end while */
1162 } /* end of block */
1166 #endif