no strict 'subs';
our $scale= 7.0;
+our $page_x= 0;
+our $page_y= 0;
+our $quiet=0;
+our $debug=0;
+our $output_layer= '*';
-if (@ARGV && $ARGV[0] =~ m/^\-S([0-9.]+)$/) {
- $scale= $1 * 1.0;
- shift @ARGV;
-}
+our @eopts;
+
+our $drawers= 'arsclmno';
+our %chdraw_emap= qw(A ARSc
+ R aRsc
+ S aRSc
+ C arsC
+ c Arsc
+ r arcs
+ L LM
+ l l
+ M Mno
+ N MNo
+ O MNO
+ m mnol);
+
+while (@ARGV && $ARGV[0] =~ m/^\-/) {
+ last if $ARGV[0] eq '-';
+ $_= shift @ARGV;
+ last if $_ eq '--';
+ s/^\-//;
+ while (length) {
+ if (s/^D(\d+)//) { $debug= $1; }
+ elsif (s/^D//) { $debug++; }
+ elsif (s/^q//) { $quiet=1; }
+ elsif (s/^l(\d+|\*)//) { $output_layer=$1; }
+ elsif (s/^S([0-9.]+)$//) { $scale= $1 * 1.0; }
+ elsif (s/^P(\d+)x(\d+)$//) { $page_x= $1; $page_y= $2; }
+ elsif (s/^(e)
+ ((?:[a-z]|\*|\?|\[[a-z][-a-z]*\])*?)
+ (\~?) (\d*) (\=*|\-+|\++) (\d*|\*)
+ ([a-z]+)$//ix) {
+ my ($ee,$g,$n,$d,$c,$v,$cc) = ($1,$2,$3,$4,$5,$6,$7);
+ my ($eo, $invert, $lfn, $ccc, $sense,$limit);
+ $g =~ s/\?/\./g; $g =~ s/\*/\.\*/g;
+ die '-[eE]GND[=]* not allowed' if $v eq '*' && length $d;
+ $d= $output_layer if !length $d;
+ $d= 5 if $d eq '*';
+ $invert= length $n;
+ $c= '=' if !length $c;
+ if (length $v && $v ne '*') {
+ die '-[eE]GN[D]CCV not allowed' if length $c > 1;
+ $c= $c x $v;
+ }
+ if ($c =~ m/^[-+]/) {
+ die '-[eE]GN+/-* not allowed' if $v eq '*';
+ $sense= ($&.'1') + 0;
+ $limit= ($sense * $d) + length($c) - 1;
+ $lfn= sub {
+ ($output_layer eq '*' ? $d
+ : $_[0]) * $sense >= $limit
+ xor $invert;
+ };
+ } elsif ($v eq '*') {
+ $lfn= sub { !$invert; };
+ } else {
+ $limit= length($c) - 1;
+ $lfn= sub {
+#my ($lfn_result)=(
+ ($output_layer eq '*' ? 1
+ : abs($_[0] - $d) <= $limit)
+ xor $invert
+#)
+ ;
+#print STDERR "output layer $output_layer; asking re $_[0] rel $d lim $limit invert $invert result $lfn_result\n";
+#$lfn_result;
+ };
+ }
+ $ccc= '';
+ foreach $c (split //, $cc) {
+ if ($ee eq 'e') {
+ die "bad -e option $c" unless defined $chdraw_emap{$c};
+ $ccc .= $chdraw_emap{$c};
+ } else {
+ die "bad -E option $c" unless $c =~ m/[$drawers]/i;
+ $ccc .= $c;
+ }
+ }
+ $eo->{GlobRe}= $g;
+ $eo->{LayerCheck}= $lfn;
+ $eo->{DrawMods}= $ccc;
+#print STDERR "created eo $eo re $eo->{GlobRe} n=$n d=$d v=$v c=$c limit=$limit cc=$cc\n";
+ push @eopts, $eo;
+ } elsif (m/^S/) {
+ die "-S option must come right at the start and have numeric arg";
+ } else {
+ die "unknown option -$_";
+ }
+ }
+}
our $ptscale= 72/25.4 / $scale;
our $olu_textallowperc= $lmu_marktpt * 5.0/11;
our $pi= atan2(0,-1);
-our $output_layer= '*';
sub allwidth2 ($) {
my ($radius)= @_;
our $ctx;
our %objs;
-our @eopts;
our @al; # current cmd
our $o='';
our $ol='';
our $param; # for parametric_curve
-our $debug=0;
# ev_... functions
#
"%!\n".
" /lf /Courier-New findfont $lmu_marktpt scalefont def\n".
" 615 0 translate 90 rotate\n".
+ " -709 $page_x mul -566 $page_y mul translate\n".
" $ptscale $ptscale scale\n"
or die $!;
newctx();
-our $drawers= 'arsclmno';
-our %chdraw_emap= qw(A ARSc
- R aRsc
- S aRSc
- C arsC
- c Arsc
- r arcs
- L LM
- l l
- M Mno
- N MNo
- O MNO
- m mnol);
-
-our $quiet=0;
-
-while (@ARGV && $ARGV[0] =~ m/^\-/) {
- last if $ARGV[0] eq '-';
- $_= shift @ARGV;
- last if $_ eq '--';
- s/^\-//;
- while (length) {
- if (s/^D(\d+)//) { $debug= $1; }
- elsif (s/^D//) { $debug++; }
- elsif (s/^q//) { $quiet=1; }
- elsif (s/^l(\d+|\*)//) { $output_layer=$1; }
- elsif (s/^(e)
- ((?:[a-z]|\*|\?|\[[a-z][-a-z]*\])*?)
- (\~?) (\d*) (\=*|\-+|\++) (\d*|\*)
- ([a-z]+)$//ix) {
- my ($ee,$g,$n,$d,$c,$v,$cc) = ($1,$2,$3,$4,$5,$6,$7);
- my ($eo, $invert, $lfn, $ccc, $sense,$limit);
- $g =~ s/\?/\./g; $g =~ s/\*/\.\*/g;
- die '-[eE]GND[=]* not allowed' if $v eq '*' && length $d;
- $d= $output_layer if !length $d;
- $d= 5 if $d eq '*';
- $invert= length $n;
- $c= '=' if !length $c;
- if (length $v && $v ne '*') {
- die '-[eE]GN[D]CCV not allowed' if length $c > 1;
- $c= $c x $v;
- }
- if ($c =~ m/^[-+]/) {
- die '-[eE]GN+/-* not allowed' if $v eq '*';
- $sense= ($&.'1') + 0;
- $limit= ($sense * $d) + length($c) - 1;
- $lfn= sub {
- ($output_layer eq '*' ? $d
- : $_[0]) * $sense >= $limit
- xor $invert;
- };
- } elsif ($v eq '*') {
- $lfn= sub { !$invert; };
- } else {
- $limit= length($c) - 1;
- $lfn= sub {
-#my ($lfn_result)=(
- ($output_layer eq '*' ? 1
- : abs($_[0] - $d) <= $limit)
- xor $invert
-#)
- ;
-#print STDERR "output layer $output_layer; asking re $_[0] rel $d lim $limit invert $invert result $lfn_result\n";
-#$lfn_result;
- };
- }
- $ccc= '';
- foreach $c (split //, $cc) {
- if ($ee eq 'e') {
- die "bad -e option $c" unless defined $chdraw_emap{$c};
- $ccc .= $chdraw_emap{$c};
- } else {
- die "bad -E option $c" unless $c =~ m/[$drawers]/i;
- $ccc .= $c;
- }
- }
- $eo->{GlobRe}= $g;
- $eo->{LayerCheck}= $lfn;
- $eo->{DrawMods}= $ccc;
-#print STDERR "created eo $eo re $eo->{GlobRe} n=$n d=$d v=$v c=$c limit=$limit cc=$cc\n";
- push @eopts, $eo;
- } elsif (m/^S/) {
- die "-S option must come right at the start and have numeric arg";
- } else {
- die "unknown option -$_";
- }
- }
-}
-
open DEBUG, ($debug ? ">&2" : ">/dev/null") or die $!;
if ($debug) {
E_TRACK= ArsCLMNo
LAYOUTOPTS_ALL= -ep=*Cm
LAYOUTOPTS= -E=*$(E_TRACK) $(LAYOUTOPTS_ALL)
+LAYOUTOPTS_PHYS= -S1.0 $(LAYOUTOPTS) '-e*A'
+XLAYOUTOPTS_LAYER= -e'=5AN' -E'*~=5rsm' -e'p~=5r' -e'*~=9C' -e'*=*l'
+
LAYERS_LS= 0 10 20
LAYERS_PS= $(addsuffix .ps, $(LAYERS_LS))
LAYERS_L= $(addprefix ours-l, $(LAYERS_PS))
LAYERS_E= $(addprefix ours-e, $(LAYERS_PS))
LAYERS= $(LAYERS_L) $(LAYERS_E)
+LPAGES= $(foreach x, 0 1 2 3 4 5 6, $(foreach y, 1 2 3 4 5, ours-p0-$xx$y.ps))
+
default: ours-a.ps ours-al.ps parts.ps
layers: $(LAYERS)
+lpages: $(LPAGES)
all: default layers circuit.bom bulkres.bom divider-tables
./layout -S1.0 <$< $(LAYOUTOPTS) '-e*A' '-ep=rm' $o
ours-l%.ps: ours.d4 layout
- ./layout <$< -l$* $(LAYOUTOPTS) \
- -e'=5AN' -E'*~=5rsm' -e'p~=5r' -e'*~=9C' -e'*=*l' $o
+ ./layout <$< -l$* $(LAYOUTOPTS) $(XLAYOUTOPTS_LAYER) $o
ours-e%.ps: ours.d4 layout
./layout <$< -l$* -E'=*aRsclMno' \
-e'p=*rm' -e'=5RN' -E'*~=5rsm' -e'p~=5r' -e'*=*l' $o
+ours-p%.ps: ours.d4 layout
+ ./layout <$< -l$$(printf %s "$*" | sed -e 's/-/ -P/') \
+ $(LAYOUTOPTS_PHYS) $(XLAYOUTOPTS_LAYER) $o
+
parts.ps: showlib.d4 layout
./layout <$< $(LAYOUTOPTS_ALL) $o
E_TRACK= ArsCLMNo
LAYOUTOPTS_ALL= -ep=*Cm
LAYOUTOPTS= -E=*$(E_TRACK) $(LAYOUTOPTS_ALL)
+LAYOUTOPTS_PHYS= -S1.0 $(LAYOUTOPTS) '-e*A'
+XLAYOUTOPTS_LAYER= -e'=5AN' -E'*~=5rsm' -e'p~=5r' -e'*~=9C' -e'*=*l'
+
LAYERS_LS= 0 10 20
LAYERS_PS= $(addsuffix .ps, $(LAYERS_LS))
LAYERS_L= $(addprefix ours-l, $(LAYERS_PS))
LAYERS_E= $(addprefix ours-e, $(LAYERS_PS))
LAYERS= $(LAYERS_L) $(LAYERS_E)
+LPAGES= $(foreach x, 0 1 2 3 4 5 6, $(foreach y, 1 2 3 4 5, ours-p0-$xx$y.ps))
+
default: ours-a.ps ours-al.ps parts.ps
layers: $(LAYERS)
+lpages: $(LPAGES)
all: default layers circuit.bom bulkres.bom divider-tables
./layout -S1.0 <$< $(LAYOUTOPTS) '-e*A' '-ep=rm' $o
ours-l%.ps: ours.d4 layout
- ./layout <$< -l$* $(LAYOUTOPTS) \
- -e'=5AN' -E'*~=5rsm' -e'p~=5r' -e'*~=9C' -e'*=*l' $o
+ ./layout <$< -l$* $(LAYOUTOPTS) $(XLAYOUTOPTS_LAYER) $o
ours-e%.ps: ours.d4 layout
./layout <$< -l$* -E'=*aRsclMno' \
-e'p=*rm' -e'=5RN' -E'*~=5rsm' -e'p~=5r' -e'*=*l' $o
+ours-p%.ps: ours.d4 layout
+ ./layout <$< -l$$(printf %s "$*" | sed -e 's/-/ -P/') \
+ $(LAYOUTOPTS_PHYS) $(XLAYOUTOPTS_LAYER) $o
+
parts.ps: showlib.d4 layout
./layout <$< $(LAYOUTOPTS_ALL) $o
E_TRACK= ArsCLMNo
LAYOUTOPTS_ALL= -ep=*Cm
LAYOUTOPTS= -E=*$(E_TRACK) $(LAYOUTOPTS_ALL)
+LAYOUTOPTS_PHYS= -S1.0 $(LAYOUTOPTS) '-e*A'
+XLAYOUTOPTS_LAYER= -e'=5AN' -E'*~=5rsm' -e'p~=5r' -e'*~=9C' -e'*=*l'
+
LAYERS_LS= 0 10 20
LAYERS_PS= $(addsuffix .ps, $(LAYERS_LS))
LAYERS_L= $(addprefix ours-l, $(LAYERS_PS))
LAYERS_E= $(addprefix ours-e, $(LAYERS_PS))
LAYERS= $(LAYERS_L) $(LAYERS_E)
+LPAGES= $(foreach x, 0 1 2 3 4 5 6, $(foreach y, 1 2 3 4 5, ours-p0-$xx$y.ps))
+
default: ours-a.ps ours-al.ps parts.ps
layers: $(LAYERS)
+lpages: $(LPAGES)
all: default layers circuit.bom bulkres.bom divider-tables
./layout -S1.0 <$< $(LAYOUTOPTS) '-e*A' '-ep=rm' $o
ours-l%.ps: ours.d4 layout
- ./layout <$< -l$* $(LAYOUTOPTS) \
- -e'=5AN' -E'*~=5rsm' -e'p~=5r' -e'*~=9C' -e'*=*l' $o
+ ./layout <$< -l$* $(LAYOUTOPTS) $(XLAYOUTOPTS_LAYER) $o
ours-e%.ps: ours.d4 layout
./layout <$< -l$* -E'=*aRsclMno' \
-e'p=*rm' -e'=5RN' -E'*~=5rsm' -e'p~=5r' -e'*=*l' $o
+ours-p%.ps: ours.d4 layout
+ ./layout <$< -l$$(printf %s "$*" | sed -e 's/-/ -P/') \
+ $(LAYOUTOPTS_PHYS) $(XLAYOUTOPTS_LAYER) $o
+
parts.ps: showlib.d4 layout
./layout <$< $(LAYOUTOPTS_ALL) $o