! @ p_beam.ima Variable [Code [Size]]
if (pro%narg.eq.0) then
  SAY "@ p_beam.ima Variable [Code [Size]]"
  SAY " "
  SAY " Plots Clean beam "
  SAY " "
  SAY " Variable: "
  SAY " - Name of the header variable that defines the Clean beam"
  SAY " "
  SAY " Code: optional argument indicating the type of beam"
  SAY " - if <0 or >23,  a hatched ellipse"
  SAY " - Otherwise, a filled ellipse of the given color in range [0,23]"
  SAY " "
  SAY " Size: optional argument indicating the size and placement of the" 
  SAY "   box in which the Clean beam is displayed"
  SAY " - If 0< abs(Size) < 1    It is the fraction of the Box size"
  SAY " - if abs(Size) > 1       It is Size times the Clean beam size"
  SAY " If Size is >=0 , the Clean box is cleared before the Clean beam is drawn"
  SAY " If Size < 0, the Clean beam is drawn directly."
  SAY " "
  return
endif
if .not.exist(&1%major) return
if (&1%major.eq.0) return
!
define real fraction 
define integer case
define logical hide
let fraction 3
let case -1
let hide yes
if pro%narg.gt.1 then
  let case &2
  if pro%narg.gt.2 let fraction &3
endif
if (fraction.lt.0) then
  let hide no
  let fraction -fraction
endif
if (fraction.gt.1) then
  let fraction fraction*&1%major/abs(user_xmax-user_xmin)
endif
!
if do_tree then
  gtv search cbeam
  if .not.gtv%exist gtvl\create dir cbeam
  chang dir cbeam
endif
if (hide) then
  define real mypoly[4,2] real dx dy
  let dx (user_xmax-user_xmin)*fraction
  let dy (user_ymax-user_ymin)*fraction
  let mypoly user_xmin user_xmin+dx user_xmin+dx user_xmin user_ymin user_ymin user_ymin+dy user_ymin+dy
  !
  ! Remember current polygon
  if (exist(poly%nxy)) then
   define real opol[poly%nxy,2]
   let opol[1] poly%x
   let opol[2] poly%y
  else
   define real opol[1,2]
  endif
  greg2\polygon mypoly /variable /fill 7 
  greg2\polygon /plot
  greg1\box n n n   ! There may be rounding issues with the Polygon that makes the previous plot partly outside the box, and thus clipped
  greg2\polygon opol /variable  ! Restore Polygon
endif
!
if (case.ge.0).and.(case.le.23) then
  greg2\ellipse 0.5*&1%major 0.5*&1%minor 90-180*&1%pa|pi /box abs(box_xmax-box_xmin)*fraction/2 abs(box_ymax-box_ymin)*fraction/2 /fill case
  pen 0
  greg2\ellipse 0.5*&1%major 0.5*&1%minor 90-180*&1%pa|pi /box abs(box_xmax-box_xmin)*fraction/2 abs(box_ymax-box_ymin)*fraction/2 
else
  !
  define real space
  let space abs((box_xmax-box_xmin)/(user_xmax-user_xmin)*&1%major)/6
  greg2\ellipse 0.5*&1%major 0.5*&1%minor 90-180*&1%pa|pi /box abs(box_xmax-box_xmin)*fraction/2 abs(box_ymax-box_ymin)*fraction/2 /hatch 0 &1%pa*180/pi+30  space
  greg2\ellipse 0.5*&1%major 0.5*&1%minor 90-180*&1%pa|pi /box abs(box_xmax-box_xmin)*fraction/2 abs(box_ymax-box_ymin)*fraction/2 
  !
endif
! 
if (do_tree) change dir ..
!
