X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?p=tinyboard.git;a=blobdiff_plain;f=panel.pl;fp=panel.pl;h=d551e566a2972a28638afdb7c091479514906730;hp=0000000000000000000000000000000000000000;hb=1bf6c604ddb905d6f6898b1472ac94d085f4b223;hpb=6d789ebc45563080cc731487a3a3455a3d8d6ef2 diff --git a/panel.pl b/panel.pl new file mode 100644 index 0000000..d551e56 --- /dev/null +++ b/panel.pl @@ -0,0 +1,126 @@ +#!/usr/bin/perl +# -*- perl -*- + +# Copyright 2006 DJ Delorie +# Released under the terms of the GNU General Public License, version 2 + +sub baseboard { + my ($file, $width, $height, $nbase) = @_; + if (! $nbase) { + $base = $file; + $base =~ s@.*/@@; + } else { + $base = $nbase; + } + + $panelcopperlayers = ".*" unless $panelcopperlayers; + + $pscript = "$base.pscript"; + open(PS, ">$pscript"); + push(@files_to_remove, "$base.pscript"); + + open(S, $file) || die("$file: $!"); + $outname = "$base.panel.pcb"; + $outname =~ s/pnl\.panel\.pcb/pcb/; + open(O, ">$outname"); + while () { + if (/PCB\[.* (\S+) (\S+)\]/) { + s/ (\S+) (\S+)\]/ $width $height\]/; + } + s/Cursor\[.*\]/Cursor[0 0 0.0]/; + if (/^Flags/) { + s/,uniquename,/,/; + s/,uniquename//; + s/uniquename,//; + } + next if /\b(Via|Pin|Pad|ElementLine|Line|Arc|ElementArc|Text)/; + if (/Polygon|Element/) { + $hole = 0; + while () { + $hole++ if /Hole \(/; + last if /^\s*\)\s*$/ && $hole <= 0; + $hole-- if /\)/; + } + next; + } + if (/Layer/) { + if (@panelvias) { + print O @panelvias; + @panelvias = (); + } + } + print O; + if (/Layer\((\d+) \"(.*)\"\)/) { + $lnum = $1; + $lname = $2; + print O scalar ; + print STDERR "layer $lnum $lname vs '$panelcopperlayers'\n"; + if ($lnum =~ /$panelcopperlayers/ || $lname =~ /$panelcopperlayers/) { + print O @panelcopper; + } + } + } + close O; + close S; + + print PS "LoadFrom(Layout,$outname)\n"; + + $ox = $oy = 0; +} + +sub loadboard { + my ($file) = @_; + $seq = 1 + $seq; + + open(S, $file); + open(O, ">temp-panel.$seq"); + while () { + if (/PCB\[.* (\S+) (\S+)\]/) { + $width = &parseval($1); + $height = &parseval($2); + } + s/Cursor\[.*\]/Cursor[0 0 0.0]/; + print O; + } + close O; + close S; + print PS "LoadFrom(LayoutToBuffer,temp-panel.$seq)\n"; + push(@files_to_remove, "temp-panel.$seq"); +} + +sub opaste { + $vx = $ox; + $vy = $oy + $height; + print PS "PasteBuffer(ToLayout,$ox,$oy)\n"; + $ox += $width; + $oy = 0; +} + +sub vpaste { + print PS "PasteBuffer(ToLayout,$vx,$vy)\n"; + $vy += $height; +} + +sub done { + print PS "SaveTo(LayoutAs,$outname)\n"; + print PS "Quit()\n"; + + close PS; + + system "set -x; pcb --action-script $pscript"; + #system "pcb -x ps $base.panel.pcb"; + #unlink @files_to_remove; +} + +sub parseval { + my ($v) = @_; + if ($v =~ /mil/) { + $v *= 100; + } + if ($v =~ /mm/) { + $v *= 3937.007874015748; + } + return 0 + $v; +} + +1;