From: ian Date: Sun, 13 Apr 2008 15:16:30 +0000 (+0000) Subject: abortive segment movpos-specific mapping arrangements (actually unneeded because... X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?p=trains.git;a=commitdiff_plain;h=03fc6fa1c7d4d48c502cc21c3354f6cf0b94c1bd abortive segment movpos-specific mapping arrangements (actually unneeded because you can just specify fixed parts as fixed and the graph extractor does the hard work) --- diff --git a/layout/informat.txt b/layout/informat.txt index c65471e..0b71b89 100644 --- a/layout/informat.txt +++ b/layout/informat.txt @@ -92,9 +92,12 @@ Commands S D ---- ---- - N N' remaps an entire segment including all features - N/M M' remaps a particular moveable feature; N is the - unmapped name (if applicable) + N N' remaps an entire segment including all features + N/M M' remaps a particular moveable feature; N is the + unmapped name (if applicable) + N/[MP] N'/[M'P'] remaps a specific moveable feature position to a + specific other moveable feature position; + empty M and M' mean the fixed portions. The effect is that (sub)segments or features used in segment commands are translated when the segment command is read; the diff --git a/layout/layout b/layout/layout index 72fc31b..678878c 100755 --- a/layout/layout +++ b/layout/layout @@ -229,8 +229,9 @@ our $allwidthmin= allwidth(undef); # $ctx->{SegName} # initial segment name (at start of object or file) # # or nonexistent if in object in unknown segment # # may have leading `-' -# $ctx->{SegMapN}{$s}= $o -# $ctx->{SegMapNM}{$s}= $o +# $ctx->{SegMapN2N}{$s}= $o +# $ctx->{SegMapNM2M}{$s}= $o +# $ctx->{SegMapNMP2NMP}{$s}= $o # $ctx->{SavedSegment} # exists iff segment command used, is a $csss # $ctx->{Layer}{Level} # $ctx->{Layer}{Kind} @@ -1268,8 +1269,9 @@ sub newctx (;$) { Trans => { X => 0.0, Y => 0.0, A => 0.0, R => 1.0 }, InRunObj => "", DrawMap => sub { $_[0]; }, - SegMapN => { }, - SegMapNM => { } + SegMapN2N => { }, + SegMapNM2M => { }, + SegMapNMP2NMP => { }, }; if (defined $ctx_save) { %{ $ctx->{Layer} }= %{ $ctx_save->{Layer} }; @@ -1345,7 +1347,7 @@ sub cva_subsegspec ($) { $segname= ''; $sign= ''; } else { - my ($map_ctx); + my ($map_ctx,$specifickey); $ctx->{SegName} =~ m/^\-?/ or die; $sign .= $&; @@ -1354,12 +1356,21 @@ sub cva_subsegspec ($) { for ($map_ctx= $ctx; defined $map_ctx; $map_ctx= $map_ctx->{Parent}) { + $specifickey= $segname.'/'. + (defined $movfeat ? sprintf "%s%d", $movfeat, $movconf : ''); + if (exists $map_ctx->{SegMapNMP2NMP}{$specifickey}) { + $map_ctx->{SegMapNMP2NMP}{$specifickey} =~ + m,^(\-?)(.*)/([A-Za-z]*)(\d*)$, or die; + $sign .= $1; + $segname= $2; + ($movfeat,$movconf)= length($3) ? ($3,$4) : (undef,undef); + } if (defined $movfeat && - exists $map_ctx->{SegMapNM}{"$segname/$movfeat"}) { - $movfeat= $map_ctx->{SegMapNM}{"$segname/$movfeat"}; + exists $map_ctx->{SegMapNM2M}{"$segname/$movfeat"}) { + $movfeat= $map_ctx->{SegMapNM2M}{"$segname/$movfeat"}; } - if (exists $map_ctx->{SegMapN}{$segname}) { - $map_ctx->{SegMapN}{$segname} =~ m/^\-?/ or die; + if (exists $map_ctx->{SegMapN2N}{$segname}) { + $map_ctx->{SegMapN2N}{$segname} =~ m/^\-?/ or die; $sign .= $&; $segname= $'; } @@ -1387,7 +1398,7 @@ sub cmd_segment { sub cva_segmap_s { my ($sp) = @_; - $sp =~ m,^\w+(?:/[a-zA-Z_]+)?$, + $sp =~ m,^\w+(?:/(?:[a-zA-Z_]+\d*)?)?$, or die "invalid (sub)segment mapping S \`$sp'"; return $sp; } @@ -1397,21 +1408,30 @@ sub cva_segmap_n { $sp =~ m,^\-?\w+$, or die "invalid segment mapping N' \`$sp'"; return $sp; } - + sub cva_segmap_m { my ($sp) = @_; $sp =~ m,^[a-zA-Z_]+$, or die "invalid segment mapping M' \`$sp'"; return $sp; } +sub cva_segmap_nmp { + my ($sp) = @_; + $sp =~ m,^\-?\w+/(?:[a-zA-Z]+\d+)$, or + die "invalid segment mapping N'/[M'P'] \`$sp'"; + return $sp; +} + sub cmd_segmap { - my ($s,$d); + my ($s); while (@al) { $s= can(\&cva_segmap_s); - if ($s =~ m,/,) { - $ctx->{SegMapNM}{$s}= can(\&cva_segmap_m); + if ($s !~ m,/,) { + $ctx->{SegMapN2N}{$s}= can(\&cva_segmap_n); + } elsif ($s =~ m/[a-zA-Z]$/) { + $ctx->{SegMapNM2M}{$s}= can(\&cva_segmap_m); } else { - $ctx->{SegMapN}{$s}= can(\&cva_segmap_n); + $ctx->{SegMapNMP2NMP}{$s}= can(\&cva_segmap_nmp); } } } diff --git a/layout/ours.m4 b/layout/ours.m4 index 93f9f00..35d8f9c 100644 --- a/layout/ours.m4 +++ b/layout/ours.m4 @@ -162,10 +162,11 @@ join bot_3rj_b bot_2rx_bl 450 extend bot_2rx_tr bot_0mx_bl len 19 1400 -segmap bot_0mx_B -A5 bot_0mx_F -A6 segment bot_0mx_ +segmap bot_0mx_B/ A5/J1 bot_0mx_F/ A6/J1 part bot_0mx cross_pecof_s bl -segment A5 + +segment -A5/J1 extend -bot_0mx_br -bot_0rj_b len 8 segment -A5