Debian Codegraph @

src/options_xsecrotate.f90

raw
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-2021 Daniel Price. All rights reserved.
19 ! Contact: [email protected]
20 !
21 !-----------------------------------------------------------------
22
23 !-------------------------------------------------------------------------
24 ! Module containing settings and options relating to cross sections,
25 ! rotations and 3D plotting.
26 ! Includes default values of these options and submenu for changing them
27 !-------------------------------------------------------------------------
28 module settings_xsecrot
29 implicit none
30 !--public variables
31 integer, public :: nframes,nseq
32 integer, public :: nxsec,irotateaxes
33 logical, public :: xsec_nomulti, irotate, flythru, use3Dperspective, use3Dopacityrendering
34 logical, public :: rendersinks
35 real, public :: anglex, angley, anglez, zobserver, dzscreenfromobserver
36 real, public :: taupartdepth,xsecwidth
37 real, public :: xsecpos_nomulti,xseclineX1,xseclineX2,xseclineY1,xseclineY2
38 real, public, dimension(3) :: xorigin,xminrotaxes,xmaxrotaxes
39
40 !--private variables related to animation sequences
41 integer, parameter, private :: maxseq = 6
42 integer, dimension(maxseq), public :: iseqstart,iseqend,iseqtype
43 integer, public :: icolchange
44 real, public :: xminseqend,xmaxseqend,yminseqend,ymaxseqend
45 real, public :: anglezend,angleyend,anglexend,zobserverend,taupartdepthend
46 real, public :: xmincolend,xmaxcolend,xsecpos_nomulti_end
47 logical, private :: ihavesetsequence
48 character(len=*), dimension(maxseq), parameter, private :: labelseqtype = &
49 (/'steady zoom on x and y axes ', &
50 'steady rotation ', &
51 'steady change of limits (e.g. for colour bar) ', &
52 'steady movement of 3D observer ', &
53 'sequence of cross section slices through a 3D box ', &
54 'steady change of opacity for 3D surface plots '/)
55
56 !--namelists for writing to defaults file and .anim file
57 public :: xsecrotopts
58 namelist /xsecrotopts/ xsec_nomulti,xsecpos_nomulti,flythru, &
59 xseclineX1,xseclineX2,xseclineY1,xseclineY2, &
60 irotate,irotateaxes,anglex, angley, anglez, &
61 xminrotaxes,xmaxrotaxes,use3Dperspective, &
62 use3Dopacityrendering,zobserver,dzscreenfromobserver, &
63 taupartdepth,xsecwidth,rendersinks
64
65 public :: animopts
66 namelist /animopts/ nseq,nframes,iseqstart,iseqend,iseqtype, &
67 xminseqend,xmaxseqend,yminseqend,ymaxseqend, &
68 anglezend,angleyend,anglexend,zobserverend,taupartdepthend, &
69 icolchange,xmincolend,xmaxcolend,xsecpos_nomulti_end
70
71 !--public procedure names
72 public :: defaults_set_xsecrotate,submenu_xsecrotate,getsequencepos,insidesequence
73 public :: setsequenceend
74
75 procedure(add_sequence), pointer :: addseq => null()
76 procedure(delete_sequence), pointer :: delseq => null()
77 procedure(check_sequences), pointer :: checkseq => null()
78
79 private
80
81 contains
82
83 !---------------------------------------------
84 ! set default values for these options
85 !---------------------------------------------
86 subroutine defaults_set_xsecrotate
87
88 xsec_nomulti = .false. ! take cross section of data / particles
89 xsecpos_nomulti = 0. ! position of cross section
90 flythru = .false. ! take series of cross sections through data
91 xseclineX1 = 0.0
92 xseclineX2 = 0.0
93 xseclineY1 = 0.0
94 xseclineY2 = 0.0
95 xsecwidth = 0.0 ! width of xsec slices - zero means suggest better value to user
96 irotate = .false.
97 irotateaxes = 0
98 anglex = 0.
99 angley = 0.
100 anglez = 0.
101 xminrotaxes = 0.
102 xmaxrotaxes = 0.
103 use3Dperspective = .false.
104 use3Dopacityrendering = .false.
105 zobserver = 0.
106 dzscreenfromobserver = 0.
107 taupartdepth = -1. ! determine kappa automatically
108
109 !--defaults for animation sequences
110 nseq = 0
111 nframes = 0
112 iseqstart(:) = 0
113 iseqend(:) = 0
114 iseqtype(:) = 0
115 xminseqend = 0.
116 xmaxseqend = 0.
117 yminseqend = 0.
118 ymaxseqend = 0.
119 anglezend = 360.
120 angleyend = 0.
121 anglexend = 0.
122 icolchange = 0
123 xmincolend = 0.
124 xmaxcolend = 0.
125 zobserverend = 0.
126 taupartdepthend = 2000.0
127 xsecpos_nomulti_end = 0.
128 ihavesetsequence = .false.
129 rendersinks = .false.
130
131 end subroutine defaults_set_xsecrotate
132
133 !----------------------------------------------------------------------
134 ! sets options relating to cross sectioning / rotation
135 !----------------------------------------------------------------------
136 subroutine submenu_xsecrotate(ichoose)
137 use filenames, only:nsteps,nstepsinfile,ifileopen
138 use labels, only:irad,get_sink_type
139 use prompting, only:prompt,print_logical
140 use promptlist, only:prompt_list
141 use settings_data, only:ndim,xorigin,iCalcQuantities,DataIsBuffered,ntypes
142 use calcquantities, only:calc_quantities
143 integer, intent(in) :: ichoose
144 integer :: ians,i
145 logical :: ichangedorigin
146 character(len=1) :: labelx(3)
147 character(len=4) :: text
148 real, dimension(3) :: xorigintemp
149
150 print "(a)",'---------- cross section / 3D plotting options --------'
151 if (ndim==1) print*,' WARNING: none of these options have any effect in 1D'
152 ians = ichoose
153 if (xsec_nomulti) then
154 text = 'xsec'
155 else
156 text = 'proj'
157 endif
158
159 if (ians <= 0 .or. ians > 5) then
160 print 10,text,print_logical(irotate),anglex,angley,anglez, &
161 print_logical(use3Dperspective),print_logical(use3Dopacityrendering), &
162 nseq
163 10 format( &
164 ' 0) exit ',/, &
165 ' 1) switch between cross section/projection ( ',a4,' )',/, &
166 ' 2) rotation and origin settings ( ',a,3(1x,f5.1),' )',/, &
167 ' 3) 3D perspective on/off ( ',a,' )',/, &
168 ' 4) 3D surface rendering on/off ( ',a,' )',/, &
169 ' 5) set animation sequence (rotate,flythru etc.) ( ',i2,' )')
170 call prompt('enter option',ians,0,5)
171 endif
172 !
173 !--options
174 !
175 select case(ians)
176 !------------------------------------------------------------------------
177 case(1)
178 xsec_nomulti = .not.xsec_nomulti
179 print *,' Cross section = ',xsec_nomulti
180 !------------------------------------------------------------------------
181 case(2)
182 call prompt('use rotation?',irotate)
183 print "(a)",' rotation is '//trim(print_logical(irotate))
184 if (irotate) then
185 print*,'note that rotations are done in the order z-y-x '
186 print*,'this means the y and x rotations are done about the *new* y and x axes'
187 print*,'if in doubt, set the angles interactively in this order'
188 call prompt('enter rotation angle about z axis (deg)',anglez,0.,360.)
189 if (ndim==3) then
190 call prompt('enter rotation angle about y axis (deg)',angley,0.,360.)
191 call prompt('enter rotation angle about x axis (deg)',anglex,0.,360.)
192 endif
193 endif
194
195 !xorigin(1:ndim) = 0.5*(lim(1:ndim,1) + lim(1:ndim,2))
196 xorigintemp(1:ndim) = xorigin(1:ndim)
197 ichangedorigin = .false.
198 print "(a)",' Note that origin settings affect both rotation and radius calculations'
199 labelx=(/'x','y','z'/)
200 do i=1,ndim
201 call prompt('enter location of origin '//labelx(i),xorigin(i))
202 if (abs(xorigin(i)-xorigintemp(i)) > tiny(0.)) then
203 ichangedorigin = .true.
204 endif
205 enddo
206 !--recalculate radius if origin settings have changed
207 if (ichangedorigin .and. iCalcQuantities .and. irad > 0) then
208 if (DataIsBuffered) then
209 call calc_quantities(1,nsteps)
210 else
211 call calc_quantities(1,nstepsinfile(ifileopen))
212 endif
213 endif
214 !------------------------------------------------------------------------
215 case(3)
216 call prompt(' Use 3D perspective? ',use3Dperspective)
217 if (use3Dperspective) then
218 if (.not.irotate) irotate = .true.
219 if (abs(anglez) < tiny(anglez) .and. &
220 abs(angley) < tiny(angley) .and. &
221 abs(anglex) < tiny(anglex)) then
222 anglez = 30.
223 anglex = 60.
224 print "(a)",' setting default rotation angles to 30,0,60'
225 endif
226 endif
227 !------------------------------------------------------------------------
228 case(4)
229 call prompt(' Use 3D opacity rendering? ',use3Dopacityrendering)
230 if (use3Dopacityrendering .and. get_sink_type(ntypes) > 0) then
231 call prompt('Include sinks in opacity rendering (no=plot on top)?',rendersinks)
232 endif
233 !------------------------------------------------------------------------
234 case(5)
235 call submenu_animseq()
236
237 end select
238
239 return
240 end subroutine submenu_xsecrotate
241
242 !----------------------------------------------------------------------
243 ! sets up animation sequences
244 !----------------------------------------------------------------------
245 subroutine submenu_animseq()
246 use promptlist, only:prompt_list
247 use prompting, only:prompt
248
249 addseq => add_sequence
250 checkseq => check_sequences
251 delseq => delete_sequence
252 call prompt_list(nseq,maxseq,'sequence',checkseq,addseq,delseq)
253
254 end subroutine submenu_animseq
255
256 !-----------------------------------
257 ! print the current list of shapes
258 !-----------------------------------
259 subroutine check_sequences(n)
260 integer, intent(in) :: n
261 integer :: iseq
262
263 print "(/,a)", ' Current list of animation sequences:'
264 if (n > 0) then
265 do iseq=1,n
266 print "(i2,') ',a)",iseq,labelseqtype(iseqtype(iseq))
267 enddo
268 else
269 print "(a)",' (none)'
270 endif
271
272 end subroutine check_sequences
273
274 subroutine delete_sequence(iseq,n)
275 integer, intent(in) :: iseq
276 integer, intent(inout) :: n
277 integer :: i
278
279 if (iseq > 0 .and. n > 0 .and. iseq <= maxseq) then
280 if (iseqtype(iseq) > 0 .and. iseqtype(iseq) <= maxseq) then
281 print "(a,i1,': ',a)",' deleting sequence ',iseq,trim(labelseqtype(iseqtype(iseq)))
282 endif
283 iseqtype(iseq) = 0
284 do i=iseq+1,n
285 iseqtype(i-1) = iseqtype(i)
286 enddo
287 n = n - 1
288 endif
289
290 end subroutine delete_sequence
291
292 subroutine add_sequence(istart,iend,n)
293 use prompting, only:prompt
294 use limits, only:lim
295 use labels, only:ix,irho
296 use settings_data, only:ndim,istartatstep,iendatstep,numplot
297 use filenames, only:nsteps
298 integer, intent(in) :: istart,iend
299 integer, intent(inout) :: n
300 integer :: i,j,ierr
301
302 i = istart + 1
303 over_sequences: do while (i <= iend .and. i <= maxseq)
304
305 if (i > n) n = i
306 if (n > 0) then
307 !--set sensible default value for number of frames
308 if (nframes==0) then
309 if (nsteps > 1) then
310 nframes = 1
311 else
312 nframes = 10
313 endif
314 endif
315 call prompt('Enter number of frames generated between dumps (applies to all sequences)',nframes,1,500)
316 !call prompt('Use same sequence position for all plots on the page?',imultiframeseq)
317 endif
318
319 print "(a,i2,a)",'----------------- sequence ',i,' ----------------------'
320 if (iseqstart(i)==0) iseqstart(i) = max(istartatstep,1)
321 if (iseqend(i)==0) iseqend(i) = max(1,iendatstep,istartatstep)
322 if (nsteps > 1) then
323 call prompt('Enter starting dump for sequence ',iseqstart(i),1,nsteps)
324 call prompt('Enter finishing dump for sequence ',iseqend(i),1,nsteps)
325 endif
326
327 ierr = 1
328 do while (ierr /= 0)
329 print "(7(/,1x,i1,1x,':',1x,a))",0,'none (remove sequence) ', &
330 (j,labelseqtype(j),j=1,maxseq)
331
332 call prompt('Enter type of sequence ',iseqtype(i),0,maxseq)
333 !--allow only one sequence of each type
334 ierr = 0
335 if (i > 0) then
336 do j=1,n
337 if (i /= j .and. (iseqtype(j)==iseqtype(i)) .and. (iseqtype(i) > 0)) ierr = 2
338 enddo
339 if (ierr==2) print "(/,a)",' Error: can only have one sequence of each type '
340 endif
341 enddo
342 select case(iseqtype(i))
343 case(1)
344 print "(a)",'Note: zoom sequence starts using current fixed x,y plot limits'
345 if (abs(xminseqend) < tiny(xminseqend) .and. abs(xmaxseqend) < tiny(xmaxseqend)) then
346 xminseqend = lim(1,1)
347 xmaxseqend = lim(1,2)
348 endif
349 call prompt(' Enter finishing xmin ',xminseqend)
350 call prompt(' Enter finishing xmax ',xmaxseqend)
351 if (abs(yminseqend) < tiny(yminseqend) .and. abs(ymaxseqend) < tiny(ymaxseqend)) then
352 yminseqend = lim(2,1)
353 ymaxseqend = lim(2,2)
354 endif
355 call prompt(' Enter finishing ymin ',yminseqend)
356 call prompt(' Enter finishing ymax ',ymaxseqend)
357 case(2)
358 if (ndim < 2) then
359 print "(a)",' ERROR: cannot use this sequence in 1D'
360 iseqtype(i) = 0
361 endif
362 if (.not.irotate) then
363 print "(a)",' Turning rotation on...'
364 irotate = .true.
365 endif
366 print "(a)",'Note: rotation sequence starts using current rotation settings'
367 call prompt(' Enter finishing rotation angle (z axis) ',anglezend)
368 call prompt(' Enter finishing rotation angle (y axis) ',angleyend)
369 call prompt(' Enter finishing rotation angle (x axis) ',anglexend)
370 case(3)
371 if (icolchange <= 0 .or. icolchange > numplot) then
372 if (irho > 0 .and. irho <= numplot) then
373 icolchange = irho
374 else
375 icolchange = 1
376 endif
377 endif
378 call prompt(' Enter column to change limits ',icolchange,1,numplot)
379 print "(a)",'Note: limits start from current fixed plot limits for this column'
380 if (abs(xmincolend) < tiny(xmincolend) .and. abs(xmaxcolend) < tiny(xmaxcolend)) then
381 xmincolend = lim(icolchange,1)
382 xmaxcolend = lim(icolchange,2)
383 endif
384 call prompt(' Enter finishing minimum value ',xmincolend)
385 call prompt(' Enter finishing maximum value ',xmaxcolend)
386 case(4)
387 if (ndim /= 3) then
388 print "(a)",' ERROR: cannot use this sequence in < 3D'
389 iseqtype(i) = 0
390 endif
391 if (.not.use3Dperspective) then
392 print "(a)",'Turning 3D perspective on...'
393 use3Dperspective = .true.
394 endif
395 print "(a)",'Note: observer starts at current observer settings '
396 print "(a)",' (screen height does not change)'
397 !--try to give sensible default values
398 if (abs(zobserverend) < tiny(zobserverend)) then
399 if (abs(zobserver) > tiny(zobserver)) then
400 zobserverend = 5.*zobserver
401 elseif (ix(3) > 0 .and. ix(3) <= numplot) then
402 zobserverend = 10.*lim(ix(3),2)
403 endif
404 endif
405 call prompt(' Enter finishing 3D observer height ',zobserverend)
406 case(5)
407 if (ndim /= 3) then
408 print "(a)",' ERROR: cannot use this sequence in < 3D'
409 iseqtype(i) = 0
410 endif
411 if (.not.xsec_nomulti) then
412 print "(a)",'Changing from projection to cross-section'
413 xsec_nomulti = .true.
414 if (use3Dperspective .and. .not.use3Dopacityrendering) then
415 print "(a)",'Turning 3D perspecitve off'
416 use3Dperspective = .false.
417 endif
418 endif
419 print "(a)",'Note: slice position starts from value set at initial prompt'
420 call prompt(' Enter finishing slice position ',xsecpos_nomulti_end)
421 case(6)
422 if (ndim /= 3) then
423 print "(a)",' ERROR: cannot use this sequence in < 3D'
424 iseqtype(i) = 0
425 endif
426 if (.not.use3Dperspective .or. .not.use3Dopacityrendering) then
427 print "(a)",'Turning 3D opacity rendering and 3D perspective on...'
428 use3Dopacityrendering = .true.
429 use3Dperspective = .true.
430 endif
431 print "(3(a,/))",'Note: opacity sequence starts from current opacity value ', &
432 ' and that logarithmic steps are used if finishing value is', &
433 ' set to more than 1000 times the starting value (or vice-versa) '
434 call prompt('Enter finishing opacity in units of average smoothing length ',taupartdepthend)
435 case default
436 call delete_sequence(i,n)
437 exit over_sequences
438 end select
439 i = i + 1
440 enddo over_sequences
441
442 if (all(iseqtype(1:n)==0)) then
443 n = 0
444 else
445 ihavesetsequence = .true.
446 endif
447
448 return
449 end subroutine add_sequence
450
451 !----------------------------------------------------------------------
452 !
453 ! subroutine called from interactive mode which sets the current
454 ! plot settings as the end point to an animation sequence
455 !
456 !----------------------------------------------------------------------
457 subroutine setsequenceend(ipos,iplotx,iploty,irender,rotation, &
458 anglexi,angleyi,anglezi,zobserveri,use3Dopacity,taupartdepthi, &
459 x_sec,xsecposi,xmin,xmax,ymin,ymax,rendermin,rendermax)
460 use limits, only:lim
461 use multiplot, only:itrans
462 use settings_data, only:ndim,numplot
463 use transforms, only:transform_limits,transform_limits_inverse,transform_label
464 integer, intent(in) :: ipos,iplotx,iploty,irender
465 real, intent(in) :: anglexi,angleyi,anglezi,zobserveri,taupartdepthi,xsecposi
466 real, intent(in) :: xmin,xmax,ymin,ymax,rendermin,rendermax
467 logical, intent(in) :: rotation, use3Dopacity,x_sec
468 integer :: i
469 real :: xminfixed,xmaxfixed,yminfixed,ymaxfixed,renderminfixed,rendermaxfixed
470
471 nseq = 0
472 iseqtype(:) = 0
473 !
474 !--compare transformed limits
475 !
476 xminfixed = lim(iplotx,1)
477 xmaxfixed = lim(iplotx,2)
478 call transform_limits(xminfixed,xmaxfixed,itrans(iplotx))
479
480 yminfixed = lim(iploty,1)
481 ymaxfixed = lim(iploty,2)
482 call transform_limits(yminfixed,ymaxfixed,itrans(iploty))
483
484 if (irender > 0 .and. irender <= numplot) then
485 renderminfixed = lim(irender,1)
486 rendermaxfixed = lim(irender,2)
487 call transform_limits(renderminfixed,rendermaxfixed,itrans(irender))
488 endif
489
490 !--set however many sequences are required to capture the change in parameters
491 !
492 !--change of x-y limits
493 if ( notequal(xmin,xminfixed) .or. notequal(xmax,xmaxfixed) &
494 .or.notequal(ymin,yminfixed) .or. notequal(ymax,ymaxfixed)) then
495 nseq = nseq + 1
496 iseqtype(nseq) = 1
497 xminseqend = xmin
498 xmaxseqend = xmax
499 yminseqend = ymin
500 ymaxseqend = ymax
501 print*,trim(transform_label('xmin,max',itrans(iplotx)))//' start = ',xminfixed,xmaxfixed, &
502 ' end = ',xminseqend,xmaxseqend
503 print*,trim(transform_label('ymin,max',itrans(iploty)))//' start = ',yminfixed,ymaxfixed, &
504 ' end = ',yminseqend,ymaxseqend
505 !--always store untransformed limits
506 call transform_limits_inverse(xminseqend,xmaxseqend,itrans(iplotx))
507 call transform_limits_inverse(yminseqend,ymaxseqend,itrans(iploty))
508 endif
509 !--change of rotation angles
510 if (ndim >= 2 .and. rotation .and. &
511 (notequal(anglexi,anglex).or.notequal(angleyi,angley).or.notequal(anglezi,anglez))) then
512 nseq = nseq + 1
513 iseqtype(nseq) = 2
514 anglexend = anglexi
515 angleyend = angleyi
516 anglezend = anglezi
517 print*,'angle x start = ',anglex,' end = ',anglexend
518 print*,'angle y start = ',angley,' end = ',angleyend
519 print*,'angle z start = ',anglez,' end = ',anglezend
520 endif
521 !--change of render limits
522 if (ndim > 1 .and. irender > 0 .and. irender <= numplot) then
523 if (notequal(rendermin,renderminfixed) .or. notequal(rendermax,rendermaxfixed)) then
524 nseq = nseq + 1
525 iseqtype(nseq) = 3
526 icolchange = irender
527 xmincolend = rendermin
528 xmaxcolend = rendermax
529 print*,trim(transform_label('rendermin,max',itrans(irender)))//' start = ',renderminfixed,rendermaxfixed, &
530 ' end = ',xmincolend,xmaxcolend
531 !--always store untransformed limits
532 call transform_limits_inverse(xmincolend,xmaxcolend,itrans(irender))
533 endif
534 endif
535 !--change of observer position
536 if (ndim==3 .and. notequal(zobserveri,zobserver)) then
537 nseq = nseq + 1
538 iseqtype(nseq) = 4
539 zobserverend = zobserveri
540 endif
541 !--change of cross section position
542 if (ndim==3 .and. x_sec .and. notequal(xsecpos_nomulti,xsecposi)) then
543 nseq = nseq + 1
544 iseqtype(nseq) = 5
545 xsecpos_nomulti_end = xsecposi
546 endif
547 !--change of opacity
548 if (use3Dopacity .and. notequal(taupartdepthi,taupartdepth)) then
549 nseq = nseq + 1
550 iseqtype(nseq) = 6
551 taupartdepthend = taupartdepthi
552 endif
553
554 !--all sequences start from 1 and end at current dump position
555 iseqstart(1:nseq) = 1
556 iseqend(1:nseq) = ipos
557
558 if (nseq > 0) then
559 print "(1x,a,i1,a)",'total of ',nseq,' sequences set:'
560 do i=1,nseq
561 print "(1x,i1,': ',a)",i,trim(labelseqtype(iseqtype(i)))
562 enddo
563 print "(a,i5)",' sequences start at dump 1 and end at dump ',ipos
564 if (nframes <= 0) then
565 if (ipos==1) then
566 nframes = 10
567 else
568 nframes = 1
569 endif
570 print "(a,i3)",' setting number of frames = ',nframes
571 endif
572 else
573 print "(a)",' no sequences set (no change in parameters)'
574 endif
575
576 return
577 end subroutine setsequenceend
578
579 !----------------------------------------------------------------------
580 ! utility function for comparing real numbers
581 !----------------------------------------------------------------------
582 logical function notequal(r1,r2)
583 real, intent(in) :: r1,r2
584
585 if (abs(r1-r2) > epsilon(r1)) then
586 notequal = .true.
587 else
588 notequal = .false.
589 endif
590
591 end function notequal
592
593 !----------------------------------------------------------------------
594 ! query function determining whether or not a given timestep
595 ! is inside an animation sequence or not
596 ! (and thus whether or not to generate extra frames)
597 !----------------------------------------------------------------------
598 logical function insidesequence(ipos)
599 integer, intent(in) :: ipos
600 integer :: i
601
602 insidesequence = .false.
603 do i=1,nseq
604 if (iseqtype(i) > 0 .and. iseqstart(i) <= ipos .and. iseqend(i) >= ipos) then
605 insidesequence = .true.
606 endif
607 enddo
608
609 return
610 end function insidesequence
611
612 !----------------------------------------------------------------------
613 ! query function which returns the current plot parameters
614 ! based on the position in each sequence
615 ! (given the current frame & dump position)
616 !----------------------------------------------------------------------
617 subroutine getsequencepos(ipos,iframe,iplotx,iploty,irender,ivectorplot, &
618 anglexi,angleyi,anglezi,zobserveri,dzscreen,taupartdepthi, &
619 xsecposi,xmin,xmax,ymin,ymax,rendermin,rendermax,vecmax,&
620 isetrenderlimits,isetvectorlimits)
621 use limits, only:lim
622 use multiplot, only:itrans
623 use transforms, only:transform_limits
624 integer, intent(in) :: ipos,iframe,iplotx,iploty,irender,ivectorplot
625 real, intent(out) :: anglexi,angleyi,anglezi,zobserveri,dzscreen,taupartdepthi,xsecposi
626 real, intent(out) :: xmin,xmax,ymin,ymax,rendermin,rendermax,vecmax
627 logical, intent(out) :: isetrenderlimits,isetvectorlimits
628 logical :: logtaudepth
629 integer :: i,iposinseq,iposend
630 real :: xfrac,xminstart,xmaxstart,xminend,xmaxend,yminstart,ymaxstart,yminend,ymaxend
631
632 isetrenderlimits = .false.
633 isetvectorlimits = .false.
634
635 do i=1,nseq
636 !--set starting values based on first position
637 if (ipos >= iseqstart(i)) then
638 iposinseq = (ipos-iseqstart(i))*nframes + iframe
639 iposend = (iseqend(i)-iseqstart(i))*nframes + nframes
640 xfrac = (iposinseq-1)/real(iposend-1)
641 xfrac = min(xfrac,1.0)
642
643 if (iposinseq > iposend) then
644 print "(1x,a)",'--> '//trim(labelseqtype(iseqtype(i)))//' finished : frac = 1.0'
645 else
646 print "(1x,a,i3,a,i3,a,f5.2)",'--> frame ', &
647 iposinseq,' / ',iposend,' of '//trim(labelseqtype(iseqtype(i)))//': frac = ',xfrac
648 endif
649 select case(iseqtype(i))
650 case(1)
651 xminstart = lim(iplotx,1)
652 xmaxstart = lim(iplotx,2)
653 yminstart = lim(iploty,1)
654 ymaxstart = lim(iploty,2)
655 call transform_limits(xminstart,xmaxstart,itrans(iplotx))
656 call transform_limits(yminstart,ymaxstart,itrans(iploty))
657 xminend = xminseqend
658 xmaxend = xmaxseqend
659 yminend = yminseqend
660 ymaxend = ymaxseqend
661 call transform_limits(xminend,xmaxend,itrans(iplotx))
662 call transform_limits(yminend,ymaxend,itrans(iploty))
663 !--steps are linear in the transformed space
664 ! and limits returned are *already transformed*
665 xmin = xminstart + xfrac*(xminend - xminstart)
666 xmax = xmaxstart + xfrac*(xmaxend - xmaxstart)
667 ymin = yminstart + xfrac*(yminend - yminstart)
668 ymax = ymaxstart + xfrac*(ymaxend - ymaxstart)
669 case(2)
670 anglexi = anglex + xfrac*(anglexend - anglex)
671 angleyi = angley + xfrac*(angleyend - angley)
672 anglezi = anglez + xfrac*(anglezend - anglez)
673 case(3)
674 !--steps are linear in the transformed space
675 ! and limits returned are *already transformed*
676 if (iplotx==icolchange) then
677 xminstart = lim(iplotx,1)
678 xmaxstart = lim(iplotx,2)
679 call transform_limits(xminstart,xmaxstart,itrans(iplotx))
680 xminend = xmincolend
681 xmaxend = xmaxcolend
682 call transform_limits(xminend,xmaxend,itrans(iplotx))
683 xmin = xminstart + xfrac*(xminend - xminstart)
684 xmax = xmaxstart + xfrac*(xmaxend - xmaxstart)
685 elseif (iploty==icolchange) then
686 yminstart = lim(iploty,1)
687 ymaxstart = lim(iploty,2)
688 call transform_limits(yminstart,ymaxstart,itrans(iploty))
689 yminend = xmincolend
690 ymaxend = xmaxcolend
691 call transform_limits(yminend,ymaxend,itrans(iploty))
692 ymin = yminstart + xfrac*(yminend - yminstart)
693 ymax = ymaxstart + xfrac*(ymaxend - ymaxstart)
694 elseif (irender==icolchange) then
695 xminstart = lim(irender,1)
696 xmaxstart = lim(irender,2)
697 call transform_limits(xminstart,xmaxstart,itrans(irender))
698 xminend = xmincolend
699 xmaxend = xmaxcolend
700 call transform_limits(xminend,xmaxend,itrans(irender))
701 rendermin = xminstart + xfrac*(xminend - xminstart)
702 rendermax = xmaxstart + xfrac*(xmaxend - xmaxstart)
703 isetrenderlimits = .true.
704 elseif (ivectorplot==icolchange) then
705 xminstart = lim(ivectorplot,1)
706 xmaxstart = lim(ivectorplot,2)
707 call transform_limits(xminstart,xmaxstart,itrans(ivectorplot))
708 xminend = xmincolend
709 xmaxend = xmaxcolend
710 call transform_limits(xminend,xmaxend,itrans(ivectorplot))
711 vecmax = xmaxstart + xfrac*(xmaxend - xmaxstart)
712 isetvectorlimits = .true.
713 endif
714 case(4)
715 zobserveri = zobserver + xfrac*(zobserverend - zobserver)
716 dzscreen = zobserveri
717 case(5)
718 xsecposi = xsecpos_nomulti + xfrac*(xsecpos_nomulti_end - xsecpos_nomulti)
719 case(6)
720 logtaudepth = (taupartdepthend > 1.001e3*taupartdepth) &
721 .or.(taupartdepthend < 1.001e-3*taupartdepth)
722 if (logtaudepth) then
723 print "(a)",' (incrementing optical depth logarithmically)'
724 taupartdepthi = taupartdepth*(taupartdepthend/taupartdepth)**xfrac
725 else
726 taupartdepthi = taupartdepth + xfrac*(taupartdepthend - taupartdepth)
727 endif
728 end select
729 endif
730 enddo
731
732 end subroutine getsequencepos
733
734 end module settings_xsecrot