#!/bin/csh -f
# 8 Nov 1999. clh. using the build-opt-env script to conform
#       to the same environment as all other OO scripts.  Note that
#	that script (build..) deals with formatting for WWW and for
#	trigramming/jgofs
# 5 Mar 99.  %20s in FULLOBJ (=object(query_string) are removed by httpd
#	server between plotopt form and here.  Put  them back.  WJS
# 6 Apr 99.  object in pathinfo received from optionserver menu has no
#       extension, no need to remove (obj:r), plus this breaks stuff that
#       has decimal points in projections/selections. clh
#
echo Content-type: text/html
echo ""

source build-opt-env

cd ${USETEMPDIR}
set path=(. ${OPTHOME}/bin $path)

unsetenv PATH_INFO

if ( "${SUBSELS}x" == "x" ) then
  set CALLFULL="${OBJECT}"
else 
  set CALLFULL="${OBJECT}(${SUBSELS})"
endif

#echo "inside plotxy" >>/usr/local/httpdOO/logs/error_log
#echo "$OBJECT" >>/usr/local/httpdOO/logs/error_log
#echo "$CALLFULL " >>/usr/local/httpdOO/logs/error_log

set POSTSTR=(`${OPTHOME}/bin/poststring xvar xopt yvar yopt sym`)
echo "$POSTSTR" > plotopt

switch ( "$POSTSTR[2]" )
case "none":
  setenv XOPT ""
  breaksw
case "reverse":
  setenv XOPT "-r"
  breaksw
case "log":
  setenv XOPT "-l"
  breaksw
case "rev/log":
  setenv XOPT "-r -l"
  breaksw
endsw
switch ( "$POSTSTR[4]" )
case "none":
  setenv YOPT ""
  breaksw
case "reverse":
  setenv YOPT "-r"
  breaksw
case "log":
  setenv YOPT "-l"
  breaksw
case "rev/log":
  setenv YOPT "-r -l"
  breaksw
endsw
switch ( "$POSTSTR[5]" )
case "line":
  setenv SYM ""
  breaksw
case "+":
  setenv SYM "-siz 3 -sym 4"
  breaksw
case "x":
  setenv SYM "-siz 3 -sym 6"
  breaksw
case "o":
  setenv SYM "-siz 3 -sym 2"
  breaksw
case "+(connected)":
  setenv SYM "-siz 3 +sym 4"
  breaksw
case "x(connected)":
  setenv SYM "-siz 3 +sym 6"
  breaksw
case "o(connected)":
  setenv SYM "-siz 3 +sym 2"
  breaksw
endsw

setenv TMP `date '+%H%M%S'`

ch plot.var xvmin=15 yvmin=15 xvmax=85 yvmax=85

rm -f *.gif

#Edited 10/9/1997 rcg Added closed parenthesis.  Seems to be blank 
#       before end parenthsis in selection criteria and closing
#       parenthsis is not present
#
#   below can be uncommented to send a debug line to the screen
#echo "command to be executed next is" >>&! $debug_file
#echo "" >>& $debug_file
#echo "p quote${OBJ}quote $XOPT $POSTSTR[1] $YOPT $POSTSTR[3] $SYM piped to #${OPTHOME}/bin/tekgif and that is sent to #temp$TMP.gif" >>& $debug_file

p "$CALLFULL" $XOPT $POSTSTR[1] $YOPT $POSTSTR[3] $SYM | ${OPTHOME}/bin/tekgif >temp$TMP.gif
#p "${OBJ}" $XOPT $POSTSTR[1] $YOPT $POSTSTR[3] $SYM > $USETEMPDIR/p.output

#echo "about to look in $USETEMPDIR" >>& $debug_file
cat << XXSTUFFXX
<p>
<img src="${USETEMPDIR}/temp$TMP.gif"> 
<p>
XXSTUFFXX
#echo "hmmm.  after the img src commmand - what happened?" >>& $debug_file
