Repository navigation
Expand file tree
/
Copy pathplot.f90
More file actions
2569 lines (2482 loc) · 109 KB
/
Copy pathplot.f90
File metadata and controls
2569 lines (2482 loc) · 109 KB
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
module plot
use defvar
use dislin
use util
implicit real*8 (a-h,o-z)
contains
!!!------------- Draw molecular structure and show isosurface of orbitals or grid data
!Also draw topology analysis results, surface extrema, basin or domain space etc.
subroutine drawmol
use topo
use surfvertex
use basinintmod
implicit real*8 (a-h,o-z)
integer i,j,idxtmp,iret,screenx,screeny,ipath,ipathp1,ipt,icp1,icp2,ipathtype,ipathmidpt,isurf,interval
real*8 abslenx,absleny,abslenz,plotlenx,plotleny,plotlenz !absolute and real 3D coordinate
real*8 plot2abs,xplotcoor,yplotcoor,absx,absy,absz,dist,textheighmod,extsiz,augplotlen
real*8 trianglex(3),triangley(3),trianglez(3)
real*8 arrayx(nx),arrayy(ny),arrayz(nz)
character ctemp*5,c80tmp*80
!Set viewpoint
!Note that due to limitation of DISLIN, it is not possible to view molecule in all viewpoints. The YVU should be limited to between -90 and 90, else the viewpoint will suddently flip
XVUold=XVU
YVUold=YVU
if (YVU==90) YVU=89.999D0 !Temporarily modify YVU, otherwise when YVU equals 90 or -90, the perspective will jump suddenly
if (YVU==-90) YVU=-89.999D0
!Determine x/y/zlow, x/y/zhigh and plotlenx/y/z, which are lower, upper positions and length of the axis
if (ifPBC>0) then !For PBC case, make the axes large enough to show all atoms
call cellminxyz(xmin,ymin,zmin)
xlow=min(xmin-3,minval(a%x)-3)
ylow=min(ymin-3,minval(a%y)-3)
zlow=min(zmin-3,minval(a%z)-3)
call cellmaxxyz(xmax,ymax,zmax)
xhigh=max(xmax+3,maxval(a%x)+3)
yhigh=max(ymax+3,maxval(a%y)+3)
zhigh=max(zmax+3,maxval(a%z)+3)
plotlenx=xhigh-xlow
plotleny=yhigh-ylow
plotlenz=zhigh-zlow
else if (ifiletype==7.or.ifiletype==8) then !For cub/grd/cube/vti file, make the axis able to show entire grid data
call gridminxyz(xmin,ymin,zmin)
call gridmaxxyz(xmax,ymax,zmax)
xlow=xmin-1
ylow=ymin-1
zlow=zmin-1
xhigh=xmax+1
yhigh=ymax+1
zhigh=zmax+1
plotlenx=xhigh-xlow
plotleny=yhigh-ylow
plotlenz=zhigh-zlow
else !Other cases, determine displayed spatial scope by boundary atoms of the system
!Determine axis range
augplotlen=8D0 !Common augmentation of plotting axis length (the sum of both direction)
if (GUI_mode==4.and.ifunctopo==25) augplotlen=24D0 !Minima of vdW potential are often very far from atoms, use larger augmentation
if (GUI_mode==5) augplotlen=12D0 !Because surface extreme points laying on vdW surface, the scatter region is large, so use larger augmentation
if (GUI_mode==7) augplotlen=12D0 !Using GUI to set box, the case is complicated, so use larger augmentation
if ((idrawisosur==1.and.aug3D>4).or.GUI_mode==6) augplotlen=aug3D*2.2D0 !Shouldn't be 2.0 as expected, otherwise sometimes there will be a band occuring at boundary
!Below comment and code are redundant, ignore them...
!Commonly, augment distances in all side are idential. However, for very long chain system, the molecule cannot be displayed unless ZVU is first set to
!fairly large value, namely extremely zooming out. To circumvent this problem, we first calculate geometric average in X,Y,Z (Davg)
!if ratio between molecular size in any direction and Davg is by far lower than a threshold, then we make all axis lengths identical to the longest one,
!in this case the molecule must be able to be shown
xmolsize=maxval(a%x)-minval(a%x)
ymolsize=maxval(a%y)-minval(a%y)
zmolsize=maxval(a%z)-minval(a%z)
!avgD=(xmolsize*ymolsize*zmolsize)**(1D0/3D0)
!ratiox=xmolsize/avgD
!ratioy=ymolsize/avgD
!ratioz=zmolsize/avgD
!thresratio=0.2D0
!write(*,*) xmolsize, ymolsize, zmolsize,augplotlen
!if (xmolsize<thresratio .or. ymolsize<thresratio .or. zmolsize<thresratio) then
! rlong=max(max(xmolsize,ymolsize),zmolsize)
! augplotlenx=augplotlen+(rlong-xmolsize)/2
! augplotleny=augplotlen+(rlong-ymolsize)/2
! augplotlenz=augplotlen+(rlong-zmolsize)/2
!else
augplotlenx=augplotlen
augplotleny=augplotlen
augplotlenz=augplotlen
!end if
xlow=minval(a%x)-augplotlenx/2
ylow=minval(a%y)-augplotleny/2
zlow=minval(a%z)-augplotlenz/2
plotlenx=xmolsize+augplotlenx
plotleny=ymolsize+augplotleny
plotlenz=zmolsize+augplotlenz
xhigh=xlow+plotlenx
yhigh=ylow+plotleny
zhigh=zlow+plotlenz
end if
!Initialize DISLIN
abslenx=2D0 !Absolute length in DISLIN
absleny=abslenx*plotleny/plotlenx
abslenz=abslenx*plotlenz/plotlenx
plot2abs=abslenx/plotlenx !The relationship between molecular coordinate and absolute coordinate
if (isavepic==0) then
call METAFL('CONS')
if (GUI_mode==6) call METAFL('CONS') !Namely showing basin, using opengl by default to accelerate displaying, however when savepic, if still use opengl, things cannot be properly shown
CALL setxid(idisgraph,'WIDGET')
else if (isavepic==1) then
if (iorbvis==0) then
call setfil("dislin."//trim(graphformat))
else
write(c80tmp,"(i6.6,'.',a)") iorbvis,trim(graphformat)
call setfil(trim(c80tmp))
end if
CALL setxid(0,'NONE')
call METAFL(graphformat)
call winsiz(graph3Dwidth,graph3Dheight) !Actual image size is set by this routine, namely 770*770
end if
CALL SCRMOD('revers')
CALL PAGE(3000,3000)
CALL IMGFMT("RGB") !If don't call this routine, the saved picture use palette color mode by default, the color is not smooth
CALL DISINI
CALL ORIGIN(ORIGIN_3D_X,ORIGIN_3D_Y) !Set origin of the map
if (iorthoview==0) then
CALL PROJ3D("PERSPECTIVE")
call VANG3D(VANG3DANG)
else if (iorthoview==1) then
CALL PROJ3D("ORTHO")
end if
CALL VFOC3D(XFOC,YFOC,ZFOC,"ABS")
CALL VUP3D(camrotang)
call ERRMOD("ALL","OFF")
! call linmod("ON","SMOOTH") !It seems that Anti-aliased doesn't take effect
CALL LABDIG(1,"X")
CALL LABDIG(1,"Y")
CALL LABDIG(1,"Z")
if (ishowaxis==0) call NOGRAF
CALL VIEW3D(XVU,YVU,ZVU,"ANGLE")
if (iorthoview==1) call vscl3d(XFAC)
CALL erase
!Set font
if (isavepic==0.or.graphformat=="pdf ") then
CALL HWFONT
else if (isavepic==1) then
if (ttfontfile=="none") then
CALL HELVES
else
CALL TTFONT(ttfontfile)
end if
CALL SHDCHA
end if
if (isavepic==0.and.isys==1) then
call height(60)
CALL HNAME(60)
else
call height(50)
CALL HNAME(50)
end if
!Set axis
CALL NAME('X-axis (Bohr)','X')
CALL NAME('Y-axis (Bohr)','Y')
CALL NAME('Z-axis (Bohr)','Z')
CALL NAMDIS(100,'XYZ')
call axis3D(abslenx,absleny,abslenz)
CALL AXSPOS(400,2600)
CALL AX3LEN(2600,2600,2600)
call labl3D("horizontal")
CALL LIGHT('on')
CALL SHDMOD('SMOOTH','SURFACE') !By default, each surface triangle has the same color and thus doesn't look smooth
nsclx=8
spcx=ceiling(plotlenx/nsclx) !Expected step size in X
spcy=ceiling(plotleny/ (plotleny/plotlenx*nsclx) )
spcz=ceiling(plotlenz/ (plotlenz/plotlenx*nsclx) /1.5D0 )
shiftx=mod(xlow,spcx) !Shift the initial point of the axis to make a label just occur at 0.0
shifty=mod(ylow,spcy)
shiftz=mod(zlow,spcz)
! CALL FLAB3D !If use this, the starting label of Y and Z axis will be plotted, however this may suppress the starting label of X axis
CALL GRAF3D(xlow,xhigh,xlow-shiftx,spcx, ylow,yhigh,ylow-shifty,spcy, zlow,zhigh,zlow-shiftz,spcz)
if (ishowaxis==1) CALL GRID3D (2,2,'bottom')
CALL ZBFINI(IRET) !Enable Z-buffer to determine visibility
call litpos(1,XVU,YVU,ZVU,'ANGLE')
call litmod(1,'on') !Dislin default light 1 is on, and off for others
!Construct global array a_tmp, for non-PBC system it is the same as a, while for PBC case it contains real atoms and replicated boundary atoms
if (idrawmol==1.or.ishowatmlab==1) then
if (ishowboundaryatom==1.and.ifPBC>0) then
call construct_atmp_withbound(ncenter_tmp)
else
if (allocated(a_tmp)) deallocate(a_tmp)
ncenter_tmp=ncenter
allocate(a_tmp(ncenter),a_tmp_idx(ncenter))
a_tmp=a
forall(i=1:ncenter) a_tmp_idx(i)=i
end if
end if
if (idrawmol==1) then
do ilight=2,8
call litmod(ilight,'off')
end do
!Draw atoms
do i=1,ncenter_tmp
if (ishowhydrogen==0.and.a_tmp(i)%index==1) cycle
CALL MATOP3(atm3Dclr(a_tmp(i)%index,1),atm3Dclr(a_tmp(i)%index,2),atm3Dclr(a_tmp(i)%index,3),'diffuse')
if (allocated(highlightatomlist)) then
if (any(highlightatomlist==i)) CALL MATOP3(0.3D0,1D0,1D0,'diffuse')
end if
if (a_tmp(i)%index/=0) then !Normal atoms
if (isavepic==1) then
CALL SPHE3D(a_tmp(i)%x,a_tmp(i)%y,a_tmp(i)%z,vdwr(a_tmp(i)%index)/4*ratioatmsphere,40,40)
else !Resolution of 30,30 is nearly perfect. For large system lower the resolution for faster view
if (ncenter_tmp<100) then
CALL SPHE3D(a_tmp(i)%x,a_tmp(i)%y,a_tmp(i)%z,vdwr(a_tmp(i)%index)/4*ratioatmsphere,30,30)
else if (ncenter_tmp<300) then
CALL SPHE3D(a_tmp(i)%x,a_tmp(i)%y,a_tmp(i)%z,vdwr(a_tmp(i)%index)/4*ratioatmsphere,20,20)
else
CALL SPHE3D(a_tmp(i)%x,a_tmp(i)%y,a_tmp(i)%z,vdwr(a_tmp(i)%index)/4*ratioatmsphere,10,10)
end if
end if
else !Bq atoms. The size keeps fixed
CALL SPHE3D(a_tmp(i)%x,a_tmp(i)%y,a_tmp(i)%z,vdwr(a_tmp(i)%index)/4,20,20)
end if
end do
!Draw bonds. If connectivity is available, then do not automatically determine bonding
CALL MATOP3(bondclrR,bondclrG,bondclrB,'diffuse')
if (allocated(connmat)) then !Note that when using defined connectivity, bonds for boundary atoms will not be plotted
do i=1,ncenter
do j=i+1,ncenter
if (ishowhydrogen==0.and.(a(i)%index==1.or.a(j)%index==1)) cycle
if (a(i)%index==0.or.a(j)%index==0) cycle !Never make Bq atoms bonding
if (connmat(i,j)/=0) then
if (ncenter<100.or.isavepic==1) then
CALL TUBE3D(a(i)%x,a(i)%y,a(i)%z,a(j)%x,a(j)%y,a(j)%z,bondradius,20,20) !Resolution of 20,20 is visually perfect
else if (ncenter<300) then
CALL TUBE3D(a(i)%x,a(i)%y,a(i)%z,a(j)%x,a(j)%y,a(j)%z,bondradius,15,15)
else
CALL TUBE3D(a(i)%x,a(i)%y,a(i)%z,a(j)%x,a(j)%y,a(j)%z,bondradius,8,8)
end if
end if
end do
end do
else
do i=1,ncenter_tmp
do j=i+1,ncenter_tmp
if (ishowhydrogen==0.and.(a_tmp(i)%index==1.or.a_tmp(j)%index==1)) cycle
if (a_tmp(i)%index==0.or.a_tmp(j)%index==0) cycle !Never make bonding
dist=dsqrt( (a_tmp(i)%x-a_tmp(j)%x)**2+(a_tmp(i)%y-a_tmp(j)%y)**2+(a_tmp(i)%z-a_tmp(j)%z)**2 )
!If the distance between two atoms exceeds 15% of sum of their covalent radii, they will be seemed to be not bonded
if (dist<( covr(a_tmp(i)%index)+covr(a_tmp(j)%index) )*bondcrit) then
if (ncenter_tmp<100.or.isavepic==1) then
CALL TUBE3D(a_tmp(i)%x,a_tmp(i)%y,a_tmp(i)%z,a_tmp(j)%x,a_tmp(j)%y,a_tmp(j)%z,bondradius,20,20) !Resolution of 20,20 is visually perfect
else if (ncenter_tmp<300) then
CALL TUBE3D(a_tmp(i)%x,a_tmp(i)%y,a_tmp(i)%z,a_tmp(j)%x,a_tmp(j)%y,a_tmp(j)%z,bondradius,15,15)
else
CALL TUBE3D(a_tmp(i)%x,a_tmp(i)%y,a_tmp(i)%z,a_tmp(j)%x,a_tmp(j)%y,a_tmp(j)%z,bondradius,8,8)
end if
end if
end do
end do
end if
end if
!Draw critical points
if (ishow3n3==1.or.ishow3n1==1.or.ishow3p1==1.or.ishow3p3==1) then
numcp_tmp=numcp
CPpos_tmp=CPpos
CPtype_tmp=CPtype
forall(i=1:numCP) CP_tmp_idx(i)=i
if (ishowboundarytopo==1.and.ifPBC>0) call construct_CPtmp_withbound(numcp_tmp)
end if
if (ishow3n3==1) then
CALL MATOP3(CP3n3RGB(1),CP3n3RGB(2),CP3n3RGB(3),'diffuse') !Purple
do i=1,numcp_tmp
if (CPtype_tmp(i)==1) CALL SPHE3D(CPpos_tmp(1,i),CPpos_tmp(2,i),CPpos_tmp(3,i),0.15D0*ratioCPsphere,20,20)
end do
end if
if (ishow3n1==1) then
CALL MATOP3(CP3n1RGB(1),CP3n1RGB(2),CP3n1RGB(3),'diffuse') !Orange
do i=1,numcp_tmp
if (CPtype_tmp(i)==2) CALL SPHE3D(CPpos_tmp(1,i),CPpos_tmp(2,i),CPpos_tmp(3,i),0.1D0*ratioCPsphere,20,20)
end do
end if
if (ishow3p1==1) then
CALL MATOP3(CP3p1RGB(1),CP3p1RGB(2),CP3p1RGB(3),'diffuse') !Yellow
do i=1,numcp_tmp
if (CPtype_tmp(i)==3) CALL SPHE3D(CPpos_tmp(1,i),CPpos_tmp(2,i),CPpos_tmp(3,i),0.1D0*ratioCPsphere,20,20)
end do
end if
if (ishow3p3==1) then
CALL MATOP3(CP3p3RGB(1),CP3p3RGB(2),CP3p3RGB(3),'diffuse') !Green
do i=1,numcp_tmp
if (CPtype_tmp(i)==4) CALL SPHE3D(CPpos_tmp(1,i),CPpos_tmp(2,i),CPpos_tmp(3,i),0.1D0*ratioCPsphere,20,20)
end do
end if
!Show trace of movement to attractor in basin generating process. If you want to enable this, move declaration of "ntrjgrid" and "trjgrid" from "generatebasin" to basinintmod
! CALL MATOP3(0.1D0, 0.5D0, 0.85D0, 'diffuse')
! do igrd=2,ntrjgrid
! attx=orgx+(trjgrid(igrd,1)-1)*dx
! atty=orgy+(trjgrid(igrd,2)-1)*dy
! attz=orgz+(trjgrid(igrd,3)-1)*dz
! CALL SPHE3D(attx,atty,attz,0.05D0,20,20)
! call tube3D(attx,atty,attz,orgx+(trjgrid(igrd-1,1)-1)*dx,orgy+(trjgrid(igrd-1,2)-1)*dy,orgz+(trjgrid(igrd-1,3)-1)*dx,0.015D0,30,30)
! end do
!For basin integration analysis
if (numatt>0.and.ishowatt==1) then
!Draw attractors
do iatt=1,numatt
if (attval(iatt)>=0) then
CALL MATOP3(0.65D0, 0.9D0, 0.45D0, 'diffuse')
else
CALL MATOP3(0.35D0, 0.7D0, 0.9D0, 'diffuse')
end if
CALL SPHE3D(attxyz(1,iatt),attxyz(2,iatt),attxyz(3,iatt),attsphsize,20,20)
end do
!Draw basin
if (idrawbasinidx/=-10) then !-10 means don't draw basins
if (idrawbasinidx<=0) then !Positive basin or the basins consist of boundary or unassigned grids
CALL MATOP3(0D0, 0.8D0, 0D0, 'diffuse') !Green
else if (realattval(idrawbasinidx)>=0) then
CALL MATOP3(0D0, 0.8D0, 0D0, 'diffuse') !Green
else !Negative basins
CALL MATOP3(0.3D0, 0.6D0, 1D0, 'diffuse') !Light blue
end if
if (basinsphsize==0) then !Sphere size has not been initialized
call calc_dvol(dvol)
!Convert grid volume to effective radius: dvol=3/4*pi*r^3, so r=(dvol*4/3/pi)**(1D0/3D0)
basinsphsize=(dvol*4/3/pi)**(1D0/3D0)*1.2D0 !1.2 is used to slightly enhance to fully fill the grid
!basinsphsize=dsqrt(dx**2+dy**2+dz**2)/2D0 !Not suitable for non-orthogonal grid
end if
do iz=2,nz-1
do iy=2,ny-1
do ix=2,nx-1
if (gridbas(ix,iy,iz)==idrawbasinidx) then
call getgridxyz(ix,iy,iz,tmpx,tmpy,tmpz)
if (ishowbasinmethod==1) then !Entire basin
if (interbasgrid(ix,iy,iz)) CALL SPHE3D(tmpx,tmpy,tmpz,basinsphsize,4,4) !Show sphere of interbasin grids
if (idrawinternalbasin==1) then !Draw quad at box boundary to shield internal region of basin
if (ix==2.or.ix==nx-1.or.iy==2.or.iy==ny-1.or.iz==2.or.iz==nz-1) CALL QUAD3D(tmpx,tmpy,tmpz,dx,dy,dz)
end if
else if (ishowbasinmethod==2) then !Basin within vdW surface
if (rhocub(ix,iy,iz)<0.001D0) cycle
if (interbasgrid(ix,iy,iz)) then !Interbasin grid
CALL SPHE3D(tmpx,tmpy,tmpz,basinsphsize,4,4)
else !Internal grid in the basin
if (idrawinternalbasin==1) CALL SPHE3D(tmpx,tmpy,tmpz,basinsphsize,4,4)
end if
end if
end if
end do
end do
end do
end if
end if
!Draw domain defined by isosurface as grids
if (idrawdomain==1.and.idrawdomainidx/=0) then
CALL MATOP3(0D0, 0.8D0, 0D0, 'diffuse') !Green
tmpsphrad=dsqrt(dx**2+dy**2+dz**2)/2D0
do igrd=1,domainsize(idrawdomainidx)
idx=domaingrid(igrd,idrawdomainidx)
CALL SPHE3D(gridxyz(1,idx),gridxyz(2,idx),gridxyz(3,idx),tmpsphrad,4,4)
end do
end if
!Draw topology paths
if (idrawpath==1) then
numpath_tmp=numpath
pathnumpt_tmp=pathnumpt
topopath_tmp=topopath
forall(i=1:numpath) path_tmp_idx(i)=i
if (ishowboundarytopo==1.and.ifPBC>0) call construct_pathtmp_withbound(numpath_tmp) !Generate paths at cell boundary
ntuberes=5
if (numpath_tmp>200) ntuberes=3 !For showing faster, use lower resolution
do ipath=1,numpath_tmp
call path_cp(path_tmp_idx(ipath),icp1,icp2,ipathtype)
!ipathtype=0: other =1: (3,-1)->(3,-3) =2: (3,+1)->(3,+3) =3: (3,-1)<-->(3,+1)
if (ipathtype==0) call MATOP3(0.8D0, 0.8D0, 0.8D0, 'diffuse')
if (ipathtype==1) call MATOP3(0.9D0, 0.7D0, 0.0D0, 'diffuse')
if (ipathtype==2) call MATOP3(0.2D0, 0.7D0, 0.2D0, 'diffuse')
if (ipathtype==3) call MATOP3(0.8D0, 0.8D0, 0.3D0, 'diffuse')
do ipt=2,pathnumpt_tmp(ipath)
xlast=topopath_tmp(1,ipt-1,ipath)
ylast=topopath_tmp(2,ipt-1,ipath)
zlast=topopath_tmp(3,ipt-1,ipath)
xthis=topopath_tmp(1,ipt,ipath)
ythis=topopath_tmp(2,ipt,ipath)
zthis=topopath_tmp(3,ipt,ipath)
dist=dsqrt((xlast-xthis)**2+(ylast-ythis)**2+(zlast-zthis)**2)
!If distance between two path points is very large, then the two points must cross box, so do not draw
if (dist<pathstepsize*2) CALL TUBE3D(xlast,ylast,zlast,xthis,ythis,zthis,0.03D0,ntuberes,ntuberes)
end do
end do
end if
!From now on, all objects plotted below use ambient of (1,1,1), which makes objects brighter than default (0.2,0.2,0.2)
call MATOP3(1D0,1D0,1D0,'ambient')
!Draw interbasin surfaces
if (idrawbassurf==1.and.numbassurf>0) then
if (isurfstyle==1) then !A bunch of paths to represent the interbasin surface
call MATOP3(0.7D0, 0.7D0, 0.8D0, 'diffuse')
do isurf=1,numbassurf
do ipath=1,nsurfpathpercp
do ipt=2,nsurfpt
CALL TUBE3D(bassurpath(1,ipt-1,ipath,isurf),bassurpath(2,ipt-1,ipath,isurf),bassurpath(3,ipt-1,ipath,isurf)&
,bassurpath(1,ipt,ipath,isurf),bassurpath(2,ipt,ipath,isurf),bassurpath(3,ipt,ipath,isurf),0.005D0,5,5)
end do
end do
end do
else if (isurfstyle==2) then !Use triangles to consist the interbasin surfaces
call MATOP3(IBSclrR, IBSclrG, IBSclrB, 'diffuse')
interval=2
do isurf=1,numbassurf
do ipath=1,nsurfpathpercp
ipathp1=ipath+1
if (ipath==nsurfpathpercp) ipathp1=1
do ipt=1,nsurfpt-interval,interval
!Use two triangle to comprise a tile of face. Define the two triangle in clockwise manner first
trianglex(:)=(/ bassurpath(1,ipt,ipath,isurf),bassurpath(1,ipt+interval,ipath,isurf),bassurpath(1,ipt+interval,ipathp1,isurf) /)
triangley(:)=(/ bassurpath(2,ipt,ipath,isurf),bassurpath(2,ipt+interval,ipath,isurf),bassurpath(2,ipt+interval,ipathp1,isurf) /)
trianglez(:)=(/ bassurpath(3,ipt,ipath,isurf),bassurpath(3,ipt+interval,ipath,isurf),bassurpath(3,ipt+interval,ipathp1,isurf) /)
call TRIA3D(trianglex,triangley,trianglez)
trianglex(:)=(/ bassurpath(1,ipt,ipath,isurf),bassurpath(1,ipt+interval,ipathp1,isurf),bassurpath(1,ipt,ipathp1,isurf) /)
triangley(:)=(/ bassurpath(2,ipt,ipath,isurf),bassurpath(2,ipt+interval,ipathp1,isurf),bassurpath(2,ipt,ipathp1,isurf) /)
trianglez(:)=(/ bassurpath(3,ipt,ipath,isurf),bassurpath(3,ipt+interval,ipathp1,isurf),bassurpath(3,ipt,ipathp1,isurf) /)
call TRIA3D(trianglex,triangley,trianglez)
!Define the two triangle in anti-clockwise manner. We must draw the surfaces two times from different view,
!otherwise the surface will be invisible from certain viewpoint
trianglex(:)=(/ bassurpath(1,ipt,ipath,isurf),bassurpath(1,ipt+interval,ipathp1,isurf),bassurpath(1,ipt+interval,ipath,isurf) /)
triangley(:)=(/ bassurpath(2,ipt,ipath,isurf),bassurpath(2,ipt+interval,ipathp1,isurf),bassurpath(2,ipt+interval,ipath,isurf) /)
trianglez(:)=(/ bassurpath(3,ipt,ipath,isurf),bassurpath(3,ipt+interval,ipathp1,isurf),bassurpath(3,ipt+interval,ipath,isurf) /)
call TRIA3D(trianglex,triangley,trianglez)
trianglex(:)=(/ bassurpath(1,ipt,ipath,isurf),bassurpath(1,ipt,ipathp1,isurf),bassurpath(1,ipt+interval,ipathp1,isurf) /)
triangley(:)=(/ bassurpath(2,ipt,ipath,isurf),bassurpath(2,ipt,ipathp1,isurf),bassurpath(2,ipt+interval,ipathp1,isurf) /)
trianglez(:)=(/ bassurpath(3,ipt,ipath,isurf),bassurpath(3,ipt,ipathp1,isurf),bassurpath(3,ipt+interval,ipathp1,isurf) /)
call TRIA3D(trianglex,triangley,trianglez)
end do
end do
end do
else if (isurfstyle==3) then !Use a lot of cylinders between adjacent paths to portray interbasin surfaces
call MATOP3(IBSclrR, IBSclrG, IBSclrB, 'diffuse')
do isurf=1,numbassurf
do ipath=1,nsurfpathpercp
ipathp1=ipath+1
if (ipath==nsurfpathpercp) ipathp1=1
do ipt=1,nsurfpt
CALL TUBE3D(bassurpath(1,ipt,ipath,isurf),bassurpath(2,ipt,ipath,isurf),bassurpath(3,ipt,ipath,isurf)&
,bassurpath(1,ipt,ipathp1,isurf),bassurpath(2,ipt,ipathp1,isurf),bassurpath(3,ipt,ipathp1,isurf),0.03D0,3,3)
end do
end do
end do
end if
end if
!Draw spheres corresponding to local minimum and maximum derived from molecular surface analysis
if (GUI_mode==5) then
if (ishowlocminpos==1) then
CALL MATOP3(0D0, 0D0, 1D0, 'diffuse') !Blue
do i=1,nsurlocmin
idxtmp=surlocminidx(i)
if (idxtmp==0) cycle !The extreme has already been discarded
CALL SPHE3D(survtx(idxtmp)%x,survtx(idxtmp)%y,survtx(idxtmp)%z,0.15D0,20,20)
end do
end if
if (ishowlocmaxpos==1) then
CALL MATOP3(1D0, 0D0, 0D0, 'diffuse') !Red
do i=1,nsurlocmax
idxtmp=surlocmaxidx(i)
if (idxtmp==0) cycle !The extreme has already been discarded
CALL SPHE3D(survtx(idxtmp)%x,survtx(idxtmp)%y,survtx(idxtmp)%z,0.15D0,20,20)
end do
end if
end if
!When isosur1style==5(transparent), isosur2style must be also 5. For transparent style, TPRINI/TPRFIN conflict with Z-buffer, so here we need to recall ZBFFIN earlier
!When one of isosur1style and isosur2style is unequal to 5, then another must not be 5. Overall, we ensure that the circumstance that only one isosurface is transparent will not occured
if (isosur1style==5) CALL ZBFFIN
if (idrawisosur==1) then
!Set lighting parameter for showing both isosurface 1 and 2
call litpos(1,XVU,YVU,ZVU,'ANGLE')
call litpos(2,XVU+90,YVU+90,ZVU,'ANGLE')
call litpos(3,XVU+90,YVU-90,ZVU,'ANGLE')
call litpos(4,XVU-90,YVU+90,ZVU,'ANGLE')
call litpos(5,XVU-90,YVU-90,ZVU,'ANGLE')
! call litpos(6,XVU+50,YVU,ZVU,'ANGLE')
! call litpos(7,XVU,YVU+50,ZVU,'ANGLE')
! call litpos(8,XVU-50,YVU,ZVU,'ANGLE')
! call litpos(8,-2*abslenx,2*absleny,2.5*abslenz,'ANGLE')
if (ienablelight1==1) call litmod(1,'on')
if (ienablelight2==1) call litmod(2,'on')
if (ienablelight3==1) call litmod(3,'on')
if (ienablelight4==1) call litmod(4,'on')
if (ienablelight5==1) call litmod(5,'on')
if (ienablelight1==0) call litmod(1,'off')
if (ienablelight2==0) call litmod(2,'off')
if (ienablelight3==0) call litmod(3,'off')
if (ienablelight4==0) call litmod(4,'off')
if (ienablelight5==0) call litmod(5,'off')
!Draw isosurface for cubmat
do ix=1,nx
arrayx(ix)=orgx+(ix-1)*gridv1(1)
end do
do iy=1,ny
arrayy(iy)=orgy+(iy-1)*gridv2(2)
end do
do iz=1,nz
arrayz(iz)=orgz+(iz-1)*gridv3(3)
end do
if (isosur1style==5) CALL TPRVAL(opacitycub1)
nplottime=1
if (isosurshowboth==1) nplottime=2 !Show both positive and negative regions
do iplottime=1,nplottime
CALL MATOP3(clrRcub1same,clrGcub1same,clrBcub1same,'diffuse') !Set color for solid isosurface 1 with the same sign of set isovalue
call setrgb(clrRcub1samemeshpt,clrGcub1samemeshpt,clrBcub1samemeshpt)
if (GUI_mode==1) then
sur_valuenow=sur_value_orb
else
sur_valuenow=sur_value
end if
if (iplottime==2) then
CALL MATOP3(clrRcub1oppo,clrGcub1oppo,clrBcub1oppo,'diffuse') !Set color for solid isosurface 1 with the opposite sign of set isovalue
call setrgb(clrRcub1oppomeshpt,clrGcub1oppomeshpt,clrBcub1oppomeshpt)
if (GUI_mode==1) then
sur_valuenow=-sur_value_orb
else
sur_valuenow=-sur_value
end if
end if
if (isosur1style==2) then !Plotted as mesh rather than solid face
call surmsh("LINES")
else if (isosur1style==-2) then !Plotted as mesh rather than solid face
if (iplottime==2) call surmsh("LINES") !Use mesh tyle only for negative part
end if
if (isosur1style==3) call surmsh("POINTS") !Plotted as points rather than solid face
if (isosur1style==4) then !Face+lines
call surmsh("ON")
else if (isosur1style==-4) then !Face+lines only for negative part
if (iplottime==2) call surmsh("ON")
end if
if (isosur1style==5) CALL TPRINI !Must be called individually for same and opposite survalue, else same part will completely overlay opposite part
call suriso(arrayx,nx,arrayy,ny,arrayz,nz,cubmat,sur_valuenow)
if (isosur1style==5) CALL TPRFIN
call surmsh("OFF") !If don't set this, then other things (atoms, bonds) will be drawn as LINES too
end do
!Draw isosurface for cubmattmp at the same time
if (isosur2style==5) CALL TPRVAL(opacitycub2)
if (isosursec==1.and.allocated(cubmattmp)) then
nplottime=1
if (isosurshowboth==1) nplottime=2 !Show both positive and negative region
do iplottime=1,nplottime
CALL MATOP3(clrRcub2same,clrGcub2same,clrBcub2same,'diffuse') !Set color for solid isosurface 2 with the same sign of set isovalue
call setrgb(clrRcub2samemeshpt,clrGcub2samemeshpt,clrBcub2samemeshpt)
if (GUI_mode==1) then
sur_valuenow=sur_value_orb
else
sur_valuenow=sur_value
end if
if (iplottime==2) then
CALL MATOP3(clrRcub2oppo,clrGcub2oppo,clrBcub2oppo,'diffuse') !Set color for solid isosurface 2 with the opposite sign of set isovalue
call setrgb(clrRcub2oppomeshpt,clrGcub2oppomeshpt,clrBcub2oppomeshpt)
if (GUI_mode==1) then
sur_valuenow=-sur_value_orb
else
sur_valuenow=-sur_value
end if
end if
if (isosur2style==2) call surmsh("LINES") !Plotted as mesh rather than solid face
if (isosur2style==3) call surmsh("POINTS") !Plotted as points rather than solid face
if (isosur2style==4) call surmsh("ON") !face+lines
if (isosur1style==5) CALL TPRINI
call suriso(arrayx,nx,arrayy,ny,arrayz,nz,cubmattmp,sur_valuenow)
if (isosur1style==5) CALL TPRFIN
call surmsh("OFF")
end do
end if
end if
!Draw a 3D rectangle box to show spatial range of present grid data or grid data to be calculated
tubethk=0.07D0
if (ishowdatarange==1) then
CALL MATOP3(0D0,0D0,0.8D0,'diffuse')
call gridvertex2(1,2,vert1x,vert1y,vert1z,vert2x,vert2y,vert2z)
call tube3D(vert1x,vert1y,vert1z,vert2x,vert2y,vert2z,tubethk,30,30)
call gridvertex2(2,3,vert1x,vert1y,vert1z,vert2x,vert2y,vert2z)
call tube3D(vert1x,vert1y,vert1z,vert2x,vert2y,vert2z,tubethk,30,30)
call gridvertex2(3,4,vert1x,vert1y,vert1z,vert2x,vert2y,vert2z)
call tube3D(vert1x,vert1y,vert1z,vert2x,vert2y,vert2z,tubethk,30,30)
call gridvertex2(1,4,vert1x,vert1y,vert1z,vert2x,vert2y,vert2z)
call tube3D(vert1x,vert1y,vert1z,vert2x,vert2y,vert2z,tubethk,30,30)
call gridvertex2(1,5,vert1x,vert1y,vert1z,vert2x,vert2y,vert2z)
call tube3D(vert1x,vert1y,vert1z,vert2x,vert2y,vert2z,tubethk,30,30)
call gridvertex2(2,6,vert1x,vert1y,vert1z,vert2x,vert2y,vert2z)
call tube3D(vert1x,vert1y,vert1z,vert2x,vert2y,vert2z,tubethk,30,30)
call gridvertex2(3,7,vert1x,vert1y,vert1z,vert2x,vert2y,vert2z)
call tube3D(vert1x,vert1y,vert1z,vert2x,vert2y,vert2z,tubethk,30,30)
call gridvertex2(4,8,vert1x,vert1y,vert1z,vert2x,vert2y,vert2z)
call tube3D(vert1x,vert1y,vert1z,vert2x,vert2y,vert2z,tubethk,30,30)
call gridvertex2(5,6,vert1x,vert1y,vert1z,vert2x,vert2y,vert2z)
call tube3D(vert1x,vert1y,vert1z,vert2x,vert2y,vert2z,tubethk,30,30)
call gridvertex2(6,7,vert1x,vert1y,vert1z,vert2x,vert2y,vert2z)
call tube3D(vert1x,vert1y,vert1z,vert2x,vert2y,vert2z,tubethk,30,30)
call gridvertex2(7,8,vert1x,vert1y,vert1z,vert2x,vert2y,vert2z)
call tube3D(vert1x,vert1y,vert1z,vert2x,vert2y,vert2z,tubethk,30,30)
call gridvertex2(5,8,vert1x,vert1y,vert1z,vert2x,vert2y,vert2z)
call tube3D(vert1x,vert1y,vert1z,vert2x,vert2y,vert2z,tubethk,30,30)
end if
!Show cell frame
if (ishowcell==1) then
!Along a
CALL MATOP3(0.7D0,0.0D0,0.0D0,'diffuse')
call cellvertex2(1,2,vert1x,vert1y,vert1z,vert2x,vert2y,vert2z)
call tube3D(vert1x,vert1y,vert1z,vert2x,vert2y,vert2z,tubethk,30,30)
call cellvertex2(3,4,vert1x,vert1y,vert1z,vert2x,vert2y,vert2z)
call tube3D(vert1x,vert1y,vert1z,vert2x,vert2y,vert2z,tubethk,30,30)
call cellvertex2(5,6,vert1x,vert1y,vert1z,vert2x,vert2y,vert2z)
call tube3D(vert1x,vert1y,vert1z,vert2x,vert2y,vert2z,tubethk,30,30)
call cellvertex2(7,8,vert1x,vert1y,vert1z,vert2x,vert2y,vert2z)
call tube3D(vert1x,vert1y,vert1z,vert2x,vert2y,vert2z,tubethk,30,30)
!Along b
CALL MATOP3(0.0D0,0.7D0,0.0D0,'diffuse')
call cellvertex2(2,3,vert1x,vert1y,vert1z,vert2x,vert2y,vert2z)
call tube3D(vert1x,vert1y,vert1z,vert2x,vert2y,vert2z,tubethk,30,30)
call cellvertex2(1,4,vert1x,vert1y,vert1z,vert2x,vert2y,vert2z)
call tube3D(vert1x,vert1y,vert1z,vert2x,vert2y,vert2z,tubethk,30,30)
call cellvertex2(6,7,vert1x,vert1y,vert1z,vert2x,vert2y,vert2z)
call tube3D(vert1x,vert1y,vert1z,vert2x,vert2y,vert2z,tubethk,30,30)
call cellvertex2(5,8,vert1x,vert1y,vert1z,vert2x,vert2y,vert2z)
call tube3D(vert1x,vert1y,vert1z,vert2x,vert2y,vert2z,tubethk,30,30)
!Along c
CALL MATOP3(0.0D0,0.0D0,0.7D0,'diffuse')
call cellvertex2(1,5,vert1x,vert1y,vert1z,vert2x,vert2y,vert2z)
call tube3D(vert1x,vert1y,vert1z,vert2x,vert2y,vert2z,tubethk,30,30)
call cellvertex2(2,6,vert1x,vert1y,vert1z,vert2x,vert2y,vert2z)
call tube3D(vert1x,vert1y,vert1z,vert2x,vert2y,vert2z,tubethk,30,30)
call cellvertex2(3,7,vert1x,vert1y,vert1z,vert2x,vert2y,vert2z)
call tube3D(vert1x,vert1y,vert1z,vert2x,vert2y,vert2z,tubethk,30,30)
call cellvertex2(4,8,vert1x,vert1y,vert1z,vert2x,vert2y,vert2z)
call tube3D(vert1x,vert1y,vert1z,vert2x,vert2y,vert2z,tubethk,30,30)
end if
if (isosur1style/=5) CALL ZBFFIN !Ending of Z-buffer
!Draw label of atom name and index of atoms/CPs/paths/surface extremes/real attractors in 3D plot
if ((ishowatmlab==1.or.ishowCPlab==1.or.ishowpathlab==1.or.ishowlocminlab==1.or.ishowlocmaxlab==1.or.(ishowattlab==1.and.numatt>0)).and.textheigh>0) then
textheighmod=textheigh+155*plot2abs**1.3D0 !Change text size according to molecule size
call height(int(textheighmod))
if (ishowatmlab==1) then
call setRGB(atmlabclrR,atmlabclrG,atmlabclrB)
do i=1,ncenter_tmp
if (ishowhydrogen==0.and.a_tmp(i)%index==1) cycle
write(ctemp,"(i5)") a_tmp_idx(i)
absx=(a_tmp(i)%x-(xhigh+xlow)/2) * plot2abs !Find atomic absolute coordinate in the axis
absy=(a_tmp(i)%y-(yhigh+ylow)/2) * plot2abs
absz=(a_tmp(i)%z-(zhigh+zlow)/2) * plot2abs
call abs3pt(absx,absy,absz,xplotcoor,yplotcoor) !Convert atomic absolute coordinate in the axis to screen coordinate (pixel)
screeny=nint(yplotcoor-textheighmod/1.8D0)
if (iatmlabtype3D==1) then !Show element
screenx=nint(xplotcoor-textheighmod/2D0)
if (a_tmp(i)%name(2:2)/=" ") screenx=nint(xplotcoor-textheighmod/1.3D0)
call messag(trim(a_tmp(i)%name),screenx,screeny)
else if (iatmlabtype3D==2) then !Show index all atoms (including Bq)
screenx=nint(xplotcoor-textheighmod/2D0)
if (i>=10) screenx=nint(xplotcoor-textheighmod/1.7D0)
call messag(ADJUSTL(ctemp),screenx,screeny)
else if (iatmlabtype3D==4.or.iatmlabtype3D==5) then !Show index only for Bq atoms
if (a_tmp(i)%index/=0) cycle
screenx=nint(xplotcoor-textheighmod/2D0)
if (iatmlabtype3D==4) then
if (i>=10) screenx=nint(xplotcoor-textheighmod/1.7D0)
else
itmp=count(a_tmp(1:i)%index==0)
write(ctemp,"(i5)") itmp
if (itmp>=10) screenx=nint(xplotcoor-textheighmod/1.7D0)
end if
call messag(ADJUSTL(ctemp),screenx,screeny)
else !Show element and index
if (iatmlabtype3D==6.and.a_tmp(i)%index==0) cycle !Do not show Bq label
if (i<10) then !Slightly move center of text so that they can at center of atom
screenx=nint(xplotcoor-textheighmod/1.1D0)
else !Move in X more, since the index has two or more digitals
screenx=nint(xplotcoor-textheighmod/0.8D0)
end if
call messag(trim(a_tmp(i)%name)//ADJUSTL(ctemp),screenx,screeny)
end if
end do
end if
if (ishowCPlab==1) then !Draw label for critical points
CALL SETRGB(CPlabclrR,CPlabclrG,CPlabclrB)
do i=1,numcp_tmp
if (CPtype_tmp(i)==1.and.ishow3n3==0) cycle
if (CPtype_tmp(i)==2.and.ishow3n1==0) cycle
if (CPtype_tmp(i)==3.and.ishow3p1==0) cycle
if (CPtype_tmp(i)==4.and.ishow3p3==0) cycle
if (lab_oneCP>0.and.lab_oneCP/=i) cycle
write(ctemp,"(i5)") CP_tmp_idx(i)
absx=(CPpos_tmp(1,i)-(xhigh+xlow)/2) * plot2abs !Find atomic absolute coordinate
absy=(CPpos_tmp(2,i)-(yhigh+ylow)/2) * plot2abs
absz=(CPpos_tmp(3,i)-(zhigh+zlow)/2) * plot2abs
call abs3pt(absx,absy,absz,xplotcoor,yplotcoor) !Convert atomic absolute coordinate to screen coordinate(pixel)
screeny=nint(yplotcoor-textheighmod/1.8)
if (i<10) then
screenx=nint(xplotcoor-textheighmod/2.6)
else if (i<100) then
screenx=nint(xplotcoor-textheighmod/1.5)
else
screenx=nint(xplotcoor-textheighmod)
end if
call messag(trim(ADJUSTL(ctemp)),screenx,screeny)
end do
end if
if (ishowpathlab==1) then
call color("RED")
do ipath=1,numpath_tmp
write(ctemp,"(i5)") path_tmp_idx(ipath)
ipathmidpt=nint(pathnumpt_tmp(ipath)/2D0)
absx=(topopath_tmp(1,ipathmidpt,ipath)-(xhigh+xlow)/2) * plot2abs !Find atomic absolute coordinate
absy=(topopath_tmp(2,ipathmidpt,ipath)-(yhigh+ylow)/2) * plot2abs
absz=(topopath_tmp(3,ipathmidpt,ipath)-(zhigh+zlow)/2) * plot2abs
call abs3pt(absx,absy,absz,xplotcoor,yplotcoor) !Convert atomic absolute coordinate to screen coordinate(pixel)
screenx=nint(xplotcoor-textheighmod/2.6D0)
screeny=nint(yplotcoor-textheighmod/1.8D0)
call messag(trim(ADJUSTL(ctemp)),screenx,screeny)
end do
end if
if (ishowlocminlab==1) then
call color("MAGENTA")
do i=1,nsurlocmin
idxtmp=surlocminidx(i)
if (idxtmp==0) cycle !The extreme has already been discarded
write(ctemp,"(i5)") i
absx=(survtx(idxtmp)%x-(xhigh+xlow)/2) * plot2abs !Find absolute coordinate
absy=(survtx(idxtmp)%y-(yhigh+ylow)/2) * plot2abs
absz=(survtx(idxtmp)%z-(zhigh+zlow)/2) * plot2abs
call abs3pt(absx,absy,absz,xplotcoor,yplotcoor) !Convert atomic absolute coordinate to screen coordinate(pixel)
screenx=nint(xplotcoor-textheighmod/2.6D0)
screeny=nint(yplotcoor-textheighmod/1.8D0)
call messag(trim(ADJUSTL(ctemp)),screenx,screeny)
end do
end if
if (ishowlocmaxlab==1) then
call color("GREEN")
do i=1,nsurlocmax
idxtmp=surlocmaxidx(i)
if (idxtmp==0) cycle !The extreme has already been discarded
write(ctemp,"(i5)") i
absx=(survtx(idxtmp)%x-(xhigh+xlow)/2) * plot2abs !Find absolute coordinate
absy=(survtx(idxtmp)%y-(yhigh+ylow)/2) * plot2abs
absz=(survtx(idxtmp)%z-(zhigh+zlow)/2) * plot2abs
call abs3pt(absx,absy,absz,xplotcoor,yplotcoor) !Convert atomic absolute coordinate to screen coordinate(pixel)
screenx=nint(xplotcoor-textheighmod/2.6D0)
screeny=nint(yplotcoor-textheighmod/1.8D0)
call messag(trim(ADJUSTL(ctemp)),screenx,screeny)
end do
end if
if (ishowattlab==1.and.numatt>0) then
CALL SETRGB(0.70D0,0.3D0,0.9D0)
do iatt=1,numatt
irealatt=attconv(iatt)
write(ctemp,"(i5)") irealatt
absx=(attxyz(1,iatt)-(xhigh+xlow)/2) * plot2abs !Find atomic absolute coordinate
absy=(attxyz(2,iatt)-(yhigh+ylow)/2) * plot2abs
absz=(attxyz(3,iatt)-(zhigh+zlow)/2) * plot2abs
call abs3pt(absx,absy,absz,xplotcoor,yplotcoor) !Convert atomic absolute coordinate to screen coordinate(pixel)
screenx=nint(xplotcoor-textheighmod/2.6)
screeny=nint(yplotcoor-textheighmod/1.8)
call messag(trim(ADJUSTL(ctemp)),screenx,screeny)
end do
end if
end if
CALL DISFIN
XVU=XVUold
YVU=YVUold
if (allocated(a_tmp)) deallocate(a_tmp,a_tmp_idx)
end subroutine
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!------------------------- Draw property in a line
!if atomr1==atomr2, then don't plot two points to highlight nuclear positions
!Input coordinate must be in Bohr
subroutine drawcurve(curvex,curvey,N,curvexmin,curvexmax,steplabx,curveymin,curveymax,steplaby,status,atomr1,atomr2,axisnamey)
implicit real*8 (a-h,o-z)
real*8 curvex(N),curvey(N),atompointx(2),atompointy(2),curvexmin,curvexmax,curveymin,curveymax,steplabx,steplaby
real*8,optional :: atomr1,atomr2
real*8 vertlinex(2),vertliney(2)
integer N
character status*4
character(len=*),optional :: axisnamey
!Set conversion factor, determined by global variable ilenunit1D
scll=1D0 !Default, namely Bohr as unit of X-axis
if (ilenunit1D==2) scll=b2a !Conver X-axis unit to Angstrom
call SCRMOD('REVERSE')
CALL PAGE(2970,2100)
CALL IMGFMT("RGB")
CALL setxid(0,'NONE') !If we don't set this, after we draw a graph embedded in GUI(e.g. relif map), curve map will not be shown
if (status=="show") then
call METAFL('xwin')
call window(200,100,900,600)
else if (status=="save") then
call METAFL(graphformat)
call winsiz(graph1Dwidth,graph1Dheight)
end if
CALL DISINI
! call LINMOD ('ON','SMOOTH') !It seems that Anti-aliased doesn't take effect
if (status=="show".and.isys==1) then
call WINTIT("Curve graph, click right mouse button to continue...")
call height(45)
CALL HNAME(45)
else
call height(40) !The text shown in graphic file is strangely larger than window, so slight decrease it
end if
CALL NAMDIS(40,'X')
CALL NAMDIS(50,'Y')
if (status=="show".or.graphformat=="pdf ") then
CALL HWFONT
else if (status=="save") then
if (ttfontfile=="none") then
CALL HELVES
else
CALL TTFONT(ttfontfile)
end if
CALL SHDCHA
end if
call center
nysize=nint(2300*curvexyratio)
call AXSLEN(2300,nysize)
if (nysize>1800) call AXSLEN(nint(2300/(nysize/1800D0)),1800)
if (ilog10y==0) then
call AXSSCL('lin','Y')
CALL LABDIG(numdigliney,"Y")
else if (ilog10y==1) then
call AXSSCL('log','Y')
call labels('log','Y')
CALL LABDIG(-1,"Y") !Do not show digit in Y
end if
if (ilenunit1D==1) CALL NAME('Position (Bohr)','X')
if (ilenunit1D==2) CALL NAME('Position (Angstrom)','X')
if (present(axisnamey)) then
if (axisnamey==" ") then
CALL NAME('Value (a.u.)','Y')
else
CALL NAME(trim(axisnamey),'Y')
end if
else
CALL NAME('Value (a.u.)','Y')
end if
CALL LABDIG(numdiglinex,"X")
CALL TICPOS("REVERS","XYZ")
call height(curve_axistextsize)
CALL HNAME(curve_axisnamesize)
call ERRMOD("ALL","OFF")
shifty=mod(curveymin,steplaby)
if (ilog10y==0) then
CALL GRAF(curvexmin*scll,curvexmax*scll,curvexmin*scll,steplabx, curveymin,curveymax,curveymin-shifty,steplaby)
else if (ilog10y==1) then
CALL GRAF(curvexmin*scll,curvexmax*scll,curvexmin*scll,steplabx, curveymin,curveymax,curveymin-shifty,1D0)
end if
CALL SETRGB(0.6D0,0.6D0,0.6D0)
CALL DASH
CALL XAXGIT !Draw the dashed line of Y=0
if (icurve_vertlinex==1) then
vertlinex=curve_vertlinex !Draw a vertical line throughing out the whole graph to help locating special position
if (ilog10y==0) then
vertliney(1)=curveymin
vertliney(2)=curveymax
else if (ilog10y==1) then
vertliney(1)=10**(curveymin)
vertliney(2)=10**(curveymax)
end if
CALL LINWID(icurvethick-2)
CALL CURVE(vertlinex,vertliney,2)
end if
call setcolor(iclrcurve)
CALL SOLID
CALL LINWID(icurvethick)
CALL CURVE(curvex*scll,curvey,N)
CALL LINWID(1)
if (present(atomr1)) then !Draw position of the two atom selected
if (atomr1/=atomr2) then
atompointx(1)=atomr1*scll !the position of atom shown in curve graph
atompointx(2)=atomr2*scll
atompointy=curveymin
CALL SETRGB(0.9D0,0D0,0D0)
CALL INCMRK(-1)
CALL MARKER(21)
CALL HSYMBL(25)
CALL CURVE(atompointx,atompointy,2)
end if
end if
CALL DISFIN
end subroutine
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!------------ Draw scatter graph for two functions
!This routine can also simultaneously plot two set of scatter data, as long as arrayx2/y2 are defined, they will be plotted as red points
!iratio=1: graph is 4:3 =2: graph is 1:1
subroutine drawscatter(arrayx,arrayy,ntot,xmin,xmax,ymin,ymax,iratio,stringx,stringy,arrayx2,arrayy2,ntot2)
real*8 arrayx(:),arrayy(:),xmin,xmax,ymin,ymax
integer ntot,iratio
character(len=*),optional :: stringx,stringy
integer,optional :: ntot2
real*8,optional :: arrayx2(:),arrayy2(:)
call SCRMOD('REVERSE')
if (iratio==1) then
CALL PAGE(3000,2250) !4:3
if (isavepic==0) then
call METAFL('xwin')
call window(100,100,800,600)
else if (isavepic==1) then
call METAFL(graphformat)
call winsiz(graph1Dwidth,nint(graph1Dwidth/4D0*3D0)) !Ensure 4:3
end if
else if (iratio==2) then
CALL PAGE(3000,3000) !1:1
if (isavepic==0) then
call METAFL('xwin')
call window(100,100,700,700)
else if (isavepic==1) then
call METAFL(graphformat)
call winsiz(graph1Dwidth,graph1Dwidth) !Ensure 1:1
end if
end if
CALL setxid(0,'NONE')
CALL DISINI
if (isavepic==0) call WINTIT("Scatter graph between two functions, click right mouse button to continue")
call ERRMOD("ALL","OFF")
if (isavepic==0.or.graphformat=="pdf ") then
call hwfont
else if (isavepic==1) then
if (ttfontfile=="none") then
CALL HELVES
else
CALL TTFONT(ttfontfile)
end if
CALL SHDCHA
end if
call center
if (iratio==1) then
call AXSLEN(2400,1800) !4:3
else if (iratio==2) then
call AXSLEN(2400,2400) !1:1
end if
CALL HNAME(45)
CALL height(40)
call TEXMOD("ON")
if (present(stringx)) then
CALL NAME(stringx,'X')
else
CALL NAME('Function 1 value','X')
end if
if (present(stringy)) then
CALL NAME(stringy,'Y')
else
CALL NAME('Function 2 value','Y')
end if
CALL LABDIG(numdiglinex,"X")
CALL LABDIG(numdigliney,"Y")
CALL TICPOS("REVERS","XYZ")
CALL GRAF(xmin,xmax,xmin,(xmax-xmin)/10,ymin,ymax,ymin,(ymax-ymin)/10)
CALL INCMRK(-1)
CALL MARKER(21)
CALL HSYMBL(symbolsize)
call curve(arrayx,arrayy,ntot)
if (present(arrayx2)) then
call color("RED")
call curve(arrayx2,arrayy2,ntot2)
call color("WHITE") !Restore to default (black)
end if
CALL DISFIN
end subroutine
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!----------Draw a matrix as color-mapped graph
!mat is the 2D matrix to be plotted, the dimension is numx,numy
!ninterpo determines the number of interpolation
!x/ymin,x/ymax are the lower and upper limit of X and Y axes
!zmin and zmax are the lower and upper limit of color bar (Z axis)
!stepx/y/z are stepsizes between labels of X/Y/Z axes
!If nlabdig=-1, the labels of X and Y axes will be integer, this is suitable for natively representation of a matrix. If =n, there will be n digitals
!textheight is size of label, optional, default is 45
!nlabdigz is the number of digial of labels in Z axis, optional, default is 4
subroutine drawmatcolor(mat,numx,numy,xmin,xmax,ymin,ymax,zmin,zmax,stepx,stepy,ninterpo,nlabdig,textheight,nlabdigz,stepzin)