-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_cell_gif
executable file
·267 lines (236 loc) · 5.89 KB
/
make_cell_gif
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
###############################################################################
#
# File: make_cell_gif
# RCS: $Header:$
# Description: Create a gif image of a cell's artwork/schematic/symbol
# Author: Floyd Moore
# Created: Wed Jan 14 09:35:36 MST 1998
# Modified:
# Language: Indented Text
# Package: N/A
# Status: Experimental (Do Not Distribute)
#
# (C) Copyright 1998, Hewlett-Packard ESL, all rights reserved.
#
###############################################################################
program=`basename $0`
usage()
{
echo "*************** Piglet to GIF image Converter ***************"
echo
echo "Usage: $0 {options...} <blockname>"
echo $version_string
echo
echo "Rep Selection Options:"
echo " The rep is selected from the piglet like suffix added to the"
echo " block name (ie for a view of an inv1_1, use inv1_1V)."
echo
echo "Control Options:"
echo " -s XxY : Set conversion size (default is 300x300)."
echo " -o <file> : Set the output file (default is <rep>.gif)."
echo " -r <res> : Set pcx file resolution (default is 150dpi)."
echo " -g <hpgl> : Use hpgl directly from file."
echo " -x : Turn on debugging information."
echo " -V : Turn on vshow information."
echo " -v : Turn on verbose information."
echo
exit 1
}
clean_exit()
{
echo "Recieved Signal, cleaning up"
rm -f /tmp/*$$*
rm -f /tmp/palin.pig
exit 1
}
#
# Parse Options
#
block=""
size="800x800"
res=150
verbose=0
if [ $# -eq 0 ]
then
usage
exit 1
fi
for opt in $*
do
case $1 in
-x) debug="set -x"; shift;;
-v) verbose=1; shift;;
-s) shift; size=$1; shift;;
-r) shift; res=$1; shift;;
-g) shift; hpgl=$1; shift;;
--) shift; break;;
-*) echo "ERROR: Bad Command line option: $1";usage; shift;;
esac
done
if [ $res -lt 0 -o $res -gt 300 ]
then
echo "Invalid resolution: must be between 0 and 300dpi"
exit -1
fi
if [ ! -z "$hpgl" ]
then
echo "Convert from HPGL file: $hpgl..."
if [ ! -f $hpgl ]
then
echo "HPGL file '$hpgl' does not exist!"
exit -1
fi
fi
raw=$1
l1=`expr length $raw`
l2=`expr $l1 - 1`
suffix="`expr substr $raw $l1 1`"
block="`expr substr $raw 1 $l2`"
xsize=`echo $size | awk '{print substr($1,0,index($1,"x")-1)}' -`
ysize=`echo $size | awk '{print substr($1,index($1,"x")+1,5)}' -`
#echo "xsize=${xsize}mm, ysize=${ysize}mm"
#
# Check is required piglet.db exists
#
case "$suffix" in
D) start="sch"; show="vshow";;
V) start="sch"; show="vshow";;
A) start="art"; show="dshow";;
E) start="art"; show="show #a";;
X) start="art"; show="show #a";;
F) start="art"; show="sho -a #a30 #a80 #a107 #a4 #a23"; suffix="A";;
*) echo "ERROR: No Suffix given in blockname";usage; exit -1;;
esac
#
# Check if block exists
#
blockpath=`get_dir $block`
if [ -z "$blockpath" ]
then
echo "Bad blockname: $block"
exit -1
fi
##########################################
# Parse Arguements from command line #
##########################################
trap "clean_exit" QUIT
trap "clean_exit" HUP
trap "clean_exit" TERM
trap "clean_exit" INT
counter=1
##
## Running Banner....
##
echo "$0 $block: "
############################################
# Create the piglet plot file
############################################
if [ -z "$hpgl" ]
then
if [ $verbose -eq 1 ]
then
echo "Plotting piglet device to file"
fi
SB_OUTDEV=""
logfile="/tmp/pigplot_log.$$"
PIGDIR=$CBROOT/$ICPROCESS/piglet
PIG_ENV=$PIGDIR/artrc
export PIG_ENV SB_OUTDEV
plotter="7590"
SB_OUTDEV=""
PIG_ENV=$PIGDIR/${start}rc
plot_file=/tmp/p${counter}p.$$
export PIG_ENV SB_OUTDEV
piglet >$logfile 2>&1 << %%
edit ${block}${suffix};
${show};
win :n99;
plot -z -c p=${plotter} ${plot_file}
exi;
bye;
%%
status=$?
if [ $status -ne 0 ]
then
echo "Piglet plot command failed"
clean_exit
else
#rm -f $logfile
echo
mv ${plot_file}_P ${block}.hpgl
fi
fi
############################################
# Convert the plot file to a gif image
############################################
plot_file=${plot_file}_P
if [ $verbose -eq 1 ]
then
if [ -z $hpgl ]
then
echo "converting ${block}.hpgl ..."
fi
fi
#hp2xx -q --truesize -c 12347560 -d 100 -m pcx ${plot_file}
#hp2xx -q -t off -c 12347560 -d 100 -m pcx ${plot_file}
if [ -z "$hpgl" ]
then
hp2xx -q -h $ysize -w $xsize -c 12347560 -d $res -m pcx ${block}.hpgl
status=$?
if [ $status -ne 0 ]
then
echo "hp2xx conversion command failed: hpgl->pcx"
clean_exit
fi
mv ${block}.hpgl.pcx ${block}.pcx
else
hp2xx -q -h $ysize -w $xsize -c 12347560 -d $res -m pcx $hpgl
status=$?
if [ $status -ne 0 ]
then
echo "hp2xx conversion command failed: hpgl->pcx"
clean_exit
fi
mv ${hpgl}.pcx ${block}.pcx
fi
convert -pen grey -opague white ${block}.pcx ${block}.gif
status=$?
if [ $status -ne 0 ]
then
echo "Imagemagic 'convert' conversion command failed: pcx->gif #1"
clean_exit
fi
convert -pen white -opague black ${block}.gif /tmp/tmp.gif
status=$?
if [ $status -ne 0 ]
then
echo "Imagemagic 'convert' conversion command failed: pcx->gif #2"
clean_exit
fi
mv /tmp/tmp.gif ${block}.gif
convert -pen black -opague grey ${block}.gif /tmp/tmp.gif
status=$?
if [ $status -ne 0 ]
then
echo "Imagemagic 'convert' conversion command failed: pcx->gif #3"
clean_exit
fi
mv /tmp/tmp.gif ${plot_file}.gif
convert -pen SkyBlue -opague blue ${block}.gif /tmp/tmp.gif
status=$?
if [ $status -ne 0 ]
then
echo "Imagemagic 'convert' conversion command failed: pcx->gif #4"
clean_exit
fi
mv /tmp/tmp.gif ${block}.gif
rm -f ${block}.pcx
############################################
# Move the plot file to the destination
############################################
if [ $verbose -eq 1 ]
then
echo "Output file written to ${block}.gif"
fi
echo "Successful"
exit 0