! @ p_mark.greg Header
!
! Compute the requested mark value (Channel, Velocity, Frequency)
! for the 3rd axis in displaying a data-cube as a series of planes.
!
! Not useable for UV display.
! 
if (mark.eq."none") return
!
define double xmark
define character cmark*12
define integer iplane
let iplane &2
!
if (&1%f_axis.eq.3) then
  if &1%f_axis.eq.0.or.mark.eq."channel" then
    let xmark iplane
    !
  else if &1%unit3.eq."VELOCITY".or.&1%unit3.eq."FREQUENCY" then
    !
    define character*12 umark
    let umark 'mark' /upper
    !
    if &1%unit3.eq.umark then
      ! User requests the natural spectroscopic axis:
      let xmark &1%convert[2,3]+(iplane-&1%convert[1,3])*&1%convert[3,3]
      !
    else
      ! Conversion between velocity and frequency are not straightforward
      ! in the general case. Use SIC\MODIFY to go from one axis unit to
      ! another, details are factorized there. This only works on Images,
      ! not UV data.
      !
      define header h * image /like &1 
      let h% &1%
      sic\modify h /specunit 'mark'
      let xmark h%convert[2,3]+(iplane-h%convert[1,3])*h%convert[3,3]
      delete /var h
    endif
    !
    if umark.eq."VELOCITY" then
      let xmark nint(xmark*1d2)*1d-2
    else
      let xmark nint(xmark*1d3)*1d-6  ! MHz to GHz
    endif
  else
    let xmark iplane
    message w mark "The unit of the frequency axis (f_axis) is neither FREQUENCY nor VELOCITY"
  endif
else
  let xmark iplane
  if (mark.ne."channel") then
    if (&1%ptype.ne.0).and.((&1%x_axis.eq.3).or.(&1%y_axis.eq.3)).or.(&1%unit3.eq."ANGLE") then
      ! If there is a projection, use current angle unit unless no Mark is requested
      define double rad_to_angle[4] factor
      let rad_to_angle 3600*180/pi 60*180/pi 180/pi 1.d0
      factor = rad_to_angle[u_angle]
      let xmark &1%convert[2,3]+(iplane-&1%convert[1,3])*&1%convert[3,3]
      let xmark xmark*factor
      let xmark 1d-2*nint(xmark*100.)
    endif
  endif
  !
endif
!
let cmark 'xmark'
greg1\draw text 0.2 -0.1 'cmark' 3 /box 7
