From: ian Date: Mon, 26 Jan 2004 02:08:53 +0000 (+0000) Subject: fix angle and "right" handling in cmd_rel; allow "=" as prefix for identity; make... X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=a8b249c8f23fed930d1245953425ec91a0258e54;p=trains.git fix angle and "right" handling in cmd_rel; allow "=" as prefix for identity; make args to rel optional --- diff --git a/layout/informat.txt b/layout/informat.txt index a47dee5..77db5ed 100644 --- a/layout/informat.txt +++ b/layout/informat.txt @@ -22,9 +22,9 @@ Commands abs P X Y A Defines loc P given coordinates (distances) and absolute bearing - rel F T L R A + rel F T [L R A] Defines loc T: start at loc F, go forward L, translate right R, - turn left A. + turn left A (defaults are all 0). extend F T len L [R] length L extend F T upto U [R] s.t. perpendicular at T passes through U @@ -63,6 +63,8 @@ Commands (`formal parameter', F must be just ) is placed at existing loc A (`actual parameter'). If prefix P (syntax is that of an identifier) is specified, each other loc L inside O is exported - into the global namespace as a new loc PL. If `flip' is used then - the object is placed with object-space y coordinates negated (ie, it - is mirrored so that the object's North exchanges with South). + into the global namespace as a new loc PL. P may be `=' to indicate + an empty prefix (default is not to export locs). If `flip' is used + then the object is placed with object-space y coordinates negated + (ie, it is mirrored so that the object's North exchanges with + South). diff --git a/layout/layout b/layout/layout index 0db06b5..b3f3666 100755 --- a/layout/layout +++ b/layout/layout @@ -232,9 +232,9 @@ sub cmd_rel { my ($from,$to,$len,$right,$turn); $from= can(\&cva_idex); $to= can(\&cva_idnew); - $len= can(\&cva_len); - $right= can(\&cva_len); - $turn= cano(\&cva_absang, 0); + $len= cano(\&cva_len,0); + $right= cano(\&cva_len,0) * $ctx->{Trans}{R}; + $turn= cano(\&cva_ang, 0) * $ctx->{Trans}{R}; my ($u)= ev_compose({}, $from, { X => $len, Y => -$right, A => 0 }); ev_compose($to, $u, { X => 0, Y => 0, A => $turn }); } @@ -667,6 +667,8 @@ sub cmd__obj ($) { $ctx->{Trans}{X}= $actual->{X} - $formcv->{X}; $ctx->{Trans}{Y}= $actual->{Y} - $formcv->{Y}; $ctx->{InRunObj}= $ctx_save->{InRunObj}."${obj_id}::"; + $ctx->{Draw}{T}= $ctx_save->{Draw}{T}; + $ctx->{Draw}{L}= $ctx_save->{Draw}{L}; $ctx->{Draw}{L} =~ s/L//; dv("cmd__obj $obj_id ",'$ctx',$ctx); { @@ -677,10 +679,14 @@ dv("cmd__obj $obj_id ",'$ctx',$ctx); cmd__one(); } }; - $pfx= cano(\&cva_idstr,''); + if (@al && $al[0] eq '=') { + $pfx= ''; shift @al; + } else { + $pfx= cano(\&cva_idstr,undef); + } $ctx_inobj= $ctx; $ctx= $ctx_save; - if (length $pfx) { + if (defined $pfx) { foreach $id (keys %{ $ctx_inobj->{Loc} }) { next if $id eq $formal_id; $newid= $pfx.$id;