From: ian Date: Wed, 11 Oct 2006 17:25:40 +0000 (+0000) Subject: started working on heights; is too hard since we actually need two degrees of freedom... X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=c709310f21b7f5a0c8321e8ea9c71affdaed6134;p=trains.git started working on heights; is too hard since we actually need two degrees of freedom etc. --- diff --git a/layout/layout b/layout/layout index cf5f9e4..eaa7f45 100755 --- a/layout/layout +++ b/layout/layout @@ -210,6 +210,7 @@ our $allwidthmin= allwidth(undef); # $ctx->{Loc}{$id}{X} # $ctx->{Loc}{$id}{Y} # $ctx->{Loc}{$id}{A} +# $ctx->{Loc}{$id}{H} # $ctx->{Loc}{$id}{LayerKind} # $ctx->{Trans}{X} # transformation. is ev representing # $ctx->{Trans}{Y} # new origin. (is applied at _input_ @@ -229,6 +230,7 @@ our $allwidthmin= allwidth(undef); # $ctx->{SavedSegment} # exists iff segment command used, is a $csss # $ctx->{Layer}{Level} # $ctx->{Layer}{Kind} +# $ctx->{HeightLayer}{$hl}= $height # # $objs{$id}{CmdLog} # $objs{$id}{Loc} @@ -416,13 +418,23 @@ sub bbox ($) { return ($min_x, $max_x, $min_y, $max_y); } -our %units_len= qw(- mm mm 1 cm 10 m 1000); +our %units_len= qw(- mm um 0.001 mm 1 cm 10 m 1000); our %units_ang= qw(- d r 1); $units_ang{'d'}= 2*$pi / 360; sub cva_len ($) { my ($sp)=@_; cva_units($sp,\%units_len); } sub cva_identity ($) { my ($sp)=@_; $sp; } sub cva_ang ($) { my ($sp)=@_; cva_units($sp,\%units_ang); } sub cva_absang ($) { input_absang(cva_ang($_[0])) } +sub cva_height ($) { + my ($sp)=@_; + my $offset= 0; + if ($sp =~ s/^([a-z]+)([-+])/$2/i) { + die unless exists $ctx->{HeightLayer}{$1}; + $offset= $ctx->{HeightLayer}{$1}; + } + return $offset + cva_units($sp, \%units_len); +} +sub cvd_height () { return undef; } sub cva_units ($$) { my ($sp,$ua)=@_; my ($n,$u,$r); @@ -496,17 +508,28 @@ sub cmd_abs { $i->{X}= can(\&cva_len); $i->{Y}= can(\&cva_len); $i->{A}= can(\&cva_ang); + $i->{H}= canf(\&cva_height, \&cvd_height); ev_compose($nl, $ctx->{Trans}, $i); } sub cmd_rel { - my ($from,$to,$len,$right,$turn); + my ($from,$to,$len,$right,$turn,$height,$base); $from= can(\&cva_idex); $to= can(\&cva_idnew); + if (@al && $al[0] =~ s/^\^//) { + if ($al[0] =~ m/^[a-z]/ || $al[0] =~ s/^0([-+])/$1/) { + $base= 0; + } else { + $base= $from->{H}; + defined $base or die "relative height but no height defined"; + } + $height= $base + can(\&cva_height); + } $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 }); + $to->{H}= $height; } sub dv__evreff ($) {