#!/bin/csh -f

#Routine matplotopt.  From plotopt, modified to use Matlab for plotting.
# Based on code from globec version. 

set version = "V2.01/September 7, 2001"

# September 7, 2001 V2.01. Will be built during build command operation.  RCG
# Version V2.00 August 5, 2001.

echo "Content-type: text/html"
echo ""
source build-opt-env
cd ${USETEMPDIR}

#echo "Changed directory to ${USETEMPDIR}<p>"
#ls ${USETEMPDIR}

#unsetenv PATH_INFO

set CUROPT=(`cat plotopt`)

if ( "${SUBSELS}x" == "x" ) then
  set DISPFULL=${OBJECT}
  set CALLURL=${OBJECT}
  set CALLFULL=${OBJECT}
else
  set DISPFULL="${OBJECT}(${DISPSS})"
  set CALLURL="${OBJECT}?${SUBSELS}"
  set CALLFULL="${OBJECT}(${SUBSELS_QS})"
endif

cat <<XXstuffXX
<html><head><title>Simple XY Plotting via Matlab</title></head>
<body>
<h1>Simple XY Plot via Matlab</h1>
<b>Current object is:  $DISPFULL</b></br>
<hr noshade>
<p>
<font size="3">
<a href="/jg/cleanplot/${OBJECT}.matplotopt?${SUBSELS}">Select this link, if the form looks incomplete</a>.
</font>
<form action="/jg/matplotxy/$CALLURL" method="POST">
XXstuffXX

#echo "<p><b>Input to listvar is $CALLFULL</b><p>"

${OPTHOME}/bin/listvar "/$CALLFULL" > variables

cat << XXSTUFFXX
Plot type (gif or postscript): <select name="matfile" size="1">
<option selected>xy-gif.m
<option>xy-ps.m
</select><p>
XXSTUFFXX

cat <<XXstuffXX
Select an X variable ($CUROPT[1]): <select name="xvar" size="4">
XXstuffXX

${OPTHOME}/bin/nawkscr $CUROPT[1] < variables

cat <<XXstuffXX
</select><br>
Select a reverse or log X axis ($CUROPT[2]):  <select name="xopt">
XXstuffXX

${OPTHOME}/bin/nawkscr $CUROPT[2] << XXSTUFFXX
none
reverse
log
rev/log
XXSTUFFXX

cat <<XXstuffXX
</select>
<br>
Select a Y variable ($CUROPT[3]): <select name="yvar" size="4">
XXstuffXX

${OPTHOME}/bin/nawkscr $CUROPT[3] < variables

cat <<XXstuffXX
</select><br>
Select a reverse or log Y axis ($CUROPT[4]):  <select name="yopt">
XXstuffXX

${OPTHOME}/bin/nawkscr $CUROPT[4]  <<XXSTUFFXX
none
reverse
log
rev/log
XXSTUFFXX

cat <<XXstuffXX
</select><br>
Select a symbol for plotting the values ($CUROPT[5]): <select name="sym">
XXstuffXX

${OPTHOME}/bin/nawkscr $CUROPT[5] <<XXSTUFFXX
line
+
o
x
+(connected)
o(connected)
x(connected)
XXSTUFFXX

cat <<XXstuffXX
</select><p>
Title: <input type="text" size="50" name="title" value="$DISPFULL"><p>
<p>
<hr noshade>
<input type="submit" value="Make the Plot"> if the selected options are satisfactory.
</form>
<p>
<i>Version: $version</i>
</body>
</html>
XXstuffXX
