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