mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2024-11-26 07:02:48 +02:00
Merged the functionality of gitsch2ppm into schhist2web.
- scripts/normalizeschps: don't edit in place and thus become capable of running in a pipe - scripts/schps2ppm: considered - to be an option and thus didn't accept it as input file name - scripts/schhist2web: open-coded functionality of "gitsch2ppm" - scripts/gitsch2ppm: removed
This commit is contained in:
parent
b3f2014863
commit
800577353e
@ -1,82 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# gitsch2ppm - Generate PPM files for KiCad schematics in git
|
|
||||||
#
|
|
||||||
# Written 2010 by Werner Almesberger
|
|
||||||
# Copyright 2010 Werner Almesberger
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
|
|
||||||
|
|
||||||
usage()
|
|
||||||
{
|
|
||||||
cat <<EOF 1>&2
|
|
||||||
usage: $0 [options] top-dir top-schem [commit] outdir
|
|
||||||
|
|
||||||
-c use cached Postscript files (from previous run, with -k)
|
|
||||||
-k keep checked-out tree (for immediate reuse with -c)
|
|
||||||
-r XxY image resolution (default: $RES)
|
|
||||||
-S sanitize the KiCad profile
|
|
||||||
-w points Postscript line width (default: $LINEWIDTH)
|
|
||||||
EOF
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
cache=false
|
|
||||||
keep=false
|
|
||||||
res=
|
|
||||||
sanitize=
|
|
||||||
width=
|
|
||||||
while true; do
|
|
||||||
case "$1" in
|
|
||||||
-c) cache=true
|
|
||||||
shift;;
|
|
||||||
-k) keep=true
|
|
||||||
shift;;
|
|
||||||
-r) [ -z "$2" ] && usage
|
|
||||||
res="-r $2"
|
|
||||||
shift 2;;
|
|
||||||
-S) sanitize=-S
|
|
||||||
shift;;
|
|
||||||
-w) [ -z "$2" ] && usage
|
|
||||||
width="-r $2"
|
|
||||||
shift 2;;
|
|
||||||
-*)
|
|
||||||
usage;;
|
|
||||||
*)
|
|
||||||
break;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
tmp=`pwd`/_gitsch2ppm
|
|
||||||
eval outdir=\${$#}
|
|
||||||
|
|
||||||
# with thanks to http://www.faqs.org/faqs/unix-faq/faq/part2/section-12.html
|
|
||||||
argv=
|
|
||||||
while [ $# -gt 1 ]; do
|
|
||||||
argv="$argv \"$1\""
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
eval set x "$argv"
|
|
||||||
shift
|
|
||||||
|
|
||||||
if ! $cache; then
|
|
||||||
rm -rf "$tmp"
|
|
||||||
rm -rf "$outdir"
|
|
||||||
gitsch2ps $sanitize "$@" "$tmp"
|
|
||||||
for n in "$tmp"/*.ps; do
|
|
||||||
normalizeschps $width "$n"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p "$outdir"
|
|
||||||
for n in "$tmp"/*.ps; do
|
|
||||||
schps2ppm $res "$n" "$outdir/`basename \"${n%.ps}.ppm\"`"
|
|
||||||
done
|
|
||||||
|
|
||||||
$keep || rm -rf "$tmp"
|
|
@ -18,7 +18,7 @@ LINEWIDTH=120
|
|||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
cat <<EOF 1>&2
|
cat <<EOF 1>&2
|
||||||
usage: $0 [options] file ...
|
usage: $0 [options] [in.ps [out.ps]]
|
||||||
|
|
||||||
-w points Postscript line width (default: $LINEWIDTH)
|
-w points Postscript line width (default: $LINEWIDTH)
|
||||||
EOF
|
EOF
|
||||||
@ -38,22 +38,24 @@ while true; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
for n in "$@"; do
|
[ -z "$3" ] || usage
|
||||||
sed -i '
|
in=${1:--}
|
||||||
1c%!PS-Adobe-3.0\
|
out=${2:-/dev/stdout}
|
||||||
currentdict /DidNormalize known not { \
|
|
||||||
/setlinewidth { '$LINEWIDTH' 2 copy lt { exch } if pop \
|
sed '
|
||||||
setlinewidth } bind def \
|
1c%!PS-Adobe-3.0\
|
||||||
/rectfill { rectstroke } bind def \
|
currentdict /DidNormalize known not { \
|
||||||
/DidNormalize true def \
|
/setlinewidth { '$LINEWIDTH' 2 copy lt { exch } if pop \
|
||||||
} if \
|
setlinewidth } bind def \
|
||||||
gsave
|
/rectfill { rectstroke } bind def \
|
||||||
/%%DocumentMedia: A4.*/a-20 -10 translate
|
/DidNormalize true def \
|
||||||
/%%DocumentMedia: A3.*/{s/A3/A4/;a-20 -10 translate 0.70 dup scale
|
} if \
|
||||||
}
|
gsave
|
||||||
/%%DocumentMedia: A2.*/{s/A2/A4/;a-18 -12 translate 0.49 dup scale
|
/%%DocumentMedia: A4.*/a-20 -10 translate
|
||||||
}
|
/%%DocumentMedia: A3.*/{s/A3/A4/;a-20 -10 translate 0.70 dup scale
|
||||||
$agrestore' "$n"
|
}
|
||||||
done
|
/%%DocumentMedia: A2.*/{s/A2/A4/;a-18 -12 translate 0.49 dup scale
|
||||||
|
}
|
||||||
|
$agrestore' "$in" >"$out"
|
||||||
|
|
||||||
# /%%Orientation: Landscape/d' "$n"
|
# /%%Orientation: Landscape/d' "$n"
|
||||||
|
@ -190,18 +190,25 @@ for n in $first `cd "$dir" && git rev-list --reverse $first..HEAD`; do
|
|||||||
echo Name change $schname to $new 1>&2
|
echo Name change $schname to $new 1>&2
|
||||||
schname="$new"
|
schname="$new"
|
||||||
fi
|
fi
|
||||||
trap "rm -rf \"$cache/ppm_$n\" \"$cache/fat_$n\"" 0
|
tmp=`pwd`/_schhist2web
|
||||||
|
trap "rm -rf \"$cache/ppm_$n\" \"$cache/fat_$n\" \"$tmp\"" 0
|
||||||
if [ ! -d "$cache/ppm_$n" ]; then
|
if [ ! -d "$cache/ppm_$n" ]; then
|
||||||
rm -rf "$cache/ppm_$n"
|
rm -rf "$cache/ppm_$n" "$cache/fat_$n"
|
||||||
mkdir "$cache/ppm_$n"
|
mkdir "$cache/ppm_$n" "$cache/fat_$n"
|
||||||
#
|
#
|
||||||
# potential optimization here: remember Postscript files from previous
|
# potential optimization here: remember Postscript files from previous
|
||||||
# run (or their md5sum) and check if they have changed. If not, skip
|
# run (or their md5sum) and check if they have changed. If not, skip
|
||||||
# the ghostscript run and just put a symlink, replacing the less
|
# the ghostscript run and just put a symlink, replacing the less
|
||||||
# efficient optimization below.
|
# efficient optimization below.
|
||||||
#
|
#
|
||||||
gitsch2ppm $sanitize -k "$dir" "$schname" $n "$cache/ppm_$n" || exit
|
gitsch2ps $sanitize "$dir" "$schname" $n "$tmp" || exit
|
||||||
gitsch2ppm -c -w 500 "$dir" "$schname" $n "$cache/fat_$n" || exit
|
for m in "$tmp"/*.ps; do
|
||||||
|
ppm="$cache/ppm_$n/`basename "$m" .ps`.ppm"
|
||||||
|
normalizeschps "$m" | schps2ppm - "$ppm" || exit
|
||||||
|
ppm="$cache/fat_$n/`basename "$m" .ps`.ppm"
|
||||||
|
normalizeschps -w 500 "$m" | schps2ppm - "$ppm" || exit
|
||||||
|
done
|
||||||
|
rm -rf "$tmp"
|
||||||
fi
|
fi
|
||||||
for m in "$cache/ppm_$n/"*; do
|
for m in "$cache/ppm_$n/"*; do
|
||||||
[ "$m" = "$cache/ppm_$n/*" ] && break
|
[ "$m" = "$cache/ppm_$n/*" ] && break
|
||||||
|
@ -31,10 +31,9 @@ while true; do
|
|||||||
-r) [ -z "$2" ] && usage
|
-r) [ -z "$2" ] && usage
|
||||||
RES="$2"
|
RES="$2"
|
||||||
shift 2;;
|
shift 2;;
|
||||||
-*)
|
-) break;;
|
||||||
usage;;
|
-*) usage;;
|
||||||
*)
|
*) break;;
|
||||||
break;;
|
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user