| 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-2012 Daniel Price. All rights reserved. |
| 19 |
! Contact: [email protected] |
| 20 |
! |
| 21 |
!----------------------------------------------------------------- |
| 22 |
|
| 23 |
!--------------------------------------------------------------------------- |
| 24 |
! The plotlib module in SPLASH provides a consistent API so that SPLASH |
| 25 |
! can be compiled against different graphics libraries as the backend |
| 26 |
! |
| 27 |
! This version provides an interface to Tim Pearson's PGPLOT, |
| 28 |
! which was the original backend used in SPLASH v1.x. Thus, |
| 29 |
! the functions mostly translate directly to PGPLOT equivalents, |
| 30 |
! and basically this is a Fortran 90 interface for PGPLOT. |
| 31 |
! |
| 32 |
! Interface written by James Wetter and Daniel Price (2010) |
| 33 |
!--------------------------------------------------------------------------- |
| 34 |
module plotlib |
| 35 |
implicit none |
| 36 |
logical, parameter :: plotlib_is_pgplot = .true. |
| 37 |
logical, parameter :: plotlib_supports_alpha = .false. |
| 38 |
integer, parameter :: plotlib_maxlinestyle = 5 |
| 39 |
integer, parameter :: plotlib_maxfillstyle = 5 |
| 40 |
integer, parameter :: plotlib_maxlinecolour = 16 |
| 41 |
integer, parameter :: plotlib_maxpalette = 7 |
| 42 |
integer, parameter :: plotlib_extend_pad = 1 ! not implemented in PGPLOT |
| 43 |
integer, parameter :: plotlib_extend_repeat = 2 ! not implemented in PGPLOT |
| 44 |
integer, parameter :: plotlib_extend_reflect = 3 ! not implemented in PGPLOT |
| 45 |
integer, parameter :: plotlib_extend_none = 0 ! not implemented in PGPLOT |
| 46 |
|
| 47 |
public |
| 48 |
|
| 49 |
character(len=1),parameter :: plot_left_click = 'A' |
| 50 |
character(len=1),parameter :: plot_right_click = 'X' |
| 51 |
character(len=1),parameter :: plot_middle_click = 'D' |
| 52 |
character(len=1),parameter :: plot_shift_click = achar(15) |
| 53 |
character(len=1),parameter :: plot_scroll_up = achar(21) |
| 54 |
character(len=1),parameter :: plot_scroll_down = achar(4) |
| 55 |
character(len=1),parameter :: plot_scroll_left = achar(12) |
| 56 |
character(len=1),parameter :: plot_scroll_right = achar(18) |
| 57 |
|
| 58 |
interface plot_qci |
| 59 |
subroutine PGQCI (CI) |
| 60 |
integer,intent(out) :: CI |
| 61 |
end subroutine PGQCI |
| 62 |
end interface |
| 63 |
|
| 64 |
interface plot_qlw |
| 65 |
subroutine PGQLW (LW) |
| 66 |
integer,intent(out) :: LW |
| 67 |
end subroutine PGQLW |
| 68 |
end interface |
| 69 |
|
| 70 |
interface plot_qcr |
| 71 |
subroutine PGQCR (CI, CR, CG, CB) |
| 72 |
integer,intent(in) :: CI |
| 73 |
real,intent(out) :: CR, CG, CB |
| 74 |
end subroutine PGQCR |
| 75 |
end interface |
| 76 |
|
| 77 |
interface plot_qvp |
| 78 |
subroutine PGQVP (UNITS, X1, X2, Y1, Y2) |
| 79 |
integer,intent(in) :: UNITS |
| 80 |
real,intent(out) :: X1, X2, Y1, Y2 |
| 81 |
end subroutine PGQVP |
| 82 |
end interface |
| 83 |
|
| 84 |
interface plot_qwin |
| 85 |
subroutine PGQWIN (X1, X2, Y1, Y2) |
| 86 |
real,intent(out) :: X1, X2, Y1, Y2 |
| 87 |
end subroutine PGQWIN |
| 88 |
end interface |
| 89 |
|
| 90 |
interface plot_ebuf |
| 91 |
subroutine PGEBUF |
| 92 |
end subroutine PGEBUF |
| 93 |
end interface |
| 94 |
|
| 95 |
interface plot_bbuf |
| 96 |
subroutine PGBBUF |
| 97 |
end subroutine PGBBUF |
| 98 |
end interface |
| 99 |
|
| 100 |
interface plot_qcs |
| 101 |
subroutine PGQCS(UNITS, XCH, YCH) |
| 102 |
integer,intent(in) :: UNITS |
| 103 |
real,intent(out) :: XCH, YCH |
| 104 |
end subroutine PGQCS |
| 105 |
end interface |
| 106 |
|
| 107 |
interface plot_annotate |
| 108 |
subroutine PGMTXT (SIDE, DISP, COORD, FJUST, TEXT) |
| 109 |
character(len=*),intent(in) :: SIDE, TEXT |
| 110 |
real,intent(in) :: DISP, COORD, FJUST |
| 111 |
end subroutine PGMTXT |
| 112 |
end interface |
| 113 |
|
| 114 |
interface plot_sch |
| 115 |
subroutine PGSCH (SIZE) |
| 116 |
real,intent(in) :: SIZE |
| 117 |
end subroutine PGSCH |
| 118 |
end interface |
| 119 |
|
| 120 |
interface plot_sci |
| 121 |
subroutine PGSCI (CI) |
| 122 |
integer,intent(in) :: CI |
| 123 |
end subroutine PGSCI |
| 124 |
end interface |
| 125 |
|
| 126 |
interface plot_slw |
| 127 |
subroutine PGSLW (LW) |
| 128 |
integer,intent(in) :: lw |
| 129 |
end subroutine PGSLW |
| 130 |
|
| 131 |
module procedure plot_slw_float |
| 132 |
end interface |
| 133 |
|
| 134 |
interface plot_page |
| 135 |
subroutine pgpage |
| 136 |
end subroutine pgpage |
| 137 |
end interface |
| 138 |
|
| 139 |
interface plot_close |
| 140 |
subroutine PGEND |
| 141 |
end subroutine PGEND |
| 142 |
end interface |
| 143 |
|
| 144 |
interface plot_svp |
| 145 |
subroutine pgsvp(XLEFT, XRIGHT, YBOT, YTOP) |
| 146 |
real,intent(in) :: XLEFT, XRIGHT, YBOT, YTOP |
| 147 |
end subroutine pgsvp |
| 148 |
end interface |
| 149 |
|
| 150 |
interface plot_swin |
| 151 |
subroutine pgswin(X1, X2, Y1, Y2) |
| 152 |
real,intent(in) :: X1, X2, Y1, Y2 |
| 153 |
end subroutine pgswin |
| 154 |
end interface |
| 155 |
|
| 156 |
interface plot_wnad |
| 157 |
subroutine pgwnad(X1, X2, Y1, Y2) |
| 158 |
real,intent(in) :: X1, X2, Y1, Y2 |
| 159 |
end subroutine pgwnad |
| 160 |
end interface |
| 161 |
|
| 162 |
interface plot_qvsz |
| 163 |
subroutine PGQVSZ (UNITS, X1, X2, Y1, Y2) |
| 164 |
integer,intent(in) :: UNITS |
| 165 |
real,intent(out) :: X1, X2, Y1, Y2 |
| 166 |
end subroutine PGQVSZ |
| 167 |
end interface |
| 168 |
|
| 169 |
interface plot_line |
| 170 |
subroutine pgline(npts,xline,yline) |
| 171 |
integer, intent(in) :: npts |
| 172 |
real, intent(in), dimension(npts) :: xline,yline |
| 173 |
end subroutine pgline |
| 174 |
end interface |
| 175 |
|
| 176 |
interface plot_box |
| 177 |
subroutine pgbox(XOPT, XTICK, NXSUB, YOPT, YTICK, NYSUB) |
| 178 |
character*(*),intent(in) :: XOPT, YOPT |
| 179 |
real,intent(in) :: XTICK, YTICK |
| 180 |
integer,intent(in) :: NXSUB, NYSUB |
| 181 |
end subroutine pgbox |
| 182 |
end interface |
| 183 |
|
| 184 |
interface plot_scr |
| 185 |
subroutine PGSCR (CI, CR, CG, CB) |
| 186 |
integer, intent(in) :: CI |
| 187 |
real, intent(in) :: CR, CG, CB |
| 188 |
end subroutine pgscr |
| 189 |
|
| 190 |
module procedure pgscra |
| 191 |
end interface |
| 192 |
|
| 193 |
interface plot_bins |
| 194 |
subroutine PGBIN (NBIN, X, DATA, CENTER) |
| 195 |
integer,intent(in) :: NBIN |
| 196 |
real,intent(in) :: X(*), DATA(*) |
| 197 |
LOGICAL,intent(in) :: CENTER |
| 198 |
end subroutine PGBIN |
| 199 |
end interface |
| 200 |
|
| 201 |
interface plot_imag |
| 202 |
module procedure plot_imag_transparent |
| 203 |
end interface |
| 204 |
|
| 205 |
interface plot_qcol |
| 206 |
subroutine pgqcol(icolmin,icolmax) |
| 207 |
integer,intent(out) :: icolmin,icolmax |
| 208 |
end subroutine pgqcol |
| 209 |
end interface |
| 210 |
|
| 211 |
interface plot_qcir |
| 212 |
subroutine pgqcir(icolmin,icolmax) |
| 213 |
integer,intent(out) :: icolmin,icolmax |
| 214 |
end subroutine pgqcir |
| 215 |
end interface |
| 216 |
|
| 217 |
interface plot_scir |
| 218 |
subroutine pgscir(icilo, icihi) |
| 219 |
integer,intent(in) :: icilo,icihi |
| 220 |
end subroutine pgscir |
| 221 |
end interface |
| 222 |
|
| 223 |
interface plot_ctab |
| 224 |
subroutine pgctab(l,r,g,b,nc,contra,bright) |
| 225 |
integer,intent(in) :: nc |
| 226 |
real,intent(in) :: l(nc),r(nc),g(nc),b(nc),contra,bright |
| 227 |
end subroutine pgctab |
| 228 |
end interface |
| 229 |
|
| 230 |
interface plot_qls |
| 231 |
subroutine pgqls(ls) |
| 232 |
integer,intent(out) :: ls |
| 233 |
end subroutine pgqls |
| 234 |
end interface |
| 235 |
|
| 236 |
interface plot_qfs |
| 237 |
subroutine pgqfs(fs) |
| 238 |
integer,intent(out) :: fs |
| 239 |
end subroutine pgqfs |
| 240 |
end interface |
| 241 |
|
| 242 |
interface plot_sls |
| 243 |
subroutine pgsls(ls) |
| 244 |
integer,intent(in) :: ls |
| 245 |
end subroutine pgsls |
| 246 |
end interface |
| 247 |
|
| 248 |
interface plot_sfs |
| 249 |
subroutine pgsfs(fs) |
| 250 |
integer,intent(in) :: fs |
| 251 |
end subroutine pgsfs |
| 252 |
end interface |
| 253 |
|
| 254 |
interface plot_rect |
| 255 |
subroutine pgrect(x1,x2,y1,y2) |
| 256 |
real,intent(in) :: x1,x2,y1,y2 |
| 257 |
end subroutine pgrect |
| 258 |
|
| 259 |
module procedure plot_rect_rounded |
| 260 |
end interface |
| 261 |
|
| 262 |
interface plot_arro |
| 263 |
subroutine pgarro(x1,y1,x2,y2) |
| 264 |
real,intent(in) :: x1,y1,x2,y2 |
| 265 |
end subroutine pgarro |
| 266 |
end interface |
| 267 |
|
| 268 |
interface plot_circ |
| 269 |
subroutine pgcirc(xcent,ycent,radius) |
| 270 |
real,intent(in) :: xcent,ycent,radius |
| 271 |
end subroutine pgcirc |
| 272 |
end interface |
| 273 |
|
| 274 |
interface plot_lcur |
| 275 |
subroutine pglcur (maxpt, npt, x, y) |
| 276 |
integer, intent(in) :: maxpt |
| 277 |
integer, intent(inout) :: npt |
| 278 |
real, intent(inout) :: x(*), y(*) |
| 279 |
end subroutine pglcur |
| 280 |
|
| 281 |
module procedure plot_clcur |
| 282 |
end interface plot_lcur |
| 283 |
|
| 284 |
interface plot_olin |
| 285 |
subroutine pgolin (maxpt, npt, x, y, symbol) |
| 286 |
integer, intent(in) :: maxpt |
| 287 |
integer, intent(inout) :: npt |
| 288 |
real, intent(inout) :: x(*), y(*) |
| 289 |
integer, intent(in) :: symbol |
| 290 |
end subroutine pgolin |
| 291 |
end interface plot_olin |
| 292 |
|
| 293 |
interface plot_ncur |
| 294 |
subroutine pgncur(maxpt, npt, x, y, symbol) |
| 295 |
integer, intent(in) :: maxpt |
| 296 |
integer, intent(inout) :: npt |
| 297 |
real, intent(inout) :: x(*), y(*) |
| 298 |
integer, intent(in) :: symbol |
| 299 |
end subroutine pgncur |
| 300 |
end interface plot_ncur |
| 301 |
|
| 302 |
interface plot_qtxt |
| 303 |
subroutine pgqtxt(x,y,angle,fjust,text,xbox,ybox) |
| 304 |
real,intent(in) :: x, y, angle, fjust |
| 305 |
character(len=*),intent(in) :: text |
| 306 |
real,intent(out),dimension(4) :: xbox,ybox |
| 307 |
end subroutine pgqtxt |
| 308 |
end interface |
| 309 |
|
| 310 |
interface plot_ptxt |
| 311 |
subroutine pgptxt(x,y,angle,fjust,text) |
| 312 |
real,intent(in) :: x,y,angle,fjust |
| 313 |
character(len=*),intent(in) :: TEXT |
| 314 |
end subroutine pgptxt |
| 315 |
end interface |
| 316 |
|
| 317 |
interface plot_stbg |
| 318 |
subroutine pgstbg(bg) |
| 319 |
integer,intent(in) :: bg |
| 320 |
end subroutine pgstbg |
| 321 |
end interface |
| 322 |
|
| 323 |
interface plot_curs |
| 324 |
! integer function pgcurs(x,y,ch) |
| 325 |
! real,intent(inout) :: x,y |
| 326 |
! character*(*),intent(out) :: ch |
| 327 |
! end function pgcurs |
| 328 |
module procedure pgcurs_sub |
| 329 |
end interface |
| 330 |
|
| 331 |
interface plot_pt |
| 332 |
subroutine pgpt(n,xpts,ypts,symbol) |
| 333 |
integer,intent(in) :: n |
| 334 |
real,intent(in) :: xpts(*),ypts(*) |
| 335 |
integer,intent(in) :: symbol |
| 336 |
end subroutine pgpt |
| 337 |
end interface |
| 338 |
|
| 339 |
interface plot_funx |
| 340 |
subroutine pgfunx(fx,n,ymin,ymax,pgflags) |
| 341 |
real,external :: fx |
| 342 |
integer,intent(in) :: n,pgflags |
| 343 |
real,intent(in) :: ymin,ymax |
| 344 |
end subroutine pgfunx |
| 345 |
end interface |
| 346 |
|
| 347 |
interface plot_label |
| 348 |
subroutine pglabel(xlbl,ylbl,toplbl) |
| 349 |
character(len=*),intent(in) :: xlbl,ylbl,toplbl |
| 350 |
end subroutine pglabel |
| 351 |
end interface |
| 352 |
|
| 353 |
interface plot_scrn |
| 354 |
subroutine pgscrn(ci,name,ier) |
| 355 |
integer,intent(in) :: ci |
| 356 |
character(len=*),intent(in) :: name |
| 357 |
integer,intent(out) :: ier |
| 358 |
end subroutine pgscrn |
| 359 |
end interface |
| 360 |
|
| 361 |
interface plot_poly |
| 362 |
subroutine pgpoly(n,xpts,ypts) |
| 363 |
integer,intent(in) :: n |
| 364 |
real,intent(in) :: xpts(*),ypts(*) |
| 365 |
end subroutine pgpoly |
| 366 |
end interface |
| 367 |
|
| 368 |
interface plot_qinf |
| 369 |
subroutine pgqinf(item,value,length) |
| 370 |
character(len=*),intent(in) :: item |
| 371 |
character(len=*),intent(out) :: value |
| 372 |
integer,intent(out) :: length |
| 373 |
end subroutine pgqinf |
| 374 |
end interface |
| 375 |
|
| 376 |
interface plot_band |
| 377 |
module procedure pgband_sub |
| 378 |
end interface |
| 379 |
|
| 380 |
interface plot_pt1 |
| 381 |
subroutine pgpt1(xpt,ypt,symbol) |
| 382 |
real,intent(in) :: xpt,ypt |
| 383 |
integer,intent(in) :: symbol |
| 384 |
end subroutine pgpt1 |
| 385 |
end interface |
| 386 |
|
| 387 |
interface plot_numb |
| 388 |
subroutine pgnumb(m,pp,form,string,nc) |
| 389 |
integer,intent(in) :: m,pp,form |
| 390 |
character(len=*),intent(out) :: string |
| 391 |
integer,intent(out) :: nc |
| 392 |
end subroutine pgnumb |
| 393 |
end interface |
| 394 |
|
| 395 |
interface plot_qch |
| 396 |
subroutine pgqch(ch) |
| 397 |
real,intent(out) :: ch |
| 398 |
end subroutine pgqch |
| 399 |
end interface |
| 400 |
|
| 401 |
interface plot_text |
| 402 |
subroutine pgtext(x,y,text) |
| 403 |
real,intent(in) :: x,y |
| 404 |
character(len=*),intent(in) :: text |
| 405 |
end subroutine pgtext |
| 406 |
end interface |
| 407 |
|
| 408 |
interface plot_err1 |
| 409 |
subroutine pgerr1(dir,x,y,e,t) |
| 410 |
integer,intent(in) :: dir |
| 411 |
real,intent(in) :: x,y,e |
| 412 |
real,intent(in) :: t |
| 413 |
end subroutine pgerr1 |
| 414 |
end interface |
| 415 |
|
| 416 |
interface plot_errb |
| 417 |
subroutine pgerrb(dir,n,x,y,e,t) |
| 418 |
integer,intent(in) :: dir,n |
| 419 |
real,intent(in) :: x(n),y(n),e(n) |
| 420 |
real,intent(in) :: t |
| 421 |
end subroutine pgerrb |
| 422 |
end interface |
| 423 |
|
| 424 |
interface plot_conb |
| 425 |
subroutine pgconb(a,idim,jdim,i1,i2,j1,j2,c,nc,tr,blank) |
| 426 |
integer,intent(in) :: idim,jdim,i1,i2,j1,j2,nc |
| 427 |
real,intent(in) :: a(idim,jdim),c(*),tr(6),blank |
| 428 |
end subroutine pgconb |
| 429 |
end interface |
| 430 |
|
| 431 |
interface plot_cons |
| 432 |
subroutine pgcons(a,idim,jdim,i1,i2,j1,j2,c,nc,tr) |
| 433 |
integer,intent(in) :: idim,jdim,i1,i2,j1,j2,nc |
| 434 |
real,intent(in) :: a(idim,jdim),c(*),tr(6) |
| 435 |
end subroutine pgcons |
| 436 |
end interface |
| 437 |
|
| 438 |
interface plot_conl |
| 439 |
subroutine pgconl(a,idim,jdim,i1,i2,j1,j2,c,tr,label,intval,mininit) |
| 440 |
integer,intent(in) :: idim,jdim,i1,i2,j1,j2,intval,mininit |
| 441 |
real,intent(in) :: a(idim,jdim),c,tr(6) |
| 442 |
character(len=*),intent(in) :: label |
| 443 |
end subroutine pgconl |
| 444 |
end interface |
| 445 |
|
| 446 |
interface plot_sah |
| 447 |
subroutine pgsah(fs, angle, cutback) |
| 448 |
integer, intent(in) :: fs |
| 449 |
real, intent(in) :: angle, cutback |
| 450 |
end subroutine pgsah |
| 451 |
end interface |
| 452 |
|
| 453 |
interface plot_vect |
| 454 |
subroutine pgvect(a,b,idim,jdim,i1,i2,j1,j2,c,nc,tr,blank) |
| 455 |
integer,intent(in) :: idim,jdim,i1,i2,j1,j2,nc |
| 456 |
real,intent(in) :: a(idim,jdim),b(idim,jdim),tr(6),blank,c |
| 457 |
end subroutine pgvect |
| 458 |
end interface |
| 459 |
|
| 460 |
interface plot_pixl |
| 461 |
subroutine pgpixl(ia,idim,jdim,i1,i2,j1,j2,x1,x2,y1,y2) |
| 462 |
integer,intent(in) :: idim,jdim,i1,i2,j1,j2 |
| 463 |
integer,intent(in) :: ia(idim,jdim) |
| 464 |
real,intent(in) :: x1,x2,y1,y2 |
| 465 |
end subroutine pgpixl |
| 466 |
end interface |
| 467 |
|
| 468 |
interface plot_env |
| 469 |
subroutine pgenv(xmin,xmax,ymin,ymax,just,axis) |
| 470 |
real,intent(in) :: xmin,xmax,ymin,ymax |
| 471 |
integer,intent(in) :: just,axis |
| 472 |
end subroutine pgenv |
| 473 |
end interface |
| 474 |
|
| 475 |
contains |
| 476 |
|
| 477 |
!--------------------------------------------- |
| 478 |
! initialise the plotting library |
| 479 |
!--------------------------------------------- |
| 480 |
subroutine plot_init(devicein, ierr, papersizex, aspectratio, paperunits) |
| 481 |
|
| 482 |
character*(*), intent(in) :: devicein |
| 483 |
integer, intent(out) :: ierr |
| 484 |
real, intent(in), optional :: papersizex,aspectratio |
| 485 |
integer, intent(in), optional :: paperunits |
| 486 |
integer :: pgopen |
| 487 |
real :: aspect |
| 488 |
|
| 489 |
if (devicein(1:1)=='?') then |
| 490 |
call pgbegin(0,'?',1,1) |
| 491 |
ierr = 1 |
| 492 |
else |
| 493 |
ierr = pgopen(devicein) |
| 494 |
endif |
| 495 |
!--check if there is an error |
| 496 |
! (be careful here: from PGPLOT zero or -ve indicates an error) |
| 497 |
if (ierr <= 0) then |
| 498 |
if (ierr==0) ierr = -1 !--make sure we return an error |
| 499 |
return |
| 500 |
else |
| 501 |
ierr = 0 |
| 502 |
endif |
| 503 |
!-- Turn off promting |
| 504 |
call pgask(.false.) |
| 505 |
|
| 506 |
!-- set paper size if given |
| 507 |
if (present(papersizex)) then |
| 508 |
if (present(aspectratio)) then |
| 509 |
aspect = aspectratio |
| 510 |
else |
| 511 |
aspect = sqrt(2.) |
| 512 |
endif |
| 513 |
if (present(paperunits)) then |
| 514 |
!--make sure that the units are in inches for PGPLOT |
| 515 |
if (paperunits /= 1) return |
| 516 |
endif |
| 517 |
call plot_pap(papersizex,aspect) |
| 518 |
endif |
| 519 |
|
| 520 |
end subroutine plot_init |
| 521 |
|
| 522 |
subroutine plot_slc(lc) |
| 523 |
integer,intent(in) :: lc |
| 524 |
|
| 525 |
!--line cap has no effect in PGPLOT |
| 526 |
|
| 527 |
end subroutine plot_slc |
| 528 |
|
| 529 |
subroutine plot_pap(width,aspect,paperunits) |
| 530 |
real,intent(in) :: width,aspect |
| 531 |
integer, intent(in), optional :: paperunits |
| 532 |
|
| 533 |
if (present(paperunits)) then |
| 534 |
if (paperunits /= 1) print "(a)",' WARNING: units not valid for PGPLOT' |
| 535 |
endif |
| 536 |
call pgpap(width,aspect) |
| 537 |
|
| 538 |
end subroutine plot_pap |
| 539 |
|
| 540 |
subroutine plot_qlc(lc) |
| 541 |
integer,intent(out) :: lc |
| 542 |
|
| 543 |
lc = 0 |
| 544 |
end subroutine plot_qlc |
| 545 |
|
| 546 |
subroutine plot_set_opacity(alpha) |
| 547 |
real, intent(in) :: alpha |
| 548 |
|
| 549 |
!--opacity has no effect in PGPLOT |
| 550 |
|
| 551 |
end subroutine plot_set_opacity |
| 552 |
|
| 553 |
!--interface to set transparent colour |
| 554 |
! (not implemented in PGPLOT) |
| 555 |
subroutine pgscra (CI, CR, CG, CB, CA) |
| 556 |
integer, intent(in) :: CI |
| 557 |
real, intent(in) :: CR, CG, CB, CA |
| 558 |
|
| 559 |
!--just throw away the alpha value |
| 560 |
call PGSCR(CI,CR,CG,CB) |
| 561 |
|
| 562 |
end subroutine pgscra |
| 563 |
|
| 564 |
!--floating point line widths |
| 565 |
! (not implemented in PGPLOT) |
| 566 |
subroutine plot_slw_float (LW) |
| 567 |
real,intent(in) :: lw |
| 568 |
|
| 569 |
call PGSLW(nint(lw)) |
| 570 |
|
| 571 |
end subroutine plot_slw_float |
| 572 |
|
| 573 |
subroutine plot_rgb_from_table(frac,r,g,b) |
| 574 |
real, intent(in) :: frac |
| 575 |
real, intent(out) :: r,g,b |
| 576 |
|
| 577 |
!--rgb from table not implemented in PGPLOT |
| 578 |
|
| 579 |
end subroutine plot_rgb_from_table |
| 580 |
|
| 581 |
subroutine plot_set_palette(lp) |
| 582 |
integer, intent(in) :: lp |
| 583 |
|
| 584 |
!--set line palette not implemented in PGPLOT |
| 585 |
|
| 586 |
end subroutine plot_set_palette |
| 587 |
|
| 588 |
logical function plot_qcur() |
| 589 |
character(len=10) :: string |
| 590 |
integer :: nc |
| 591 |
call pgqinf('CURSOR',string,nc) |
| 592 |
|
| 593 |
if (string(1:nc)=='YES') then |
| 594 |
plot_qcur = .true. |
| 595 |
else |
| 596 |
plot_qcur = .false. |
| 597 |
endif |
| 598 |
|
| 599 |
end function plot_qcur |
| 600 |
|
| 601 |
! |
| 602 |
!--inverts the return value of pgcurs |
| 603 |
! |
| 604 |
function pgcurs_sub(x,y,ch) |
| 605 |
real,intent(inout) :: x,y |
| 606 |
character*(*),intent(out) :: ch |
| 607 |
integer :: pgcurs_sub,ierr |
| 608 |
integer, external :: pgcurs |
| 609 |
|
| 610 |
ierr = pgcurs(x,y,ch) |
| 611 |
|
| 612 |
if (ierr==0) then |
| 613 |
pgcurs_sub = 1 |
| 614 |
else |
| 615 |
pgcurs_sub = 0 |
| 616 |
endif |
| 617 |
|
| 618 |
end function pgcurs_sub |
| 619 |
|
| 620 |
!--transparent rendering does not work in PGPLOT, but |
| 621 |
! we give it an interface anyway |
| 622 |
subroutine plot_imag_transparent(a, idim, jdim, i1, i2, j1, j2, a1, a2, tr, iextend) |
| 623 |
integer,intent(in) :: IDIM, JDIM, I1, I2, J1, J2 |
| 624 |
real,intent(in) :: A(IDIM,JDIM), A1, A2, TR(6) |
| 625 |
integer, intent(in), optional :: iextend |
| 626 |
|
| 627 |
call pgimag(a, idim, jdim, i1, i2, j1, j2, a1, a2, tr) |
| 628 |
|
| 629 |
end subroutine plot_imag_transparent |
| 630 |
|
| 631 |
subroutine plot_imag_alpha(dat, alpha, idim, jdim, i1, i2, j1, j2, a1, a2, tr, iextend) |
| 632 |
integer,intent(in) :: IDIM, JDIM, I1, I2, J1, J2 |
| 633 |
real,intent(in) :: dat(IDIM,JDIM), alpha(IDIM,JDIM), A1, A2, TR(6) |
| 634 |
real :: affine(6) |
| 635 |
integer, intent(in), optional :: iextend |
| 636 |
|
| 637 |
call pgimag(dat, idim, jdim, i1, i2, j1, j2, a1, a2, tr) |
| 638 |
|
| 639 |
end subroutine plot_imag_alpha |
| 640 |
|
| 641 |
!--giza version of plot_gray takes additional arguments |
| 642 |
subroutine plot_gray(a, idim, jdim, i1, i2, j1, j2, a1, a2, tr, iextend) |
| 643 |
integer,intent(in) :: IDIM, JDIM, I1, I2, J1, J2 |
| 644 |
real,intent(in) :: A(IDIM,JDIM), A1, A2, TR(6) |
| 645 |
integer, intent(in), optional :: iextend |
| 646 |
|
| 647 |
call pggray(a, idim, jdim, i1, i2, j1, j2, a1, a2, tr) |
| 648 |
|
| 649 |
end subroutine plot_gray |
| 650 |
|
| 651 |
!--version of lcur that returns last character pressed |
| 652 |
subroutine plot_clcur(maxpt, npt, x, y, ch) |
| 653 |
integer, intent(in) :: maxpt |
| 654 |
integer, intent(inout) :: npt |
| 655 |
real, intent(inout) :: x(*), y(*) |
| 656 |
character*(*),intent(out) :: ch |
| 657 |
|
| 658 |
call pglcur (maxpt, npt, x, y) |
| 659 |
ch = 'A' |
| 660 |
|
| 661 |
end subroutine plot_clcur |
| 662 |
|
| 663 |
!--rounded rectangle plotting |
| 664 |
! (not implemented -- just calls pgrect) |
| 665 |
subroutine plot_rect_rounded(x1,x2,y1,y2,r) |
| 666 |
real,intent(in) :: x1,x2,y1,y2,r |
| 667 |
|
| 668 |
call pgrect(x1,x2,y1,y2) |
| 669 |
|
| 670 |
end subroutine plot_rect_rounded |
| 671 |
! |
| 672 |
!--inverts the return value of pgband |
| 673 |
! |
| 674 |
function pgband_sub(mode, posn, xref, yref, x, y, ch) |
| 675 |
integer,intent(in) :: mode, posn |
| 676 |
real,intent(in) :: xref, yref |
| 677 |
real,intent(inout) :: x, y |
| 678 |
character*(*),intent(out) :: ch |
| 679 |
integer :: ierr,pgband_sub |
| 680 |
integer,external :: pgband |
| 681 |
|
| 682 |
ierr = pgband(mode,posn,xref,yref,x,y,ch) |
| 683 |
|
| 684 |
if (ierr==1) then |
| 685 |
pgband_sub = 0 |
| 686 |
else |
| 687 |
pgband_sub = 1 |
| 688 |
endif |
| 689 |
end function pgband_sub |
| 690 |
|
| 691 |
! |
| 692 |
!--this subroutine can be called after PGSVP to |
| 693 |
! make sure that the viewport lies exactly on |
| 694 |
! pixel boundaries. |
| 695 |
! |
| 696 |
! Queries PGPLOT routines directly so no need |
| 697 |
! for input/output |
| 698 |
! |
| 699 |
|
| 700 |
subroutine plot_set_exactpixelboundaries() |
| 701 |
real :: xminpix,xmaxpix,yminpix,ymaxpix |
| 702 |
real :: vptxmin,vptxmax,vptymin,vptymax |
| 703 |
real :: dv |
| 704 |
real, parameter :: tol = 1.e-6 |
| 705 |
! |
| 706 |
! setting axes adjusts the viewport, so query to get adjusted settings |
| 707 |
! |
| 708 |
call pgqvp(0,vptxmin,vptxmax,vptymin,vptymax) |
| 709 |
!print*,'got ',vptxmin,vptxmax,vptymin,vptymax |
| 710 |
! |
| 711 |
! adjust viewport on pixel devices so that |
| 712 |
! boundaries lie exactly on pixel boundaries |
| 713 |
! |
| 714 |
! query viewport size in pixels |
| 715 |
call pgqvp(3,xminpix,xmaxpix,yminpix,ymaxpix) |
| 716 |
!print*,' in pixels = ',xminpix,xmaxpix,yminpix,ymaxpix |
| 717 |
|
| 718 |
! work out how many viewport coords/pixel |
| 719 |
dv = (vptymax - vptymin)/(ymaxpix-yminpix) |
| 720 |
|
| 721 |
! adjust viewport min/max to lie on pixel boundaries |
| 722 |
vptymin = max((nint(yminpix)-tol)*dv,0.) |
| 723 |
vptymax = min((nint(ymaxpix)-tol)*dv,1.0-epsilon(1.0)) ! be careful of round-off errors |
| 724 |
|
| 725 |
! same for x |
| 726 |
dv = (vptxmax - vptxmin)/(xmaxpix-xminpix) |
| 727 |
vptxmin = max((nint(xminpix)-tol)*dv,0.) |
| 728 |
vptxmax = min((nint(xmaxpix)-tol)*dv,1.0-epsilon(1.0)) ! be careful of round-off errors |
| 729 |
|
| 730 |
! adjust viewport |
| 731 |
!print*,'adjusting ',vptxmin,vptxmax,vptymin,vptymax |
| 732 |
call pgsvp(vptxmin,vptxmax,vptymin,vptymax) |
| 733 |
|
| 734 |
!call pgqvp(3,xminpix,xmaxpix,yminpix,ymaxpix) |
| 735 |
!print*,' in pixels = ',xminpix,xmaxpix,yminpix,ymaxpix |
| 736 |
|
| 737 |
return |
| 738 |
end subroutine plot_set_exactpixelboundaries |
| 739 |
|
| 740 |
end module plotlib |