From 51a9657a4400c98baf1eb338208a12f3a51d646f Mon Sep 17 00:00:00 2001 From: ian Date: Mon, 2 Feb 2004 02:12:01 +0000 Subject: [PATCH] default layer * --- layout/informat.txt | 17 ++++++++++------- layout/layout | 37 ++++++++++++++++++++++++++++--------- 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/layout/informat.txt b/layout/informat.txt index c70f3fa..e434b0d 100644 --- a/layout/informat.txt +++ b/layout/informat.txt @@ -33,11 +33,12 @@ Commands Defines loc T: start at loc F, go forward L, translate right R, turn left A (defaults are all 0). - layer KL + layer K[L] 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: + (digits, or `=' meaning current layer; default for L is `='; default + KL at start of file is `layer 5'). 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 @@ -163,9 +164,11 @@ Command-line options 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{Trans}{R} # but multiply all y coords by this! # $ctx->{Draw} # sequence of one or more chrs from uc $drawers # # or X meaning never draw anything (eg in defobj) +# $ctx->{Layer}{Level} +# $ctx->{Layer}{Kind} # # $objs{$id}{CmdLog} # $objs{$id}{Loc} @@ -682,11 +684,14 @@ sub input_abscoords ($$) { return ($out->{X}, $out->{Y}); } -sub newctx () { +sub newctx (;$) { + my ($ctx_save) = @_; $ctx= { Trans => { X => 0.0, Y => 0.0, A => 0.0, R => 1.0 }, InRunObj => "" }; + %{ $ctx->{Layer} }= %{ $ctx_save->{Layer} } + if defined $ctx_save; } our $defobj_save; @@ -702,10 +707,11 @@ sub cmd__defobj ($) { die "repeated defobj" if exists $objs{$id}; $defobj_save= $ctx; $defobj_ispart= $ispart; - newctx(); + newctx($defobj_save); $ctx->{CmdLog}= [ ]; $ctx->{InDefObj}= $id; $ctx->{Draw}= 'X'; + $ctx->{Layer}= { Level => 5, Kind => '' }; } sub cmd_enddef { @@ -718,6 +724,7 @@ sub cmd_enddef { $objs{$id}{Part}= $defobj_ispart; $ctx= $defobj_save; $defobj_save= undef; + $defobj_ispart= undef; } sub cmd__runobj ($) { @@ -735,9 +742,12 @@ sub cmd__runobj ($) { sub cmd_layer { my ($kl, $k,$l, $eo,$cc); $kl= can(\&cva_identity); - return if $ctx->{Draw} =~ m/X/; - $kl =~ m/^([A-Za-z_]*)(\d+)$/ or die "invalid layer spec"; + $kl =~ m/^([A-Za-z_]*)(\d*|\=)$/ or die "invalid layer spec"; ($k,$l)=($1,$2); + $l= $ctx->{Layer}{Level} if $l =~ m/^\=?$/; + $ctx->{Layer}{Kind}= $l; + $ctx->{Layer}{Level}= $l; + return if $ctx->{Draw} =~ m/X/; if ($output_layer ne '*' && $l != $output_layer) { $ctx->{Draw} = ''; } elsif ($k eq '') { @@ -751,7 +761,7 @@ sub cmd_layer { } foreach $eo (@eopts) { next unless $k =~ m/^$eo->{GlobRe}$/; - next unless $output_layer eq '*' || &{ $eo->{LayerCheck} }($l); + next unless &{ $eo->{LayerCheck} }($l); foreach $cc (split //, $eo->{DrawMods}) { $ctx->{Draw} =~ s/$cc//ig; $ctx->{Draw} .= $cc if $cc =~ m/[A-Z]/; @@ -788,7 +798,7 @@ sub cmd__obj ($) { $formal= $obj->{Loc}{$formal_id}; die "unknown formal $formal_id" unless $formal; $ctx_save= $ctx; - newctx(); + newctx($ctx_save); $how *= $ctx_save->{Trans}{R}; $ctx->{Trans}{R}= $how; $ctx->{Trans}{A}= $actual->{A} - $formal->{A}/$how; @@ -915,7 +925,7 @@ sub cmd_showlibrary { $obj= $objs{$obj_id}; next unless $obj->{Part}; ($min_x, $max_x, $min_y, $max_y) = bbox($obj->{Loc}); - newctx(); + newctx($ctx_save); for (;;) { $width= $max_x - $min_x; @@ -1008,6 +1018,7 @@ while (@ARGV && $ARGV[0] =~ m/^\-/) { my ($eo, $invert, $lfn, $ccc, $sense,$limit); $g =~ s/[?*]/\\$&/g; $d= $output_layer if !length $d; + $d= 5 if $d eq '*'; $invert= length $n; $c= '=' if !length $c; if (length $v) { @@ -1017,10 +1028,18 @@ while (@ARGV && $ARGV[0] =~ m/^\-/) { if ($c =~ m/^[-+]/) { $sense= ($c.'1') + 0; $limit= ($sense * $d) + length($c) - 1; - $lfn= sub { $_[0] * $sense >= $limit xor $invert }; + $lfn= sub { + ($output_layer eq '*' ? $d + : $_[0]) * $sense >= $limit + xor $invert; + }; } else { $limit= length($c) - 1; - $lfn= sub { abs($_[0] - $d) <= $limit xor $invert }; + $lfn= sub { + ($output_layer eq '*' ? 1 + : abs($_[0] - $d) <= $limit) + xor $invert; + }; } $ccc= ''; foreach $c (split //, $cc) { -- 2.30.2