File: lasergnu

package info (click to toggle)
gnuplot 3.5beta6.347-3
  • links: PTS
  • area: main
  • in suites: slink
  • size: 5,032 kB
  • ctags: 4,235
  • sloc: ansic: 42,086; makefile: 561; asm: 539; sh: 386; objc: 379; csh: 297; pascal: 194; perl: 138; lisp: 88
file content (230 lines) | stat: -rw-r--r-- 6,706 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#!/bin/csh -f
#
# $Id: lasergnu,v 1.5 1994/01/29 16:27:12 alex Exp $
#
# Print gnuplot output on an Imagen or Postscript laser printer.

set print_banner = on   # Print a banner page unless told otherwise.
set input_files = ()    # the plot input command files
set lpr_opts = ()       # options to lpr

# Default printer set by shell variable PRINTER.
if (! $?PRINTER) then
    if ($?LASER) then
        set PRINTER=$LASER
    else
        set PRINTER="lw0"
    endif
endif
set printer = (-P$PRINTER)

# File for plot commands, and for plot output
set TMP=/tmp/plot$$
set outfile=$TMP.out    # the output file
onintr cleanup

# default is Imagen mode for Imagen printer; see -p option
set setterm="set terminal imagen"
set LANG="-Limpress"

# Loop through the command-line arguments.

top:
    if ($#argv > 0) then

        switch ("$argv[1]")

        case -b*:   # Do not print a banner page.
        case -J*:   # Compatible with imprint.
            set print_banner = off
                set lpr_opts=($lpr_opts -h)
            shift argv
            goto top

        case -f?*:  # Specify file containing plot commands
            set input_files = ($input_files `echo $argv[1] | sed 's/^-f//'`)
            shift argv
            goto top

        case -f:    # Specify file containing plot commands
            shift argv
            if ($#argv > 0) then
                set input_files = ($input_files $argv[1])
                shift argv
            else
                echo "Usage: -f file ..."
                echo "Type    lasergnu -help    for help."
                exit (1)
            endif
            goto top

              case -F?*:              # Specify font 
                      set fontsize = `echo $argv[1] | sed 's/^-F//'`)
                      shift argv
                      goto top

              case -F:        # Specify font 
                      shift argv
                      if ($#argv > 0) then
                              set font = $argv[1]
                              shift argv
                      else
                              echo "Usage: -F font"
                              echo "Type    lasergnu -help    for help."
                              exit (1)
                      endif
                      goto top

        case -t?*:  # Specify title of plot
            echo set title \""`echo $argv[1] | sed 's/^-t//'`"\" >> $TMP
            shift argv
            goto top

        case -t:    # Specify title of plot
            shift argv
            if ($#argv > 0) then
                echo set title \""$1"\" >> $TMP
                shift argv
            else
                echo "Usage: -t title ..."
                echo "Type    lasergnu -help    for help."
                exit (1)
            endif
            goto top
        case -help:
			goto usage

        case -P?*:  # Set the printer, exactly as by itroff.
            set printer = $argv[1]
            shift argv
            goto top

        case -P:    # Set the printer, exactly as by itroff.
            shift argv
            if ($#argv > 0) then
                set printer = (-P$argv[1])
                shift argv
            else
                echo "Usage: -P printer ..."
                echo "Type    lasergnu -help    for help."
                exit (1)
            endif
            goto top

                # use impress
        case -I:
             echo Imagen is the default mode now
             shift argv
             goto top

                # use postscript instead of impress language
        case -p:
             set setterm="set term postscript"
             set LANG="-Lpostscript"
             shift argv
             goto top

		case -s?*:	# Specify scale of plot
			echo set size `echo $argv[1] | sed 's/^-s//'` >> $TMP
			shift argv
			goto top

		case -s:	# Specify scale of plot
			shift argv
			if ($#argv > 0) then
				echo set size "$1" >> $TMP
				shift argv
			else
				echo "Usage: -s xscale,yscale"
				echo "Type    lasergnu -help    for help."
				exit (1)
			endif
			goto top

		case -w?*:	# Specify split page in multiplot (horiz,vertical)
			set windows=`echo "$argv[1]\]" | sed 's/^-s/[/'`
			shift argv
			goto top

		case -w:	# Specify split page
			shift argv
			if ($#argv > 0) then
				set windows="[$argv[1]]"
				shift argv
			else
				echo "Usage: -w horiz,vertical"
				echo "Type    lasergnu -help    for help."
				exit (1)
			endif
			goto top

    	   	case -O:
	   		 set orientation="portrait"
			 shift argv
	   		 goto top

        case -?*:
            echo "I do not recognize option $argv[1]."
			goto usage

        default:
              echo "$argv[1]"   >> $TMP
            shift argv
            goto top

        endsw
    endif

# try to devine the printer type
if ($printer =~ -Plw*) then
    set setterm="set term postscript"
    set LANG="-Lpostscript"
endif

if ($printer =~ -Pim*) then
    set setterm="set term imagen $windows $orientation $font"
    set LANG="-Limpress"
endif

# Set up input file
echo "$setterm" > $TMP.plt
echo set output \"$outfile\" >> $TMP.plt
if (-e $TMP) cat $TMP >> $TMP.plt
grep -v "set te" $input_files | grep -v "set o" >> $TMP.plt
echo "quit" >> $TMP.plt
# If input file is specified AND command line contains plot commands, then
#   do command line args first, then plot commands in input file.
gnuplot $TMP.plt < /dev/null 
#gnuplot $TMP.plt $input_files

if ($status == 0 && -e $outfile && ! -z $outfile) then
    # The printer is whatever printer was last specified,
    # or the default printer if none was specified.
    # Imagen terminal driver support the page header
    if ($LANG == -Limpress) then
        /usr/local/bin/ipr $LANG $printer \
           -D"jobheader $print_banner" \
           -D"pagereversal on" \
           -D"program lasergnu" $outfile
    else if ($LANG == -Lpostscript) then
           lpr $lpr_opts $printer $outfile
    endif
else
    echo "lasergnu: error in plotting or empty plot; nothing printed."
endif

cleanup:
rm -f $TMP* $outfile
exit

usage:
echo "usage: lasergnu [-Pprinter] [-F font] [-w nx,ny ] [-s xscale,yscale][-b] [-O] [-p] [-t title] [-f file] ['plot command']...."
echo "  -O           : Orientation Portrait (default is Landscape)"
echo "  -F font      : fontsize in points for imagen"
echo "  -w nx,ny     : split page (nx and ny: no. plots horizontal and vertical)"
echo "  -s xscale,yscale : scaling in horiz, vertical direction"
echo "  -P printer   : Printer to send the plot"
echo "  -p           : set gnuplot driver to postscript (default is Imagen)"
echo "  -I           : set gnuplot terminal driver to imagen (default)"
echo "  -b           : don't print jobheader page"
echo ""