| 1 |
!----------------------------------------------------------------- |
| 2 |
! |
| 3 |
! This file is (or was) part of SPLASH, a visualisation tool |
| 4 |
! for Smoothed Particle Hydrodynamics written by Daniel Price: |
| 5 |
! |
| 6 |
! http://users.monash.edu.au/~dprice/splash |
| 7 |
! |
| 8 |
! SPLASH comes with ABSOLUTELY NO WARRANTY. |
| 9 |
! This is free software; and you are welcome to redistribute |
| 10 |
! it under the terms of the GNU General Public License |
| 11 |
! (see LICENSE file for details) and the provision that |
| 12 |
! this notice remains intact. If you modify this file, please |
| 13 |
! note section 2a) of the GPLv2 states that: |
| 14 |
! |
| 15 |
! a) You must cause the modified files to carry prominent notices |
| 16 |
! stating that you changed the files and the date of any change. |
| 17 |
! |
| 18 |
! Copyright (C) 2005-2022 Daniel Price. All rights reserved. |
| 19 |
! Contact: [email protected] |
| 20 |
! |
| 21 |
!----------------------------------------------------------------- |
| 22 |
|
| 23 |
!------------------------------------------------------------------------- |
| 24 |
! Module containing settings and options relating to renderings |
| 25 |
! includes default values of these options and submenu for changing them |
| 26 |
!------------------------------------------------------------------------- |
| 27 |
module settings_render |
| 28 |
use colourbar, only:ColourBarDisp,iplotcolourbarlabel,ColourBarPosx,ColourBarPosy,& |
| 29 |
ColourBarLen,ColourBarFmtStr,ColourBarWidth |
| 30 |
use labels, only:lenlabel |
| 31 |
use kernels, only:ikernel |
| 32 |
implicit none |
| 33 |
integer :: ncontours,npix,icolours,iColourBarStyle,iColourBarPos |
| 34 |
logical :: iplotcont_nomulti,ilabelcont |
| 35 |
logical :: icolour_particles,inormalise_interpolations |
| 36 |
logical :: ifastrender,idensityweightedinterpolation |
| 37 |
logical :: double_rendering,exact_rendering,iauto_densityweighted |
| 38 |
character(len=lenlabel+20) :: projlabelformat |
| 39 |
integer :: iapplyprojformat |
| 40 |
character(len=120) :: rgbfile |
| 41 |
|
| 42 |
namelist /renderopts/ npix,icolours,ncontours,iplotcont_nomulti, & |
| 43 |
icolour_particles,ColourBarDisp,inormalise_interpolations, & |
| 44 |
ifastrender,idensityweightedinterpolation,iColourBarStyle, & |
| 45 |
iplotcolourbarlabel,ilabelcont,projlabelformat,iapplyprojformat, & |
| 46 |
double_rendering,ikernel,ColourBarPosx,ColourBarPosy,ColourBarLen,& |
| 47 |
ColourBarFmtStr,ColourBarWidth,iColourBarPos,rgbfile,exact_rendering,& |
| 48 |
iauto_densityweighted |
| 49 |
|
| 50 |
contains |
| 51 |
|
| 52 |
!--------------------------------------------- |
| 53 |
! set default values for these options |
| 54 |
!--------------------------------------------- |
| 55 |
subroutine defaults_set_render |
| 56 |
|
| 57 |
icolours = 2 ! colour scheme to use |
| 58 |
npix = 0 ! pixels in x direction for rendering |
| 59 |
iColourBarStyle = 1 ! whether or not to plot the colour bar and style |
| 60 |
iplotcont_nomulti = .false. ! plot contours |
| 61 |
icolour_particles = .false. ! colour particles instead of using pixels |
| 62 |
ncontours = 30 ! number of contours to plot |
| 63 |
ColourBarDisp = 5.0 ! displacement of colour bar label from edge |
| 64 |
inormalise_interpolations = .false. ! do not normalise interpolations |
| 65 |
ifastrender = .false. ! use accelerated rendering |
| 66 |
idensityweightedinterpolation = .false. |
| 67 |
iauto_densityweighted = .true. |
| 68 |
iplotcolourbarlabel = .true. |
| 69 |
ilabelcont = .false. ! print numeric labels on contours |
| 70 |
projlabelformat = ' ' |
| 71 |
iapplyprojformat = 0 |
| 72 |
double_rendering = .false. |
| 73 |
ikernel = 0 ! just take default kernel |
| 74 |
ColourBarPosx = 0.75 ! default values used for floating colour bars |
| 75 |
ColourBarPosy = 0.7 |
| 76 |
ColourBarLen = 0.25 |
| 77 |
ColourBarWidth = 2. |
| 78 |
ColourBarFmtStr = 'BCMSTV' |
| 79 |
iColourBarPos = 3 |
| 80 |
rgbfile = 'colours.ctb' |
| 81 |
exact_rendering = .false. |
| 82 |
|
| 83 |
return |
| 84 |
end subroutine defaults_set_render |
| 85 |
|
| 86 |
!--------------------------------------------- |
| 87 |
! set default values for 360 video |
| 88 |
!--------------------------------------------- |
| 89 |
subroutine defaults_set_render_360 |
| 90 |
use colourbar, only:set_floating_bar_style |
| 91 |
|
| 92 |
iColourBarStyle = 7 |
| 93 |
call set_floating_bar_style(iColourBarStyle,4) |
| 94 |
|
| 95 |
end subroutine defaults_set_render_360 |
| 96 |
|
| 97 |
!----------------------------------------------------------------------------- |
| 98 |
! options for rendered plots |
| 99 |
!----------------------------------------------------------------------------- |
| 100 |
subroutine submenu_render(ichoose) |
| 101 |
use colourbar, only:maxcolourbarstyles,labelcolourbarstyles,barisvertical,& |
| 102 |
isfloating,iscustombar,labelfloatingstyles,& |
| 103 |
set_floating_bar_style,maxfloatingstyles,ilogcolourbaraxis |
| 104 |
use colours, only:schemename,ncolourschemes,ncoltable,rgbtable,icustom |
| 105 |
use prompting, only:prompt,print_logical |
| 106 |
use params, only:maxplot |
| 107 |
use plotlib, only:plotlib_supports_alpha |
| 108 |
use filenames, only:fileprefix |
| 109 |
use kernels, only:select_kernel,kernelname,nkernels |
| 110 |
use projections3D, only:setup_integratedkernel |
| 111 |
use asciiutils, only:read_asciifile |
| 112 |
integer, intent(in) :: ichoose |
| 113 |
character(len=5) :: string,stringd |
| 114 |
character(len=20) :: kname |
| 115 |
integer :: ians,i,ierr,icolourprev |
| 116 |
! |
| 117 |
!--rendering options |
| 118 |
! |
| 119 |
ians = ichoose |
| 120 |
print "(a)",'----------------- rendering options -------------------' |
| 121 |
|
| 122 |
if (ians <= 0 .or. ians > 10) then |
| 123 |
if (npix > 0) then |
| 124 |
write(string,"(i5)") npix |
| 125 |
else |
| 126 |
string = 'AUTO' |
| 127 |
endif |
| 128 |
if (iauto_densityweighted) then |
| 129 |
stringd = 'AUTO' |
| 130 |
else |
| 131 |
stringd = print_logical(idensityweightedinterpolation) |
| 132 |
endif |
| 133 |
kname = '' |
| 134 |
if (ikernel >= 0 .and. ikernel <= nkernels) kname = trim(kernelname(ikernel)) |
| 135 |
print 10,trim(string),icolours,print_logical(iplotcont_nomulti), & |
| 136 |
iColourBarStyle,print_logical(icolour_particles), & |
| 137 |
print_logical(inormalise_interpolations),print_logical(ifastrender),& |
| 138 |
trim(stringd),trim(projlabelformat),& |
| 139 |
trim(kname) |
| 140 |
10 format( & |
| 141 |
' 0) exit ',/, & |
| 142 |
' 1) set number of pixels ( ',a,' )',/, & |
| 143 |
' 2) change colour scheme (',i2,' )',/, & |
| 144 |
' 3) contour plot settings ( ',a,' )',/, & |
| 145 |
' 4) change colour bar style ( ',i2,' )',/,& |
| 146 |
' 5) use particle colours not pixels ( ',a,' )',/,& |
| 147 |
' 6) normalise interpolations ( ',a,' )',/,& |
| 148 |
' 7) use accelerated rendering ( ',a,' )',/,& |
| 149 |
' 8) use density weighted interpolation ( ',a,' )',/, & |
| 150 |
' 9) customize label on projection plots ( ',a,' )',/,& |
| 151 |
' 10) set kernel ( ',a,' )') |
| 152 |
call prompt('enter option',ians,0,10) |
| 153 |
endif |
| 154 |
! |
| 155 |
!--options |
| 156 |
! |
| 157 |
select case(ians) |
| 158 |
!------------------------------------------------------------------------ |
| 159 |
case(1) |
| 160 |
print "(5(/,a),/)",' Note: setting number of pixels = 0 means that ', & |
| 161 |
' the number of pixels will be automatically ', & |
| 162 |
' chosen to match the device used for plotting.', & |
| 163 |
' The number of pixels is then determined by ', & |
| 164 |
' the page size (set in the p)age menu).' |
| 165 |
call prompt('enter number of pixels along x axis (0=auto)',npix,0,100000) |
| 166 |
!------------------------------------------------------------------------ |
| 167 |
case(2) |
| 168 |
ierr = 1 |
| 169 |
icolourprev = icolours |
| 170 |
write(*,"(i2,a,1x)") (i,': '//trim(schemename(i)),i=1,ncolourschemes) |
| 171 |
write(*,"(i3,a,1x)") icustom,': custom' |
| 172 |
print "(a)",'(-ve = inverse, 0 = contours only)' |
| 173 |
promptloop: do while (ierr /= 0) |
| 174 |
call prompt('enter colour scheme for rendering ',icolours,& |
| 175 |
-ncolourschemes+1,ncolourschemes+1,icustom,icustom) |
| 176 |
! |
| 177 |
! custom colour map from file !demonstration plot of all colour schemes |
| 178 |
! |
| 179 |
ierr = 0 |
| 180 |
if (icolours==ncolourschemes+1) icolours=icustom |
| 181 |
if (icolours==-(ncolourschemes+1)) icolours=-icustom |
| 182 |
if (abs(icolours)==icustom) then |
| 183 |
call prompt('enter filename for rgb table',rgbfile,noblank=.true.) |
| 184 |
call read_asciifile(rgbfile,ncoltable,rgbtable,ierr) |
| 185 |
if (ierr /= 0 .or. ncoltable <= 0) then |
| 186 |
print "(a)",'ERROR: could not read colours from '//trim(rgbfile) |
| 187 |
else |
| 188 |
print "(a,i3,a)",'read ',ncoltable,' colours from '//trim(rgbfile) |
| 189 |
endif |
| 190 |
if (ierr /= 0) icolours = icolourprev |
| 191 |
endif |
| 192 |
enddo promptloop |
| 193 |
!------------------------------------------------------------------------ |
| 194 |
case(3) |
| 195 |
if (icolours==0) then |
| 196 |
print "(2(/,a),/)",' Warning: this option has no effect if colour scheme 0 is set', & |
| 197 |
' (cannot plot contours on top of contours)' |
| 198 |
endif |
| 199 |
if (plotlib_supports_alpha) then |
| 200 |
call prompt(' allow contour/double render prompt?',iplotcont_nomulti) |
| 201 |
print "(3(/,a),/)",' Double rendering renders the first quantity in black and white', & |
| 202 |
' and the second in colour with a transparent background ', & |
| 203 |
' (such that data below the colour bar minimum appears transparent)' |
| 204 |
call prompt('use double rendering instead of contours?',double_rendering) |
| 205 |
else |
| 206 |
call prompt('allow contour plotting prompt?',iplotcont_nomulti) |
| 207 |
endif |
| 208 |
|
| 209 |
if (double_rendering) then |
| 210 |
print "(a)",' Second render prompt is '//trim(print_logical(iplotcont_nomulti)) |
| 211 |
else |
| 212 |
print "(a)",' Contour plotting prompt is '//trim(print_logical(iplotcont_nomulti)) |
| 213 |
endif |
| 214 |
if ((iplotcont_nomulti .or. icolours==0) .and. .not.double_rendering) then |
| 215 |
print "(5(/,a),/)",& |
| 216 |
' To set contour levels and level labels manually, create a file called', & |
| 217 |
' '''//trim(fileprefix)//'.contours'' in the working directory, with the following format:',& |
| 218 |
' 1.0 label1 ', & |
| 219 |
' 2.0 label2 ', & |
| 220 |
' ...' |
| 221 |
call prompt('enter number of contours between min,max',ncontours,0,500) |
| 222 |
!call prompt('plot contour labels?',ilabelcont) |
| 223 |
endif |
| 224 |
!------------------------------------------------------------------------ |
| 225 |
case(4) |
| 226 |
do i=0,maxcolourbarstyles |
| 227 |
print "(i2,')',1x,a)",i,trim(labelcolourbarstyles(i)) |
| 228 |
enddo |
| 229 |
call prompt('enter colour bar style to use ',iColourBarStyle,0,maxcolourbarstyles) |
| 230 |
print "(a,/)",'colour bar style = '//trim(labelcolourbarstyles(iColourBarStyle)) |
| 231 |
|
| 232 |
if (iColourBarStyle > 0) then |
| 233 |
if (isfloating(iColourBarStyle)) then |
| 234 |
print "(5(a,/),a)",' Positioning of floating colour bar: ', & |
| 235 |
(trim(labelfloatingstyles(i)),i=1,maxfloatingstyles) |
| 236 |
call prompt('enter option',iColourBarPos,1,maxfloatingstyles) |
| 237 |
if (iColourBarPos >= 1 .and. iColourBarPos < maxfloatingstyles) ColourBarLen = 0.25 |
| 238 |
if (iColourBarPos == maxfloatingstyles) then |
| 239 |
call prompt('enter x position of colour bar as fraction of viewport',ColourBarPosx,-1.,1.5) |
| 240 |
call prompt('enter y position of colour bar as fraction of viewport',ColourBarPosy,-1.,1.5) |
| 241 |
call prompt('enter length of colour bar as fraction of viewport',ColourBarLen,0.,1.) |
| 242 |
else |
| 243 |
call set_floating_bar_style(iColourBarStyle,iColourBarPos) |
| 244 |
endif |
| 245 |
endif |
| 246 |
call prompt('plot colour bar label?',iplotcolourbarlabel) |
| 247 |
if (barisvertical(iColourBarStyle) .and. iplotcolourbarlabel) then |
| 248 |
call prompt('enter displacement of text from edge (character heights) ', & |
| 249 |
ColourBarDisp) |
| 250 |
endif |
| 251 |
call prompt('use log axis on colour bar?',ilogcolourbaraxis) |
| 252 |
if (iscustombar(iColourBarStyle)) then |
| 253 |
call prompt('enter width of colour bar in character heights',ColourBarWidth,0.,20.) |
| 254 |
if (barisvertical(iColourBarstyle)) then |
| 255 |
print "(a)",' A=axis,B=bottom,C=top,T=major ticks,S=minor ticks,N=labels,V=vertical,L=log,M=labels above' |
| 256 |
else |
| 257 |
print "(a)",' B=left,C=right,T=major ticks,S=minor ticks,N=labels,L=log,M=labels to left' |
| 258 |
if (ColourBarFmtStr=='BCMSTV') then |
| 259 |
ColourBarFmtStr='BCNST' ! use default string for horizontal bars instead |
| 260 |
endif |
| 261 |
endif |
| 262 |
call prompt('enter format code string for colour bar ticks/numbering',ColourBarFmtStr) |
| 263 |
endif |
| 264 |
endif |
| 265 |
!------------------------------------------------------------------------ |
| 266 |
case(5) |
| 267 |
icolour_particles = .not.icolour_particles |
| 268 |
print "(a)",' Use particle colours instead of pixels is ' & |
| 269 |
//trim(print_logical(icolour_particles)) |
| 270 |
!------------------------------------------------------------------------ |
| 271 |
case(6) |
| 272 |
call prompt('Use normalised interpolations?',inormalise_interpolations) |
| 273 |
print "(a)",' Normalisation of interpolations is ' & |
| 274 |
//trim(print_logical(inormalise_interpolations)) |
| 275 |
if (.not.inormalise_interpolations) then |
| 276 |
call prompt('Use exact rendering? (slower but more accurate)',exact_rendering) |
| 277 |
print "(a)",' Exact rendering is ' & |
| 278 |
//trim(print_logical(exact_rendering)) |
| 279 |
endif |
| 280 |
!------------------------------------------------------------------------ |
| 281 |
case(7) |
| 282 |
ifastrender = .not.ifastrender |
| 283 |
print "(a)",' Accelerated rendering is '//trim(print_logical(ifastrender)) |
| 284 |
if (ifastrender) then |
| 285 |
print*,' Warning: this is slightly approximate (particle position' |
| 286 |
print*,' assumed to be at centre of pixel)' |
| 287 |
endif |
| 288 |
!------------------------------------------------------------------------ |
| 289 |
case(8) |
| 290 |
idensityweightedinterpolation = .not.idensityweightedinterpolation |
| 291 |
print "(a)",' Density weighted interpolation is '// & |
| 292 |
print_logical(idensityweightedinterpolation) |
| 293 |
iauto_densityweighted = .not.idensityweightedinterpolation |
| 294 |
|
| 295 |
if (.not.idensityweightedinterpolation) & |
| 296 |
call prompt('Switch density weighting on/off automatically?',iauto_densityweighted) |
| 297 |
!------------------------------------------------------------------------ |
| 298 |
case(9) |
| 299 |
print "(5(/,a),/,4(/,a),/)", & |
| 300 |
' Example format strings: ', & |
| 301 |
' \(2268) %l d%z %uz : this is the default format "\int rho [g/cm^3] dz [cm]"', & |
| 302 |
' column %l : would print "column density" for density', & |
| 303 |
' surface %l : would print "surface density"', & |
| 304 |
' %l integrated through %z : would print "density integrated through z"', & |
| 305 |
' Format codes: ', & |
| 306 |
' %l : label for rendered quantity ', & |
| 307 |
' %z : label for ''z'' ', & |
| 308 |
' %uz : units label for z (only if physical units applied)' |
| 309 |
|
| 310 |
call prompt(' enter label format for projection plots: ',projlabelformat) |
| 311 |
call prompt(' enter which column to apply format to (0=all) ',iapplyprojformat,0,maxplot) |
| 312 |
!------------------------------------------------------------------------ |
| 313 |
case(10) |
| 314 |
do i=0,nkernels |
| 315 |
print "(1x,i1,')',1x,a)",i,trim(kernelname(i)) |
| 316 |
enddo |
| 317 |
call prompt(' enter kernel to use for interpolations (0=default)',ikernel,0,nkernels) |
| 318 |
call select_kernel(ikernel) |
| 319 |
call setup_integratedkernel ! need to redo the kernel table if kernel has changed |
| 320 |
end select |
| 321 |
|
| 322 |
return |
| 323 |
end subroutine submenu_render |
| 324 |
|
| 325 |
end module settings_render |