From bc36e0c8db99ec2f7f0284ea07a5f88e086229a2 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Sun, 2 Oct 2011 11:55:58 -0600 Subject: [PATCH] Adding a script to graphically diff PCB files --- tools/Makefile.am | 3 +- tools/pcbdiff | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletions(-) create mode 100755 tools/pcbdiff diff --git a/tools/Makefile.am b/tools/Makefile.am index d9665a9..f350471 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -21,7 +21,8 @@ TOOLS= \ tgo2pcb.tcl \ MergePCBPS \ Merge_dimPCBPS \ - PCB2HPGL + PCB2HPGL \ + pcbdiff DIST_SCM= \ gnet-pcbfwd.scm diff --git a/tools/pcbdiff b/tools/pcbdiff new file mode 100755 index 0000000..00378cd --- /dev/null +++ b/tools/pcbdiff @@ -0,0 +1,64 @@ +#! /bin/sh + +usage () +{ + echo Usage: + echo \\tpcbdiff firstfile secondfile + echo \\tView a graphical diff of PCB files + echo + echo \\tTo use with git, just place this script in your PATH and do + echo \\tgit difftool -x pcbdiff ... + echo + echo \\tTo use with mercurial, add the following lines to your .hgrc: + echo \\t\\t[extensions] + echo \\t\\thgext.extdiff = + echo \\t\\t[extdiff] + echo \\t\\tcmd.pcbdiff = /PATH/TO/pcbdiff + echo \\tthen to invoke it, do + echo \\thg pcbdiff ... + echo + echo \\tTo use with subversion, place it in your PATH and do + echo \\tsvn diff --diff-cmd pcbdiff ... + + echo \\tRequirements: Imagemagick and gschem be installed +} + + +for PROG in pcb convert composite +do + if which $PROG > /dev/null + then + true + else + echo "$PROG is not found. Either it is not installed, or not in your PATH" + exit 1 + fi +done + +#In case the script was invoked with extra option arguments, throw them away +shift `expr $# - 2` + +if test -d $1 -o -d $2 + then echo "ERROR: pcbdiff cannot diff entire directories" + exit 1 +fi + +LEFTFILE=$1 +RIGHTFILE=$2 +LEFTPNG=`mktemp --tmpdir pcbdiff.XXXXXXXXXX` +RIGHTPNG=`mktemp --tmpdir pcbdiff.XXXXXXXXXX` +LEFTBNW=`mktemp --tmpdir pcbdiff.XXXXXXXXXX` +RIGHTBNW=`mktemp --tmpdir pcbdiff.XXXXXXXXXX` +DIFFPNG=`mktemp --tmpdir pcbdiff.XXXXXXXXXX` + +pcb -x png --dpi 200 --only-visible --photo-mode --outfile $LEFTPNG $LEFTFILE +pcb -x png --dpi 200 --only-visible --photo-mode --outfile $RIGHTPNG $RIGHTFILE +convert -colorspace gray $LEFTPNG $LEFTBNW +convert -colorspace gray $RIGHTPNG $RIGHTBNW +composite -stereo 0 $LEFTBNW $RIGHTBNW $DIFFPNG +display $DIFFPNG +rm $LEFTPNG +rm $RIGHTPNG +rm $LEFTBNW +rm $RIGHTBNW +rm $DIFFPNG -- 1.7.0.4