!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! @ l-old-beam
!
! &1: aaa
!
! Plots beam of aaa
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! Nothing to be done when the beam is not defined!
if (&1%major.eq.0) then
  return
endif
!
! Define useful variables
define double box[4] user[4] poly[4,2] u0 v0
!
! Save current box parameters
let box[1] box_xmin
let box[2] box_ymin
let box[3] box_xmax
let box[4] box_ymax
let user[1] user_xmin
let user[2] user_ymin
let user[3] user_xmax
let user[4] user_ymax
!
! Set box and limits as a fraction of current box
if ("&2none".eq."none") then
   greg1\set box box[1] box[1]+0.2*(box[3]-box[1]) box[2] box[2]+0.2*(box[4]-box[2])
   greg1\limits user[1] user[1]+0.2*(user[3]-user[1]) user[2] user[2]+0.2*(user[4]-user[2])
   let u0 user[1]+0.1*(user[3]-user[1])
   let v0 user[2]+0.1*(user[4]-user[2])
else if ("&2none".eq."brcnone") then
   greg1\set box box[3]-0.2*(box[3]-box[1]) box[3] box[2] box[2]+0.2*(box[4]-box[2])
   greg1\limits user[3]-0.2*(user[3]-user[1]) user[3] user[2] user[2]+0.2*(user[4]-user[2])
   let u0 user[3]-0.1*(user[3]-user[1])
   let v0 user[2]+0.1*(user[4]-user[2])
else if ("&2none".eq."tlcnone") then
   greg1\set box box[1] box[1]+0.2*(box[3]-box[1]) box[4]-0.2*(box[4]-box[2]) box[4]
   greg1\limits user[1] user[1]+0.2*(user[3]-user[1]) user[4]-0.2*(user[4]-user[2]) user[4]
   let u0 user[1]+0.1*(user[3]-user[1])
   let v0 user[4]-0.1*(user[4]-user[2])
else if ("&2none".eq."trcnone") then
   greg1\set box box[3]-0.2*(box[3]-box[1]) box[3] box[4]-0.2*(box[4]-box[2]) box[4]
   greg1\limits user[3]-0.2*(user[3]-user[1]) user[3] user[4]-0.2*(user[4]-user[2]) user[4]
   let u0 user[3]-0.1*(user[3]-user[1])
   let v0 user[4]-0.1*(user[4]-user[2])
endif
!
! Define masking polygon
let poly user_xmin user_xmax user_xmax user_xmin user_ymin user_ymin user_ymax user_ymax
!
! Save current polygon if needed
if (exist(poly%nxy)) then
 define real opol[poly%nxy,2]
 let opol[1] poly%x
 let opol[2] poly%y
endif
!
! Mask region
greg2\polygon poly /variable
greg2\polygon /fill 7
!
if exist(opol) then
   ! Restore original polygon
   greg2\polygon opol /variable
else
   greg2\polygon /reset
endif
!
! Draw ellipse at center of box
greg2\ellipse 0.5*&1%major 0.5*&1%minor 90-180*&1%pa/pi -
              /box abs(box[3]-box[1])*0.1 abs(box[4]-box[2])*0.1
! Draw hatched ellipse at center of box
greg2\ellipse 0.5*&1%major 0.5*&1%minor 90-180*&1%pa/pi -
              /box abs(box[3]-box[1])*0.1 abs(box[4]-box[2])*0.1 -
              /hatch 0 45 .05
!
! Draw box
greg1\box n n n
!
! Reset parameters
greg1\set box box[1] box[3] box[2] box[4]
greg1\limits user[1] user[3] user[2] user[4]
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
