!-----------------------------------------------------------------------
! Plot all the possible pen colours.
! Default is to do the plot in a dedicated window without modifying
! the current user plots. If argument "<GREG" is present, plot in main
! <GREG window instead.
!-----------------------------------------------------------------------
!
begin procedure plot_lut
  !
  gtvl\lut 'pro%arg[1]'
  greg2\plot
  greg1\pencil /col grey
  greg1\box n n n
  greg1\pencil /col foreground
  greg1\draw text 0 0.3 'pro%arg[1]' 6 /box 7
  !
end procedure plot_lut
!
define logical useother
if (pro%narg.ge.1) then
  let useother pro%arg[1].ne."<GREG"
else
  let useother yes
endif
!
if (useother) then
  ! Perform the plot in a dedicated window
  define char*32 oldpwd
  let oldpwd 'gtv%pwd'
  gtvl\gtv search <luts
  if (.not.gtv%exist)  g\create directory <luts
  gtvl\change directory <luts
endif
!
gtvl\clear directory
greg1\set /def
!
! Dummy data
define real x[128,2]
define real y z /like x
let x[i,j] i
let y[i,j] j
let z[i,j] i
greg2\rgdata x y z /blank -1000
greg1\limits /rg
!
define integer nrows
let nrows 10
define real xinc yinc xw yw
let xinc page_x/8.0
let yinc page_y/11.3
let xw xinc*0.4
let yw yinc*0.2
!
gtvl\change lut static
greg1\set char 0.5
define integer ilut
!
!--- Monotoneous luminance ---
define integer nmono
let nmono 20
define character*16 mono[nmono]
let mono "BLACK" "WHITE" "RED" "GREEN" "BLUE" "YELLOW" "CYAN" "MAGENTA" -
  "blulut.lut" "heat.lut" "inferno.lut" "light.lut" "magma.lut" -
  "mousse.lut" "neg.lut" "pastel.lut" "plasma.lut" "ramp.lut" "real.lut" -
  "viridis.lut"
!
let ilut 0
for i 1 to 2
  for j nrows to 1 by -1
    let ilut ilut+1
    if (ilut.gt.nmono)  break
    !
    greg1\set box_loc xinc*i-xw xinc*i+xw yinc*j-yw yinc*j+yw
    @ plot_lut 'mono[ilut]'
  next j
next i
!
greg1\set box_loc 0.55*xinc 2.45*xinc 0.55*yinc (nrows+0.6)*yinc
greg1\box n n n
greg1\draw text 0. 0.5 "Monotoneous luminance" 6 /box 7
!
!
!--- Staircase ---
define integer nstair
let nstair 16
define character*16 stair[nstair]
let stair "aips0.lut" "color.lut" "flag.lut" "gamma3.lut" "halley.lut" -
  "idl12.lut" "lnspiral.lut" "manycol.lut" "random.lut" "random1.lut" -
  "random2.lut" "random3.lut" "random4.lut" "staircase.lut" "stairs8.lut" -
  "stairs9.lut"
!
let ilut 0
for i 3 to 4
  for j nrows to 1 by -1
    let ilut ilut+1
    if (ilut.gt.nstair)  break
    !
    greg1\set box_loc xinc*i-xw xinc*i+xw yinc*j-yw yinc*j+yw
    @ plot_lut 'stair[ilut]'
  next j
next i
!
greg1\set box_loc 2.55*xinc 4.45*xinc 0.55*yinc (nrows+0.6)*yinc
greg1\box n n n
greg1\draw text 0. 0.5 "Staircase" 6 /box 7
!
!
!--- Others ---
define integer nother
let nother 24
define character*16 other[nother]
let other "DEFAULT" "COLOR" "BLUERED" "NULL" "alex.lut" "backgr.lut" -
  "idl2.lut" "idl4.lut" "idl5.lut" "idl6.lut" "idl11.lut" "idl14.lut" -
  "idl15.lut" "ikon.lut" "isophot.lut" "pseudo1.lut" "pseudo2.lut" -
  "rainbow.lut" "rainbow1.lut" "rainbow2.lut" "rainbow3.lut" -
  "rainbow4.lut" "smooth.lut" "standard.lut"
!
let ilut 0
for i 5 to 7
  for j nrows to 1 by -1
    let ilut ilut+1
    if (ilut.gt.nother)  break
    !
    greg1\set box_loc xinc*i-xw xinc*i+xw yinc*j-yw yinc*j+yw
    @ plot_lut 'other[ilut]'
  next j
next i
!
greg1\set box_loc 4.55*xinc 7.45*xinc 0.55*yinc (nrows+0.6)*yinc
greg1\box n n n
greg1\draw text 0. 0.5 "Others" 6 /box 7
!
!
! --- Cleaning ---
if useother  g\change directory 'oldpwd'
