From: ian Date: Mon, 2 Feb 2004 00:38:58 +0000 (+0000) Subject: layers and kinds X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=04cab7a444fccf206064f2f70e51e314962a219a;p=trains.git layers and kinds --- diff --git a/.cvsignore b/.cvsignore index 36333db..258a92a 100644 --- a/.cvsignore +++ b/.cvsignore @@ -3,3 +3,5 @@ qs t u testjoin +*.ps +*.d4 diff --git a/layout/informat.txt b/layout/informat.txt index 147be43..80bf23c 100644 --- a/layout/informat.txt +++ b/layout/informat.txt @@ -33,6 +33,18 @@ Commands Defines loc T: start at loc F, go forward L, translate right R, turn left A (defaults are all 0). + layer KL + K is layer kind (letters and `_', may be empty), L is a layer depth + (digits). Controls drawing style, by selecting appropriate parts of + the track and locs to draw, according to element selection rules. + Default outcomes: + K L result (description) result (element letters) + any other nothing - + empty current default track RLMNasco + `s' current nothing (`silent') - + `l' current centrelines only CLMNarso + other current everything ARSCLMNO + extend F T len L [R] length L extend F T upto U [R] s.t. perpendicular at T passes through U extend F T ang A R subtending directionally A @@ -101,9 +113,11 @@ Commands Command-line options -D turn on debug (level 1) } currently only debug levels are - -Dnnn set debug level to nnn } 0 (none) and 1 (some) + -Dnnn set debug level to nnn } 0 (none) and 1 (some), default=0 + + -lL output for layer L (default: 5) - -e[ARSCcLlMNOm]... + -e[ARSCcLlMNOm]... Turn on and off drawing of elements in groups. These are abbreviations for various -E... options. track -E.... @@ -120,8 +134,8 @@ Command-line options N bars for top-level locs and those in obj's MNo O bars for everything, including those inside parts MNO m no bars (turns off labelling too) mnol - - -E[ARSCLMNOarsclmno]... + + -E[ARSCLMNOarsclmno]... enable (capitals) or disable (lowercase) drawing of individual elements A draw track swept area, with ticks @@ -136,7 +150,23 @@ Command-line options -q quiet: do not print info to stderr (default: prints bounding box, at the moment) - Default is -d0, -EaRscLMNo, not quiet. + (for -e and -E) works as follows: + + When file says `layer KL', default drawing element set is set + depending on K and L (see description of `layer' command), using last + specified -l layer. Then all -e/-E options are scanned, in order, + and each one that matches modifies the drawing element set. + + is GN[D][C]. It matches `layer KL' iff the glob pattern G + (which may be empty) matches the whole of K, and layer restriction + N[D]C matches L. C is several identical `=', `+' or `-'; D+ matches + L iff L>=D; D++ iff L>D; D+++ iff L>D+1 and so on; D- matches L iff + L<=D; D-- iff L{CmdLog}= [ ]; $ctx->{InDefObj}= $id; - $ctx->{Draw}= ''; + $ctx->{Draw}= 'X'; } sub cmd_enddef { @@ -724,6 +732,38 @@ sub cmd__runobj ($) { } } +sub cmd_layer { + my ($kl, $k,$l, $eo,$cc); + return if $ctx->{Draw} =~ m/X/; + $kl= can(\&cva_identity); + $kl =~ m/^([A-Za-z_]*)(\d+)$/ or die "invalid layer spec"; + ($k,$l)=($1,$2); + if ($l != $output_layer) { + $ctx->{Draw} = ''; + } elsif ($k eq '') { + $ctx->{Draw}= 'RLMN'; + } elsif ($k eq 's') { + $ctx->{Draw}= ''; + } elsif ($k eq 'l') { + $ctx->{Draw}= 'CLMN'; + } else { + $ctx->{Draw}= 'ARSCLMNO'; + } + print STDERR "layer $k $l drawdef |$ctx->{Draw}|\n"; + foreach $eo (@eopts) { + print STDERR "layer $k $l eo $eo->{GlobRe}\n"; + next unless $k =~ m/^$eo->{GlobRe}$/; + print STDERR "layer $k $l lc $eo->{LayerCheck}\n"; + next unless &{ $eo->{LayerCheck} }($l); + print STDERR "layer $k $l dm $eo->{DrawMods}\n"; + foreach $cc (split //, $eo->{DrawMods}) { + $ctx->{Draw} =~ s/$cc//ig; + $ctx->{Draw} .= $cc if $cc =~ m/[A-Z]/; + } + } + print STDERR "layer $k $l drawing |$ctx->{Draw}|\n"; +} + sub cmd_part { cmd__obj(Part); } sub cmd_obj { cmd__obj(1); } sub cmd_objflip { cmd__obj(-1); } @@ -953,8 +993,6 @@ our %chdraw_emap= qw(A ARSc N MNo O MNO m mnol); - -$ctx->{Draw}= 'RLMN'; our $quiet=0; @@ -967,22 +1005,38 @@ while (@ARGV && $ARGV[0] =~ m/^\-/) { if (s/^D(\d+)//) { $debug= $1; } elsif (s/^D//) { $debug++; } elsif (s/^q//) { $quiet=1; } - elsif (s/^([Ee])([a-zA-Z]+)//) { - my ($ee,$c,@c,$cc); - $ee= $1; - foreach $c (split //, $2) { + elsif (s/^(e) + ((?:[a-z]|\*|\?|\[[a-z][-a-z]*\])*?) + (\~?) (\d*) (\=*|\-+|\++) + ([a-z]+)//ix) { + my ($ee,$g,$n,$d,$c,$cc) = ($1,$2,$3,$4,$5,$6); + my ($eo, $invert, $lfn, $ccc, $sense,$limit); + $g =~ s/[?*]/\\$&/g; + $d= $output_layer if !length $d; + $invert= length $n; + if ($c =~ m/^[-+]/) { + $sense= ($c.'1') + 0; + $limit= ($sense * $d) + length($c) - 1; + $lfn= sub { $_[0] * $sense >= $limit xor $invert }; + } else { + $limit= length($c) - 1; + $limit=0 if $limit<0; + $lfn= sub { abs($_[0] - $d) <= $limit xor $invert }; + } + $ccc= ''; + foreach $c (split //, $cc) { if ($ee eq 'e') { die "bad -e option $c" unless defined $chdraw_emap{$c}; - @c= split //, $chdraw_emap{$c}; + $ccc .= $chdraw_emap{$c}; } else { die "bad -E option $c" unless $c =~ m/[$drawers]/i; - @c= ($c); - } - foreach $cc (@c) { - $ctx->{Draw} =~ s/$cc//ig; - $ctx->{Draw} .= $cc if $cc =~ m/[A-Z]/; + $ccc .= $c; } } + $eo->{GlobRe}= $g; + $eo->{LayerCheck}= $lfn; + $eo->{DrawMods}= $ccc; + push @eopts, $eo; } else { die "unknown option -$_"; } @@ -996,6 +1050,11 @@ if ($debug) { select(STDOUT); $|=1; } +$ctx->{Draw}= ''; + +@al= qw(layer 5); +cmd__one(); + while (<>) { next if m/^\s*\#/; chomp; s/^\s+//; s/\s+$//; diff --git a/layout/ours.m4 b/layout/ours.m4 index 87221cb..ec6717f 100644 --- a/layout/ours.m4 +++ b/layout/ours.m4 @@ -70,7 +70,7 @@ part l23_dj ^dualjn_peco_r ic extend l23_dj_oa l3_sh uptoang 180 -315 -#thinlines: +layer l5 extend l3_pbl sq_bl_o upto l3_lst rel sq_bl_o sq_bl_i 0 0 -90 @@ -84,7 +84,9 @@ extend sq_tr_i sq_br_o upto sq_bl_i rel sq_br_o sq_br_i 0 0 -90 extend sq_br_i sq_bl_o2 upto sq_bl_o -#endthinlines + +layer 5 + rel sq_tl_i l4_ct 352 37 180 rel l4_ct l5_ct 0 37 diff --git a/pcb/Makefile b/pcb/Makefile new file mode 100644 index 0000000..41e08b2 --- /dev/null +++ b/pcb/Makefile @@ -0,0 +1,19 @@ + +M4INCS= parts.i4 + +LAYOUTOPTS= -EArC + +all: ours-l0.ps \ + ours-l10.ps \ + ours-l20.ps + +o=>$@.new && mv -f $@.new $@ + +%.d4: %.m4 $(M4INCS) + m4 -s <$< $o + +ours-l%.ps: ours.d4 layout + ./layout <$< $(LAYOUTOPTS) $o + +clean: + -rm -f -- *.d4 *.ps diff --git a/pic.make b/pic.make new file mode 100644 index 0000000..41e08b2 --- /dev/null +++ b/pic.make @@ -0,0 +1,19 @@ + +M4INCS= parts.i4 + +LAYOUTOPTS= -EArC + +all: ours-l0.ps \ + ours-l10.ps \ + ours-l20.ps + +o=>$@.new && mv -f $@.new $@ + +%.d4: %.m4 $(M4INCS) + m4 -s <$< $o + +ours-l%.ps: ours.d4 layout + ./layout <$< $(LAYOUTOPTS) $o + +clean: + -rm -f -- *.d4 *.ps diff --git a/spice/Makefile b/spice/Makefile new file mode 100644 index 0000000..41e08b2 --- /dev/null +++ b/spice/Makefile @@ -0,0 +1,19 @@ + +M4INCS= parts.i4 + +LAYOUTOPTS= -EArC + +all: ours-l0.ps \ + ours-l10.ps \ + ours-l20.ps + +o=>$@.new && mv -f $@.new $@ + +%.d4: %.m4 $(M4INCS) + m4 -s <$< $o + +ours-l%.ps: ours.d4 layout + ./layout <$< $(LAYOUTOPTS) $o + +clean: + -rm -f -- *.d4 *.ps