chiark / gitweb /
more flexibility: -NEWL, ^OBJ, etc., and restart layout design
[trains.git] / layout / informat.txt
1 Locations, angles, etc.
2
3  Key type is a `loc', which is a named location (absolute, 2D) and
4  direction (at the location).  Angles are generally positive
5  anticlockwise; bearings are angles measured from East.  The origin is
6  at the South-West.
7
8 Syntaxes
9  New location
10   <identifier>
11   -<identifier>       reverse the sense (ie, 180 degrees off)
12  Existing location
13   <identifier>        simply the named location
14   -<identifier>       reverse the sense (ie, 180 degrees off)
15   O![-]<identifier>   the location from the specified object
16                       in whatever coordinate system that object
17                       happens to have
18   ^O![-]<identifier>  the same, but the object is flipped
19                       N-S first (see `part' and `objflip')
20  Quantity (length/angle)
21   <number>[<unit>]
22   Angle units: d (degrees,default)  r (radians)
23   Length units: mm (default)  cm  m
24  Identifiers (of locs and objects) start with lc letter, then
25  alphanums and underscores
26
27 Commands
28
29  abs P X Y A
30   Defines loc P given coordinates (distances) and absolute bearing
31
32  rel F T [L R A]
33   Defines loc T: start at loc F, go forward L, translate right R,
34   turn left A (defaults are all 0).
35
36  extend F T len L [R]        length L
37  extend F T upto U [R]       s.t. perpendicular at T passes through U
38  extend F T ang A R          subtending directionally A
39  extend F T uptoang A R      s.t. direction at T is A
40  extend F T parallel U R     s.t. direction at T is same as at U
41   Draws an arc or line from loc F, defining the other end as loc T.
42   If length R specified, draws an arc of radius R; R +ve curves to the
43   right; R -ve to the left.
44
45  join F T R [S ...]
46   Joins one existing loc, F, to another, T.  F's direction points to
47   the new track; T's away - ie the added track leaves F in F's
48   direction and arrives at T in T's direction.  R is the minimum curve
49   radius allowed.  S selects from the available solutions, and may be
50   any of the following
51      long                  prefer longer length solution
52      short                 prefer shorter length solution
53      right|left            prefer mostly bending to the left resp. right
54      beginright|beginleft  prefer first bend to the right
55      endright|endleft      prefer final bend to the right
56      [!]twoarcs            prefer [not] two circular arcs of equal radius
57      [!]arcline            prefer [not] one line and an arc of max radius
58      [!]arcsline           prefer [not] line between two arcs of min radius
59   if this doesn't resolve, will pick the shortest.
60
61  defobj|defpart O
62  [commands]
63  enddef
64   Defines the object or part O.  Inside the definition, the commands
65   do not draw when the object is being defined.  The object has its
66   own coordinate space and its own location namespace.  `defpart'
67   defines a `part', which is like an object except that:
68    * showlibrary lists only parts, not objects
69    * the -e and -E command line options distinguish parts and objects
70
71  part N [^]O [F [A]] [FR AR ...]
72  obj[flip] O A F [P]
73   Places an instance of object or part O.  The loc defined inside O as
74   F (`formal parameter', F must be just <identifier>) is placed at
75   existing loc A (`actual parameter').
76
77   Both objects (defined with defobj) and parts (defined with defpart)
78   may be placed with either command !  Whether it's a part or an obj
79   depends on the definition, not on the use - the use is just
80   different syntaxes for the same kind of operation, and where the
81   features offered by both `part' and `obj[flip]' overlap the
82   behaviour is identical.
83
84   If `part N ^O' or `objflip' is used, rather than `part N O' or
85   `obj', then the object is placed with object-space y coordinates
86   negated (ie, it is mirrored so that the object's North exchanges
87   with South).
88
89   For `part', each FR (`formal result') and AR (`actual result')
90   specifies that the loc FR inside O is exported into the global
91   namespace as a new loc AR.  Either FR or AR may start with `-'.
92   Also, each loc L inside O is exported into the global namespace as a
93   new loc N_L (unless N_L already exists).  If A is not specified then
94   N_F is used.
95
96   For `obj[flip]' if prefix P (syntax is that of an identifier) is
97   specified, each other loc L inside O is exported into the global
98   namespace as a new loc PL (unless PL already exists).  P may be `='
99   to indicate an empty prefix (default is not to export locs).
100
101 Command-line options
102
103  -D       turn on debug (level 1)  } currently only debug levels are
104  -Dnnn    set debug level to nnn   }  0 (none) and 1 (some)
105
106  -e[ARSCcLlMNOm]...
107           Turn on and off drawing of elements in groups.
108           These are abbreviations for various -E... options.
109             track                                                 -E....
110               A  full track                                         ARSc
111               R  rails only                                         aRsc
112               S  rails and sleepers only                            aRSc
113               C  centrelines only                                   arsC
114               c  swept area and ticks only                          Arsc
115             labels at locs
116               L  label top-level locs (turns on bars for them too)  LM
117               l  do not label any locs                              l
118             bars at locs (thick lines perp to track dir'n)
119               M  bars for top-level locs only                       Mno
120               N  bars for top-level locs and those in obj's         MNo
121               O  bars for everything, including those inside parts  MNO
122               m  no bars (turns off labelling too)                  mnol
123              
124  -E[ARSCLMNOarsclmno]...
125           enable (capitals) or disable (lowercase) drawing of
126           individual elements
127               A  draw track swept area, with ticks
128               R  draw track rails
129               S  draw track sleepers
130               C  draw track centrelines
131               L  label locs
132               M  mark locs with a bar
133               N  mark locs with a bar in objs
134               O  mark locs with a bar in parts
135
136  -q       quiet: do not print info to stderr
137           (default: prints bounding box, at the moment)
138
139  Default is -d0, -EaRscLMNo, not quiet.
140
141 Special comments in PostScript:
142
143  %L cmd S C [A...]
144        a command C with args A is read for execution in scope S
145  %L point SL X Y A
146        point L in scope S has coords X Y and angle A
147  %L bbox width  W (L..R)
148  %L bbox height H (B..T)
149        bounding box, giving width W, height H, left L, right R,
150        bottom B and top T.  Includes full swept area of track,
151        but only at locs (so curves which bend outside bounding
152        box don't get counted)
153  %L bbox no locs, no bbox
154        there were no locs, so there is no bounding box
155        usu because input file was just obj defns and showlibrary
156
157  Scope S is
158    O!    when defining object or part O
159    N:T   scope T but inside part (introduced with `part') N      } when
160    O::T  scope T but inside obj (introduced with `obj[flip]') O  } placing