-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathchoglmodA.f90
2347 lines (2282 loc) · 74.1 KB
/
choglmodA.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
! Copyright 2012, 2012 Christian Hafner
!
! This file is part of OpenMaX.
!
! OpenMaX is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
! OpenMaX is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
! You should have received a copy of the GNU General Public License
! along with OpenMaX. If not, see <http://www.gnu.org/licenses/>.
MODULE CHoGL
use CHMOV
use IFOPNGL
!use opengl_gl
use opengl_glu
use opengl_glut
implicit none
private
public :: CHGLreset,ChGLviewInit,ChGLviewReset,ChGLdisplay,CHGLColorPalette,CHGLDrawAxes,CHGLDrawSurfaces,CHGLDrawGrids, &
& CHGLDrawIsoLines,CHGLDrawVectors,CHGLDrawExpansions,CHGLDrawTubes,CHGLDrawPFDsensors,CHGLDrawPFDsources,CHGLclear, &
& CHGLDefaults,CHGLwindowDialog,CHGLDraw,ChGLsaveBMP
Integer(2), public :: iCHGLmode
private :: mouse,motion,arrows,menu_handler,set_left_button,set_middle_button,set_arrow_keys, &
& sphere2cart,cart2sphere,cart3D_plus_cart3D,cart3D_minus_cart3D, &
& CHGLDrawVector,DrawIsoIn3,SetVertex,r3Vec_Prod,r3Vec_Length,Unit3DV,Ortho3DSpace, &
& SetCHGLwindowData,GetCHGLwindowData,updateCHGLwindow,CHGLMovie, &
& CHGLxscale_factor,CHGLyscale_factor,CHGLzscale_factor, &
& ZOOM,PANXY,ROTATE,SCALEX,SCALEY,SCALEZ,ShowAxes,ShowSurface,ShowVectors,RESET,DRAW,MOVIE,BITMAP,PI,&
& left_button_func,middle_button_func,arrow_key_func,&
& angle,shift,xscale_factor,yscale_factor,moving_left,moving_middle,begin_left,begin_middle
type,private :: cart2D ! 2D cartesian coordinates
real(8) :: x,y
end type cart2D
type,private :: cart3D ! 3D cartesian coordinates
real(8) :: x,y,z
end type cart3D
type,private :: sphere3D ! 3D spherical coordinates
real(8) :: theta,phi,rho
end type sphere3D
Integer(2),parameter :: NOTHING=0,ZOOM=1,PANXY=2,ROTATE=3,SCALEX=4,SCALEY=5,SCALEZ=6,ShowAxes=7, &
& ShowSurface=8,ShowGrid=9,ShowIso=10,ShowVectors=11,ShowExpansions=12,RESET=13,DRAW=14,MOVIE=15,BITMAP=16, &
& ShowTubes=17,ShowPointSources=18,ShowXsensors=19
Integer(2), private :: iCR(0:10),iCG(0:10),iCB(0:10)
Real(8), private :: CHGLlookAtCurrent(3),CHGLf
type(cart2D),save :: angle,begin_left,begin_middle
type(cart3D),save :: shift
real(8),save :: xscale_factor,yscale_factor,zscale_factor, &
CHGLxscale_factor,CHGLyscale_factor,CHGLzscale_factor
logical,save :: moving_left,moving_middle
interface operator(+)
module procedure cart3D_plus_cart3D
end interface
interface operator(-)
module procedure cart3D_minus_cart3D
end interface
!initial configuration
integer(4),save :: left_button_func=ROTATE,middle_button_func=PANXY,arrow_key_func=ZOOM
contains
! Initialization
subroutine CHGLDefaults(lini)
Implicit none
Real(8) d
Integer(4) ier,idum
Logical, intent(in) :: lini
call setNameExt(ProFileName,'OGL',OGLFileName)
d=max(abs(WinXmax(kWin)-WinXmin(kWin)),abs(WinYmax(kWin)-WinYmin(kWin)))
CHGLf=2.0d0*d
if(lini) then
rCHGLMovie=10.0d0
iCHGLMovie=0_2
iCHGLxAxisColor=2_2
iCHGLyAxisColor=3_2
iCHGLzAxisColor=4_2
iCHGLxGridColor=2_2
iCHGLyGridColor=3_2
iCHGLzGridColor=4_2
CHGLxAxisW=3.0d0
CHGLyAxisW=3.0d0
CHGLzAxisW=3.0d0
CHGLxAxisL=1.5d0*d
CHGLyAxisL=1.5d0*d
CHGLzAxisL=1.5d0*d
CHGLxGridLineW=1.0d0
CHGLyGridLineW=1.0d0
CHGLzGridLineW=1.0d0
CHGLExpLen=0.025d0*d
space=viewPlane
CHGLlookAt(1:3)=viewPlane(1:3,0)+0.5d0*(WinXmax(kWin)+WinXmin(kWin))*viewPlane(1:3,1)+ &
& 0.5d0*(WinYmax(kWin)+WinYmin(kWin))*viewPlane(1:3,2)
CHGLlookFrom(1:3)=CHGLlookAt(1:3)+6.0d0*d*viewPlane(1:3,3)
CHGLlookAtCurrent(1:3)=CHGLlookAt(1:3)
iCHGLwidth=max(64_2,iWinWidth(kWin))
iCHGLheight=max(64_2,iWinHeight(kWin))
iCHGLwidthCurrent=iCHGLwidth
iCHGLheightCurrent=iCHGLheight
CHGLViewAngle=10.0d0
CHGLViewAspect=max(0.1d0,min(10.0d0,Dble(iWinWidth(kWin))/Dble(iWinHeight(kWin))))
CHGLViewNear=max(pSmall,min(1.0d30,0.1d0*d))
CHGLViewFar=max(CHGLViewNear,min(1.0d30,1.0d3*d))
nCHGLTube=1
kCHGLTube=1
mCHGLTube=1
DeAllocate(CHGLTubeStart,CHGLTubeR,CHGLTubeD,iCHGLTubeR,iCHGLTubeD,iCHGLTubeColor,Stat=ier)
Allocate(CHGLTubeStart(3,nCHGLTube),CHGLTubeR(nCHGLTube),CHGLTubeD(nCHGLTube),iCHGLTubeR(nCHGLTube), &
& iCHGLTubeD(nCHGLTube),iCHGLTubeColor(3,nCHGLTube),Stat=ier)
if(ier.ne.0) then
idum=MessageBoxQQ('Memory allocation error!'C,'Open OpenGL data'C, &
MB$OK.or.MB$ICONSTOP)
mCHGLTube=0
end if
CHGLTubeStart(1:3,nCHGLTube)=0.0d0
CHGLTubeR(nCHGLTube)=0.0d0
CHGLTubeD(nCHGLTube)=0.0d0
iCHGLTubeR(nCHGLTube)=0
iCHGLTubeD(nCHGLTube)=0
iCHGLTubeColor(1:3,nCHGLTube)=0
end if
iCHGLrColorMin=minCIntensity
iCHGLrColorMax=maxCIntensity
CHGLIsoMinF=rMinFld
CHGLIsoMaxF=rMaxFld
CHGLIsoStepF=rIsoStep
CHGLSurfaceMinF=rMinFld
CHGLSurfaceMaxF=rMaxFld
CHGLSurfaceStepF=rIsoStep
iCHGLxVectorColor=minCArrow
iCHGLyVectorColor=maxCArrow
iCHGLxVectorStep=nsFld
iCHGLyVectorStep=nsFld
CHGLVectorScale=scaleArrow*ArrowLength/max(dabs(rMinFld),dabs(rMaxFld),1.0d-100)
CHGLVectorMaxLength=ArrowLength
CHGLxscale_factor=1.08
CHGLyscale_factor=1.08
CHGLzscale_factor=1.08
end subroutine CHGLDefaults
subroutine ChGLviewReset
! resets the view to the current orientation and scale
Implicit none
call fglMatrixMode(GL_MODELVIEW)
call fglPopMatrix
call fglPushMatrix
call fglTranslated(shift%x,shift%y,shift%z)
call fglRotated(angle%x,0.08,0.08,1.08)
call fglRotated(angle%y,cos(PI*angle%x/180.08),&
-sin(PI*angle%x/180.08),0.08)
call fglTranslated(-CHGLlookAtCurrent(1),-CHGLlookAtCurrent(2),-CHGLlookAtCurrent(3))
call fglScaled(xscale_factor,yscale_factor,zscale_factor)
end subroutine ChGLviewReset
function ChGLviewInit() result(menuid)
! initializes the view modifier variables and sets initial view.
! It should be called immediately after glutCreateWindow
Implicit none
integer(2) :: menuid
integer(2) :: button_left,button_middle,arrow_keys
! set the callback functions
call fglutMouseFunc(mouse)
call fglutMotionFunc(motion)
call fglutSpecialFunc(arrows)
! create the menu
button_left=glutCreateMenu(set_left_button)
! call fglutAddMenuEntry("rotate",ROTATE)
! call fglutAddMenuEntry("zoom",ZOOM)
! call fglutAddMenuEntry("pan",PANXY)
! call fglutAddMenuEntry("scale x",SCALEX)
! call fglutAddMenuEntry("scale y",SCALEY)
! call fglutAddMenuEntry("scale z",SCALEZ)
! call fglutAddMenuEntry("nothing",NOTHING)
button_middle=glutCreateMenu(set_middle_button)
! call fglutAddMenuEntry("rotate",ROTATE)
! call fglutAddMenuEntry("zoom",ZOOM)
! call fglutAddMenuEntry("pan",PANXY)
! call fglutAddMenuEntry("scale x",SCALEX)
! call fglutAddMenuEntry("scale y",SCALEY)
! call fglutAddMenuEntry("scale z",SCALEZ)
! call fglutAddMenuEntry("nothing",NOTHING)
arrow_keys=glutCreateMenu(set_arrow_keys)
! call fglutAddMenuEntry("rotate",ROTATE)
! call fglutAddMenuEntry("zoom",ZOOM)
! call fglutAddMenuEntry("pan",PANXY)
! call fglutAddMenuEntry("scale x",SCALEX)
! call fglutAddMenuEntry("scale y",SCALEY)
! call fglutAddMenuEntry("scale z",SCALEZ)
! call fglutAddMenuEntry("nothing",NOTHING)
menuid=glutCreateMenu(menu_handler)
! call fglutAddMenuEntry("reset to initial view",RESET)
! call fglutAddMenuEntry("draw 3D objects",DRAW)
! call fglutAddMenuEntry("save bitmap",BITMAP)
! call fglutAddMenuEntry("generate movie",MOVIE)
! call fglutAddMenuEntry("show/hide axes",ShowAxes)
! call fglutAddMenuEntry("show/hide surface",ShowSurface)
! call fglutAddMenuEntry("show/hide grid",ShowGrid)
! call fglutAddMenuEntry("show/hide iso-lines",ShowIso)
! call fglutAddMenuEntry("show/hide vectors",ShowVectors)
! call fglutAddMenuEntry("show/hide expansions",ShowExpansions)
! call fglutAddMenuEntry("show/hide field-tubes",ShowTubes)
! call fglutAddMenuEntry("show/hide PFD sources",ShowPointSources)
! call fglutAddMenuEntry("show/hide PFD sensors",ShowXsensors)
! call fglutAddSubMenu("left mouse button",button_left)
! call fglutAddSubMenu("middle mouse button",button_middle)
! call fglutAddSubMenu("arrow keys",arrow_keys)
call CHGLreset
end function ChGLviewInit
subroutine CHGLclear()
implicit none
call fglClearColor(1.0,1.0,1.0,0.0)
call fglLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE)
call fglEnable(GL_LIGHTING)
call fglEnable(GL_DEPTH_TEST)
end subroutine CHGLclear
! Dialogs
Subroutine CHGLwindowDialog(lCheck)
! Dialog for the data of the graphic windows
Implicit none
Include 'RESOURCE.FD'
Integer(4) idum
Logical, intent(in) :: lCheck
Logical ldum
Type(dialog) dlg
Integer(4), save:: IsOpen
Data IsOpen/0/
if(IsOpen.ne.0) return
ldum=lCheck
ldum=DlgInit(IDD_OGL,dlg)
if(.not.ldum) then
idum=MessageBoxQQ('Dialog initialization failed!'C,'CHGLwindow dialog'C, &
MB$OK.or.MB$ICONSTOP)
return
else
IsOpen=1
call SetCHGLwindowData(dlg)
ldum=DlgSetSub(dlg,idok,updateCHGLwindow)
ldum=DlgSetSub(dlg,idc_ogl_tube,updateCHGLwindow)
ldum=DlgSetSub(dlg,idc_ogl_read,updateCHGLwindow)
ldum=DlgSetSub(dlg,idc_ogl_write,updateCHGLwindow)
ldum=DlgSetSub(dlg,idc_ogl_default,updateCHGLwindow)
end if
ldum=DlgModal(dlg)
call DlgUnInit(dlg)
IsOpen=0
end Subroutine CHGLwindowDialog
Subroutine SetCHGLwindowData(dlg)
! set dialog boxes containing graphic window data
Implicit none
Include 'RESOURCE.FD'
Type(dialog) dlg
call DlgSetI(Dlg,idc_OGL_Xcolor,0,Int4(iCHGLxAxisColor),1,236)
call DlgSetI(Dlg,idc_OGL_Ycolor,0,Int4(iCHGLyAxisColor),1,236)
call DlgSetI(Dlg,idc_OGL_Zcolor,0,Int4(iCHGLzAxisColor),1,236)
call DlgSetI(Dlg,idc_OGL_Xcolor2,0,Int4(iCHGLxGridColor),1,236)
call DlgSetI(Dlg,idc_OGL_Ycolor2,0,Int4(iCHGLyGridColor),1,236)
call DlgSetI(Dlg,idc_OGL_Zcolor2,0,Int4(iCHGLzGridColor),1,236)
call DlgSetI(Dlg,idc_OGL_Width,0,Int4(iCHGLwidth),64,10000)
call DlgSetI(Dlg,idc_OGL_Height,0,Int4(iCHGLheight),64,10000)
call DlgSetI(Dlg,idc_OGL_iMovie,0,iCHGLMovie,0,1000000)
call DlgSetR(Dlg,idc_OGL_Xwidth,CHGLxAxisW,2)
call DlgSetR(Dlg,idc_OGL_Ywidth,CHGLyAxisW,2)
call DlgSetR(Dlg,idc_OGL_Zwidth,CHGLzAxisW,2)
call DlgSetR(Dlg,idc_OGL_Xwidth2,CHGLxGridLineW,2)
call DlgSetR(Dlg,idc_OGL_Ywidth2,CHGLyGridLineW,2)
call DlgSetR(Dlg,idc_OGL_Zwidth2,CHGLzGridLineW,2)
call DlgSetR(Dlg,idc_OGL_Xlength,CHGLxAxisL,2)
call DlgSetR(Dlg,idc_OGL_Ylength,CHGLyAxisL,2)
call DlgSetR(Dlg,idc_OGL_Zlength,CHGLzAxisL,2)
call DlgSetR(Dlg,idc_OGL_ExpLen,CHGLExpLen,2)
call DlgSetR(Dlg,idc_OGL_rMovie,rCHGLMovie,2)
call DlgSetR(Dlg,idc_OGL_XlookFrom,CHGLlookFrom(1),2)
call DlgSetR(Dlg,idc_OGL_YlookFrom,CHGLlookFrom(2),2)
call DlgSetR(Dlg,idc_OGL_ZlookFrom,CHGLlookFrom(3),2)
call DlgSetR(Dlg,idc_OGL_XlookAt,CHGLlookAt(1),2)
call DlgSetR(Dlg,idc_OGL_YlookAt,CHGLlookAt(2),2)
call DlgSetR(Dlg,idc_OGL_ZlookAt,CHGLlookAt(3),2)
call DlgSetR(Dlg,idc_OGL_ViewAngle,CHGLViewAngle,2)
call DlgSetR(Dlg,idc_OGL_ViewAspect,CHGLViewAspect,2)
call DlgSetR(Dlg,idc_OGL_ViewNear,CHGLViewNear,2)
call DlgSetR(Dlg,idc_OGL_ViewFar,CHGLViewFar,2)
end Subroutine SetCHGLwindowData
Subroutine GetCHGLwindowData(dlg)
! get graphic window data
Implicit none
Include 'RESOURCE.FD'
Integer(4) idum
Type(dialog) dlg
call DlgGetI(Dlg,idc_OGL_Xcolor,0,0,idum,0,236,2)
iCHGLxAxisColor=Int2(idum)
call DlgGetI(Dlg,idc_OGL_Ycolor,0,0,idum,0,236,2)
iCHGLyAxisColor=Int2(idum)
call DlgGetI(Dlg,idc_OGL_Zcolor,0,0,idum,0,236,2)
iCHGLzAxisColor=Int2(idum)
call DlgGetI(Dlg,idc_OGL_Xcolor2,0,0,idum,0,236,2)
iCHGLxGridColor=Int2(idum)
call DlgGetI(Dlg,idc_OGL_Ycolor2,0,0,idum,0,236,2)
iCHGLyGridColor=Int2(idum)
call DlgGetI(Dlg,idc_OGL_Zcolor2,0,0,idum,0,236,2)
iCHGLzGridColor=Int2(idum)
call DlgGetI(Dlg,idc_OGL_Width,0,0,idum,64,10000,400)
iCHGLwidth=max(64_2,Int2(idum))
call DlgGetI(Dlg,idc_OGL_Height,0,0,idum,64,10000,400)
iCHGLheight=max(64_2,Int2(idum))
call DlgGetI(Dlg,idc_OGL_iMovie,0,0,iCHGLMovie,0,1000000,36)
call DlgGetR(Dlg,idc_OGL_Xwidth,CHGLxAxisW,0.0d0,1.0d3,3.0d0,2)
call DlgGetR(Dlg,idc_OGL_Ywidth,CHGLyAxisW,0.0d0,1.0d3,3.0d0,2)
call DlgGetR(Dlg,idc_OGL_Zwidth,CHGLzAxisW,0.0d0,1.0d3,3.0d0,2)
call DlgGetR(Dlg,idc_OGL_Xwidth2,CHGLxGridLineW,0.0d0,1.0d3,1.0d0,2)
call DlgGetR(Dlg,idc_OGL_Ywidth2,CHGLyGridLineW,0.0d0,1.0d3,1.0d0,2)
call DlgGetR(Dlg,idc_OGL_Zwidth2,CHGLzGridLineW,0.0d0,1.0d3,1.0d0,2)
call DlgGetR(Dlg,idc_OGL_Xlength,CHGLxAxisL,0.0d0,1.0d3,1.5d0,2)
call DlgGetR(Dlg,idc_OGL_Ylength,CHGLyAxisL,0.0d0,1.0d3,1.5d0,2)
call DlgGetR(Dlg,idc_OGL_Zlength,CHGLzAxisL,0.0d0,1.0d3,1.5d0,2)
call DlgGetR(Dlg,idc_OGL_ExpLen,CHGLExpLen,0.0d0,1.0d3,0.05d0,2)
call DlgGetR(Dlg,idc_OGL_rMovie,rCHGLMovie,nBig,pBig,10.0d0,2)
call DlgGetR(Dlg,idc_OGL_XlookFrom,CHGLlookFrom(1),-1.0d30,1.0d30,10.0d0,2)
call DlgGetR(Dlg,idc_OGL_YlookFrom,CHGLlookFrom(2),-1.0d30,1.0d30,10.0d0,2)
call DlgGetR(Dlg,idc_OGL_ZlookFrom,CHGLlookFrom(3),-1.0d30,1.0d30,10.0d0,2)
call DlgGetR(Dlg,idc_OGL_XlookAt,CHGLlookAt(1),-1.0d30,1.0d30,0.0d0,2)
call DlgGetR(Dlg,idc_OGL_YlookAt,CHGLlookAt(2),-1.0d30,1.0d30,0.0d0,2)
call DlgGetR(Dlg,idc_OGL_ZlookAt,CHGLlookAt(3),-1.0d30,1.0d30,0.0d0,2)
call DlgGetR(Dlg,idc_OGL_ViewAngle,CHGLViewAngle,1.0d-10,180d0,10.0d0,2)
call DlgGetR(Dlg,idc_OGL_ViewAspect,CHGLViewAspect,1.0d-1,1.0d1,1.0d0,2)
call DlgGetR(Dlg,idc_OGL_ViewNear,CHGLViewNear,pSmall,1.0d30,0.01d0,2)
call DlgGetR(Dlg,idc_OGL_ViewFar,CHGLViewFar,CHGLViewNear,1.0d30,1.0d30,2)
end Subroutine GetCHGLwindowData
Subroutine updateCHGLwindow(dlg,control_name,callbackType)
! callback for CHGLwindowDialog
Implicit none
Include 'RESOURCE.FD'
Integer(4) control_name,callbackType,idum
Type (dialog) dlg
idum=callbackType
Select Case(control_name)
Case(idok)
call GetCHGLwindowData(dlg)
call DlgExit(dlg)
Case(idc_ogl_tube)
call TubeDialog(.true.)
Case(idc_ogl_read)
call GetCHGLWindowData(dlg)
call OpenCHGLWindow(.false.)
call SetCHGLWindowData(dlg)
Case(idc_ogl_write)
call GetCHGLWindowData(dlg)
call SaveCHGLWindow(.false.)
call SetCHGLWindowData(dlg)
Case(idc_ogl_default)
call CHGLDefaults(.true.)
call SetCHGLWindowData(dlg)
end Select
end Subroutine updateCHGLwindow
Subroutine TubeDialog(lCheck)
! dialog for the field tube data
Implicit none
Include 'RESOURCE.FD'
Logical, intent(in) :: lCheck
Logical ldum
Integer(4) idum
Type(dialog) dlg
Integer(4), save:: IsOpen
Data IsOpen/0/
if(IsOpen.ne.0) return
ldum=lCheck
ldum=DlgInit(IDD_Tube,dlg)
if(.not.ldum) then
idum=MessageBoxQQ('Dialog initialization failed!'C,'Tube dialog'C, &
MB$OK.or.MB$ICONSTOP)
return
else
IsOpen=1
call SetTubeData(dlg)
ldum=DlgSetSub(dlg,idc_kTube,updateTube)
ldum=DlgSetSub(dlg,idc_kTubeS,updateTube)
ldum=DlgSetSub(dlg,idc_Modify_Tube,updateTube)
ldum=DlgSetSub(dlg,idc_Add_Tube,updateTube)
ldum=DlgSetSub(dlg,idc_Del_Tube,updateTube)
ldum=DlgSetSub(dlg,idcancel,updateTube)
end if
ldum=DlgModal(dlg)
call DlgUnInit(dlg)
IsOpen=0
end Subroutine TubeDialog
Subroutine SetTubeData(dlg)
! set the Tube data in its dialog
Implicit none
Include 'RESOURCE.FD'
Type(dialog) dlg
call DlgSetI(Dlg,idc_kTube,idc_kTubeS,kCHGLTube,1,nCHGLTube)
call DlgSetI(Dlg,idc_nTube,0,nCHGLTube,1,10000)
call DlgSetI(Dlg,idc_TubeColorg,0,Int4(iCHGLTubeColor(1,kCHGLTube)),0,235)
call DlgSetI(Dlg,idc_TubeColori,0,Int4(iCHGLTubeColor(2,kCHGLTube)),0,235)
call DlgSetI(Dlg,idc_TubeColoro,0,Int4(iCHGLTubeColor(3,kCHGLTube)),0,235)
call DlgSetI(Dlg,idc_TubeNR,0,iCHGLTubeR(kCHGLTube),0,10000)
call DlgSetI(Dlg,idc_TubeND,0,iCHGLTubeD(kCHGLTube),0,10000)
call DlgSetR(Dlg,idc_TubeX,CHGLTubeStart(1,kCHGLTube),7)
call DlgSetR(Dlg,idc_TubeY,CHGLTubeStart(2,kCHGLTube),7)
call DlgSetR(Dlg,idc_TubeZ,CHGLTubeStart(3,kCHGLTube),7)
call DlgSetR(Dlg,idc_TubeR,CHGLTubeR(kCHGLTube),7)
call DlgSetR(Dlg,idc_TubeD,CHGLTubeD(kCHGLTube),7)
end Subroutine SetTubeData
Subroutine GetTubeData(dlg)
! get the Tube data from its dialog
Implicit none
Include 'RESOURCE.FD'
Integer(4) idum
Type(dialog) dlg
call DlgGetI(Dlg,idc_kTube,idc_kTubeS,0,kCHGLTube,1,nCHGLTube,1)
call DlgGetI(Dlg,idc_TubeColorg,0,0,idum,0,235,1)
iCHGLTubeColor(1,kCHGLTube)=Int2(idum)
call DlgGetI(Dlg,idc_TubeColori,0,0,idum,0,235,1)
iCHGLTubeColor(2,kCHGLTube)=Int2(idum)
call DlgGetI(Dlg,idc_TubeColoro,0,0,idum,0,235,1)
iCHGLTubeColor(3,kCHGLTube)=Int2(idum)
call DlgGetI(Dlg,idc_TubeNR,0,0,iCHGLTubeR(kCHGLTube),0,10000,0)
call DlgGetI(Dlg,idc_TubeND,0,0,iCHGLTubeD(kCHGLTube),0,10000,0)
call DlgGetR(Dlg,idc_TubeX,CHGLTubeStart(1,kCHGLTube),nBig,pBig,0.0d0,7)
call DlgGetR(Dlg,idc_TubeY,CHGLTubeStart(2,kCHGLTube),nBig,pBig,0.0d0,7)
call DlgGetR(Dlg,idc_TubeZ,CHGLTubeStart(3,kCHGLTube),nBig,pBig,0.0d0,7)
call DlgGetR(Dlg,idc_TubeR,CHGLTubeR(kCHGLTube),nBig,pBig,0.0d0,7)
call DlgGetR(Dlg,idc_TubeD,CHGLTubeD(kCHGLTube),nBig,pBig,0.0d0,7)
end Subroutine GetTubeData
Subroutine updateTube(dlg,control_name,callbackType)
! callback for TubeDialog
Implicit none
Include 'RESOURCE.FD'
Integer(4) control_name,callbackType,idum
Logical ldum
Type (dialog) dlg
idum=callbackType
Select Case(control_name)
Case(idc_kTube)
call DlgGetI(Dlg,idc_kTube,idc_kTubeS,0,kCHGLTube,1,nCHGLTube,1)
call SetTubeData(dlg)
Case(idc_kTubeS)
call DlgGetI(Dlg,idc_kTube,idc_kTubeS,1,kCHGLTube,1,nCHGLTube,1)
call SetTubeData(dlg)
Case(idc_Modify_Tube)
call GetTubeData(dlg)
Case(idc_Add_Tube)
call InsertTube(kCHGLTube,ldum)
if(ldum) then
call DlgSetI(Dlg,idc_nTube,0,nCHGLTube,1,10000)
call GetTubeData(dlg)
end if
Case(idc_Del_Tube)
call GetTubeData(dlg)
if(nCHGLTube.gt.1) then
nCHGLTube=nCHGLTube-1
do idum=kCHGLTube,nCHGLTube
CHGLTubeStart(1:3,idum)=CHGLTubeStart(1:3,idum+1)
CHGLTubeR(idum)=CHGLTubeR(idum+1)
CHGLTubeD(idum)=CHGLTubeD(idum+1)
iCHGLTubeR(idum)=iCHGLTubeR(idum+1)
iCHGLTubeD(idum)=iCHGLTubeD(idum+1)
iCHGLTubeColor(1:3,idum)=iCHGLTubeColor(1:3,idum+1)
end do
end if
call SetTubeData(dlg)
Case(idcancel)
call DlgExit(dlg)
end Select
end Subroutine updateTube
Subroutine InsertTube(loc,lOK)
Implicit none
Real(8), Allocatable:: Start(:,:),R(:),D(:)
Integer(4), Allocatable:: NR(:),ND(:)
Integer(2), Allocatable:: IC(:,:)
Integer(4) loc,idum
Logical lOK
lOK=.false.
DeAllocate(Start,R,D,NR,ND,IC,stat=idum)
Allocate(Start(3,nCHGLTube+1),R(nCHGLTube+1),D(nCHGLTube+1),NR(nCHGLTube+1),ND(nCHGLTube+1),IC(3,nCHGLTube+1), &
& stat=idum)
if(idum.ne.0) then
idum=MessageBoxQQ('Memory allocation error!'C,'Insert field tube'C, &
MB$OK.or.MB$ICONSTOP)
return
end if
do idum=1,loc
Start(1:3,idum)=CHGLTubeStart(1:3,idum)
R(idum)=CHGLTubeR(idum)
D(idum)=CHGLTubeD(idum)
NR(idum)=iCHGLTubeR(idum)
ND(idum)=iCHGLTubeD(idum)
IC(1:3,idum)=iCHGLTubeColor(1:3,idum)
end do
do idum=loc,nCHGLTube
Start(1:3,idum+1)=CHGLTubeStart(1:3,idum)
R(idum+1)=CHGLTubeR(idum)
D(idum+1)=CHGLTubeD(idum)
NR(idum+1)=iCHGLTubeR(idum)
ND(idum+1)=iCHGLTubeD(idum)
IC(1:3,idum+1)=iCHGLTubeColor(1:3,idum)
end do
DeAllocate(CHGLTubeStart,CHGLTubeR,CHGLTubeD,iCHGLTubeR,iCHGLTubeD,iCHGLTubeColor,Stat=idum)
nCHGLTube=nCHGLTube+1
Allocate(CHGLTubeStart(3,nCHGLTube),CHGLTubeR(nCHGLTube),CHGLTubeD(nCHGLTube),iCHGLTubeR(nCHGLTube), &
& iCHGLTubeD(nCHGLTube),iCHGLTubeColor(3,nCHGLTube),Stat=idum)
if(idum.ne.0) then
idum=MessageBoxQQ('Memory allocation error!'C,'Insert field tube'C, &
MB$OK.or.MB$ICONSTOP)
return
end if
CHGLTubeStart=Start
CHGLTubeR=R
CHGLTubeD=D
iCHGLTubeR=NR
iCHGLTubeD=ND
iCHGLTubeColor=IC
DeAllocate(Start,R,D,NR,ND,IC,stat=idum)
lOK=.true.
end Subroutine InsertTube
! public routines
subroutine CHGLreset
! resets the view to the initial configuration
Implicit none
Integer(4) iw,ih
Real(8) ViewAngle,ViewAspect,ViewNear,ViewFar
type(Cart3D) :: clookfrom
type(sphere3D) :: slookfrom
! set the palette
call CHGLColorPalette()
! set the perspective
call fglMatrixMode(GL_PROJECTION)
call fglLoadIdentity
ViewAngle=CHGLViewAngle
ViewAspect=CHGLViewAspect
ViewNear=CHGLViewNear
ViewFar=CHGLViewFar
call gluPerspective(ViewAngle,ViewAspect,ViewNear,ViewFar)
! set the initial view
call fglPushMatrix
CHGLlookAtCurrent(1:3)=CHGLlookAt(1:3)
clookfrom%x=CHGLlookFrom(1)-CHGLlookAt(1)
clookfrom%y=CHGLlookFrom(2)-CHGLlookAt(2)
clookfrom%z=CHGLlookFrom(3)-CHGLlookAt(3)
slookfrom=cart2sphere(clookfrom)
angle%x=-180.08*slookfrom%phi/PI-90.08
angle%y=-180.08*slookfrom%theta/PI
shift%x=0.08
shift%y=0.08
shift%z=-slookfrom%rho
xscale_factor=CHGLxscale_factor
yscale_factor=CHGLyscale_factor
zscale_factor=CHGLzscale_factor
lCHGLlist(1:3)=.true.
lCHGLlist(4:9)=.false.
iw=iCHGLwidth
ih=iCHGLheight
call fglutReshapeWindow(max(64,iw),max(64,ih))
call fglutPostRedisplay
end subroutine CHGLreset
subroutine ChGLdisplay
! This gets called when the display needs to be redrawn
Implicit none
Integer(4) i
Integer(4) iw,ih,id
call ChGLviewReset
call fglClear(ior(GL_COLOR_BUFFER_BIT,GL_DEPTH_BUFFER_BIT))
do i=nCHGLlists,1,-1
if(lCHGLlist(i)) then
call fglCallList(i)
end if
end do
call fglutSetWindow(1)
iw=glutGet(GLUT_WINDOW_WIDTH)
id=modulo(iw,4_4)
if(id.ne.0_4) then
iw=iw+4_4-id
end if
ih=glutGet(GLUT_WINDOW_HEIGHT)
id=modulo(ih,4_4)
if(id.ne.0_4) then
ih=ih+4_4-id
end if
if((iCHGLWidthCurrent.ne.iw).or.(iCHGLHeightCurrent.ne.ih)) then
iCHGLWidthCurrent=iw
iCHGLHeightCurrent=ih
call fglutReshapeWindow(max(64,iw),max(64,ih))
end if
call fglutShowWindow()
call fglutSwapBuffers
call fglutPostRedisplay
end subroutine ChGLdisplay
Subroutine CHGLColorPalette()
! generate the default color palette
Implicit none
Real(4), dimension(4) :: c
Integer(4) i
iCR(0:10)=iWinCR(0:10,kWin)
iCG(0:10)=iWinCG(0:10,kWin)
iCB(0:10)=iWinCB(0:10,kWin)
if(iCHGLmode.gt.0_2) then
do i=0_4,235_4
call GetColorV(Int2(i),c)
call fglutSetColor(i,c(1),c(2),c(3))
end do
end if
end Subroutine CHGLColorPalette
subroutine GetColorV(iCi,c)
Implicit none
real(4), dimension(4) :: c
Integer(2) iCi,iC,ii,ired,igreen,iblue
c(1:3)=0.0
iC=Max(0_2,Min(235_2,iCi))
if(iC.lt.16_2) then
select case (iC)
case(0,2,5,6)
c(1)=1.0
case(9,10,13,14)
c(1)=0.5
end select
select case (iC)
case(0,3,5,7)
c(2)=1.0
case(9,11,13,15)
c(2)=0.5
end select
select case (iC)
case(0,4,6,7)
c(3)=1.0
case(9,12,14,15)
c(3)=0.5
end select
else if(iC.lt.116_2) then
ii=(iC-16_2)/10_2
ired= iCR(ii)+(iCR(ii+1_2)-iCR(ii))*(iC-10_2*ii-16_2)/10_2
igreen=iCG(ii)+(iCG(ii+1_2)-iCG(ii))*(iC-10_2*ii-16_2)/10_2
iblue= iCB(ii)+(iCB(ii+1_2)-iCB(ii))*(iC-10_2*ii-16_2)/10_2
ired=min(255_2,max(0_2,ired))
igreen=min(255_2,max(0_2,igreen))
iblue=min(255_2,max(0_2,iblue))
c(1)=float(ired)/255.0
c(2)=float(igreen)/255.0
c(3)=float(iblue)/255.0
else if(iC.lt.216_2) then
ii=(iC-116_2)/10_2
ired= iCR(ii)+(iCR(ii+1_2)-iCR(ii))*(iC-10_2*ii-116_2)/10_2
igreen=iCG(ii)+(iCG(ii+1_2)-iCG(ii))*(iC-10_2*ii-116_2)/10_2
iblue= iCB(ii)+(iCB(ii+1_2)-iCB(ii))*(iC-10_2*ii-116_2)/10_2
ired=255_2-min(255_2,max(0_2,ired))
igreen=255_2-min(255_2,max(0_2,igreen))
iblue=255_2-min(255_2,max(0_2,iblue))
c(1)=float(ired)/255.0
c(2)=float(igreen)/255.0
c(3)=float(iblue)/255.0
else
ired=(iC-215_2)*12_2
ired=min(255_2,max(0_2,ired))
c(1)=float(ired)/255.0
c(2)=c(1)
c(3)=c(1)
end if
c(4)=1.0
end subroutine GetColorV
subroutine CHGLSetColorI(iCi,iCj)
Implicit none
Integer(2) iCi
Integer(2), Optional :: iCj
Integer(4) ic(3)
Real(4), dimension(4) :: c
call fglIndexS(iCi)
if(iCHGLmode.gt.0_2) then
ic=0
ic(1:3)=Int(iCi)
call fglMaterialiv(GL_FRONT,GL_COLOR_INDEXES,ic)
if(Present(iCj)) ic(1:3)=Int(iCj)
call fglMaterialiv(GL_BACK,GL_COLOR_INDEXES,ic)
else
call GetColorV(iCi,c)
call fglMaterialfv(GL_FRONT,GL_AMBIENT_AND_DIFFUSE,c)
call fglMaterialfv(GL_FRONT,GL_EMISSION,c)
if(Present(iCj)) call GetColorV(iCj,c)
call fglMaterialfv(GL_BACK,GL_AMBIENT_AND_DIFFUSE,c)
call fglMaterialfv(GL_BACK,GL_EMISSION,c)
end if
end subroutine CHGLSetColorI
subroutine CHGLSetColorR(fi,fj)
Implicit none
real(8) fi,f
real(8), Optional :: fj
Integer(2) iC,jC
f=Max(0.0d0,Min(1.0d0,fi))
if(iCHGLrColorMax.ge.iCHGLrColorMin) then
iC=min(iCHGLrColorMax,iCHGLrColorMin+Int2(f*Dble(iCHGLrColorMax-iCHGLrColorMin)))
else
iC=min(iCHGLrColorMin,iCHGLrColorMax+Int2((1.0d0-f)*Dble(iCHGLrColorMin-iCHGLrColorMax)))
end if
if(Present(fj)) then
f=Max(0.0d0,Min(1.0d0,fj))
if(iCHGLrColorMax.ge.iCHGLrColorMin) then
jC=min(iCHGLrColorMax,iCHGLrColorMin+Int2(f*Dble(iCHGLrColorMax-iCHGLrColorMin)))
else
jC=min(iCHGLrColorMin,iCHGLrColorMax+Int2((1.0d0-f)*Dble(iCHGLrColorMin-iCHGLrColorMax)))
end if
call CHGLSetColorI(iC,jC)
else
call CHGLSetColorI(iC)
end if
end subroutine CHGLSetColorR
! draw
subroutine CHGLDrawAxes
! draw x,y,z axes
implicit none
real(4) wi
call OutTxt('t2','OGL Axes'C)
call OutTxt('n2',' 'C)
call OutTxt('m2',' 'C)
call OutTxt('t1',' 'C)
call OutTxt('n1',' 'C)
call OutTxt('m1',' 'C)
nCHGLlists=max(1,nCHGLlists)
call fglNewList(1,GL_COMPILE)
call fglDepthRange(0.0,1.0)
wi=CHGLxAxisW
call fglLineWidth(wi)
call fglBegin(GL_QUADS) !TRIANGLES)
! call fglIndexi(1)
call fglColor3f(1.0, 0.0, 0.0)
call fglVertex3d(1.0d0,0.0d0,0.5d0)
! call fglIndexi(2)
call fglColor3f(0.0, 1.0, 0.0)
call fglVertex3d(0.0d0,1.0d0,0.5d0)
! call fglIndexi(3)
call fglColor3f(0.0, 0.0, 1.0)
call fglVertex3d(-1.0d0,0.0d0,0.0d0)
! call fglIndexi(3)
call fglColor3f(0.0, 0.0, 0.0)
call fglVertex3d(0.0d0,-1.0d0,0.0d0)
! call fglIndexi(1)
call fglColor3f(1.0, 1.0, 0.0)
call fglVertex3d(1.0d0,0.5d0,0.0d0)
! call fglIndexi(2)
call fglColor3f(0.0, 1.0, 1.0)
call fglVertex3d(0.5d0,1.0d0,0.0d0)
! call fglIndexi(3)
call fglColor3f(1.0, 0.0, 1.0)
call fglVertex3d(-1.0d0,0.5d0,0.5d0)
! call fglIndexi(3)
call fglColor3f(0.0, 0.0, 0.0)
call fglVertex3d(0.5d0,-1.0d0,0.5d0)
call fglEnd
call CHGLSetColorI(iCHGLxAxisColor)
call fglBegin(GL_LINES)
call SetVertex(CHGLxAxisL,0.0d0,0.0d0,0.0d0)
call SetVertex(CHGLxAxisL,1.0d0,0.0d0,0.0d0)
call SetVertex(CHGLxAxisL,1.05d0,-0.05d0,0.05d0)
call SetVertex(CHGLxAxisL,1.05d0,0.05d0,-0.05d0)
call SetVertex(CHGLxAxisL,1.05d0,-0.05d0,-0.05d0)
call SetVertex(CHGLxAxisL,1.05d0,0.05d0,0.05d0)
call fglEnd
wi=CHGLyAxisW
call fglLineWidth(wi)
call CHGLSetColorI(iCHGLyAxisColor)
call fglBegin(GL_LINES)
call SetVertex(CHGLyAxisL,0.0d0,0.0d0,0.0d0)
call SetVertex(CHGLyAxisL,0.0d0,1.0d0,0.0d0)
call SetVertex(CHGLyAxisL,-0.05d0,1.05d0,0.05d0)
call SetVertex(CHGLyAxisL,0.0d0,1.05d0,0.0d0)
call SetVertex(CHGLyAxisL,0.05d0,1.05d0,0.05d0)
call SetVertex(CHGLyAxisL,0.0d0,1.05d0,0.0d0)
call SetVertex(CHGLyAxisL,0.0d0,1.05d0,0.0d0)
call SetVertex(CHGLyAxisL,0.0d0,1.05d0,-0.05d0)
call fglEnd
wi=CHGLzAxisW
call fglLineWidth(wi)
call CHGLSetColorI(iCHGLzAxisColor)
call fglBegin(GL_LINES)
call SetVertex(CHGLzAxisL,0.0d0,0.0d0,0.0d0)
call SetVertex(CHGLzAxisL,0.0d0,0.0d0,1.0d0)
call SetVertex(CHGLzAxisL,-0.05d0,0.05d0,1.05d0)
call SetVertex(CHGLzAxisL,0.05d0,0.05d0,1.05d0)
call SetVertex(CHGLzAxisL,0.05d0,0.05d0,1.05d0)
call SetVertex(CHGLzAxisL,-0.05d0,-0.05d0,1.05d0)
call SetVertex(CHGLzAxisL,-0.05d0,-0.05d0,1.05d0)
call SetVertex(CHGLzAxisL,0.05d0,-0.05d0,1.05d0)
call fglEnd
call fglLineWidth(1.0)
call fglEndList
call OutTxt('t2','OGL Axes end'C)
call OutTxt('n2',' 'C)
call OutTxt('m2',' 'C)
call OutTxt('t1',' 'C)
call OutTxt('n1',' 'C)
call OutTxt('m1',' 'C)
end subroutine CHGLDrawAxes
subroutine CHGLDrawSurfaces()
! draw surfaces
Implicit None
Real(8) fmin,fmax,fl,fb,r4(3,4),dmin,rNmin(3),val(2)
Integer(4) i,j,k,ik,jk,ikn,lout
Integer(2) iC,jC,iCmi,iCma
call OutTxt('t2','OGL Surf Obj'C)
call OutTxt('n2',' 'C)
call OutTxt('m2',' 'C)
call OutTxt('t1','ny'C)
call OutTxt('n1',' 'C)
call OutTxt('m1',' 'C)
if(iObjDra.eq.3) then ! error
fmin=0.0d0
fmax=1.0d0
else
fmin=CHGLSurfaceMinF
fmax=CHGLSurfaceMaxF
end if
nCHGLlists=max(2,nCHGLlists)
call fglNewList(2,GL_COMPILE)
call fglDepthRange(0.0d0,1.0d0)
jk=1
do j=1,nObjWeb
call IntToStr(j,0,0,SpaceText,lout)
call OutTxt('n2',SpaceText(1:lout))
call IntToStr(Int4(nObjWeb),0,0,SpaceText,lout)
call OutTxt('m2',SpaceText(1:lout))
if(lObjFlg.and.(j.eq.nObjWeb)) then
fmin=CHGLSurfaceMinF
fmax=CHGLSurfaceMaxF
end if
ik=jk
jk=jk+nxObjWeb(j)*nyObjWeb(j)
if(iCObjWeb(j).eq.-30001_2) Cycle ! transparent
if(iCObjWeb(j).gt.-30001_2) then ! object colors
call unPackObjC(1.0d0,iCObjWeb(j),iCmi,iCma)
call CHGLSetColorI(iCmi,iCma)
else if(iCObjWeb(j).eq.-30002_2) then ! domain colors
call unPackDom(1.0d0,iObjWeb(ik),iCmi,iCma)
if(iCmi.lt.0) call DistPtObj(0_2,0_2,BndPt3D(1:3,0,ik),.true.,dmin,rNmin,iCmi,val,.true.)
if(iCma.lt.0) call DistPtObj(0_2,0_2,BndPt3D(1:3,0,ik),.true.,dmin,rNmin,iCma,val,.true.)
iC=iDom(max(0_2,iCmi))
jC=iDom(max(0_2,iCma))
call CHGLSetColorI(iC,jC)
end if
do k=1,nyObjWeb(j)-1
call IntToStr(k,0,0,SpaceText,lout)
call OutTxt('n1',SpaceText(1:lout))
call IntToStr(nyObjWeb(j)-1,0,0,SpaceText,lout)
call OutTxt('m1',SpaceText(1:lout))
call fglBegin(GL_TRIANGLE_STRIP)
do i=1,nxObjWeb(j)
if(iCObjWeb(j).eq.-30002_2) then ! domain colors
call unPackDom(1.0d0,iObjWeb(ik),iCmi,iCma)
if(iCmi.lt.0) then
call DistPtObj(0_2,0_2,ObjWeb(1:3,ik),.true.,dmin,rNmin,iCmi,val,.true.)
if(iCma.lt.0) iCma=iCmi
else if(iCma.lt.0) then
call DistPtObj(0_2,0_2,ObjWeb(1:3,ik),.true.,dmin,rNmin,iCma,val,.true.)
end if
iC=iDom(max(0_2,iCmi))
jC=iDom(max(0_2,iCma))
call CHGLSetColorI(iC,jC)
else if(iCObjWeb(j).lt.-30002_2) then ! error or field
fl=(ObjWebF(ik)-fmin)/(fmax-fmin)
fb=fl
call CHGLSetColorR(fl,fb)
end if
call SetVertex(1.0d0,ObjWeb(1,ik),ObjWeb(2,ik),ObjWeb(3,ik))
ikn=ik+nxObjWeb(j)
if(iCObjWeb(j).eq.-30002_2) then ! domain colors
call unPackDom(1.0d0,iObjWeb(ikn),iCmi,iCma)
if(iCmi.lt.0) then
call DistPtObj(0_2,0_2,ObjWeb(1:3,ikn),.true.,dmin,rNmin,iCmi,val,.true.)
if(iCma.lt.0) iCma=iCmi
else if(iCma.lt.0) then
call DistPtObj(0_2,0_2,ObjWeb(1:3,ikn),.true.,dmin,rNmin,iCma,val,.true.)
end if
iC=iDom(max(0_2,iCmi))
jC=iDom(max(0_2,iCma))
call CHGLSetColorI(iC,jC)
else if(iCObjWeb(j).lt.-30002_2) then ! error or field
fl=(ObjWebF(ikn)-fmin)/(fmax-fmin)
fb=fl
call CHGLSetColorR(fl,fb)
end if
call SetVertex(1.0d0,ObjWeb(1,ikn),ObjWeb(2,ikn),ObjWeb(3,ikn))
ik=ik+1
end do
call fglEnd()
end do
end do
if(lObjMat.and.(nBndPt3D.gt.0)) then ! matching points
call OutTxt('t2','OGL Surf'C)
call OutTxt('n2',' 'C)
call OutTxt('m2',' 'C)
call OutTxt('t1','Mat.Point'C)
call OutTxt('n1',' 'C)
call OutTxt('m1',' 'C)
ik=1
if(iObjDra.eq.2) then ! domain colors
call unPackDom(1.0d0,iBndPt3D(ik),iCmi,iCma)
if(iCmi.lt.0) then
call DistPtObj(0_2,0_2,ObjWeb(1:3,ikn),.true.,dmin,rNmin,iCmi,val,.true.)
if(iCma.lt.0) iCma=iCmi
else if(iCma.lt.0) then
call DistPtObj(0_2,0_2,ObjWeb(1:3,ikn),.true.,dmin,rNmin,iCma,val,.true.)
end if
iC=iDom(max(0_2,iCmi))
jC=iDom(max(0_2,iCma))
call CHGLSetColorI(iC,jC)
else if(iObjDra.eq.0) then ! object colors
call unPackObjC(1.0d0,iBndPt3D(ik),iC,jC)
iC=max(iC,0)
jC=max(jC,0)
call CHGLSetColorI(iC,jC)
else if(iObjDra.eq.3) then ! error
fmin=0.0d0
fmax=1.0d0
end if
! call fglBegin(GL_QUADS) !!! WHY???
do ik=1,nBndPt3D
if(iObjDra.eq.1) Cycle ! transparent
if(.not.lgcFld) then
if(iObjBndPt3D(ik).lt.0) Cycle
end if
call IntToStr(ik,0,0,SpaceText,lout)
call OutTxt('n1',SpaceText(1:lout))
call IntToStr(nBndPt3D,0,0,SpaceText,lout)
call OutTxt('m1',SpaceText(1:lout))
if(iObjDra.gt.2) then ! error or field
fl=(BndPt3DF(ik)-fmin)/(fmax-fmin)
fb=fl
call CHGLSetColorR(fl,fb)
else if(iObjDra.eq.2) then ! domain colors
call unPackDom(1.0d0,iBndPt3D(ik),iCmi,iCma)
if(iCmi.lt.0) then
call DistPtObj(0_2,0_2,ObjWeb(1:3,ikn),.true.,dmin,rNmin,iCmi,val,.true.)
if(iCma.lt.0) iCma=iCmi
else if(iCma.lt.0) then
call DistPtObj(0_2,0_2,ObjWeb(1:3,ikn),.true.,dmin,rNmin,iCma,val,.true.)
end if
iC=iDom(max(0_2,iCmi))
jC=iDom(max(0_2,iCma))
call CHGLSetColorI(iC,jC)
else if(iObjDra.eq.0) then ! object colors
call unPackObjC(1.0d0,iBndPt3D(ik),iC,jC)
iC=max(iC,0)
jC=max(jC,0)
call CHGLSetColorI(iC,jC)
end if
r4(1:3,1)=BndPt3D(1:3,0,ik)-0.5d0*(BndPt3D(1:3,1,ik)+BndPt3D(1:3,2,ik))
r4(1:3,2)=r4(1:3,1)+BndPt3D(1:3,1,ik)
r4(1:3,3)=r4(1:3,2)+BndPt3D(1:3,2,ik)
r4(1:3,4)=r4(1:3,3)-BndPt3D(1:3,1,ik)
call fglBegin(GL_QUADS)
call SetVertex(1.0d0,r4(1,1),r4(2,1),r4(3,1))
call SetVertex(1.0d0,r4(1,2),r4(2,2),r4(3,2))
call SetVertex(1.0d0,r4(1,3),r4(2,3),r4(3,3))
call SetVertex(1.0d0,r4(1,4),r4(2,4),r4(3,4))
call fglEnd()
end do
! call fglEnd()
end if
call fglLineWidth(1.0)
call fglEndList
call OutTxt('t2','OGL Surf end'C)
call OutTxt('n2',' 'C)
call OutTxt('m2',' 'C)
call OutTxt('t1',' 'C)
call OutTxt('n1',' 'C)
call OutTxt('m1',' 'C)
end subroutine CHGLDrawSurfaces
subroutine CHGLDrawGrids
! draw grid
Implicit None
Integer(4) i,j,k,ik,jk,lout
Integer(2) kOb
Real(8) r4(3,4)