#! /bin/csh -f
# Last edited on 2001-11-15 21:42:19 by stolfi

set usage = "$0 [-label DX DY SIZE XXX] [-sampleDots] [-grid NNN] [-plotStep NNN] FLCFILE XMIN XMAX YMIN YMAX EPSNAME"

set cmd = $0
echo "=== begin ${cmd:t} ===" 
echo "${cmd:t} $*"

set opts = ( )
while ( ( $#argv > 0 ) && ( "x$1" =~ x-* ) )
  if ( ( $#argv >= 5) && ( "x$1" == "x-label" ) ) then
    set opts = ( ${opts} -label "$2" "$3" "$4" "$5" );
    shift; shift; shift; shift; shift;
  else if ( ( $#argv >= 2) && ( "x$1" == "x-plotStep" ) ) then
    set opts = ( ${opts} -plotStep "$2" ); shift; shift;
  else if ( ( $#argv >= 2) && ( "x$1" == "x-grid" ) ) then
    set opts = ( ${opts} -grid "$2" ); shift; shift;
  else if ( "x$1" == "x-sampleDots" ) then
    set opts = ( ${opts} "-sampleDots" ); shift
  else
    echo "usage: ${usage}"; exit 1
  endif
end

if ( $#argv != 6 ) then
  echo "usage: ${usage}"; exit 1
endif

set flcfile = $1; shift;
set xmin = $1; shift;
set xmax = $1; shift;
set ymin = $1; shift;
set ymax = $1; shift;
set epsname = $1; shift;

if ( $#argv != 0 ) then
  echo "usage: ${usage}"; exit 1
endif

set path = ( \
  ${STOLFIHOME}/programs/pm3-1.1.15/THESES/hcgl/1/bin/${PLATFORM} \
  ${cmd:h} \
  ${path} \
)

if ( "/${flcfile:e}" == "/" ) then
  set flcfile = "${flcfile}.flc"
endif

if ( "/${epsname:e}" == "/.eps" ) then
  set epsname = "${epsname:r}"
endif

echo ${flcfile}' -> '${epsname}.eps' ...'

/bin/rm -f ${epsname}.eps

echo "opts = ( ${opts} )"

nice PZDraw \
  -window ${xmin} ${xmax} ${ymin} ${ymax} \
  -output ${epsname} \
  ${opts} \
  -epsFormat \
  < ${flcfile}

/bin/rm ${winame}.wnd

ghostview ${epsname}.eps

echo "=== end ${cmd:t} =========" 


