| 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-2019 Daniel Price. All rights reserved. |
| 19 |
! Contact: [email protected] |
| 20 |
! |
| 21 |
!----------------------------------------------------------------- |
| 22 |
|
| 23 |
!----------------------------------------------------------------- |
| 24 |
! module which handles plotting of arbitrary shapes |
| 25 |
! written by Daniel Price 2008 |
| 26 |
! as part of the SPLASH SPH visualisation package |
| 27 |
!----------------------------------------------------------------- |
| 28 |
module shapes |
| 29 |
implicit none |
| 30 |
integer, parameter, private :: maxshapes = 32 |
| 31 |
integer, parameter, private :: maxshapetype = 8 |
| 32 |
integer :: nshapes |
| 33 |
integer, parameter, private :: lentext = 120 |
| 34 |
|
| 35 |
type shapedef |
| 36 |
integer :: itype |
| 37 |
integer :: icolour |
| 38 |
integer :: linestyle |
| 39 |
integer :: linewidth |
| 40 |
integer :: ifillstyle |
| 41 |
integer :: iunits |
| 42 |
integer :: iplotonpanel |
| 43 |
real :: xpos |
| 44 |
real :: ypos |
| 45 |
real :: xlen,ylen |
| 46 |
real :: angle,fjust |
| 47 |
real :: opacity |
| 48 |
character(len=lentext) :: text |
| 49 |
end type |
| 50 |
type(shapedef), dimension(maxshapes), public :: shape |
| 51 |
|
| 52 |
character(len=9), dimension(maxshapetype), & |
| 53 |
parameter, public :: labelshapetype = & |
| 54 |
(/'square ', & |
| 55 |
'rectangle', & |
| 56 |
'arrow ', & |
| 57 |
'circle ', & |
| 58 |
'line ', & |
| 59 |
'text ', & |
| 60 |
'f(x) ', & |
| 61 |
'marker '/) |
| 62 |
namelist /shapeopts/ nshapes,shape |
| 63 |
|
| 64 |
integer, parameter, public :: & |
| 65 |
ishape_square = 1, & |
| 66 |
ishape_rectangle = 2, & |
| 67 |
ishape_arrow = 3, & |
| 68 |
ishape_circle = 4, & |
| 69 |
ishape_line = 5, & |
| 70 |
ishape_text = 6, & |
| 71 |
ishape_function = 7, & |
| 72 |
ishape_marker = 8 |
| 73 |
|
| 74 |
integer, parameter, private :: maxunits = 2 |
| 75 |
character(len=20), dimension(maxunits), & |
| 76 |
parameter, private :: labelunits = & |
| 77 |
(/'units of plot ', & |
| 78 |
'viewport coordinates'/) |
| 79 |
! 'inches ', & |
| 80 |
! 'millimeters ', & |
| 81 |
! 'pixels '/) |
| 82 |
|
| 83 |
procedure(check_shapes), pointer, private :: checkshapes => null() |
| 84 |
procedure(add_shape), pointer, private :: addshape => null() |
| 85 |
procedure(delete_shape), pointer, private :: delshape => null() |
| 86 |
|
| 87 |
real, parameter, private :: pi = 4.*atan(1.) |
| 88 |
|
| 89 |
contains |
| 90 |
!----------------------------------------------------------------- |
| 91 |
! shape default settings |
| 92 |
!----------------------------------------------------------------- |
| 93 |
subroutine defaults_set_shapes |
| 94 |
|
| 95 |
nshapes = 0 |
| 96 |
shape(:)%itype = 0 |
| 97 |
shape(:)%icolour = 1 |
| 98 |
shape(:)%linestyle = 1 |
| 99 |
shape(:)%linewidth = 1 |
| 100 |
shape(:)%ifillstyle = 2 |
| 101 |
shape(:)%iunits = 1 |
| 102 |
shape(:)%iplotonpanel = 0 |
| 103 |
shape(:)%xpos = 0.5 |
| 104 |
shape(:)%ypos = 0.5 |
| 105 |
shape(:)%xlen = 1. |
| 106 |
shape(:)%ylen = 1. |
| 107 |
shape(:)%angle = 0. |
| 108 |
shape(:)%text = ' ' |
| 109 |
shape(:)%fjust = 0. |
| 110 |
shape(:)%opacity = 1. |
| 111 |
|
| 112 |
end subroutine defaults_set_shapes |
| 113 |
|
| 114 |
!----------------------------------------------------------------- |
| 115 |
! shape submenu |
| 116 |
!----------------------------------------------------------------- |
| 117 |
subroutine submenu_shapes() |
| 118 |
use promptlist, only:prompt_list |
| 119 |
|
| 120 |
checkshapes => check_shapes |
| 121 |
addshape => add_shape |
| 122 |
delshape => delete_shape |
| 123 |
call prompt_list(nshapes,maxshapes,'shape',checkshapes,addshape,delshape) |
| 124 |
|
| 125 |
end subroutine submenu_shapes |
| 126 |
|
| 127 |
!----------------------------------- |
| 128 |
! print the current list of shapes |
| 129 |
!----------------------------------- |
| 130 |
subroutine check_shapes(nshape) |
| 131 |
integer, intent(in) :: nshape |
| 132 |
integer :: ishape |
| 133 |
|
| 134 |
print "(/,a)", ' Current list of plot annotations:' |
| 135 |
if (nshape > 0) then |
| 136 |
do ishape=1,nshape |
| 137 |
call print_shapeinfo(ishape,shape(ishape)%itype,shape(ishape)) |
| 138 |
enddo |
| 139 |
else |
| 140 |
print "(a)",' (none)' |
| 141 |
endif |
| 142 |
|
| 143 |
end subroutine check_shapes |
| 144 |
|
| 145 |
!---------------------------------------- |
| 146 |
! pretty-print information about a shape |
| 147 |
!---------------------------------------- |
| 148 |
subroutine print_shapeinfo(inum,itype,shapein) |
| 149 |
integer, intent(in) :: inum,itype |
| 150 |
type(shapedef), intent(in), optional :: shapein |
| 151 |
character(len=20), parameter :: fmtstring = "('Shape ',i2,': ',a)" |
| 152 |
|
| 153 |
select case(itype) |
| 154 |
case(ishape_square) |
| 155 |
print "(10x,a)",' --' |
| 156 |
write(*,fmtstring,advance='no') inum,' | | '//labelshapetype(itype) |
| 157 |
if (present(shapein)) then |
| 158 |
print "(5x,es10.2,' x ',es10.2)",shapein%xlen,shapein%ylen |
| 159 |
else |
| 160 |
print* |
| 161 |
endif |
| 162 |
print "(10x,a)",' --' |
| 163 |
case(ishape_rectangle) |
| 164 |
print "(10x,a)",' -----' |
| 165 |
write(*,fmtstring,advance='no') inum,' | | '//labelshapetype(itype) |
| 166 |
if (present(shapein)) then |
| 167 |
print "(5x,es10.2,' x ',es10.2)",shapein%xlen,shapein%ylen |
| 168 |
else |
| 169 |
print* |
| 170 |
endif |
| 171 |
print "(10x,a)",' -----' |
| 172 |
case(ishape_arrow) |
| 173 |
print "(10x,a)" |
| 174 |
write(*,fmtstring,advance='no') inum,' ------> '//labelshapetype(itype) |
| 175 |
if (present(shapein)) then |
| 176 |
print "(2x,'(x,y) = (',es10.2,es10.2,') to (x,y) = (',es10.2,es10.2,')')",& |
| 177 |
shapein%xpos,shapein%ypos,shapein%xlen,shapein%ylen |
| 178 |
else |
| 179 |
print* |
| 180 |
endif |
| 181 |
print "(10x,a)" |
| 182 |
case(ishape_circle) |
| 183 |
print "(10x,a)",' ___ ' |
| 184 |
print "(10x,a)",' / \ ' |
| 185 |
write(*,fmtstring,advance='no') inum,' ( ) '//labelshapetype(itype) |
| 186 |
if (present(shapein)) then |
| 187 |
print "(6x,'radius = ',es10.2)",& |
| 188 |
shapein%xlen |
| 189 |
else |
| 190 |
print* |
| 191 |
endif |
| 192 |
print "(10x,a)",' \___/ ' |
| 193 |
case(ishape_line) |
| 194 |
print "(10x,a)" |
| 195 |
write(*,fmtstring,advance='no') inum,' -------- '//labelshapetype(itype) |
| 196 |
if (present(shapein)) then |
| 197 |
print "(6x,'length = ',es10.2)",shapein%xlen |
| 198 |
else |
| 199 |
print* |
| 200 |
endif |
| 201 |
print "(10x,a)" |
| 202 |
case(ishape_text) |
| 203 |
print "(10x,a)", ' ' |
| 204 |
write(*,fmtstring,advance='no') inum,' TEXT ' |
| 205 |
if (present(shapein)) then |
| 206 |
print "('""',a,'""')",trim(shapein%text) |
| 207 |
else |
| 208 |
print* |
| 209 |
endif |
| 210 |
print "(10x,a)", ' ' |
| 211 |
case(ishape_function) |
| 212 |
print "(10x,a)",' _ / ' |
| 213 |
write(*,fmtstring,advance='no') inum,' / \ / '//trim(labelshapetype(itype)) |
| 214 |
if (present(shapein)) then |
| 215 |
print "(' = ',a)",trim(shapein%text) |
| 216 |
else |
| 217 |
print* |
| 218 |
endif |
| 219 |
print "(10x,a)",'/ \_/ ' |
| 220 |
case(ishape_marker) |
| 221 |
write(*,fmtstring,advance='no') inum,' (x) '//labelshapetype(itype) |
| 222 |
print "(a)" |
| 223 |
case default |
| 224 |
print "(a)" |
| 225 |
write(*,fmtstring,advance='no') inum,' '//labelshapetype(itype) |
| 226 |
print "(a)" |
| 227 |
end select |
| 228 |
|
| 229 |
end subroutine print_shapeinfo |
| 230 |
|
| 231 |
!------------------------------------------ |
| 232 |
! utility routine to add new shape object |
| 233 |
!------------------------------------------ |
| 234 |
subroutine add_shape(istart,iend,nshape) |
| 235 |
use params, only:maxplot |
| 236 |
use prompting, only:prompt |
| 237 |
use exactfunction, only:check_function |
| 238 |
use plotlib, only:plotlib_maxlinestyle,plotlib_maxlinecolour,plotlib_maxfillstyle,plotlib_supports_alpha |
| 239 |
integer, intent(in) :: istart,iend |
| 240 |
integer, intent(inout) :: nshape |
| 241 |
integer :: i,ishape,itype,indexi,iunits,ierr,itry |
| 242 |
character(len=10) :: poslabel |
| 243 |
character(len=80) :: string |
| 244 |
|
| 245 |
itype = 1 |
| 246 |
ishape = istart + 1 |
| 247 |
if (ishape > maxshapes) then |
| 248 |
print "(/,a,i2,a)",' *** Error, maximum number of shapes (',maxshapes,') reached, cannot add any more.' |
| 249 |
print "(a)", ' *** If you hit this limit, *please email me* so I can change the default limits!' |
| 250 |
print "(a)", ' *** (and then edit shapes.f90, changing the parameter "maxshapes" to something higher...)' |
| 251 |
return |
| 252 |
endif |
| 253 |
! |
| 254 |
!--fill prompt string with list of shapes |
| 255 |
! |
| 256 |
indexi = 1 |
| 257 |
do i=1,maxshapetype |
| 258 |
if (i < 10) then |
| 259 |
write(string(indexi:),"(1x,i1,') ',a)") i,trim(labelshapetype(i)) |
| 260 |
else |
| 261 |
write(string(indexi:),"(1x,i2,') ',a)") i,trim(labelshapetype(i)) |
| 262 |
endif |
| 263 |
indexi = len_trim(string) + 1 |
| 264 |
enddo |
| 265 |
print "(/,a)",trim(string) |
| 266 |
!print "(i2,a)",(i,') '//trim(labelshapetype(i)),i=1,maxshapetype) |
| 267 |
|
| 268 |
over_shapes: do while(ishape <= iend .and. i <= maxshapes) |
| 269 |
if (istart==0 .or. shape(ishape)%itype <= 0 .or. shape(ishape)%itype > maxshapetype) then |
| 270 |
call prompt('choose an object type (0=none) ',shape(ishape)%itype,0,maxshapetype) |
| 271 |
endif |
| 272 |
itype = shape(ishape)%itype |
| 273 |
if (itype==0) then |
| 274 |
call delete_shape(ishape,nshape) |
| 275 |
exit over_shapes |
| 276 |
else |
| 277 |
call print_shapeinfo(ishape,itype) |
| 278 |
|
| 279 |
if (itype==ishape_function) then |
| 280 |
shape(ishape)%iunits = 1 |
| 281 |
else |
| 282 |
!--choose units |
| 283 |
do i=1,maxunits |
| 284 |
print "(i1,')',1x,a)",i,trim(labelunits(i)) |
| 285 |
enddo |
| 286 |
call prompt('enter units to use for plotting shape',shape(ishape)%iunits,0,maxunits) |
| 287 |
endif |
| 288 |
iunits = shape(ishape)%iunits |
| 289 |
|
| 290 |
select case(itype) |
| 291 |
case(ishape_square) ! square |
| 292 |
call prompt('enter length of side (in '//trim(labelunits(iunits))//')',shape(ishape)%xlen,0.) |
| 293 |
shape(ishape)%ylen = shape(ishape)%xlen |
| 294 |
poslabel = ' centre' |
| 295 |
case(ishape_rectangle) ! rectangle |
| 296 |
call prompt('enter x position of left edge (in '//trim(labelunits(iunits))//')',shape(ishape)%xpos) |
| 297 |
call prompt('enter x position of right edge (in '//trim(labelunits(iunits))//')',shape(ishape)%xlen) |
| 298 |
call prompt('enter y position of bottom edge (in '//trim(labelunits(iunits))//')',shape(ishape)%ypos) |
| 299 |
call prompt('enter y position of top edge (in '//trim(labelunits(iunits))//')',shape(ishape)%ylen) |
| 300 |
poslabel = '' |
| 301 |
case(ishape_arrow) ! arrow |
| 302 |
call prompt('enter starting x position (in '//trim(labelunits(iunits))//') ',shape(ishape)%xpos) |
| 303 |
call prompt('enter starting y position (in '//trim(labelunits(iunits))//') ',shape(ishape)%ypos) |
| 304 |
call prompt('enter finishing x position (in '//trim(labelunits(iunits))//') ',shape(ishape)%xlen) |
| 305 |
call prompt('enter finishing y position (in '//trim(labelunits(iunits))//') ',shape(ishape)%ylen) |
| 306 |
call prompt('enter (optional) text string ',shape(ishape)%text) |
| 307 |
if (len_trim(shape(ishape)%text) > 0) then |
| 308 |
call prompt('enter justification factor (0.0=left 1.0=right)',shape(ishape)%fjust) |
| 309 |
endif |
| 310 |
poslabel = '' |
| 311 |
case(ishape_circle) ! circle |
| 312 |
call prompt('enter radius (in '//trim(labelunits(iunits))//')',shape(ishape)%xlen,0.) |
| 313 |
poslabel = ' centre' |
| 314 |
case(ishape_line) ! line |
| 315 |
call prompt('enter line length (in '//trim(labelunits(iunits))//')',shape(ishape)%xlen,0.) |
| 316 |
call prompt('enter angle of line in degrees (0.0 = horizontal) ',shape(ishape)%angle) |
| 317 |
poslabel = ' starting' |
| 318 |
case(ishape_text) ! text |
| 319 |
call prompt('enter text string ',shape(ishape)%text) |
| 320 |
call prompt('enter angle for text in degrees (0 = horizontal) ',shape(ishape)%angle) |
| 321 |
call prompt('enter justification factor (0.0=left 1.0=right)',shape(ishape)%fjust) |
| 322 |
poslabel = ' starting' |
| 323 |
case(ishape_function) ! arbitrary function |
| 324 |
ierr = 1 |
| 325 |
itry = 1 |
| 326 |
do while(ierr /= 0 .and. itry <= 3) |
| 327 |
if (itry > 1) print "(a,i1,a)",'attempt ',itry,' of 3:' |
| 328 |
print "(a,6(/,11x,a),/)",' Examples: sin(2*pi*x)','sqrt(0.5*x)','x^2', & |
| 329 |
'exp(-2*x**2)','log10(x/2)','exp(p),p=sin(pi*x)','cos(z/d),z=acos(d),d=x^2' |
| 330 |
call prompt('enter function f(x) to plot ',shape(ishape)%text) |
| 331 |
call check_function(shape(ishape)%text,ierr) |
| 332 |
if (ierr /= 0 .and. len(shape(ishape)%text)==len_trim(shape(ishape)%text)) then |
| 333 |
print "(a,i3,a)",' (errors are probably because string is too long, max length = ',len(shape(ishape)%text),')' |
| 334 |
endif |
| 335 |
itry = itry + 1 |
| 336 |
enddo |
| 337 |
if (ierr /= 0) then |
| 338 |
print "(a)",' *** too many tries, aborting ***' |
| 339 |
ishape = ishape - 1 |
| 340 |
cycle over_shapes |
| 341 |
endif |
| 342 |
poslabel = ' starting' |
| 343 |
case(ishape_marker) |
| 344 |
print "(/,' Marker options (for all from -8->31, see plot library userguide):',12(/,i2,') ',a))", & |
| 345 |
0,'square',1,'.',2,'+',3,'*',4,'o',5,'x',12,'5-pointed star',17,'bold circle',-8,'large bold circle' |
| 346 |
call prompt('Enter marker type ',shape(ishape)%ifillstyle) |
| 347 |
poslabel = '' |
| 348 |
end select |
| 349 |
if (itype /= ishape_function .and. itype /= ishape_rectangle .and. itype /= ishape_arrow) then |
| 350 |
call prompt('enter'//trim(poslabel)//' x position (in '//trim(labelunits(iunits))//') ',shape(ishape)%xpos) |
| 351 |
call prompt('enter'//trim(poslabel)//' y position (in '//trim(labelunits(iunits))//') ',shape(ishape)%ypos) |
| 352 |
elseif (itype==7) then |
| 353 |
call prompt('enter xmin for line segment (0=ignore)',shape(ishape)%xpos) |
| 354 |
call prompt('enter xmax for line segment (0=ignore)',shape(ishape)%xlen) |
| 355 |
endif |
| 356 |
if (itype==ishape_square .or. itype==ishape_rectangle .or. itype==ishape_circle) then |
| 357 |
call prompt('enter fill style (1=solid,2=outline,3=hatch,4=crosshatch) for '// & |
| 358 |
trim(labelshapetype(itype)),shape(ishape)%ifillstyle,0,plotlib_maxfillstyle) |
| 359 |
endif |
| 360 |
if (itype /= ishape_text .and. itype /= ishape_marker) then |
| 361 |
call prompt('enter line style (1=solid,2=dash,3=dotdash,4=dot,5=dashdot) for '// & |
| 362 |
trim(labelshapetype(itype)),shape(ishape)%linestyle,0,plotlib_maxlinestyle) |
| 363 |
endif |
| 364 |
if (itype==ishape_text .or. itype==ishape_marker) then |
| 365 |
call prompt('enter character height for '//trim(labelshapetype(itype)),shape(ishape)%xlen,0.,10.) |
| 366 |
else |
| 367 |
call prompt('enter line width for '//trim(labelshapetype(itype)),shape(ishape)%linewidth,0) |
| 368 |
endif |
| 369 |
call prompt('enter '//trim(labelshapetype(itype))//' colour (0=background, 1=foreground, 2-16=plot lib colour indices)', & |
| 370 |
shape(ishape)%icolour,0,plotlib_maxlinecolour) |
| 371 |
if (plotlib_supports_alpha) then |
| 372 |
call prompt('enter '//trim(labelshapetype(itype))//' opacity (0.0-1.0)', & |
| 373 |
shape(ishape)%opacity,0.,1.) |
| 374 |
endif |
| 375 |
|
| 376 |
print "(/,' 0 : plot on every panel ',/,"// & |
| 377 |
"' -1 : plot on first row only ',/,"// & |
| 378 |
"' -2 : plot on first column only ',/,"// & |
| 379 |
"' n : plot on nth panel only ')" |
| 380 |
|
| 381 |
!--make sure the current setting falls within the allowed bounds |
| 382 |
if (shape(ishape)%iplotonpanel < -2 .or. & |
| 383 |
shape(ishape)%iplotonpanel > maxplot) shape(:)%iplotonpanel = 0 |
| 384 |
|
| 385 |
call prompt('Enter selection ',shape(ishape)%iplotonpanel,-2,maxplot) |
| 386 |
if (ishape > nshape) nshape = ishape |
| 387 |
ishape = ishape + 1 |
| 388 |
endif |
| 389 |
enddo over_shapes |
| 390 |
|
| 391 |
end subroutine add_shape |
| 392 |
|
| 393 |
!------------------------------------------ |
| 394 |
! utility routine to delete a shape object |
| 395 |
!------------------------------------------ |
| 396 |
subroutine delete_shape(ishape,nshape) |
| 397 |
integer, intent(in) :: ishape |
| 398 |
integer, intent(inout) :: nshape |
| 399 |
integer :: i |
| 400 |
|
| 401 |
if (ishape > 0 .and. nshape > 0 .and. ishape <= maxshapes) then |
| 402 |
do i=ishape+1,nshape |
| 403 |
shape(i-1) = shape(i) |
| 404 |
enddo |
| 405 |
print "(a)",'> deleted shape: '//trim(labelshapetype(shape(ishape)%itype)) |
| 406 |
!--restore defaults |
| 407 |
shape(nshape)%itype = 0 |
| 408 |
shape(nshape)%icolour = 1 |
| 409 |
shape(nshape)%linestyle = 1 |
| 410 |
shape(nshape)%linewidth = 1 |
| 411 |
shape(nshape)%ifillstyle = 2 |
| 412 |
shape(nshape)%iunits = 1 |
| 413 |
shape(nshape)%iplotonpanel = 0 |
| 414 |
shape(nshape)%xpos = 0.5 |
| 415 |
shape(nshape)%ypos = 0.5 |
| 416 |
shape(nshape)%xlen = 1. |
| 417 |
shape(nshape)%ylen = 1. |
| 418 |
shape(nshape)%angle = 0. |
| 419 |
shape(nshape)%text = ' ' |
| 420 |
shape(nshape)%fjust = 0. |
| 421 |
nshape = nshape - 1 |
| 422 |
endif |
| 423 |
|
| 424 |
end subroutine delete_shape |
| 425 |
|
| 426 |
!------------------------------------------------------------ |
| 427 |
! actual routine that implements plotting of various shapes |
| 428 |
!------------------------------------------------------------ |
| 429 |
subroutine plot_shapes(ipanel,irow,icolumn,itransx,itransy,time,nvar,allvars,tags) |
| 430 |
use exactfunction, only:exact_function |
| 431 |
use transforms, only:transform_inverse,transform |
| 432 |
use asciiutils, only:string_replace |
| 433 |
use plotlib, only:plot_qci,plot_qls,plot_qlw,plot_qfs,plot_qwin,plot_sci,plot_sfs,plot_slw, & |
| 434 |
plot_sci,plot_rect,plot_sls,plot_line,plot_arro,plot_circ,plot_ptxt,plot_numb,& |
| 435 |
plotlib_supports_alpha,plot_set_opacity,plot_pt1,plot_sch,plot_qch,plot_qcs |
| 436 |
use parsetext, only:parse_text,rn |
| 437 |
use params, only:ltag |
| 438 |
integer, intent(in) :: ipanel,irow,icolumn,itransx,itransy |
| 439 |
real, intent(in) :: time |
| 440 |
integer, intent(in) :: nvar |
| 441 |
real, intent(in), dimension(nvar) :: allvars |
| 442 |
character(len=*), dimension(nvar), intent(in) :: tags |
| 443 |
integer :: icolourprev,linestyleprev,linewidthprev,ifillstyle |
| 444 |
integer :: i,j,ierr,iplotonthispanel |
| 445 |
integer, parameter :: maxfuncpts = 1000 |
| 446 |
real :: xmin,xmax,ymin,ymax,dxplot,dyplot,charheightprev,ysign |
| 447 |
real :: xpos,ypos,xlen,ylen,anglerad,dx,xmini,xmaxi,xch,ych |
| 448 |
real, dimension(2) :: xline,yline |
| 449 |
real, dimension(maxfuncpts) :: xfunc,yfunc |
| 450 |
character(len=lentext) :: text |
| 451 |
real(kind=rn), dimension(nvar+1) :: vals |
| 452 |
character(len=ltag), dimension(nvar+1) :: vars |
| 453 |
! |
| 454 |
!--store current settings |
| 455 |
! |
| 456 |
call plot_qci(icolourprev) |
| 457 |
call plot_qls(linestyleprev) |
| 458 |
call plot_qlw(linewidthprev) |
| 459 |
call plot_qfs(ifillstyle) |
| 460 |
call plot_qch(charheightprev) |
| 461 |
! |
| 462 |
!--convert hpos and vpos to x, y to plot arrow |
| 463 |
! |
| 464 |
call plot_qwin(xmin,xmax,ymin,ymax) |
| 465 |
dxplot = xmax - xmin |
| 466 |
dyplot = ymax - ymin |
| 467 |
! |
| 468 |
!--query window size in a variety of other units |
| 469 |
! |
| 470 |
do i=1,nshapes |
| 471 |
|
| 472 |
iplotonthispanel = shape(i)%iplotonpanel |
| 473 |
if (iplotonthispanel==0 & |
| 474 |
.or.(iplotonthispanel > 0 .and. ipanel==iplotonthispanel) & |
| 475 |
.or.(iplotonthispanel==-1 .and. irow==1) & |
| 476 |
.or.(iplotonthispanel==-2 .and. icolumn==1)) then |
| 477 |
|
| 478 |
call plot_sci(shape(i)%icolour) |
| 479 |
call plot_sls(shape(i)%linestyle) |
| 480 |
if (shape(i)%itype==ishape_text .or. shape(i)%itype==ishape_marker) then |
| 481 |
call plot_sch(shape(i)%xlen) |
| 482 |
endif |
| 483 |
call plot_slw(shape(i)%linewidth) |
| 484 |
call plot_sfs(shape(i)%ifillstyle) |
| 485 |
if (plotlib_supports_alpha) call plot_set_opacity(shape(i)%opacity) |
| 486 |
|
| 487 |
anglerad = shape(i)%angle*(pi/180.) |
| 488 |
|
| 489 |
call convert_units(shape(i),xpos,ypos,xlen,ylen, & |
| 490 |
xmin,ymin,dxplot,dyplot,itransx,itransy) |
| 491 |
|
| 492 |
!call print_shapeinfo(i,shape(i)%itype,shape(i)) |
| 493 |
!print "(a)",'> plotting shape: '//trim(labelshapetype(shape(i)%itype)) |
| 494 |
select case(shape(i)%itype) |
| 495 |
case(ishape_square,ishape_rectangle) ! square, rectangle |
| 496 |
if (xlen > dxplot .or. ylen > dyplot) then |
| 497 |
print "(2x,a)",'Error: shape size exceeds plot dimensions: not plotted' |
| 498 |
else |
| 499 |
if (shape(i)%itype==1) then |
| 500 |
call plot_rect(xpos-0.5*xlen,xpos+0.5*xlen,ypos-0.5*ylen,ypos + 0.5*ylen) |
| 501 |
else |
| 502 |
call plot_rect(xpos,xlen,ypos,ylen) |
| 503 |
endif |
| 504 |
endif |
| 505 |
case(ishape_arrow) ! arrow |
| 506 |
!print "(1x,2(a,es10.2,es10.2))",trim(shape(i)%text),xpos,ypos,'->',xlen,ylen |
| 507 |
call plot_arro(xpos,ypos,xlen,ylen) |
| 508 |
!--plot text label under the arrow, if present |
| 509 |
call plot_qcs(4,xch,ych) |
| 510 |
text = trim(shape(i)%text) |
| 511 |
if (len_trim(text) > 0) then |
| 512 |
ysign = max(sign(1.,ylen-ypos),-0.15) |
| 513 |
call plot_ptxt(xpos,ypos-ysign*ych,shape(i)%angle,shape(i)%fjust,trim(text)) |
| 514 |
endif |
| 515 |
case(ishape_circle) ! circle |
| 516 |
if (xlen > dxplot .or. xlen > dyplot) then |
| 517 |
print "(2x,a)",'Error: circle radius exceeds plot dimensions: circle not plotted' |
| 518 |
else |
| 519 |
call plot_circ(xpos,ypos,xlen) |
| 520 |
if (shape(i)%ifillstyle > 2) then |
| 521 |
call plot_sfs(2) ! also plot outline if fill style is hatched |
| 522 |
call plot_circ(xpos,ypos,xlen) |
| 523 |
endif |
| 524 |
endif |
| 525 |
case(ishape_line) ! line |
| 526 |
xline(1) = xpos |
| 527 |
yline(1) = ypos |
| 528 |
xline(2) = xpos + xlen*cos(anglerad) |
| 529 |
yline(2) = ypos + xlen*sin(anglerad) |
| 530 |
call plot_line(2,xline,yline) |
| 531 |
case(ishape_text) ! text |
| 532 |
text = trim(shape(i)%text) |
| 533 |
!--handle special characters in text strings (e.g. replace %t with time) |
| 534 |
if (index(text,'%') /= 0) then |
| 535 |
vars = (/'t'/) |
| 536 |
vals(1) = real(time,kind=rn) |
| 537 |
if (nvar > 0) then |
| 538 |
vars(2:1+nvar) = tags(1:nvar) |
| 539 |
vals(2:1+nvar) = allvars(1:nvar) |
| 540 |
endif |
| 541 |
call parse_text(text,vars,vals) |
| 542 |
endif |
| 543 |
!--plot text string |
| 544 |
call plot_ptxt(xpos,ypos,shape(i)%angle,shape(i)%fjust,trim(text)) |
| 545 |
case(ishape_function) ! arbitrary function |
| 546 |
!--set x to be evenly spaced in transformed (plot) coordinates |
| 547 |
xmini = xmin |
| 548 |
xmaxi = xmax |
| 549 |
if (abs(shape(i)%xpos) > 0.) xmini = shape(i)%xpos |
| 550 |
if (abs(shape(i)%xlen) > 0.) xmaxi = shape(i)%xlen |
| 551 |
dx = (xmaxi-xmini)/real(maxfuncpts - 1) |
| 552 |
do j=1,maxfuncpts |
| 553 |
xfunc(j) = xmini + (j-1)*dx |
| 554 |
enddo |
| 555 |
!--transform x array back to untransformed space to evaluate f(x) |
| 556 |
if (itransx > 0) call transform_inverse(xfunc,itransx) |
| 557 |
call exact_function(shape(i)%text,xfunc,yfunc,0.,ierr) |
| 558 |
if (ierr==0) then |
| 559 |
!--reset x values |
| 560 |
do j=1,maxfuncpts |
| 561 |
xfunc(j) = xmini + (j-1)*dx |
| 562 |
enddo |
| 563 |
!--transform y if necessary |
| 564 |
if (itransy > 0) call transform(yfunc,itransy) |
| 565 |
!--plot the line |
| 566 |
call plot_line(maxfuncpts,xfunc,yfunc) |
| 567 |
endif |
| 568 |
case(ishape_marker) ! marker |
| 569 |
call plot_pt1(xpos,ypos,shape(i)%ifillstyle) |
| 570 |
end select |
| 571 |
endif |
| 572 |
enddo |
| 573 |
|
| 574 |
call plot_sci(icolourprev) |
| 575 |
call plot_sls(linestyleprev) |
| 576 |
call plot_slw(linewidthprev) |
| 577 |
call plot_sfs(ifillstyle) |
| 578 |
call plot_sch(charheightprev) |
| 579 |
if (plotlib_supports_alpha) call plot_set_opacity(1.0) |
| 580 |
|
| 581 |
end subroutine plot_shapes |
| 582 |
|
| 583 |
!------------------------------------------------------------ |
| 584 |
! query function asking whether or not a point falls within |
| 585 |
! a shape object |
| 586 |
!------------------------------------------------------------ |
| 587 |
integer function inshape(xpt,ypt,itransx,itransy,xmin,xmax,ymin,ymax) |
| 588 |
use plotlib, only:plot_qwin,plot_qtxt,plot_qcs |
| 589 |
real, intent(in) :: xpt,ypt,xmin,ymin,xmax,ymax |
| 590 |
integer, intent(in) :: itransx,itransy |
| 591 |
integer :: i |
| 592 |
real :: xpos,ypos,xlen,ylen,ysign,xch,ych |
| 593 |
real :: dxplot,dyplot |
| 594 |
real, dimension(4) :: xbox,ybox |
| 595 |
|
| 596 |
dxplot = xmax - xmin |
| 597 |
dyplot = ymax - ymin |
| 598 |
|
| 599 |
inshape = 0 |
| 600 |
do i=1,nshapes |
| 601 |
|
| 602 |
call convert_units(shape(i),xpos,ypos,xlen,ylen, & |
| 603 |
xmin,ymin,dxplot,dyplot,itransx,itransy) |
| 604 |
|
| 605 |
select case(shape(i)%itype) |
| 606 |
case(ishape_square,ishape_rectangle) ! square, rectangle |
| 607 |
|
| 608 |
case(ishape_arrow) ! arrow |
| 609 |
if (near_pt(xpos,ypos,xpt,ypt,dxplot,dyplot) .or. & |
| 610 |
near_pt(xlen,ylen,xpt,ypt,dxplot,dyplot)) then |
| 611 |
inshape = i |
| 612 |
endif |
| 613 |
call plot_qtxt(xpos,ypos,shape(i)%angle,shape(i)%fjust,trim(shape(i)%text),xbox,ybox) |
| 614 |
call plot_qcs(4,xch,ych) |
| 615 |
ysign = max(sign(1.,ylen-ypos),0.) |
| 616 |
call plot_qtxt(xpos,ypos-ysign*ych,shape(i)%angle,shape(i)%fjust,trim(shape(i)%text),xbox,ybox) |
| 617 |
if (xpt > minval(xbox) .and. xpt <= maxval(xbox) & |
| 618 |
.and. ypt > minval(ybox) .and. ypt <= maxval(ybox)) then |
| 619 |
inshape = i |
| 620 |
endif |
| 621 |
case(ishape_circle) ! circle |
| 622 |
|
| 623 |
case(ishape_line) ! line |
| 624 |
|
| 625 |
case(ishape_text) ! text |
| 626 |
call plot_qtxt(xpos,ypos,shape(i)%angle,shape(i)%fjust,trim(shape(i)%text),xbox,ybox) |
| 627 |
if (xpt > minval(xbox) .and. xpt <= maxval(xbox) & |
| 628 |
.and. ypt > minval(ybox) .and. ypt <= maxval(ybox)) then |
| 629 |
inshape = i |
| 630 |
endif |
| 631 |
end select |
| 632 |
enddo |
| 633 |
|
| 634 |
end function inshape |
| 635 |
|
| 636 |
!-------------------------------------------- |
| 637 |
! work out whether a mouse click is "close" |
| 638 |
! to a plotted point |
| 639 |
!-------------------------------------------- |
| 640 |
logical function near_pt(x1,y1,xc,yc,dx,dy) |
| 641 |
real, intent(in) :: x1,y1,xc,yc,dx,dy |
| 642 |
real :: xtol,ytol |
| 643 |
|
| 644 |
xtol = dx/128. ! as in 1/128th of the page width |
| 645 |
ytol = dy/128. ! as in 1/128th of the page height |
| 646 |
near_pt = ((x1-xc)**2 < xtol*xtol) .and. & |
| 647 |
((y1-yc)**2 < ytol*ytol) |
| 648 |
|
| 649 |
end function near_pt |
| 650 |
|
| 651 |
!--------------------------------------- |
| 652 |
! routine to edit shapes interactively |
| 653 |
!--------------------------------------- |
| 654 |
subroutine edit_shape(i,xpt,ypt,itransx,itransy,first) |
| 655 |
use plotlib, only:plot_qwin,plot_qtxt,plot_qcs |
| 656 |
integer, intent(in) :: i,itransx,itransy |
| 657 |
real, intent(in) :: xpt,ypt |
| 658 |
logical, intent(in) :: first |
| 659 |
real :: xmin,xmax,ymin,ymax,dxplot,dyplot,xlen,ylen |
| 660 |
real :: xpos,ypos,xbox(4),ybox(4),xch,ych,ysign |
| 661 |
|
| 662 |
call plot_qwin(xmin,xmax,ymin,ymax) |
| 663 |
dxplot = xmax - xmin |
| 664 |
dyplot = ymax - ymin |
| 665 |
|
| 666 |
call convert_units(shape(i),xpos,ypos,xlen,ylen, & |
| 667 |
xmin,ymin,dxplot,dyplot,itransx,itransy) |
| 668 |
|
| 669 |
select case(shape(i)%itype) |
| 670 |
case(ishape_text) |
| 671 |
call edit_textbox(xpos,ypos,shape(i)%angle,shape(i)%fjust,shape(i)%text) |
| 672 |
case(ishape_arrow) |
| 673 |
call plot_qtxt(xpos,ypos,shape(i)%angle,shape(i)%fjust,trim(shape(i)%text),xbox,ybox) |
| 674 |
call plot_qcs(4,xch,ych) |
| 675 |
ysign = max(sign(1.,ylen-ypos),0.0) |
| 676 |
if (near_pt(xlen,ylen,xpt,ypt,dxplot,dyplot)) then |
| 677 |
! if click on head of arrow, move the tail |
| 678 |
call edit_arrow(xlen,ylen,shape(i)%xpos,shape(i)%ypos) |
| 679 |
elseif (xpt > minval(xbox) .and. xpt <= maxval(xbox) & |
| 680 |
.and. ypt-0.5*ysign*ych > minval(ybox) .and. ypt-0.5*ysign*ych <= maxval(ybox)) then |
| 681 |
! if click on text box, edit text |
| 682 |
call edit_textbox(xpos,ypos,shape(i)%angle,shape(i)%fjust,shape(i)%text) |
| 683 |
else |
| 684 |
! if click on tail of arrow, move the head |
| 685 |
call edit_arrow(xpos,ypos,shape(i)%xlen,shape(i)%ylen) |
| 686 |
if (first) call edit_textbox(xpos,ypos,shape(i)%angle,shape(i)%fjust,shape(i)%text) |
| 687 |
endif |
| 688 |
end select |
| 689 |
|
| 690 |
end subroutine edit_shape |
| 691 |
|
| 692 |
!-------------------------------------------------------- |
| 693 |
! utility routine to add a new text shape interactively |
| 694 |
!-------------------------------------------------------- |
| 695 |
subroutine add_shape_interactive(xpt,ypt,itransx,itransy,ipanel,ierr,shape_type) |
| 696 |
use plotlib, only:plot_qwin,plot_qch |
| 697 |
real, intent(in) :: xpt,ypt |
| 698 |
integer, intent(in) :: itransx,itransy,ipanel |
| 699 |
integer, intent(out) :: ierr |
| 700 |
integer, intent(in), optional :: shape_type |
| 701 |
integer :: i,itype |
| 702 |
real :: xmin,xmax,ymin,ymax,xposi,yposi,charheight |
| 703 |
|
| 704 |
itype = ishape_text ! text shape by default |
| 705 |
if (present(shape_type)) itype = shape_type |
| 706 |
|
| 707 |
ierr = 0 |
| 708 |
nshapes = nshapes + 1 |
| 709 |
if (nshapes > maxshapes) then |
| 710 |
print*,' *** cannot add shape: array limits reached, delete some shapes first ***' |
| 711 |
nshapes = maxshapes |
| 712 |
ierr = 1 |
| 713 |
return |
| 714 |
endif |
| 715 |
i = nshapes |
| 716 |
shape(i)%itype = itype |
| 717 |
print*,' adding shape '//trim(labelshapetype(shape(i)%itype)) |
| 718 |
shape(i)%icolour = 1 |
| 719 |
shape(i)%linestyle = 1 |
| 720 |
shape(i)%linewidth = 1 |
| 721 |
shape(i)%ifillstyle = 2 |
| 722 |
shape(i)%iplotonpanel = ipanel |
| 723 |
! |
| 724 |
!--position shapes relative to viewport |
| 725 |
! |
| 726 |
shape(i)%iunits = 2 |
| 727 |
call plot_qwin(xmin,xmax,ymin,ymax) |
| 728 |
xposi = (xpt - xmin)/(xmax-xmin) |
| 729 |
yposi = (ypt - ymin)/(ymax-ymin) |
| 730 |
shape(i)%xpos = xposi |
| 731 |
shape(i)%ypos = yposi |
| 732 |
|
| 733 |
call plot_qch(charheight) |
| 734 |
shape(i)%xlen = charheight |
| 735 |
shape(i)%ylen = 1. |
| 736 |
shape(i)%angle = 0. |
| 737 |
shape(i)%text = 'click to edit' |
| 738 |
shape(i)%fjust = 0. |
| 739 |
if (itype==ishape_arrow) shape(i)%fjust = 0.5 |
| 740 |
call edit_shape(i,xposi,yposi,itransx,itransy,first=.true.) |
| 741 |
|
| 742 |
end subroutine add_shape_interactive |
| 743 |
|
| 744 |
!------------------------------------------------------------ |
| 745 |
! utility routine to add a new text shape non-interactively |
| 746 |
!----------------------------------------------------------- |
| 747 |
subroutine add_text(xpos,ypos,string) |
| 748 |
use plotlib, only:plot_qch |
| 749 |
real, intent(in) :: xpos,ypos |
| 750 |
character(len=*), intent(in) :: string |
| 751 |
integer :: i,ierr |
| 752 |
real :: charheight |
| 753 |
|
| 754 |
ierr = 0 |
| 755 |
! do nothing if string is blank |
| 756 |
if (len_trim(string) <= 0) return |
| 757 |
|
| 758 |
call delete_text(string) ! delete if already exists |
| 759 |
nshapes = nshapes + 1 |
| 760 |
if (nshapes > maxshapes) then |
| 761 |
print*,' *** cannot add shape: array limits reached, delete some shapes first ***' |
| 762 |
nshapes = maxshapes |
| 763 |
ierr = 1 |
| 764 |
return |
| 765 |
endif |
| 766 |
i = nshapes |
| 767 |
shape(i)%itype = 6 |
| 768 |
!print*,' adding shape '//trim(labelshapetype(shape(i)%itype)) |
| 769 |
shape(i)%icolour = 1 |
| 770 |
shape(i)%linestyle = 1 |
| 771 |
shape(i)%linewidth = 1 |
| 772 |
shape(i)%ifillstyle = 2 |
| 773 |
shape(i)%iplotonpanel = 1 |
| 774 |
shape(i)%iunits = 2 |
| 775 |
shape(i)%xpos = xpos |
| 776 |
shape(i)%ypos = ypos |
| 777 |
|
| 778 |
call plot_qch(charheight) |
| 779 |
shape(i)%xlen = charheight |
| 780 |
shape(i)%ylen = 1. |
| 781 |
shape(i)%angle = 0. |
| 782 |
shape(i)%text = string |
| 783 |
shape(i)%fjust = 0. |
| 784 |
|
| 785 |
end subroutine add_text |
| 786 |
|
| 787 |
!------------------------------------------------------------ |
| 788 |
! delete matching text shape |
| 789 |
!----------------------------------------------------------- |
| 790 |
subroutine delete_text(string) |
| 791 |
character(len=*), intent(in) :: string |
| 792 |
integer :: i,nshapesold |
| 793 |
|
| 794 |
nshapesold = nshapes |
| 795 |
do i=1,nshapesold |
| 796 |
if (shape(i)%itype == 6 .and. shape(i)%text == trim(string)) then |
| 797 |
call delete_shape(i,nshapes) |
| 798 |
endif |
| 799 |
enddo |
| 800 |
|
| 801 |
end subroutine delete_text |
| 802 |
|
| 803 |
!----------------------------------------------------------------- |
| 804 |
! utility routine to convert between units used in shape plotting |
| 805 |
!----------------------------------------------------------------- |
| 806 |
subroutine convert_units(shape,xpos,ypos,xlen,ylen,xmin,ymin,dxplot,dyplot,itransx,itransy) |
| 807 |
use transforms, only:transform |
| 808 |
type(shapedef), intent(in) :: shape |
| 809 |
real, intent(out) :: xpos,ypos,xlen,ylen |
| 810 |
real, intent(in) :: xmin,ymin,dxplot,dyplot |
| 811 |
integer, intent(in) :: itransx,itransy |
| 812 |
|
| 813 |
xpos = shape%xpos |
| 814 |
ypos = shape%ypos |
| 815 |
xlen = shape%xlen |
| 816 |
ylen = shape%ylen |
| 817 |
|
| 818 |
select case(shape%iunits) |
| 819 |
case(2) ! translate from viewport coordinates into plot coordinates |
| 820 |
xpos = xmin + xpos*dxplot |
| 821 |
ypos = ymin + ypos*dyplot |
| 822 |
if (shape%itype == ishape_circle) then |
| 823 |
xlen = xlen*dxplot |
| 824 |
ylen = ylen*dyplot |
| 825 |
else |
| 826 |
xlen = xmin + xlen*dxplot |
| 827 |
ylen = ymin + ylen*dyplot |
| 828 |
endif |
| 829 |
case(1) |
| 830 |
if (itransx > 0) then |
| 831 |
call transform(xpos,itransx) |
| 832 |
call transform(xlen,itransx) |
| 833 |
endif |
| 834 |
if (itransy > 0) then |
| 835 |
call transform(ypos,itransy) |
| 836 |
call transform(ylen,itransy) |
| 837 |
endif |
| 838 |
! do nothing here |
| 839 |
case default ! should never happen |
| 840 |
print "(a)",' INTERNAL ERROR: unknown units whilst plotting shape' |
| 841 |
end select |
| 842 |
|
| 843 |
end subroutine convert_units |
| 844 |
|
| 845 |
!-------------------------------------------------------- |
| 846 |
! utility routine to edit a text object interactively |
| 847 |
!-------------------------------------------------------- |
| 848 |
subroutine edit_textbox(xpt,ypt,angle,fjust,string) |
| 849 |
use plotlib, only:plot_stbg,plot_ptxt,plot_curs |
| 850 |
real, intent(in) :: xpt,ypt,angle,fjust |
| 851 |
character(len=1) :: mychar |
| 852 |
real :: xpt2,ypt2 |
| 853 |
character(len=*), intent(inout) :: string |
| 854 |
character(len=len(string)) :: oldstring |
| 855 |
integer :: i,ierr |
| 856 |
|
| 857 |
print*,'editing text box, esc or ctrl-c to quit' |
| 858 |
call plot_stbg(0) |
| 859 |
mychar = ' ' |
| 860 |
oldstring = string |
| 861 |
i = max(len_trim(string)+1,1) |
| 862 |
call plot_ptxt(xpt,ypt,angle,fjust,string(1:i)//'_') |
| 863 |
|
| 864 |
xpt2 = xpt |
| 865 |
ypt2 = ypt |
| 866 |
ierr = plot_curs(xpt2,ypt2,mychar) |
| 867 |
do while (mychar /= achar(13) & ! carriage return |
| 868 |
.and. mychar /= achar(27) & ! ctrl-c |
| 869 |
.and. mychar /= achar(3)) ! esc |
| 870 |
if (mychar==achar(8)) then ! backspace |
| 871 |
i = max(i - 1,1) |
| 872 |
string(i:i) = '_' |
| 873 |
call plot_ptxt(xpt,ypt,angle,fjust,string(1:i)) |
| 874 |
string(i:i) = ' ' |
| 875 |
else |
| 876 |
if (trim(string)=='click to edit') then |
| 877 |
!print*,'erasing string' |
| 878 |
string = ' ' |
| 879 |
i = 1 |
| 880 |
endif |
| 881 |
string(i:i) = mychar |
| 882 |
call plot_ptxt(xpt,ypt,angle,fjust,string(1:i)) |
| 883 |
i = min(i + 1,len(string)) |
| 884 |
if (i==len(string)) print*,' reached end of string' |
| 885 |
endif |
| 886 |
ierr = plot_curs(xpt2,ypt2,mychar) |
| 887 |
enddo |
| 888 |
|
| 889 |
!--if ctrl-c or esc, restore original string |
| 890 |
if (mychar==achar(3) .or. mychar==achar(27)) then |
| 891 |
string = oldstring |
| 892 |
print*,'cancelled' |
| 893 |
else |
| 894 |
print*,'done: text = "'//trim(string)//'"' |
| 895 |
endif |
| 896 |
call plot_stbg(-1) |
| 897 |
|
| 898 |
end subroutine edit_textbox |
| 899 |
|
| 900 |
!-------------------------------------------------------- |
| 901 |
! utility routine to edit a text object interactively |
| 902 |
!-------------------------------------------------------- |
| 903 |
subroutine edit_arrow(xpt,ypt,x2,y2) |
| 904 |
use plotlib, only:plot_band,plot_qwin |
| 905 |
real, intent(in) :: xpt,ypt |
| 906 |
real, intent(out) :: x2,y2 |
| 907 |
character(len=1) :: char2 |
| 908 |
integer :: ierr |
| 909 |
real :: xmin,xmax,ymin,ymax |
| 910 |
|
| 911 |
! get point in plot units |
| 912 |
ierr = plot_band(1,1,xpt,ypt,x2,y2,char2) |
| 913 |
|
| 914 |
! transform point to viewport coordinates |
| 915 |
call plot_qwin(xmin,xmax,ymin,ymax) |
| 916 |
x2 = (x2 - xmin)/(xmax-xmin) |
| 917 |
y2 = (y2 - ymin)/(ymax-ymin) |
| 918 |
|
| 919 |
end subroutine edit_arrow |
| 920 |
|
| 921 |
end module shapes |