#! /bin/csh -f
# Last edited on 2008-02-04 20:07:23 by stolfi
set usage = "$0 [ XMIN XMAX YMIN YMAX ] NAME > PLOT.gif"
# Reads files in the following formats
#
# NAME.tplot TRECHO X Y (in pairs w/ blank lines)
# NAME.eplot ESQUINA X Y
# NAME.cplot SERVICO X Y
# NAME.pplot SERVICO XK YK (with blank lines between servicos)
#
# Plots them as appropriate
if ($#argv >= 4) then
set xlo = $1; shift;
set xhi = $1; shift;
set ylo = $1; shift;
set yhi = $1; shift;
endif
if ($#argv != 1) then
echo "usage: ${usage}"; exit 1
endif
set name = "$1"; shift;
set tfile = "${name}.tplot"
set efile = "${name}.eplot"
set cfile = "${name}.cplot"
set pfile = "${name}.pplot"
set tmp = "/tmp/$$"
set tefile = "${tmp}.eplot"
set ttfile = "${tmp}.tplot"
set spfile = "${tmp}.pplot"
set scfile = "${tmp}.cplot"
set bmfile = "${tmp}.ppm"
set gffile = "${tmp}.gif"
cat ${efile} > ${tefile}
cat ${tfile} > ${ttfile}
cat ${cfile} > ${scfile}
cat ${pfile} > ${spfile}
if ( $?xlo ) then
set xlim = ( $xlo $xhi )
set ylim = ( $ylo $yhi )
else
set xlim = ( `cat ${tefile} ${ttfile} ${scfile} ${spfile} | gawk 'BEGIN{a=9999;b=-9999;} /./ {v=$2; if(vb){b=v}} END{print a,b}'` )
set ylim = ( `cat ${tefile} ${ttfile} ${scfile} ${spfile} | gawk 'BEGIN{a=9999;b=-9999;} /./ {v=$3; if(vb){b=v}} END{print a,b}'` )
endif
gawk -v bds="${xlim} ${ylim}" \
'BEGIN{printf "bounds: %s\n", bds > "/dev/stderr";}'
gnuplot < ${gffile}
cat ${gffile}
( display ${gffile}; /bin/rm -f ${tefile} ${ttfile} ${scfile} ${spfile} ${gffile} ) &
endif
/bin/rm -f ${bmfile}