3 # $Id: lasergnu,v 1.1 1999/03/26 21:48:14 lhecking Exp $
5 # Print gnuplot output on an Imagen or Postscript laser printer.
7 set print_banner = on # Print a banner page unless told otherwise.
8 set input_files = () # the plot input command files
9 set lpr_opts = () # options to lpr
11 # Default printer set by shell variable PRINTER.
19 set printer = (-P$PRINTER)
21 # File for plot commands, and for plot output
23 set outfile=$TMP.out # the output file
26 # default is Imagen mode for Imagen printer; see -p option
27 set setterm="set terminal imagen"
30 # Loop through the command-line arguments.
37 case -b*: # Do not print a banner page.
38 case -J*: # Compatible with imprint.
39 set print_banner = off
40 set lpr_opts=($lpr_opts -h)
44 case -f?*: # Specify file containing plot commands
45 set input_files = ($input_files `echo $argv[1] | sed 's/^-f//'`)
49 case -f: # Specify file containing plot commands
52 set input_files = ($input_files $argv[1])
55 echo "Usage: -f file ..."
56 echo "Type lasergnu -help for help."
61 case -F?*: # Specify font
62 set fontsize = `echo $argv[1] | sed 's/^-F//'`)
66 case -F: # Specify font
73 echo "Type lasergnu -help for help."
78 case -t?*: # Specify title of plot
79 echo set title \""`echo $argv[1] | sed 's/^-t//'`"\" >> $TMP
83 case -t: # Specify title of plot
86 echo set title \""$1"\" >> $TMP
89 echo "Usage: -t title ..."
90 echo "Type lasergnu -help for help."
97 case -P?*: # Set the printer, exactly as by itroff.
98 set printer = $argv[1]
102 case -P: # Set the printer, exactly as by itroff.
105 set printer = (-P$argv[1])
108 echo "Usage: -P printer ..."
109 echo "Type lasergnu -help for help."
116 echo Imagen is the default mode now
120 # use postscript instead of impress language
122 set setterm="set term postscript"
123 set LANG="-Lpostscript"
127 case -s?*: # Specify scale of plot
128 echo set size `echo $argv[1] | sed 's/^-s//'` >> $TMP
132 case -s: # Specify scale of plot
135 echo set size "$1" >> $TMP
138 echo "Usage: -s xscale,yscale"
139 echo "Type lasergnu -help for help."
144 case -w?*: # Specify split page in multiplot (horiz,vertical)
145 set windows=`echo "$argv[1]\]" | sed 's/^-s/[/'`
149 case -w: # Specify split page
152 set windows="[$argv[1]]"
155 echo "Usage: -w horiz,vertical"
156 echo "Type lasergnu -help for help."
162 set orientation="portrait"
167 echo "I do not recognize option $argv[1]."
171 echo "$argv[1]" >> $TMP
178 # try to devine the printer type
179 if ($printer =~ -Plw*) then
180 set setterm="set term postscript"
181 set LANG="-Lpostscript"
184 if ($printer =~ -Pim*) then
185 set setterm="set term imagen $windows $orientation $font"
190 echo "$setterm" > $TMP.plt
191 echo set output \"$outfile\" >> $TMP.plt
192 if (-e $TMP) cat $TMP >> $TMP.plt
193 grep -v "set te" $input_files | grep -v "set o" >> $TMP.plt
194 echo "quit" >> $TMP.plt
195 # If input file is specified AND command line contains plot commands, then
196 # do command line args first, then plot commands in input file.
197 gnuplot $TMP.plt < /dev/null
198 #gnuplot $TMP.plt $input_files
200 if ($status == 0 && -e $outfile && ! -z $outfile) then
201 # The printer is whatever printer was last specified,
202 # or the default printer if none was specified.
203 # Imagen terminal driver support the page header
204 if ($LANG == -Limpress) then
205 /usr/local/bin/ipr $LANG $printer \
206 -D"jobheader $print_banner" \
207 -D"pagereversal on" \
208 -D"program lasergnu" $outfile
209 else if ($LANG == -Lpostscript) then
210 lpr $lpr_opts $printer $outfile
213 echo "lasergnu: error in plotting or empty plot; nothing printed."
221 echo "usage: lasergnu [-Pprinter] [-F font] [-w nx,ny ] [-s xscale,yscale][-b] [-O] [-p] [-t title] [-f file] ['plot command']...."
222 echo " -O : Orientation Portrait (default is Landscape)"
223 echo " -F font : fontsize in points for imagen"
224 echo " -w nx,ny : split page (nx and ny: no. plots horizontal and vertical)"
225 echo " -s xscale,yscale : scaling in horiz, vertical direction"
226 echo " -P printer : Printer to send the plot"
227 echo " -p : set gnuplot driver to postscript (default is Imagen)"
228 echo " -I : set gnuplot terminal driver to imagen (default)"
229 echo " -b : don't print jobheader page"