#! /bin/dash # # interactive plotting script prog=$(basename "$0") case "$prog" in p1|p3) Xmin="Xmin"; Xmax="Xmax";; p2) Xmin="Tmin"; Xmax="Tmax";; esac xmin="$1" xmax="$2" zoom="$3" shift="$4" xlabel="$5" ylabel="$6" title="$7" fname="$8" xstart="$9" # check/set default xmin, xmax, zoom, shift, xlabel, ylabel values # if [ -z "$xmin" ]; then xmin="0.0" fi # if [ -z "$xmax" ]; then xmax="1.0" fi # if [ -z "$zoom" ]; then zoom="1.5" fi # if [ -z "$shift" ]; then shift="0.5" fi # if [ -z "$xlabel" ]; then xlabel="x" fi # if [ -z "$ylabel" ]; then ylabel="y" fi # if [ -z "$fname" ]; then fname="$prog" fi # if [ -z "$xstart" ]; then xstart="$xmax" fi # set plot gif file, check/remove old files # gif="$$.gif" # if [ -s "rm.list" ]; then rm -f `cat rm.list` fi # echo "$gif" > rm.list # get/check option # read option # nflag="" save="" Save="Save" # if [ -z "$option" ]; then xaxis="checked" xopt="" yaxis="checked" yopt="" lines="checked" points="checked" else xaxis="" xopt="-x" yaxis="" yopt="-y" lines="" points="" # oldxmin="$xmin" oldxmax="$xmax" # case "$option" in *Shift\ Left*) xmin=$(echo "$oldxmin" "$shift" | awk '{ print $1 - $2; }') xmax=$(echo "$oldxmax" "$shift" | awk '{ print $1 - $2; }') ;; *Shift\ Right*) xmin=$(echo "$oldxmin" "$shift" | awk '{ print $1 + $2; }') xmax=$(echo "$oldxmax" "$shift" | awk '{ print $1 + $2; }') ;; *Zoom\ in*) xmin=$(echo "$oldxmin" "$oldxmax" "$zoom" | awk '{ print ($2+$1-($2-$1)/$3)/2; }') xmax=$(echo "$oldxmin" "$oldxmax" "$zoom" | awk '{ print ($2+$1+($2-$1)/$3)/2; }') ;; *Zoom\ out*) xmin=$(echo "$oldxmin" "$oldxmax" "$zoom" | awk '{ print ($2+$1-($2-$1)*$3)/2; }') xmax=$(echo "$oldxmin" "$oldxmax" "$zoom" | awk '{ print ($2+$1+($2-$1)*$3)/2; }') ;; *Newton*) nflag="-n $xstart" Save="NSave" ;; *NSave*) nflag="-n $xstart" Save="NSave" save="1" gif="$fname.gif" ;; *Save*) save="1" gif="$fname.gif" ;; esac # case "$option" in *X-axis*) xaxis="checked" xopt="" ;; esac # case "$option" in *Y-axis*) yaxis="checked" yopt="" ;; esac # case "$option" in *Lines*) lines="checked" ;; esac # case "$option" in *Points*) points="checked" ;; esac fi # set linespoints # if [ "$lines" = "checked" ]; then if [ "$points" = "checked" ]; then linespoints="with linespoints" else linespoints="with lines" fi elif [ "$points" = "checked" ]; then linespoints="with points" else linespoints="" fi # set title and labels # labels="set title \"$title\"\nset xlabel \"$xlabel\"\nset ylabel \"$ylabel\"" # create plot # exec 2>plot.stderr # ./$prog.exe $nflag $xopt $yopt "$xmin" "$xmax" | (echo "set term gif\nset output\n $labels\n plot '-' notitle $linespoints"; cat) | /usr/bin/gnuplot > "$gif" # create web page # echo "iPlot/$prog
${Xmin}: ${Xmax}: Zoom: Shift: X-label: Y-label:
X-axis Y-axis Lines Points Title:
.html " if [ "$prog" = "p3" ]; then echo " Xstart: " fi # img element for the gif/plot # img="
\"\"" # DEBUG: # # echo "
# args = $@
# data = $option
# img = $img
# 
" # function to display newton.out file # check_newton() { if [ "$prog" = "p3" -a "$nflag" ]; then echo "
"
    cat newton.out
    echo "
" fi } # function to display $prog.c file # display_prog() { echo "
$prog.c:
"
  sed -e 's/\&/\&/g' -e 's//\>/g' "$prog.c"
  echo "
" } # check Save option # if [ -n "$save" ]; then echo "iPlot/$prog/$fname " > "$fname.html" echo "$img" >> "$fname.html" check_newton >> "$fname.html" display_prog >> "$fname.html" echo "" >> "$fname.html" # echo "

Saved to $fname.html" fi echo "$img" check_newton display_prog echo "

"