From: ian Date: Sat, 16 Sep 2006 00:43:34 +0000 (+0000) Subject: first cut of distance labels X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?p=trains.git;a=commitdiff_plain;h=292e033dc19c1de5cb986989eddba2257aa0e216 first cut of distance labels --- diff --git a/layout/Makefile b/layout/Makefile index 050eda1..c0d1c17 100644 --- a/layout/Makefile +++ b/layout/Makefile @@ -32,7 +32,7 @@ for-test-ui: ours.graph.c ours.redactgraph ours.raw.neato.ps \ layers: $(LAYERS) lpages: $(LPAGES) -extras: dualjn-a.ps parts.ps +extras: ours-a.ps ours-al.ps dualjn-a.ps parts.ps include ours.dgram.m include segencolayers.m @@ -83,7 +83,7 @@ compose-segenco: compose-segenco.o m4 -s <$< $o %-a.ps: %.d4 layout - ./layout <$< $(LAYOUTOPTS) '-E*l' $o + ./layout <$< $(LAYOUTOPTS) '-E*lD' $o %-al.ps: %.d4 layout ./layout <$< $(LAYOUTOPTS) '-e*C' '-ep=rm' $o @@ -140,7 +140,8 @@ subseg2display.o compose-segenco.o: segcmap.h clean: -rm -f -- *.d4 *~ t.* *.m *.new core - -rm -f ours.*.ps parts.ps *.neato.ps ours.*.neato + -rm -f ours.*.ps ours-*.ps parts.ps *.neato.ps ours.*.neato + -rm -f dualjn-*.ps -rm -f *.pin-info *+pindata.asm -rm -f *.redacted.forsafety *.redacted.forneato -rm -f *.oprint-*.ps *.run-layout diff --git a/layout/informat.txt b/layout/informat.txt index 9a4cab7..29f5fe1 100644 --- a/layout/informat.txt +++ b/layout/informat.txt @@ -212,16 +212,19 @@ Command-line options -e[ARSCcLlMNOm]... Turn on and off drawing of elements in groups. These are abbreviations for various -E... options. - track -E.... - A full track ARScg - R rails only aRscg - S rails and sleepers only aRScg - C centrelines only arsCg - c swept area and ticks only Arscg - r no lines drawn at all arcs + track -E..... + A full track ARScgd + R rails only aRscgD + S rails and sleepers only aRScgd + C centrelines only arsCgd + c swept area and ticks only Arscgd + r no lines drawn at all arsc labels at locs L label top-level locs (turns on bars for them too) LMg l do not label any locs l + label distances + D label all distances D + d do not label any locs d bars at locs (thick lines perp to track dir'n) M bars for top-level locs only Mnog N bars for top-level locs and those in obj's MNog @@ -238,6 +241,7 @@ Command-line options S draw track sleepers C draw track centrelines L label locs + D label distances along the track M mark locs with a bar N mark locs with a bar in objs O mark locs with a bar in parts diff --git a/layout/layout b/layout/layout index 3f5f6b5..ed8ba2f 100755 --- a/layout/layout +++ b/layout/layout @@ -25,12 +25,12 @@ our @eopts; our @segments= ('/'); our %subsegcmap; -our $drawers= 'arsclmnog'; -our %chdraw_emap= qw(A ARScg - R aRscg - S aRScg - C arsCg - c Arscg +our $drawers= 'arscldmnog'; +our %chdraw_emap= qw(A ARScgd + R aRscgD + S aRScgd + C arsCgd + c Arscgd r arcs L LMg l l @@ -165,8 +165,11 @@ our $lmu_marklw= 4; our $lmu_marktpt= 11; our $lmu_txtboxtxty= $lmu_marktpt * 0.300; our $lmu_txtboxh= $lmu_marktpt * 1.100; +our $lmu_lenboxh= $lmu_marktpt * 1.100; our $lmu_txtboxpadx= $lmu_marktpt * 0.335; +our $lmu_lenboxpadx= $lmu_marktpt * 0.005; our $lmu_txtboxoff= $lmu_marklw / 2; +our $lmu_lenboxoff= -$lmu_marklw * 1.5; our $lmu_txtboxlw= 1; our $olu_left= 10 * $scale; @@ -686,10 +689,10 @@ sub segment_used_end ($$) { } sub parametric_segment ($$$$$) { my ($p0,$p1,$lenperp,$minradius,$calcfn) = @_; - # makes $p (global) go from $p0 to $p1 ($p1>$p0) + # makes $param (global) go from $p0 to $p1 ($p1>$p0) # $lenperp is the length of one unit p, ie the curve # must have a uniform `density' in parameter space - # $calcfn is invoked with $p set and should return a loc + # $calcfn is invoked with $param set and should return a loc # (ie, ref to X =>, Y =>, A =>). my ($pa,$pb,@ends,$side,$ppu,$e,$v,$tick,$draw,$allwidth); return unless $ctx->{Draw} =~ m/[ARSCG]/; @@ -770,6 +773,19 @@ print DEBUG "ps $p0 $p1 $lenperp ($ppu)\n"; parametric__o_pt(&$calcfn); o(" stroke\n"); } + if ($draw =~ m/D/) { + my ($pt,$ad,$len); + $param= ($p0+$p1)*0.5; + $pt= &$calcfn; + $ad= ang2deg($pt->{A}) + 90; + $len= sprintf "%.0f", $lenperp * abs($p1-$p0); + ol(" gsave\n". + " $pt->{X} $pt->{Y} translate\n". + " $ad rotate 0.75 dup scale\n". + " 0 $lmu_lenboxh $lmu_lenboxpadx $lmu_lenboxoff". + " ($len) label_in_box\n". + " grestore\n"); + } return unless $draw =~ m/[ARS]/; for ($pa= $p0; $pa<$p1; $pa=$pb) { $pb= $pa + $ppu; @@ -1460,19 +1476,8 @@ dv("cmd__do $ctx @al ",'$ctx',$ctx); " $lmu_marklw setlinewidth stroke\n"); } if ($draw =~ m/L/) { - ol(" /s ($id) def\n". - " lf setfont\n". - " /sx5 s stringwidth pop\n". - " 0.5 mul $lmu_txtboxpadx add def\n". - " -90 rotate 0 $lmu_txtboxoff translate newpath\n". - " sx5 neg 0 moveto\n". - " sx5 neg $lmu_txtboxh lineto\n". - " sx5 $lmu_txtboxh lineto\n". - " sx5 0 lineto closepath\n". - " gsave 1 setgray fill grestore\n". - " $lmu_txtboxlw setlinewidth stroke\n". - " sx5 neg $lmu_txtboxpadx add $lmu_txtboxtxty\n". - " moveto s show\n"); + ol(" $lmu_txtboxlw $lmu_txtboxh $lmu_txtboxpadx". + " $lmu_txtboxoff ($id) label_in_box\n"); } ol(" grestore\n"); } @@ -1563,6 +1568,28 @@ if ($page_x || $page_y) { o(" -$ps_page_xmul $page_x mul -$ps_page_ymul $page_y mul translate\n". " $ptscale $ptscale scale\n"); +o("/label_in_box {\n". + '% linewidth $lmu_*boxh $lmu_*padx $lmu_*boxoff (s)'. + ' label_in_box => _'."\n". + " /s exch def\n". + " /boxoff exch def\n". + " /padx exch def\n". + " /boxh exch def\n". + " setlinewidth\n". + " lf setfont\n". + " /sx5 s stringwidth pop\n". + " 0.5 mul padx add def\n". + " -90 rotate 0 boxoff translate newpath\n". + " sx5 neg 0 moveto\n". + " sx5 neg boxh lineto\n". + " sx5 boxh lineto\n". + " sx5 0 lineto closepath\n". + " gsave 1 setgray fill grestore\n". + " stroke\n". + " sx5 neg padx add $lmu_txtboxtxty\n". + " moveto s show\n". + "} def\n"); + newctx(); open DEBUG, ($debug ? ">&2" : ">/dev/null") or die $!;