1 /***********************************************************************
2 *
3 *               *****   ***    ***
4 *                  *   *   *  *   *
5 *                 *     ***    ***
6 *                *     *   *  *   *
7 *               *****   ***    ***
8 *
9 * A FREE Finite Elements Analysis Program in ANSI C for the Windows OS.
10 *
11 * Composed and edited and copyright by
12 * Professor Dr.-Ing. Frank Rieg, University of Bayreuth, Germany
13 *
14 * eMail:
15 * frank.rieg@uni-bayreuth.de
16 * dr.frank.rieg@t-online.de
17 *
18 * V15.0  November 18, 2015
19 *
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2, or (at your option)
23 * any later version.
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28 * GNU General Public License for more details.
29 *
30 * You should have received a copy of the GNU General Public License
31 * along with this program; see the file COPYING.  If not, write to
32 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
33 ***********************************************************************/
34 /***********************************************************************
35 *  Z88O fuer Windows
36 *  7.3.2017 RIEG
37 ***********************************************************************/
38 /***********************************************************************
39 * Windows
40 ***********************************************************************/
41 #ifdef FR_WIN
42 #include <z88o.h>
43 #include <windows.h>
44 #include <commctrl.h>
45 #include <commdlg.h>
46 #include <gl\gl.h>
47 #include <string.h>  /* strcpy */
48 #include <stdio.h>   /* fopen, fprintf, fclose */
49 #endif
50 
51 /***********************************************************************
52 * Font- Structure GLFONT
53 ***********************************************************************/
54 typedef struct
55     {
56     GLuint base;        /* DisplayList Nr.erstes Zeichen */
57     int    widths[256]; /* Zeichenweite in Pixels */
58     int    height;      /* Zeichenhoehe */
59     } GLFONT;
60 
61 /**********************************************************
62 * Deklaration von Window- Functions
63 **********************************************************/
64 LRESULT CALLBACK Z88O_WinProc(HWND, UINT, WPARAM, LPARAM);
65 HWND             InitToolBar (HWND hParent);
66 BOOL    CALLBACK StrucDiaProc(HWND, UINT, WPARAM, LPARAM);
67 BOOL    CALLBACK FaktorVerDiaProc(HWND,UINT,WPARAM,LPARAM);
68 BOOL    CALLBACK FaktorRotDiaProc(HWND,UINT,WPARAM,LPARAM);
69 BOOL    CALLBACK FaktorZmDiaProc( HWND,UINT,WPARAM,LPARAM);
70 BOOL    CALLBACK KnotenDiaProc(   HWND,UINT,WPARAM,LPARAM);
71 BOOL    CALLBACK ElementDiaProc(  HWND,UINT,WPARAM,LPARAM);
72 void    PopFileInitialize(HWND) ;
73 BOOL    PopFileOpenDlg(HWND);
74 
75 /**********************************************************
76 * Deklaration von User-Functions
77 **********************************************************/
78 int      dyn88o(void);
79 int      ri1x88(void);
80 int      ri2x88(void);
81 int      ri5x88(void);
82 int      ro2x88(void);
83 int      ro5x88(void);
84 int      ro8x88(void);
85 int      rogl88(void);
86 int      wlog88o(FR_INT4,int);
87 int      ale88o(int);
88 int      lan88o(void);
89 int      vu3b88(void);
90 int      vv3b88(void);
91 int      vgpc88(void);
92 int      vsca88(void);
93 int      vcur88(void);
94 int      stro88(void);
95 int      snow88(void);
96 int      spgp88(void);
97 int      fvx88(void);
98 int      fvy88(void);
99 int      fvz88(void);
100 int      mko88(void);
101 int      tet188(void);
102 int      tet288(void);
103 int      tet388(void);
104 int      tet488(void);
105 int      tet588(void);
106 int      fsca88(void);
107 int      malk88(void);
108 int      magp88(void);
109 int      fsrb88(void);
110 int      mrbd88(void);
111 int      man88o(void);
112 
113 GLFONT * FontCreate(HDC hdc,const char *typeface,
114                     int height,int weight,DWORD italic);
115 void	 FontPuts(GLFONT *font, const char *cs);
116 void     FontDelete(GLFONT *font);
117 
118 /**********************************************************
119 *  externe Variable
120 **********************************************************/
121 HINSTANCE    hInstance,hProgram;
122 
123 HMENU        hMenuGer,hMenuEng;
124 
125 HCURSOR      waitcur;
126 
127 HWND         hWnd,hToolBar;
128 
129 OPENFILENAME ofn;
130 
131 HDC          hDC;
132 HGLRC        hRC;
133 
134 GLFONT       *Font;
135 
136 int          iRb=1,ixClient= 1024,iyClient= 740,ix,iy;
137 
138 PIXELFORMATDESCRIPTOR pfd = {
139     sizeof(PIXELFORMATDESCRIPTOR), /* WORD  nSize        */
140     1,                             /* WORD  nVersion     */
141     PFD_DRAW_TO_WINDOW |           /* DWORD dwFlags      */
142     PFD_SUPPORT_OPENGL |
143     PFD_DOUBLEBUFFER,
144     PFD_TYPE_RGBA,                 /* BYTE  iPixelType   */
145     32,                            /* BYTE  cColorBits   */
146     0,0,0,0,0,0,0,0,0,0,0,0,0,     /* brauchen wir nicht */
147     16,                            /* BYTE  cDepthBits   */
148     0,                             /* BYTE  cStencilBits */
149     0,                             /* BYTE  cAuxBuffers  */
150     PFD_MAIN_PLANE,                /* BYTE  iLayerType   */
151     0,0,0,0};                      /* brauchen wir nicht */
152 
153 FILE *fdyn,*fwlo,*fi1,*fi2,*fi5,*fo2,*fo5,*fo8,*fcfg,*fman;
154 
155 /*
156 ** fdyn= z88.dyn
157 ** fwlo= z88o.log
158 ** fo2=  z88o2.txt
159 ** fi1=  z88i1.txt
160 ** fi2=  z88i2.txt
161 ** fi5=  z88i5.txt
162 ** fo5=  z88o5.txt
163 ** fo8=  z88o8.txt
164 ** fcfg= z88com.cfg
165 */
166 
167 FR_DOUBLEAY x;
168 FR_DOUBLEAY y;
169 FR_DOUBLEAY z;
170 FR_DOUBLEAY ux;
171 FR_DOUBLEAY uy;
172 FR_DOUBLEAY uz;
173 FR_DOUBLEAY xv;
174 FR_DOUBLEAY yv;
175 FR_DOUBLEAY zv;
176 FR_DOUBLEAY sep;
177 FR_DOUBLEAY sne;
178 FR_DOUBLEAY rwert;
179 FR_DOUBLEAY xgp;
180 FR_DOUBLEAY ygp;
181 FR_DOUBLEAY zgp;
182 FR_DOUBLEAY xgpo;
183 FR_DOUBLEAY ygpo;
184 FR_DOUBLEAY zgpo;
185 FR_DOUBLEAY siggp;
186 
187 FR_INT4AY   ityp;
188 FR_INT4AY   koi;
189 FR_INT4AY   ityp;
190 FR_INT4AY   koffs;
191 FR_INT4AY   noi;
192 FR_INT4AY   noffs;
193 FR_INT4AY   nep;
194 FR_INT4AY   iep;
195 FR_INT4AY   ifarbe;
196 FR_INT4AY   jfarbe;
197 FR_INT4AY   kfarbe;
198 FR_INT4AY   nkn;
199 FR_INT4AY   ifg;
200 FR_INT4AY   iflag1;
201 
202 FR_DOUBLE   xe[9];
203 FR_DOUBLE   ye[9];
204 FR_DOUBLE   ze[9];
205 FR_DOUBLE   vx[13];
206 FR_DOUBLE   vy[13];
207 FR_DOUBLE   vz[13];
208 FR_DOUBLE   fspa[14];
209 
210 FR_INT4     kf[9];
211 
212 GLfloat     rot[13];
213 GLfloat     gruen[13];
214 GLfloat     blau[13];
215 
216 GLfloat     back_col[4];
217 GLfloat     specula0[4];
218 GLfloat     specula1[4];
219 GLfloat     specula2[4];
220 GLfloat     ambient0[4];
221 GLfloat     ambient1[4];
222 GLfloat     diffuse0[4];
223 GLfloat     diffuse1[4];
224 GLfloat     positio0[4];
225 GLfloat     positio1[4];
226 GLfloat     positio2[4];
227 GLfloat     spec_mat[4];
228 GLfloat     diff_mat[4];
229 GLfloat     shine[1];
230 GLfloat     hide_col[3];
231 GLfloat     hide_off[2];
232 GLfloat     node_col[3];
233 GLfloat     elem_col[3];
234 
235 GLfloat     bline= 2.0;
236 
237 FR_DOUBLE xx= 0., yy=0.;
238 FR_DOUBLE rx= 0., ry= 0., rz= 0., s= 1., tx=0., ty=0.;
239 
240 FR_DOUBLE xm= -100.0, xp= 100.0;
241 FR_DOUBLE ym= -100.0, yp= 100.0;
242 FR_DOUBLE zm= -100.0, zp= 100.0;
243 FR_DOUBLE ymsv,ypsv,SV;
244 FR_DOUBLE xw= 100.;
245 
246 FR_DOUBLE fux= 100., fuy= 100., fuz= 100.;
247 FR_DOUBLE facx= 1.,facy= 1.,facz= 1.;
248 FR_DOUBLE cx= 0.,cy= 0.,cz= 0.;
249 FR_DOUBLE rotx= 0.,roty= 0.,rotz= 0.;
250 FR_DOUBLE xmin,xmax,ymin,ymax,zmin,zmax,fycor;
251 FR_DOUBLE fzoom= 1.1;
252 FR_DOUBLE zorbd= 1.0;
253 FR_DOUBLE zoogp= 0.25;
254 FR_DOUBLE fazoo= 0.17;
255 
256 FR_DOUBLE sigmin,sigmax=0.,siginc;
257 FR_DOUBLE snemin,snemax=0.,sneinc;
258 FR_DOUBLE spamin,spamax=0.,spainc;
259 FR_DOUBLE fxmin,fxmax=-1e-10,fxinc;
260 FR_DOUBLE fymin,fymax=-1e-10,fyinc;
261 FR_DOUBLE fzmin,fzmax=-1e-10,fzinc;
262 
263 FR_INT4 MAXKOI,MAXE,MAXK,MAXRBD,MAXPR,MAXGP;
264 FR_INT4 IDYNMEM,LANG=2;
265 
266 FR_INT4 ndim,nkp,ne,nfg,iepanz,kflag,ibflag,ipflag,iqflag;
267 FR_INT4 i,j,idummy,jdummy,kofold,nrb,npr,nnp;
268 FR_INT4 izoom= 1;
269 FR_INT4 jkvon= 0,jkbis= 0,jevon= 0,jebis= 0;
270 FR_INT4 isflag,igpanz;
271 FR_INT4 NEEDKOI;
272 
273 int iflade= ID_NOTLOADSTRUC;
274 int iflaver=ID_NOTLOADVERF;
275 int iflspa= ID_NOTLOADSPANN;  /* Z88O8.TXT */
276 int iflao5= ID_NOTLOADSPAO5;  /* Z88O5.TXT */
277 int iflarbd=ID_NOTLOADRBD;
278 int iflai5= ID_NOTLOADI5;
279 
280 int ifkom=  ID_FUNKEY;
281 
282 int ifmaus= IDM_ZOOM;
283 int ifverf= IDM_UNVERFORMT;
284 int if3d  = IDM_LIGHT;
285 int iflabe= IDM_NOLABELS;
286 int ifscale=IDM_YESSCALE;
287 int ifrbd = IDM_NORBD;
288 int ifwbc=  IDM_RBDALL;
289 int ifkoor= IDM_YESKOOR;
290 int ifnost= IDM_YESNOST;
291 int ifvcur;
292 
293 int  iret,iplot;
294 
295 int  IB,IH;
296 int  imatrix=1;
297 
298 int  *pp;
299 
300 size_t laenge;
301 
302 char cline[256];
303 
304 char  cdyn[8]   = "z88.dyn";
305 char  clgd[12]  = "z88o.log";
306 char  cstrn[128]= "z88i1.txt";
307 char  ci2[10]   = "z88i2.txt";
308 char  ci5[10]   = "z88i5.txt";
309 char  co2[10]   = "z88o2.txt";
310 char  co5[10]   = "z88o5.txt";
311 char  co8[10]   = "z88o8.txt";
312 char  cfg[11]   = "z88com.cfg";
313 char  cman[11]  = "z88man.txt";
314 
315 char  cfname[256];
316 char  ctname[256];
317 
318 /*--------------------------------------------------------------------------
319 * Char-Arrays
320 *-------------------------------------------------------------------------*/
321 char cstore[256];
322 char cbcall[128];
323 char cbpref[128];
324 char cbhelp[512];
325 char cmess [512];
326 char cbytes[128];
327 char callbrow[512];
328 
329 /**********************************************************
330 * Hauptprogramm mit Message- Loop
331 **********************************************************/
WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,PSTR szCmdLine,int iCmdShow)332 int WINAPI WinMain(HINSTANCE hInstance,
333                    HINSTANCE hPrevInstance,
334                    PSTR szCmdLine, int iCmdShow)
335 {
336 extern HINSTANCE hProgram;
337 
338 extern HWND      hWnd;
339 extern int       ixClient,iyClient;
340 
341 HACCEL           hAccel;
342 MSG              msg;
343 WNDCLASSEX       wndclass;
344 
345 char             capname[10];
346 
347 /*---------------------------------------------------------
348 * Window registrieren
349 *--------------------------------------------------------*/
350 hProgram= hInstance;
351 
352 strcpy(capname, "Z88O");
353 
354 wndclass.cbSize        = sizeof(wndclass);
355 wndclass.style         = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
356 wndclass.lpfnWndProc   = Z88O_WinProc;
357 wndclass.cbClsExtra    = 0;
358 wndclass.cbWndExtra    = 0;
359 wndclass.hInstance     = hProgram;
360 wndclass.hIcon         = LoadIcon(hProgram,
361                            MAKEINTRESOURCE(ICO_Z88O));
362 wndclass.hCursor       = LoadCursor(NULL, IDC_ARROW);
363 wndclass.hbrBackground = CreateSolidBrush(RGB(255,255,255));
364 wndclass.lpszMenuName  = NULL;
365 wndclass.lpszClassName = capname;
366 wndclass.hIconSm       = NULL;
367 
368 RegisterClassEx(&wndclass);
369 
370 /*---------------------------------------------------------
371 * Window erzeugen
372 *--------------------------------------------------------*/
373 hWnd = CreateWindow(capname,
374                     "Z88O",
375                     WS_OVERLAPPEDWINDOW |
376                     WS_CLIPCHILDREN |
377                     WS_CLIPSIBLINGS ,
378                     0,0,
379                     ixClient,iyClient,
380                     NULL, NULL, hProgram, NULL);
381 if(!hWnd)
382   {
383   MessageBox(NULL,"Impossible to start Main Window!",
384              "Z88O",MB_OK | MB_ICONINFORMATION);
385   return (0);
386   }
387 
388 /*---------------------------------------------------------
389 * Toolbar ermoeglichen
390 *--------------------------------------------------------*/
391 InitCommonControls();
392 
393 /*---------------------------------------------------------
394 * Window darstellen
395 *--------------------------------------------------------*/
396 ShowWindow(hWnd,iCmdShow);
397 
398 /*---------------------------------------------------------
399 * Accelerators laden
400 *--------------------------------------------------------*/
401 hAccel= LoadAccelerators(hInstance,capname);
402 
403 /*---------------------------------------------------------
404 * Message- Loop: Ereigneisse abfangen
405 *--------------------------------------------------------*/
406 while(GetMessage(&msg, NULL, 0, 0))
407   {
408   if(!TranslateAccelerator(hWnd,hAccel,&msg))
409     {
410     TranslateMessage(&msg);
411     DispatchMessage(&msg);
412     }
413   }
414 
415 return msg.wParam;
416 }
417 
418 /**********************************************************
419 * Main Window Procedure: Das eigentliche Steuerprogramm
420 **********************************************************/
Z88O_WinProc(HWND hWnd,UINT Message,WPARAM wParam,LPARAM lParam)421 LRESULT CALLBACK Z88O_WinProc(HWND hWnd, UINT Message,
422                              WPARAM wParam, LPARAM lParam)
423 {
424 HMENU hMenu;
425 
426 int   iPF,imess,ialert;
427 
428 extern char  cmess[];
429 
430 /*----------------------------------------------------------------------
431 * Los gehts - je nach Message verzweigen
432 *---------------------------------------------------------------------*/
433 switch(Message)
434   {
435 /*----------------------------------------------------------------------
436 * WM_CREATE
437 *---------------------------------------------------------------------*/
438   case WM_CREATE:
439 
440 /*======================================================================
441 * hInstance kommen lassen
442 *=====================================================================*/
443 #ifdef FR_XWIN64
444     hInstance= (HINSTANCE)GetWindowLongPtr(hWnd,GWLP_HINSTANCE);
445 #endif
446 #ifdef FR_XWIN32
447     hInstance= (HINSTANCE)GetWindowLong(hWnd,GWL_HINSTANCE);
448 #endif
449 
450 /*======================================================================
451 * Wartecursor anlegen
452 *=====================================================================*/
453     waitcur= LoadCursor(hInstance,MAKEINTRESOURCE(CUR_Z88O));
454 
455 /*======================================================================
456 * Sprache feststellen
457 *=====================================================================*/
458     iret= lan88o();
459 
460     if(iret != 0)
461       {
462       ale88o(iret);
463       PostQuitMessage(0);
464       return(1);
465       }
466 
467     hMenuGer= LoadMenu(hInstance,"GERMAN");
468     hMenuEng= LoadMenu(hInstance,"ENGLISH");
469 
470     if(LANG == 1) SetMenu(hWnd,hMenuGer);
471     if(LANG == 2) SetMenu(hWnd,hMenuEng);
472 
473 /*======================================================================
474 * dynamischen Speicher anfordern
475 *=====================================================================*/
476     iret= dyn88o();
477     if(iret != 0)
478       {
479       ale88o(iret);
480       PostQuitMessage(0);
481       return(1);
482       }
483 
484 /*======================================================================
485 * FYCOR, Farben, Licht und Material einlesen
486 *=====================================================================*/
487     iret= rogl88();
488     if(iret != 0)
489       {
490       ale88o(iret);
491       PostQuitMessage(0);
492       return 0;
493       }
494 
495     ym*= fycor;
496     yp*= fycor;
497 
498 /*======================================================================
499 * Toolbar
500 *=====================================================================*/
501     hToolBar= InitToolBar(hWnd);
502 
503 /*======================================================================
504 * Fileauswahlbox initialisiren
505 *=====================================================================*/
506     PopFileInitialize(hWnd);
507 
508 /*======================================================================
509 * OpenGL aktivieren
510 *=====================================================================*/
511     hDC = GetDC(hWnd);
512     iPF = ChoosePixelFormat(hDC, &pfd);
513     SetPixelFormat(hDC, iPF, &pfd);
514     hRC = wglCreateContext(hDC);
515     wglMakeCurrent(hDC, hRC);
516 
517     Font= FontCreate(hDC,"Helvetica",20,0,1);
518 
519     IB= ixClient;
520     IH= iyClient-48;
521 
522     SV = (double) IH / (double) IB;
523     ymsv = ym * SV;
524     ypsv = yp * SV;
525 
526     glViewport(0,0,IB,IH);
527 
528     glMatrixMode(GL_PROJECTION);
529     glLoadIdentity();
530     glOrtho(xm,xp,ymsv,ypsv,zm,zp);
531 
532   return 0;
533 
534 /*----------------------------------------------------------------------
535 * case WM_INITMENU
536 *---------------------------------------------------------------------*/
537   case WM_INITMENU:
538     hMenu= GetMenu(hWnd);
539     CheckMenuItem(hMenu,iflabe,           MF_CHECKED   | MF_BYCOMMAND);
540     CheckMenuItem(hMenu,ifrbd,            MF_CHECKED   | MF_BYCOMMAND);
541     CheckMenuItem(hMenu,ifwbc,            MF_CHECKED   | MF_BYCOMMAND);
542     CheckMenuItem(hMenu,ifkoor,           MF_CHECKED   | MF_BYCOMMAND);
543     CheckMenuItem(hMenu,ifnost,           MF_CHECKED   | MF_BYCOMMAND);
544   return 0;
545 
546 /*----------------------------------------------------------------------
547 * WM_NOTIFY
548 *---------------------------------------------------------------------*/
549   case WM_NOTIFY:
550     {
551     LPNMHDR pnmh= (LPNMHDR) lParam;
552     LPSTR   pReply;
553 
554     if(pnmh->code == TTN_NEEDTEXT)
555       {
556       LPTOOLTIPTEXT lpttt= (LPTOOLTIPTEXT) lParam;
557 
558       switch(lpttt->hdr.idFrom)
559         {
560         case ITC_RUN:
561           if(LANG == 1) pReply= "Start frei";
562           if(LANG == 2) pReply= "Go";
563         break;
564 
565         case ITC_FILE:
566           if(LANG == 1) pReply= "Strukturfile angeben";
567           if(LANG == 2) pReply= "define structure file";
568         break;
569 
570         case ITC_MAUS:
571           if(LANG == 1) pReply= "Zoom-Schieben-Rotieren ueber Tastatur (aus) oder Maus (ein)";
572           if(LANG == 2) pReply= "Zoom-Pan-Rotate by Keyboard (off) or by Mouse (on)";
573         break;
574 
575         case ITC_HELP:
576           if(LANG == 1) pReply= "OnLine-Hilfe fuer Plotprogramm";
577           if(LANG == 2) pReply= "OnLine Help for Plot Program";
578         break;
579 
580         case ITC_UNVERFORMT:
581           if(LANG == 1) pReply= "Zeige unverformte Struktur";
582           if(LANG == 2) pReply= "Show Undeflected Structure";
583         break;
584 
585         case ITC_VERFORMT:
586           if(LANG == 1) pReply= "Zeige verformte Struktur";
587           if(LANG == 2) pReply= "Show Deflected Structure";
588         break;
589 
590         case ITC_LIGHT:
591           if(LANG == 1) pReply= "Licht an, auf Wunsch Anzeige Randbedingungen";
592           if(LANG == 2) pReply= "Light on, show Boundary Conditions on request";
593         break;
594 
595         case ITC_HIDDEN:
596           if(LANG == 1) pReply= "Verdeckte Linien (nur 3D), auf Wunsch Anzeige Randbedingungen";
597           if(LANG == 2) pReply= "Hidden Line (3D only), show Boundary Conditions on request";
598         break;
599 
600         case ITC_WIREFR:
601           if(LANG == 1) pReply= "Wireframe, auf Wunsch Anzeige Randbedingungen";
602           if(LANG == 2) pReply= "Wireframe, show Boundary Conditions on request";
603         break;
604 
605         case ITC_SHOWSPANN:
606           if(LANG == 1) pReply= "Vergleichsspannungen in den Eckknoten";
607           if(LANG == 2) pReply= "Reduced Stresses (v.Mises,Rankine,Tresca) in corner nodes";
608         break;
609 
610         case ITC_SHOWGAUSS:
611           if(LANG == 1) pReply= "Vergleichsspannungen pro Element gemittelt";
612           if(LANG == 2) pReply= "Reduced Stresses (v.Mises,Rankine,Tresca) mean values per Element";
613         break;
614 
615         case ITC_SHOWGAUPU:
616           if(LANG == 1) pReply= "Vergleichsspannungen (nur unverformte Struktur) in den Gausspunkten";
617           if(LANG == 2) pReply= "Reduced Stresses (v.Mises,Rankine,Tresca) -undeflected structure only- in Gauss points";
618         break;
619 
620         case ITC_SHOWVX:
621           if(LANG == 1) pReply= "Zeige X-Verschiebungen";
622           if(LANG == 2) pReply= "Show X Displacements";
623         break;
624 
625         case ITC_SHOWVY:
626           if(LANG == 1) pReply= "Zeige Y-Verschiebungen";
627           if(LANG == 2) pReply= "Show Y Displacements";
628         break;
629 
630         case ITC_SHOWVZ:
631           if(LANG == 1) pReply= "Zeige Z-Verschiebungen";
632           if(LANG == 2) pReply= "Show Z Displacements";
633         break;
634 
635         case ITC_YESSCALE:
636           if(LANG == 1) pReply= "Auto-Skalieren";
637           if(LANG == 2) pReply= "AutoScale";
638         break;
639 
640         case ITC_RBD:
641           if(LANG == 1) pReply= "Zeige Randbedingungen ja/nein";
642           if(LANG == 2) pReply= "Show Boundary Conditions yes/no";
643         break;
644 
645         case ITC_XIT:
646           if(LANG == 1) pReply= "Beende";
647           if(LANG == 2) pReply= "Exit";
648         break;
649 
650         }
651       lstrcpy(lpttt->szText,pReply);
652       }
653     return 0;  /* sehr wichtig */
654     }
655 
656 /*----------------------------------------------------------------------
657 * WM_DESTROY
658 *---------------------------------------------------------------------*/
659   case WM_DESTROY:
660     wglMakeCurrent(hDC,NULL);
661     wglDeleteContext(hRC);
662     PostQuitMessage(0);
663   return 0;
664 
665 /*----------------------------------------------------------------------
666 * case WM_COMMAND
667 *---------------------------------------------------------------------*/
668   case WM_COMMAND:
669     switch (LOWORD(wParam))
670       {
671 /*======================================================================
672 * Info
673 *=====================================================================*/
674       case IDM_WER:
675         if(LANG == 1) strcpy(cmess,
676 "Plotprogramm Z88O fuer Windows\n\
677 Version 15OS\n\
678 Copyright Univ.-Prof.Dr.-Ing. Frank Rieg,\n\
679 Universitaet Bayreuth, 2017\n\
680 Alle Rechte vorbehalten\n");
681 
682           if(LANG == 2) strcpy(cmess,
683 "Plot Program Z88O for Windows\n\
684 Version 15OS\n\
685 Copyright Prof.Dr. Frank Rieg,\n\
686 University of Bayreuth, Germany 2017\n\
687 All rights reserved\n");
688 
689 #ifdef FR_XQUAD
690         sprintf(cbytes,"Floats: %d Bytes\n",(int)sizeof(long double));
691         strcat(cmess,cbytes);
692 #endif
693 #ifdef FR_XDOUB
694         sprintf(cbytes,"Floats: %d Bytes\n",(int)sizeof(double));
695         strcat(cmess,cbytes);
696 #endif
697 #ifdef FR_XINT
698         sprintf(cbytes,"Integers: %d Bytes\n",(int)sizeof(int));
699         strcat(cmess,cbytes);
700 #endif
701 #ifdef FR_XLONG
702         sprintf(cbytes,"Integers: %d Bytes\n",(int)sizeof(long));
703         strcat(cmess,cbytes);
704 #endif
705 #ifdef FR_XLOLO
706         sprintf(cbytes,"Integers: %d Bytes\n",(int)sizeof(long long));
707         strcat(cmess,cbytes);
708 #endif
709         sprintf(cbytes,"Pointers: %d Bytes\n",(int)sizeof(pp));
710         strcat(cmess,cbytes);
711 
712         MessageBox(hWnd,cmess,"Z88O", MB_OK | MB_ICONINFORMATION);
713       return 0;
714 
715 /*======================================================================
716 * Strukturfile
717 *=====================================================================*/
718       case ITC_FILE:
719         if(PopFileOpenDlg(hWnd))
720           {
721           iflade = ID_NOTLOADSTRUC;  /* Z88I1.TXT */
722           iflaver= ID_NOTLOADVERF;   /* Z88O2.TXT */
723           iflspa = ID_NOTLOADSPANN;  /* Z88O8.TXT */
724           iflao5 = ID_NOTLOADSPAO5;  /* Z88O5.TXT */
725           ifscale= IDM_YESSCALE;
726           rotx= 0.;
727           roty= 0.;
728           rotz= 0.;
729           }
730         else
731           {
732           if(LANG == 1) strcpy(cmess,"Z88O: keine Datei ausgewaehlt");
733           if(LANG == 2) strcpy(cmess,"Z88O: You did not choose any file");
734           MessageBox(hWnd,cmess,"Z88O", MB_OK | MB_ICONINFORMATION);
735           }
736       return 0;
737 
738 /*======================================================================
739 * Ende
740 *=====================================================================*/
741       case IDM_XIT:
742       case ITC_XIT:
743         PostQuitMessage(0);
744       return 0;
745 
746 /*======================================================================
747 * Go: Z88MAN.TXT untersuchen und Strukturdaten Z88I1.TXT laden
748 *=====================================================================*/
749       case ITC_RUN:
750         SetCursor(waitcur);
751         ShowCursor(TRUE);
752 
753 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
754 * Z88MAN.TXT lesen --> ibflag,ipflag, Z88I5.TXT pruefen --> iqflag
755 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
756         man88o();
757 
758 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
759 * Z88I1.TXT oeffnen
760 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
761         fi1= fopen(cstrn,"r");
762         if(fi1 == NULL)
763           {
764           wlog88o(0,LOG_NOSTRFI);
765           ale88o(AL_NOSTRFI);
766           return(0);
767           }
768         rewind(fi1);
769 
770 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
771 * Z88I1.TXT laden
772 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
773         ialert=ri1x88();
774         if(ialert != 0) ale88o(ialert);
775         else            iflade= ID_LOADSTRUC;
776 
777         if(fi1) fclose(fi1);
778         SetCursor(LoadCursor(NULL,IDC_ARROW));
779         jkvon= 1;
780         jkbis= nkp;
781         jevon= 1;
782         jebis= ne;
783         InvalidateRect(hWnd,NULL,TRUE);
784       return(0);
785 
786 /*======================================================================
787 * COMMAND : Hilfe
788 *=====================================================================*/
789       case ITC_HELP:
790         fcfg= fopen(cfg,"r");          /* Z88COM.CFG oeffnen */
791         if(fcfg == NULL)
792           {
793           if(LANG == 1) strcpy(cmess,
794           "Datei Z88COM.CFG nicht vorhanden oder zerschossen !");
795           if(LANG == 2) strcpy(cmess,
796           "File Z88COM.CFG not available or destroyed !");
797           MessageBox(NULL,cmess,"Z88G", MB_OK | MB_ICONHAND);
798           }
799 
800         rewind(fcfg);
801 
802         fgets(cstore,128,fcfg);
803         fgets(cstore,128,fcfg);
804 
805         fgets(cstore,128,fcfg);
806         laenge= strlen(cstore);
807         strncpy(cbpref,cstore,laenge-1);
808         strcat (cbpref,"\0");
809 
810         fgets(cstore,128,fcfg);
811         laenge= strlen(cstore);
812         strncpy(cbcall,cstore,laenge-1);
813         strcat (cbcall,"\0");
814 
815         fclose(fcfg);
816 
817         strcpy(callbrow,cbcall);
818         strcat(callbrow," ");
819         strcat(callbrow,cbpref);
820         if(LANG == 1) strcat(callbrow,"z88mang.pdf");
821         if(LANG == 2) strcat(callbrow,"z88mane.pdf");
822         imess= WinExec(callbrow,SW_SHOW);
823         if(imess < 33)
824           {
825           wlog88o(0L,LOG_NOACROBAT);
826           ale88o(AL_NOACROBAT);
827           }
828       return 0;
829 
830 /*======================================================================
831 * Keyboard oder Maus fuer Zoom-Schieben-Rotieren
832 *=====================================================================*/
833       case ITC_MAUS:
834         if(ifkom == ID_FUNKEY ) ifkom= ID_MOUSE;
835         else                    ifkom= ID_FUNKEY;
836       return 0;
837 
838 /*======================================================================
839 * Unverformt oder verformt
840 *=====================================================================*/
841       case ITC_UNVERFORMT:
842         ifverf = IDM_UNVERFORMT;
843         InvalidateRect(hWnd,NULL,TRUE);
844       return 0;
845 
846       case ITC_VERFORMT:
847         ifverf = IDM_VERFORMT;
848         InvalidateRect(hWnd,NULL,TRUE);
849       return 0;
850 
851 /*======================================================================
852 * Bild
853 *=====================================================================*/
854       case IDM_PRIOR:
855         facx *= fzoom;
856         facy *= fzoom;
857         facz *= fzoom;
858         izoom++;
859         InvalidateRect(hWnd,NULL,TRUE);
860       return 0;
861 
862       case IDM_NEXT:
863         facx /= fzoom;
864         facy /= fzoom;
865         facz /= fzoom;
866         izoom--;
867         InvalidateRect(hWnd,NULL,TRUE);
868       return 0;
869 
870       case IDM_UP:
871         if(ifvcur == 0) vcur88();
872         cy= cy - 0.05*(fabs(ymax) + fabs(ymin))/pow(fzoom,(double)izoom);
873         InvalidateRect(hWnd,NULL,TRUE);
874       return 0;
875 
876       case IDM_DOWN:
877         if(ifvcur == 0) vcur88();
878         cy= cy + 0.05*(fabs(ymax) + fabs(ymin))/pow(fzoom,(double)izoom);
879         InvalidateRect(hWnd,NULL,TRUE);
880       return 0;
881 
882       case IDM_RIGHT:
883         if(ifvcur == 0) vcur88();
884         cx= cx - 0.05*(fabs(xmax) + fabs(xmin))/pow(fzoom,(double)izoom);
885         InvalidateRect(hWnd,NULL,TRUE);
886       return 0;
887 
888       case IDM_LEFT:
889         if(ifvcur == 0) vcur88();
890         cx= cx + 0.05*(fabs(xmax) + fabs(xmin))/pow(fzoom,(double)izoom);
891         InvalidateRect(hWnd,NULL,TRUE);
892       return 0;
893 
894       case IDM_HOME:
895         if(ifvcur == 0) vcur88();
896         cz= cz - 0.05*(fabs(zmax) + fabs(zmin))/pow(fzoom,(double)izoom);
897         InvalidateRect(hWnd,NULL,TRUE);
898       return 0;
899 
900       case IDM_END:
901         if(ifvcur == 0) vcur88();
902         cz= cz + 0.05*(fabs(zmax) + fabs(zmin))/pow(fzoom,(double)izoom);
903         InvalidateRect(hWnd,NULL,TRUE);
904       return 0;
905 
906       case IDM_F2:
907         rotx -= 10.;
908         if ((int)rotx == -10) rotx= 350.;
909         InvalidateRect(hWnd,NULL,TRUE);
910       return 0;
911 
912       case IDM_F3:
913         rotx += 10.;
914         if ((int)rotx == 360) rotx= 0.;
915         InvalidateRect(hWnd,NULL,TRUE);
916       return 0;
917 
918       case IDM_F4:
919         roty -= 10.;
920         if ((int)roty == -10) roty= 350.;
921         InvalidateRect(hWnd,NULL,TRUE);
922       return 0;
923 
924       case IDM_F5:
925         roty += 10.;
926         if ((int)roty == 360) roty= 0.;
927         InvalidateRect(hWnd,NULL,TRUE);
928       return 0;
929 
930       case IDM_F6:
931         rotz -= 10.;
932         if ((int)rotz == -10) rotz= 350.;
933         InvalidateRect(hWnd,NULL,TRUE);
934       return 0;
935 
936       case IDM_F7:
937         rotz += 10.;
938         if ((int)rotz == 360) rotz= 0.;
939         InvalidateRect(hWnd,NULL,TRUE);
940       return 0;
941 
942       case IDM_F8:
943         rotx= 0.;
944         roty= 0.;
945         rotz= 0.;
946         InvalidateRect(hWnd,NULL,TRUE);
947       return 0;
948 
949 /*======================================================================
950 * Faktor-Boxen
951 *=====================================================================*/
952       case IDM_VER:
953         if(LANG == 1) DialogBox(hInstance,"Dlg_Ver88G",hWnd,FaktorVerDiaProc);
954         if(LANG == 2) DialogBox(hInstance,"Dlg_Ver88E",hWnd,FaktorVerDiaProc);
955         InvalidateRect(hWnd,NULL,TRUE);
956       return 0;
957 
958       case IDM_ROT:
959         if(LANG == 1) DialogBox(hInstance,"Dlg_Rot88G",hWnd,FaktorRotDiaProc);
960         if(LANG == 2) DialogBox(hInstance,"Dlg_Rot88E",hWnd,FaktorRotDiaProc);
961         InvalidateRect(hWnd,NULL,TRUE);
962       return 0;
963 
964       case IDM_ZM:
965         if(LANG == 1) DialogBox(hInstance,"Dlg_ZM88G",hWnd,FaktorZmDiaProc);
966         if(LANG == 2) DialogBox(hInstance,"Dlg_ZM88E",hWnd,FaktorZmDiaProc);
967         glViewport(0,0,IB,IH);
968 
969         glMatrixMode(GL_PROJECTION);
970         glLoadIdentity();
971         glOrtho(xm,xp,ym,yp,zm,zp);
972 
973         InvalidateRect(hWnd,NULL,TRUE);
974       return 0;
975 
976 /*======================================================================
977 * Labels via Menue
978 *=====================================================================*/
979       case IDM_NOLABELS:
980       case IDM_KNOTEN:
981       case IDM_ELEMENTE:
982       case IDM_LALLES:
983         hMenu= GetMenu(hWnd);
984         CheckMenuItem(hMenu,iflabe,MF_UNCHECKED | MF_BYCOMMAND);
985         iflabe= LOWORD(wParam);
986         CheckMenuItem(hMenu,iflabe,MF_CHECKED | MF_BYCOMMAND);
987 
988         if(iflabe == IDM_LALLES) iplot = 1;
989         else                     iplot = 0;
990 
991         if(iflabe == IDM_KNOTEN)
992           {
993           if(LANG == 1) DialogBox(hInstance,"Dlg_Kno88G",hWnd,KnotenDiaProc);
994           if(LANG == 2) DialogBox(hInstance,"Dlg_Kno88E",hWnd,KnotenDiaProc);
995           }
996 
997         if(iflabe == IDM_ELEMENTE)
998           {
999           if(LANG == 1) DialogBox(hInstance,"Dlg_Ele88G",hWnd,ElementDiaProc);
1000           if(LANG == 2) DialogBox(hInstance,"Dlg_Ele88E",hWnd,ElementDiaProc);
1001           }
1002 
1003       InvalidateRect(hWnd,NULL,TRUE);
1004       return 0;
1005 
1006 /*======================================================================
1007 * Licht/Hidden Line/Spannungen/Verschiebungen X,Y,Z
1008 *=====================================================================*/
1009       case ITC_LIGHT:
1010         if3d = IDM_LIGHT;
1011         InvalidateRect(hWnd,NULL,TRUE);
1012       return 0;
1013 
1014       case ITC_HIDDEN:
1015         if3d = IDM_HIDDEN;
1016         InvalidateRect(hWnd,NULL,TRUE);
1017       return 0;
1018 
1019       case ITC_WIREFR:
1020         if3d = IDM_WIREFR;
1021         InvalidateRect(hWnd,NULL,TRUE);
1022       return 0;
1023 
1024       case ITC_SHOWSPANN:
1025         if3d = IDM_SHOWSPANN;
1026         InvalidateRect(hWnd,NULL,TRUE);
1027       return 0;
1028 
1029       case ITC_SHOWGAUSS:
1030         if3d = IDM_SHOWGAUSS;
1031         InvalidateRect(hWnd,NULL,TRUE);
1032       return 0;
1033 
1034       case ITC_SHOWGAUPU:
1035         if3d = IDM_SHOWGAUPU;
1036         InvalidateRect(hWnd,NULL,TRUE);
1037       return 0;
1038 
1039       case ITC_SHOWVX:
1040         if3d = IDM_SHOWVX;
1041         InvalidateRect(hWnd,NULL,TRUE);
1042       return 0;
1043 
1044       case ITC_SHOWVY:
1045         if3d = IDM_SHOWVY;
1046         InvalidateRect(hWnd,NULL,TRUE);
1047       return 0;
1048 
1049       case ITC_SHOWVZ:
1050         if3d = IDM_SHOWVZ;
1051         InvalidateRect(hWnd,NULL,TRUE);
1052       return 0;
1053 
1054 /*======================================================================
1055 *     Autoscale setzen
1056 *=====================================================================*/
1057       case ITC_YESSCALE:
1058         ifscale = IDM_YESSCALE;
1059         izoom= 1;
1060         rotx= 0.;
1061         roty= 0.;
1062         rotz= 0.;
1063         s   = 1.;
1064         rx  = 0.;
1065         ry  = 0.;
1066         rz  = 0.;
1067         tx  = 0.;
1068         ty  = 0.;
1069         InvalidateRect(hWnd,NULL,TRUE);
1070       return 0;
1071 
1072 /*======================================================================
1073 *     Koordinatensystem ?
1074 *=====================================================================*/
1075       case IDM_YESKOOR:
1076       case IDM_NOKOOR:
1077         hMenu= GetMenu(hWnd);
1078         CheckMenuItem(hMenu,ifkoor,MF_UNCHECKED | MF_BYCOMMAND);
1079         ifkoor= LOWORD(wParam);
1080         CheckMenuItem(hMenu,ifkoor,MF_CHECKED | MF_BYCOMMAND);
1081         InvalidateRect(hWnd,NULL,TRUE);
1082       return 0;
1083 
1084 /*======================================================================
1085 *     Netz ueber Spannungen ?
1086 *=====================================================================*/
1087       case IDM_YESNOST:
1088       case IDM_NONOST:
1089         hMenu= GetMenu(hWnd);
1090         CheckMenuItem(hMenu,ifnost,MF_UNCHECKED | MF_BYCOMMAND);
1091         ifnost= LOWORD(wParam);
1092         CheckMenuItem(hMenu,ifnost,MF_CHECKED | MF_BYCOMMAND);
1093         InvalidateRect(hWnd,NULL,TRUE);
1094       return 0;
1095 
1096 /*======================================================================
1097 *     Randbedingungen malen?
1098 *=====================================================================*/
1099       case IDM_YESRBD:
1100       case IDM_NORBD:
1101         if(!(if3d == IDM_SHOWSPANN || if3d == IDM_SHOWGAUSS ||
1102              if3d == IDM_SHOWVX || if3d == IDM_SHOWVY || if3d == IDM_SHOWVZ))
1103           {
1104           hMenu= GetMenu(hWnd);
1105           CheckMenuItem(hMenu,ifrbd,MF_UNCHECKED | MF_BYCOMMAND);
1106           ifrbd= LOWORD(wParam);
1107           CheckMenuItem(hMenu,ifrbd,MF_CHECKED | MF_BYCOMMAND);
1108           if(ifrbd == IDM_YESRBD)
1109             SendMessage(hToolBar,TB_CHECKBUTTON,(WPARAM)ITC_RBD,(LPARAM) MAKELONG(TRUE,0) );
1110           else
1111             SendMessage(hToolBar,TB_CHECKBUTTON,(WPARAM)ITC_RBD,(LPARAM) MAKELONG(FALSE,0) );
1112           InvalidateRect(hWnd,NULL,TRUE);
1113           }
1114         else
1115           {
1116           hMenu= GetMenu(hWnd);
1117           CheckMenuItem(hMenu,ifrbd,MF_UNCHECKED | MF_BYCOMMAND);
1118           SendMessage(hToolBar,TB_CHECKBUTTON,(WPARAM)ITC_RBD,(LPARAM) MAKELONG(FALSE,0) );
1119           }
1120       return 0;
1121 
1122       case ITC_RBD:
1123         if(!(if3d == IDM_SHOWSPANN || if3d == IDM_SHOWGAUSS ||
1124              if3d == IDM_SHOWVX || if3d == IDM_SHOWVY || if3d == IDM_SHOWVZ))
1125           {
1126           hMenu= GetMenu(hWnd);
1127           CheckMenuItem(hMenu,ifrbd,MF_UNCHECKED | MF_BYCOMMAND);
1128           if(ifrbd == IDM_YESRBD) ifrbd= IDM_NORBD;
1129           else                    ifrbd= IDM_YESRBD;
1130           if(ifrbd == IDM_YESRBD)
1131             CheckMenuItem(hMenu,IDM_YESRBD,MF_CHECKED | MF_BYCOMMAND);
1132           else
1133             CheckMenuItem(hMenu,IDM_NORBD,MF_CHECKED | MF_BYCOMMAND);
1134           InvalidateRect(hWnd,NULL,TRUE);
1135           }
1136         else
1137           {
1138           hMenu= GetMenu(hWnd);
1139           CheckMenuItem(hMenu,ifrbd,MF_UNCHECKED | MF_BYCOMMAND);
1140           SendMessage(hToolBar,TB_CHECKBUTTON,
1141           (WPARAM)ITC_RBD,(LPARAM) MAKELONG(FALSE,0) );
1142           }
1143       return 0;
1144 
1145       case IDM_RBDALL:
1146       case IDM_RBDUX:
1147       case IDM_RBDUY:
1148       case IDM_RBDUZ:
1149       case IDM_RBDU4:
1150       case IDM_RBDU5:
1151       case IDM_RBDU6:
1152       case IDM_RBDUA:
1153       case IDM_RBDOL:
1154       case IDM_RBDFX:
1155       case IDM_RBDFY:
1156       case IDM_RBDFZ:
1157         hMenu= GetMenu(hWnd);
1158         CheckMenuItem(hMenu,ifwbc,MF_UNCHECKED | MF_BYCOMMAND);
1159         ifwbc= LOWORD(wParam);
1160         CheckMenuItem(hMenu,ifwbc,MF_CHECKED | MF_BYCOMMAND);
1161         InvalidateRect(hWnd,NULL,TRUE);
1162       return 0;
1163 
1164 /*======================================================================
1165 *     Randbedingungen zoomen?
1166 *=====================================================================*/
1167       case IDM_ZOPLUS:
1168         zorbd *= 1.5;
1169         InvalidateRect(hWnd,NULL,TRUE);
1170       return 0;
1171 
1172       case IDM_ZOMINUS:
1173         zorbd /= 1.5;
1174         InvalidateRect(hWnd,NULL,TRUE);
1175       return 0;
1176 
1177 /*======================================================================
1178 *     Gausspunkte zoomen?
1179 *=====================================================================*/
1180       case IDM_GPZOPLUS:
1181         zoogp *= 1.5;
1182         InvalidateRect(hWnd,NULL,TRUE);
1183       return 0;
1184 
1185       case IDM_GPZOMINUS:
1186         zoogp /= 1.5;
1187         InvalidateRect(hWnd,NULL,TRUE);
1188       return 0;
1189 
1190 /*======================================================================
1191 * Default
1192 *=====================================================================*/
1193       default:
1194         return DefWindowProc(hWnd, Message, wParam, lParam); /* end switch */
1195       }
1196 
1197 /*----------------------------------------------------------------------
1198 * WM_SIZE: Wenn das Window veraendert wird,dann
1199 *---------------------------------------------------------------------*/
1200   case WM_SIZE:
1201     iyClient= HIWORD(lParam);
1202     ixClient= LOWORD(lParam);
1203 
1204     IB= ixClient;
1205     IH= iyClient-48;
1206 
1207     SV = (double) IH / (double) IB;
1208     ymsv = ym * SV;
1209     ypsv = yp * SV;
1210 
1211     glViewport(0,0,IB,IH);
1212 
1213     glMatrixMode(GL_PROJECTION);
1214     glLoadIdentity();
1215     glOrtho(xm,xp,ymsv,ypsv,zm,zp);
1216 
1217     glMatrixMode(GL_MODELVIEW);
1218   return 0;
1219 
1220 /*----------------------------------------------------------------------
1221 * WM_MOUSEMOVE: Wenn Maus bewegt und linke Taste,dann
1222 *---------------------------------------------------------------------*/
1223   case WM_MOUSEMOVE:
1224     if(wParam & MK_LBUTTON)
1225       {
1226       iy= HIWORD(lParam);
1227       ix= LOWORD(lParam);
1228       xx= (FR_DOUBLE)ix;
1229       yy= (FR_DOUBLE)iy;
1230       ifmaus= IDM_PAN;
1231       InvalidateRect(hWnd,NULL,TRUE);
1232       }
1233     if(wParam & MK_MBUTTON)
1234       {
1235       iy= HIWORD(lParam);
1236       ix= LOWORD(lParam);
1237       xx= (FR_DOUBLE)ix;
1238       yy= (FR_DOUBLE)iy;
1239       ifmaus= IDM_ZOOM;
1240       InvalidateRect(hWnd,NULL,TRUE);
1241       }
1242     if(wParam & MK_RBUTTON)
1243       {
1244       iy= HIWORD(lParam);
1245       ix= LOWORD(lParam);
1246       xx= (FR_DOUBLE)ix;
1247       yy= (FR_DOUBLE)iy;
1248       ifmaus= IDM_ROTATE;
1249       InvalidateRect(hWnd,NULL,TRUE);
1250       }
1251   return 0;
1252 
1253 /*----------------------------------------------------------------------
1254 * WM_PAINT:
1255 *---------------------------------------------------------------------*/
1256   case WM_PAINT:
1257 
1258 /*======================================================================
1259 * Polygon-Modus FILL und Hidden-Surface Removal an
1260 *=====================================================================*/
1261     glEnable(GL_DEPTH_TEST);
1262     glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
1263 
1264 /*======================================================================
1265 * Hintergrundfarbe
1266 *=====================================================================*/
1267     glClearColor(back_col[0],back_col[1],back_col[2],back_col[3]);
1268     glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
1269 
1270 /*======================================================================
1271 * Lichtquelle immer am selben Ort lassen
1272 *=====================================================================*/
1273     glMatrixMode(GL_MODELVIEW);
1274     glLoadIdentity();
1275 
1276 /*======================================================================
1277 * Z88I1.TXT schon geladen?
1278 *=====================================================================*/
1279     if(iflade == ID_NOTLOADSTRUC) goto Lflush;
1280 
1281 /*======================================================================
1282 * Maximalwerte ermitteln und Skalieren
1283 *=====================================================================*/
1284     if(ifscale == IDM_YESSCALE) vsca88();
1285 
1286 /*======================================================================
1287 * Laden von Z88O2.TXT, wenn Anzeige der Verformungen
1288 *=====================================================================*/
1289     if(iflaver == ID_NOTLOADVERF &&
1290        (ifverf == IDM_VERFORMT   ||   if3d   == IDM_SHOWVX     ||
1291         if3d   == IDM_SHOWVY     ||   if3d   == IDM_SHOWVZ))
1292       {
1293       SetCursor(waitcur);
1294       ShowCursor(TRUE);
1295 
1296       fo2= fopen("z88o2.txt","r");
1297       if(fo2 == NULL)
1298         {
1299         ale88o(AL_NOO2);
1300         wlog88o(0,LOG_NOO2);
1301         SetCursor(LoadCursor(NULL,IDC_ARROW));
1302         goto Lflush;
1303         }
1304       rewind(fo2);
1305 
1306       ro2x88();
1307       iflaver= ID_LOADVERF;
1308       if(fo2) fclose(fo2);
1309       SetCursor(LoadCursor(NULL,IDC_ARROW));
1310       }
1311 
1312 /*======================================================================
1313 * Laden von Z88I2.TXT, wenn Anzeige der Randbedingungen
1314 *=====================================================================*/
1315     if(iflarbd == ID_NOTLOADRBD && ifrbd == IDM_YESRBD)
1316       {
1317       SetCursor(waitcur);
1318       ShowCursor(TRUE);
1319 
1320       fi2= fopen("z88i2.txt","r");
1321       if(fi2 == NULL)
1322         {
1323         ale88o(AL_NOI2);
1324         wlog88o(0,LOG_NOI2);
1325         SetCursor(LoadCursor(NULL,IDC_ARROW));
1326         hMenu= GetMenu(hWnd);
1327         CheckMenuItem(hMenu,(int)IDM_YESRBD,MF_UNCHECKED | MF_BYCOMMAND);
1328         CheckMenuItem(hMenu,(int)IDM_NORBD, MF_CHECKED   | MF_BYCOMMAND);
1329         SendMessage(hToolBar,TB_CHECKBUTTON,(WPARAM)ITC_RBD,(LPARAM) MAKELONG(FALSE,0) );
1330         ifrbd= IDM_NORBD;
1331         goto Lflush;
1332         }
1333       rewind(fi2);
1334 
1335       ialert= ri2x88();
1336       if(ialert != 0)
1337         {
1338         ale88o(ialert);
1339         wlog88o(0,LOG_EXMAXRBD);
1340         SetCursor(LoadCursor(NULL,IDC_ARROW));
1341         hMenu= GetMenu(hWnd);
1342         CheckMenuItem(hMenu,(int)IDM_YESRBD,MF_UNCHECKED | MF_BYCOMMAND);
1343         CheckMenuItem(hMenu,(int)IDM_NORBD, MF_CHECKED   | MF_BYCOMMAND);
1344         SendMessage(hToolBar,TB_CHECKBUTTON,(WPARAM)ITC_RBD,(LPARAM) MAKELONG(FALSE,0) );
1345         ifrbd= IDM_NORBD;
1346         goto Lflush;
1347         }
1348       else
1349         iflarbd= ID_LOADRBD;
1350 
1351       if(fi2) fclose(fi2);
1352       SetCursor(LoadCursor(NULL,IDC_ARROW));
1353       }
1354 
1355 /*======================================================================
1356 * Laden von Z88I5.TXT, wenn Anzeige der Randbedingungen und Flaechenla.
1357 *=====================================================================*/
1358     if(iflai5 == ID_NOTLOADI5 && ifrbd == IDM_YESRBD && iqflag == 1)
1359       {
1360       SetCursor(waitcur);
1361       ShowCursor(TRUE);
1362 
1363       fi5= fopen("z88i5.txt","r");
1364       if(fi5 == NULL)
1365         {
1366         ale88o(AL_NOI5);
1367         wlog88o(0,LOG_NOI5);
1368         SetCursor(LoadCursor(NULL,IDC_ARROW));
1369         hMenu= GetMenu(hWnd);
1370         CheckMenuItem(hMenu,(int)IDM_YESRBD,MF_UNCHECKED | MF_BYCOMMAND);
1371         CheckMenuItem(hMenu,(int)IDM_NORBD, MF_CHECKED   | MF_BYCOMMAND);
1372         SendMessage(hToolBar,TB_CHECKBUTTON,(WPARAM)ITC_RBD,(LPARAM) MAKELONG(FALSE,0) );
1373         ifrbd= IDM_NORBD;
1374         goto Lflush;
1375         }
1376       rewind(fi5);
1377 
1378       ialert= ri5x88();
1379       if(ialert != 0)
1380         {
1381         ale88o(ialert);
1382         wlog88o(0,LOG_EXMAXPR);
1383         SetCursor(LoadCursor(NULL,IDC_ARROW));
1384         hMenu= GetMenu(hWnd);
1385         CheckMenuItem(hMenu,(int)IDM_YESRBD,MF_UNCHECKED | MF_BYCOMMAND);
1386         CheckMenuItem(hMenu,(int)IDM_NORBD, MF_CHECKED   | MF_BYCOMMAND);
1387         SendMessage(hToolBar,TB_CHECKBUTTON,(WPARAM)ITC_RBD,(LPARAM) MAKELONG(FALSE,0) );
1388         ifrbd= IDM_NORBD;
1389         goto Lflush;
1390         }
1391       else
1392         iflai5= ID_LOADI5;
1393 
1394       if(fi5) fclose(fi5);
1395       SetCursor(LoadCursor(NULL,IDC_ARROW));
1396       }
1397 
1398 /*======================================================================
1399 * Laden von Z88O8.TXT, wenn Anzeige der Spannungen in Eckknoten
1400 *=====================================================================*/
1401     if(iflspa == ID_NOTLOADSPANN &&
1402         (if3d == IDM_SHOWSPANN ||
1403          if3d == IDM_SHOWGAUSS))
1404       {
1405       SetCursor(waitcur);
1406       ShowCursor(TRUE);
1407 
1408       fo8= fopen("z88o8.txt","r");
1409       if(fo8 == NULL)
1410         {
1411         ale88o(AL_NOO8);
1412         wlog88o(0,LOG_NOO8);
1413         SetCursor(LoadCursor(NULL,IDC_ARROW));
1414         goto Lflush;
1415         }
1416       rewind(fo8);
1417 
1418       ialert= ro8x88();
1419       if(ialert != 0) ale88o(ialert);
1420       else            iflspa= ID_LOADSPANN;
1421 
1422       if(fo8) fclose(fo8);
1423       SetCursor(LoadCursor(NULL,IDC_ARROW));
1424       }
1425 
1426 /*======================================================================
1427 * Laden von Z88O5.TXT, wenn Anzeige der Spannungen in Gausspunkten
1428 *=====================================================================*/
1429     if(iflao5 == ID_NOTLOADSPAO5 && if3d == IDM_SHOWGAUPU)
1430       {
1431       fo5= fopen("z88o5.txt","r");
1432       if(fo5 == NULL)
1433         {
1434         ale88o(AL_NOO5);
1435         wlog88o(0,LOG_NOO5);
1436         return(AL_NOO5);
1437         }
1438       rewind(fo5);
1439 
1440       ialert= ro5x88();
1441       if(ialert != 0) ale88o(ialert);
1442       else            iflao5= ID_LOADSPAO5;
1443 
1444       if(fo5) fclose(fo5);
1445       SetCursor(LoadCursor(NULL,IDC_ARROW));
1446       }
1447 
1448 /*======================================================================
1449 * Anzeige Randbedingungen ausschalten fuer die folgenden anderen Anzeigen
1450 *=====================================================================*/
1451     if(if3d == IDM_SHOWSPANN || if3d == IDM_SHOWGAUSS || if3d == IDM_SHOWGAUPU ||
1452        if3d == IDM_SHOWVX    || if3d == IDM_SHOWVY    || if3d == IDM_SHOWVZ)
1453       {
1454       ifrbd= IDM_NORBD;
1455       hMenu= GetMenu(hWnd);
1456       CheckMenuItem(hMenu,(int)IDM_YESRBD,MF_UNCHECKED | MF_BYCOMMAND);
1457       CheckMenuItem(hMenu,(int)IDM_NORBD, MF_CHECKED   | MF_BYCOMMAND);
1458       SendMessage(hToolBar,TB_CHECKBUTTON,(WPARAM)ITC_RBD,(LPARAM) MAKELONG(FALSE,0) );
1459       }
1460 
1461 /*======================================================================
1462 * Berechnen der Spannungs- und Verschiebungsfarbwerte
1463 *=====================================================================*/
1464     if(if3d == IDM_SHOWSPANN && iflspa == ID_LOADSPANN) stro88();
1465     if(if3d == IDM_SHOWGAUSS && iflspa == ID_LOADSPANN) snow88();
1466     if(if3d == IDM_SHOWGAUPU && iflao5 == ID_LOADSPAO5) spgp88();
1467     if(if3d == IDM_SHOWVX)    fvx88();
1468     if(if3d == IDM_SHOWVY)    fvy88();
1469     if(if3d == IDM_SHOWVZ)    fvz88();
1470 
1471 /*======================================================================
1472 * Spannungsskala bzw. Verschiebungsskala zeichnen
1473 *=====================================================================*/
1474     if((if3d == IDM_SHOWSPANN && iflspa == ID_LOADSPANN) ||
1475        (if3d == IDM_SHOWGAUSS && iflspa == ID_LOADSPANN) ||
1476        (if3d == IDM_SHOWGAUPU && iflao5 == ID_LOADSPAO5) ||
1477        if3d == IDM_SHOWVX    ||  if3d == IDM_SHOWVY      || if3d == IDM_SHOWVZ)
1478       {
1479       glDisable(GL_NORMALIZE);
1480       glDisable(GL_LIGHTING);
1481       glShadeModel(GL_FLAT);
1482       fsca88();
1483       }
1484 
1485 /*======================================================================
1486 * Randbedingungsskala zeichnen
1487 *=====================================================================*/
1488     if(ifrbd == IDM_YESRBD && iflarbd == ID_LOADRBD)
1489       {
1490       glDisable(GL_NORMALIZE);
1491       glDisable(GL_LIGHTING);
1492       glShadeModel(GL_FLAT);
1493       fsrb88();
1494       }
1495 
1496 /*========================================================
1497 * Licht ?
1498 *=======================================================*/
1499     if(if3d == IDM_LIGHT)
1500       {
1501       glEnable(GL_NORMALIZE);
1502       glEnable(GL_LIGHTING);
1503 
1504       glLightfv(GL_LIGHT0,GL_SPECULAR,specula0);
1505       glLightfv(GL_LIGHT0,GL_DIFFUSE ,diffuse0 );
1506       glLightfv(GL_LIGHT0,GL_POSITION,positio0);
1507       glLightfv(GL_LIGHT0,GL_AMBIENT ,ambient0 );
1508       glEnable(GL_LIGHT0);
1509 
1510       glLightfv(GL_LIGHT1,GL_SPECULAR,specula1);
1511       glLightfv(GL_LIGHT1,GL_DIFFUSE ,diffuse1);
1512       glLightfv(GL_LIGHT1,GL_POSITION,positio1);
1513       glLightfv(GL_LIGHT1,GL_AMBIENT ,ambient1);
1514       glEnable(GL_LIGHT1);
1515 
1516       glLightfv(GL_LIGHT2,GL_SPECULAR,specula2);
1517       glLightfv(GL_LIGHT2,GL_POSITION,positio2);
1518       glEnable(GL_LIGHT2);
1519 
1520       glMaterialfv(GL_FRONT,GL_AMBIENT_AND_DIFFUSE,diff_mat);
1521       glMaterialfv(GL_FRONT,GL_SPECULAR,spec_mat);
1522       glMaterialfv(GL_FRONT,GL_SHININESS,shine);
1523       }
1524 
1525 /*========================================================
1526 * Die Transformationen ausfuehren
1527 *=======================================================*/
1528     glMatrixMode(GL_MODELVIEW);
1529     glLoadIdentity();
1530 
1531     if(ifmaus == IDM_ZOOM)  /* Zoom */
1532       {
1533       s=8./3.*xx*xx/IB/IB+1./3.;
1534       if(s < 0.) s= 0.;
1535       }
1536 
1537     if(ifmaus == IDM_PAN)  /* Panning */
1538       {
1539       xw= (FR_DOUBLE)IB;
1540       ty= -yp*2/(xw/2) *(yy-xw/2);
1541       tx= -yp*2/(xw/2) *(xw/2-xx);
1542       }
1543 
1544     if(ifmaus == IDM_ROTATE)  /* Rotieren */
1545       {
1546       rx= yy;
1547       ry= xx;
1548       }
1549 
1550     if(ifkom == ID_MOUSE)
1551       {
1552       glScaled(s,s,s);
1553       glTranslated(tx,ty,0);
1554       glRotated(rx,0.,1.,0.);
1555       glRotated(ry,1.,0.,0.);
1556       }
1557 
1558     if(ifkom == ID_FUNKEY);
1559       {
1560       glRotated(rotx,1.,0.,0.);
1561       glRotated(roty,0.,1.,0.);
1562       glRotated(rotz,0.,0.,1.);
1563       }
1564 
1565 /*========================================================
1566 * Koordinaten umrechnen
1567 *=======================================================*/
1568     if(ifverf == IDM_UNVERFORMT) vu3b88();
1569     else                         vv3b88();
1570 
1571 /*========================================================
1572 * Schleife ueber alle Elemente, mit Licht
1573 *=======================================================*/
1574     if(ifkoor == IDM_YESKOOR)
1575       {
1576       glColor3f(hide_col[0],hide_col[1],hide_col[2]);
1577       mko88();
1578       }
1579 
1580 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1581 * 1) mit Licht
1582 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
1583     if(if3d == IDM_LIGHT)
1584       {
1585       tet188();
1586       if(ifrbd == IDM_YESRBD)
1587         {
1588         glDisable(GL_NORMALIZE);
1589         glDisable(GL_LIGHTING);
1590         glShadeModel(GL_SMOOTH);
1591         mrbd88();
1592         }
1593       }
1594 
1595 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1596 * 2) Hidden Lines
1597 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
1598     if(if3d == IDM_HIDDEN && ndim == 3)
1599       {
1600       glDisable(GL_NORMALIZE);
1601       glDisable(GL_LIGHTING);
1602       glEnable(GL_DEPTH_TEST);
1603       glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
1604       glColor3f(hide_col[0],hide_col[1],hide_col[2]);
1605       tet388();
1606 
1607       glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
1608       glEnable(GL_POLYGON_OFFSET_FILL);
1609       glPolygonOffset(hide_off[0],hide_off[1]);
1610       glColor3f(back_col[0],back_col[1],back_col[2]);
1611       tet388();
1612 
1613       if(ifrbd == IDM_YESRBD) mrbd88();
1614 
1615       glDisable(GL_POLYGON_OFFSET_FILL);
1616       }
1617 
1618 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1619 * 3) Wireframe
1620 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
1621     if(if3d == IDM_WIREFR)
1622       {
1623       glDisable(GL_NORMALIZE);
1624       glDisable(GL_LIGHTING);
1625       glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
1626       glColor3f(hide_col[0],hide_col[1],hide_col[2]);
1627       tet588();
1628       if(ifrbd == IDM_YESRBD) mrbd88();
1629       }
1630 
1631 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1632 * 4) Spannungen an Eckknoten, Verschiebungen an Eckknoten
1633 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
1634     if(if3d == IDM_SHOWSPANN || if3d == IDM_SHOWVX    ||
1635        if3d == IDM_SHOWVY    || if3d == IDM_SHOWVZ)
1636       {
1637       glDisable(GL_NORMALIZE);
1638       glDisable(GL_LIGHTING);
1639       glShadeModel(GL_SMOOTH);
1640       tet288();
1641 
1642       if(ndim == 3 && ifnost == IDM_YESNOST)
1643         {
1644         glLineWidth(bline);
1645 
1646         glDisable(GL_NORMALIZE);
1647         glDisable(GL_LIGHTING);
1648         glEnable(GL_DEPTH_TEST);
1649         glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
1650         glColor3f(hide_col[0],hide_col[1],hide_col[2]);
1651         tet388();
1652 
1653         glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
1654         glEnable(GL_POLYGON_OFFSET_FILL);
1655         glPolygonOffset(hide_off[0],hide_off[1]);
1656         glColor3f(back_col[0],back_col[1],back_col[2]);
1657         tet388();
1658 
1659         glDisable(GL_POLYGON_OFFSET_FILL);
1660         glLineWidth(1.0);
1661         }
1662       }
1663 
1664 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1665 * 5) Spannungen pro Element gemittelt
1666 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
1667     if(if3d == IDM_SHOWGAUSS)
1668       {
1669       glDisable(GL_NORMALIZE);
1670       glDisable(GL_LIGHTING);
1671       glShadeModel(GL_FLAT);
1672       tet488();
1673 
1674       if(ndim == 3 && ifnost == IDM_YESNOST)
1675         {
1676         glLineWidth(bline);
1677 
1678         glDisable(GL_NORMALIZE);
1679         glDisable(GL_LIGHTING);
1680         glEnable(GL_DEPTH_TEST);
1681         glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
1682         glColor3f(hide_col[0],hide_col[1],hide_col[2]);
1683         tet388();
1684 
1685         glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
1686         glEnable(GL_POLYGON_OFFSET_FILL);
1687         glPolygonOffset(hide_off[0],hide_off[1]);
1688         glColor3f(back_col[0],back_col[1],back_col[2]);
1689         tet388();
1690 
1691         glDisable(GL_POLYGON_OFFSET_FILL);
1692         glLineWidth(1.0);
1693         }
1694       }
1695 
1696 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1697 * 6) Spannungen in den Gausspunkten
1698 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
1699     if(if3d == IDM_SHOWGAUPU && ifverf == IDM_UNVERFORMT &&
1700        iflao5 == ID_LOADSPAO5)
1701       {
1702       glDisable(GL_NORMALIZE);
1703       glDisable(GL_LIGHTING);
1704       glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
1705       glColor3f(hide_col[0],hide_col[1],hide_col[2]);
1706       tet588();
1707       vgpc88();
1708       spgp88();
1709       magp88();
1710       }
1711 
1712 /*========================================================
1713 * Knotennummern plotten ?
1714 *=======================================================*/
1715     if((iflabe == IDM_KNOTEN || iflabe == IDM_LALLES)
1716         &&
1717        (if3d == IDM_WIREFR   ||
1718        (if3d == IDM_HIDDEN && ndim == 3))) malk88();
1719 
1720 /*========================================================
1721 * fertig OpenGL
1722 *=======================================================*/
1723 Lflush:
1724     glFlush();
1725     SwapBuffers(hDC);
1726     ValidateRect(hWnd,NULL);
1727   return 0;
1728 
1729 /*=========================================================
1730 * Wenn keine der obigen Cases zutrifft, dann
1731 *========================================================*/
1732   default:
1733     return DefWindowProc(hWnd,Message,wParam,lParam);
1734   }
1735 }
1736 
1737