| 1 |
%% symbol library for TikZ track schematics |
| 2 |
% |
| 3 |
% Copyright (c) 2018 - 2022, Martin Scheidt (ISC license) |
| 4 |
% |
| 5 |
% Permission to use, copy, modify, and/or distribute this file for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. |
| 6 |
% |
| 7 |
\ProvidesFileRCS{tikzlibrarytrackschematic.vehicles.code.tex}% |
| 8 |
% |
| 9 |
%%%%%%%%%%%%%%% |
| 10 |
% Requirements |
| 11 |
%%%%%%%%%%%%%%% |
| 12 |
\RequirePackage{tikz,etoolbox}% |
| 13 |
\usetikzlibrary{calc}% |
| 14 |
% |
| 15 |
\ifdeflength{\objectlength}{}{% Not defined, so define it! |
| 16 |
\newlength{\objectlength}% |
| 17 |
}% |
| 18 |
\setlength{\objectlength}{4cm}% |
| 19 |
% |
| 20 |
%%%%%%%%%%%%%%% |
| 21 |
% tikz keys for multiple use |
| 22 |
%%%%%%%%%%%%%%% |
| 23 |
\pgfkeys{% |
| 24 |
/tikz/trackschematic/.is family,% |
| 25 |
/tikz/trackschematic/.cd,% |
| 26 |
%% face |
| 27 |
face/.value required,% forward OR backward |
| 28 |
face/.store in=\face,% |
| 29 |
/tikz/face/.forward to=/tikz/trackschematic/face,% |
| 30 |
/tikz/forward/.code={\pgfkeys{/tikz/trackschematic/face=forward}},% |
| 31 |
/tikz/backward/.code={\pgfkeys{/tikz/trackschematic/face=backward}},% |
| 32 |
/tikz/bidirectional/.code={\pgfkeys{/tikz/trackschematic/face=bidirectional}},% |
| 33 |
%% operation |
| 34 |
operation mode/.store in=\operationmode,% manual, automatic OR undefined |
| 35 |
operation mode=none,% DEFAULT |
| 36 |
/tikz/operation/.forward to=/tikz/trackschematic/operation mode,% |
| 37 |
%% length |
| 38 |
length/.store in=\objectlength,% default length 4cm |
| 39 |
/tikz/length/.forward to=/tikz/trackschematic/length,% |
| 40 |
%% label |
| 41 |
shift label/.store in=\labelcoord,% (coord) |
| 42 |
shift label=(none),% DEFAULT |
| 43 |
/tikz/shift label/.forward to=/tikz/trackschematic/shift label,% |
| 44 |
}% |
| 45 |
% |
| 46 |
%%%%%%%%%%%%%%% |
| 47 |
% commands |
| 48 |
%%%%%%%%%%%%%%% |
| 49 |
% |
| 50 |
%% command: parked vehicles |
| 51 |
\newcommand\parkedvehicles{}% just for safety |
| 52 |
\def\parkedvehicles[#1]#2(#3)#4(#5){% \parkedvehicles[options] at (coord) label (name); |
| 53 |
\pic[parked,operation=undefined,forward,#1] at (#3) {vehicles={#2/#4/#5}}% symbol |
| 54 |
}% |
| 55 |
%% command: shunting movements |
| 56 |
\newcommand\shunting{}% just for safety |
| 57 |
\def\shunting[#1]#2(#3)#4(#5){% \shunting[options] at (coord) label (name); |
| 58 |
\pic[shunting mode,operation=undefined,#1] at (#3) {vehicles={#2/#4/#5}}% symbol |
| 59 |
}% |
| 60 |
%% command: train run |
| 61 |
\newcommand\train{}% just for safety |
| 62 |
\def\train[#1]#2(#3)#4(#5){% \train[options] at (coord) label (name); |
| 63 |
\pic[train mode,operation=undefined,#1] at (#3) {vehicles={#2/#4/#5}}% symbol |
| 64 |
}% |
| 65 |
% |
| 66 |
%%%%%%%%%%%%%%% |
| 67 |
% tikz keys |
| 68 |
%%%%%%%%%%%%%%% |
| 69 |
\pgfkeys{% |
| 70 |
/tikz/trackschematic/vehicles/.is family,% |
| 71 |
/tikz/trackschematic/vehicles/.cd,% |
| 72 |
%% parked vehicles |
| 73 |
parked/.value forbidden,% |
| 74 |
parked/.code={\settoggle{is_parked}{true}},% |
| 75 |
/tikz/parked/.forward to=/tikz/trackschematic/vehicles/parked,% |
| 76 |
%% shunting mode |
| 77 |
shunting mode/.value forbidden,% |
| 78 |
shunting mode/.code={\settoggle{in_shunting_mode}{true}},% |
| 79 |
/tikz/shunting mode/.forward to=/tikz/trackschematic/vehicles/shunting mode,% |
| 80 |
%% shunting movement |
| 81 |
movement/.value forbidden,% |
| 82 |
movement/.code={\settoggle{is_shunting}{true}},% |
| 83 |
/tikz/movement/.forward to=/tikz/trackschematic/vehicles/movement,% |
| 84 |
%% train mode |
| 85 |
train mode/.value forbidden,% |
| 86 |
train mode/.code={\settoggle{in_train_mode}{true}},% |
| 87 |
/tikz/train mode/.forward to=/tikz/trackschematic/vehicles/train mode,% |
| 88 |
%% ghost train |
| 89 |
ghost train/.value forbidden,% |
| 90 |
ghost train/.code={\settoggle{train_is_a_ghost}{true}},% |
| 91 |
/tikz/ghost/.forward to=/tikz/trackschematic/vehicles/ghost train,% |
| 92 |
%% train run |
| 93 |
run/.store in=\trainrun,% slow, normal, fast OR none |
| 94 |
run=none,% DEFAULT |
| 95 |
/tikz/run/.forward to=/tikz/trackschematic/vehicles/run,% |
| 96 |
%% label |
| 97 |
label align/.store in=\labelalign,% left, right OR center |
| 98 |
label align=center,% DEFAULT |
| 99 |
/tikz/label align/.forward to=/tikz/trackschematic/vehicles/label align,% |
| 100 |
%% train bend |
| 101 |
bend right at/.store in=\bendrightcoord,% (coord) |
| 102 |
bend right at=(none),% DEFAULT |
| 103 |
/tikz/bend right at/.forward to=/tikz/trackschematic/vehicles/bend right at,% |
| 104 |
bend left at/.store in=\bendleftcoord,% (coord) |
| 105 |
bend left at=(none),% DEFAULT |
| 106 |
/tikz/bend left at/.forward to=/tikz/trackschematic/vehicles/bend left at,% |
| 107 |
}% |
| 108 |
% options |
| 109 |
\newtoggle{is_parked}\settoggle{is_parked}{false}% |
| 110 |
\newtoggle{in_shunting_mode}\settoggle{in_shunting_mode}{false}% |
| 111 |
\newtoggle{is_shunting}\settoggle{is_shunting}{false}% |
| 112 |
\newtoggle{in_train_mode}\settoggle{in_train_mode}{false}% |
| 113 |
\newtoggle{train_is_a_ghost}\settoggle{train_is_a_ghost}{false}% |
| 114 |
\newtoggle{single_bend}\settoggle{single_bend}{false}% |
| 115 |
\newtoggle{double_bend}\settoggle{double_bend}{false}% |
| 116 |
% |
| 117 |
%%%%%%%%%%%%%%% |
| 118 |
% symbol definition |
| 119 |
%%%%%%%%%%%%%%% |
| 120 |
% |
| 121 |
\tikzset{% |
| 122 |
pics/vehicles/.default=,% |
| 123 |
pics/vehicles/.style args={#1/#2/#3}{code={% |
| 124 |
%% |
| 125 |
%%%%%%%[steps]%%%%%% |
| 126 |
%% |
| 127 |
%% 0. setup settings |
| 128 |
%% 1. calculate coordinates |
| 129 |
%% - calculation of vehicle coordinates: |
| 130 |
%% |
| 131 |
%% rear bend front bend |
| 132 |
%% (ts-b-r1) (ts-b-f1) |
| 133 |
%% (ts-v-r1)•__________•_______•__________•(ts-v-f1) |
| 134 |
%% | \ |
| 135 |
%% | label•(ts-v-l) •(ts-v-f) front tip |
| 136 |
%% |__________ _______ __________ / |
| 137 |
%% (ts-v-r2)• • • •(ts-v-f2) |
| 138 |
%% (ts-b-r2) (ts-b-f2) |
| 139 |
%% |
| 140 |
%% - the base coord is depend on usage |
| 141 |
%% for parked: (ts-v-l) |
| 142 |
%% else: (ts-v-f) |
| 143 |
%% |
| 144 |
%% 2. set style for line and background |
| 145 |
%% 3. draw arrows for speed indication |
| 146 |
%% 4. draw vehicle shape |
| 147 |
%% 5. draw operation mode |
| 148 |
%% 6. draw label |
| 149 |
%% |
| 150 |
%%%%%%%%%%%%%%%%%%%% |
| 151 |
%% 0. settings |
| 152 |
\def\coordcommand{#1}% beware of leading and tailing spaces! |
| 153 |
\def\labelcommand{#2}% beware of leading and tailing spaces! |
| 154 |
\def\labelcontent{#3}% |
| 155 |
%% face setup |
| 156 |
\ifdefstring{\face}{forward}{% face |
| 157 |
\pgfmathsetmacro{\facefactor}{1}% |
| 158 |
}{% |
| 159 |
\ifdefstring{\face}{backward}{% face |
| 160 |
\pgfmathsetmacro{\facefactor}{-1}% |
| 161 |
}{% error message |
| 162 |
\pgfkeys{/errors/unknown choice value={/tikz/trackschematic/face}{“forward“ OR “backward“ as key required}}% |
| 163 |
}% |
| 164 |
}% end \ifdefstring{\face} |
| 165 |
%% bend setup |
| 166 |
% determine number of bends and find front and rear bend from left to right |
| 167 |
\ifdefstring{\bendleftcoord}{(none)}{}{% NOT default |
| 168 |
\settoggle{single_bend}{true}% |
| 169 |
\path \bendleftcoord;\pgfgetlastxy{\bendX}{\bendY}% absolut coord |
| 170 |
\pgfmathsetmacro\bendfactor{1}% |
| 171 |
}% |
| 172 |
\ifdefstring{\bendrightcoord}{(none)}{}{% NOT default |
| 173 |
\iftoggle{single_bend}{% |
| 174 |
\settoggle{double_bend}{true}% |
| 175 |
\settoggle{single_bend}{false}% |
| 176 |
\path \bendrightcoord;\pgfgetlastxy{\bendrightX}{\bendrightY} |
| 177 |
\ifdimcomp{\bendrightX}{>}{\bendX}{% which one comes first? |
| 178 |
\ifdefstring{\face}{forward}{% |
| 179 |
\pgfmathsetmacro\frontBendfactor{1}% |
| 180 |
\pgfmathsetmacro\rearBendfactor{-1}% |
| 181 |
\pgfmathsetlengthmacro\frontBendX{\bendrightX}% |
| 182 |
\pgfmathsetlengthmacro\rearBendX{\bendX}% |
| 183 |
\pgfmathsetlengthmacro\rearBendY{\bendY}% |
| 184 |
}{% face backward |
| 185 |
\pgfmathsetmacro\frontBendfactor{-1}% |
| 186 |
\pgfmathsetmacro\rearBendfactor{1}% |
| 187 |
\pgfmathsetlengthmacro\frontBendX{\bendX}% |
| 188 |
\pgfmathsetlengthmacro\rearBendX{\bendrightX}% |
| 189 |
\pgfmathsetlengthmacro\rearBendY{\bendrightY}% |
| 190 |
}% |
| 191 |
}{% {\bendrightX}{<}{\bendleftX}% |
| 192 |
\ifdefstring{\face}{forward}{% |
| 193 |
\pgfmathsetmacro\frontBendfactor{-1}% |
| 194 |
\pgfmathsetmacro\rearBendfactor{1}% |
| 195 |
\pgfmathsetlengthmacro\frontBendX{\bendX}% |
| 196 |
\pgfmathsetlengthmacro\rearBendX{\bendrightX}% |
| 197 |
\pgfmathsetlengthmacro\rearBendY{\bendrightY}% |
| 198 |
}{% face backward |
| 199 |
\pgfmathsetmacro\frontBendfactor{1}% |
| 200 |
\pgfmathsetmacro\rearBendfactor{-1}% |
| 201 |
\pgfmathsetlengthmacro\frontBendX{\bendrightX}% |
| 202 |
\pgfmathsetlengthmacro\rearBendX{\bendX}% |
| 203 |
\pgfmathsetlengthmacro\rearBendY{\bendY}% |
| 204 |
}% |
| 205 |
}% |
| 206 |
}{% NOT double bend |
| 207 |
\settoggle{single_bend}{true}% |
| 208 |
\path \bendrightcoord;\pgfgetlastxy{\bendX}{\bendY}% absolut coord |
| 209 |
\pgfmathsetmacro\bendfactor{-1}% |
| 210 |
}% |
| 211 |
}% |
| 212 |
%%%%%%%%%%%%%%%%%%%% |
| 213 |
%% 1. coordinate calculations |
| 214 |
%% basic coords for corners |
| 215 |
\iftoggle{is_parked}{% |
| 216 |
\coordinate (ts-v-f1) at ($ 0.5*(\objectlength,0) + (0, 0.3)$);% |
| 217 |
\coordinate (ts-v-f2) at ($ 0.5*(\objectlength,0) + (0,-0.3)$);% |
| 218 |
\coordinate (ts-v-r1) at ($-0.5*(\objectlength,0) + (0, 0.3)$);% |
| 219 |
\coordinate (ts-v-r2) at ($-0.5*(\objectlength,0) + (0,-0.3)$);% |
| 220 |
}{% |
| 221 |
\coordinate (ts-v-f1) at ($\facefactor*(-0.3,0) + (0, 0.3)$);% |
| 222 |
\coordinate (ts-v-f2) at ($\facefactor*(-0.3,0) + (0,-0.3)$);% |
| 223 |
\coordinate (ts-v-r1) at ($\facefactor*(-\objectlength,0) + (0, 0.3)$);% |
| 224 |
\coordinate (ts-v-r2) at ($\facefactor*(-\objectlength,0) + (0,-0.3)$);% |
| 225 |
}% |
| 226 |
%% front tip for traveling direction |
| 227 |
\iftoggle{is_parked}{% |
| 228 |
\coordinate (ts-v-f) at ($ 0.5*(\objectlength,0) + (0, 0 )$);% |
| 229 |
}{% |
| 230 |
\coordinate (ts-v-f) at (0,0);% |
| 231 |
}% |
| 232 |
%% bend - DEFAULT: no bend |
| 233 |
\coordinate (ts-b-f1) at (ts-v-f1);% |
| 234 |
\coordinate (ts-b-f2) at (ts-v-f2);% |
| 235 |
\coordinate (ts-b-r1) at (ts-v-r1);% |
| 236 |
\coordinate (ts-b-r2) at (ts-v-r2);% |
| 237 |
% |
| 238 |
\iftoggle{single_bend}{% |
| 239 |
% \bendX is a absolut coordinate |
| 240 |
% make them relative to base |
| 241 |
\path (0,0);\pgfgetlastxy{\baseX}{\baseY}% absolut coord |
| 242 |
% calc bend position |
| 243 |
\coordinate (ts-b-r1) at ($(-\baseX,0) + (\bendX, 0.3) + \facefactor*\bendfactor*( 0.1,0)$);% |
| 244 |
\coordinate (ts-b-r2) at ($(-\baseX,0) + (\bendX,-0.3) + \facefactor*\bendfactor*(-0.1,0)$);% |
| 245 |
% calc length from bend to end with factor ~0.7071 at 45 degree to a projected length |
| 246 |
\pgfmathsetlengthmacro\bendlength{(\facefactor*\objectlength - \baseX + \bendX)*0.7071}% |
| 247 |
\coordinate (ts-v-r1) at ($(ts-b-r1) + (-\bendlength,0) + \facefactor*\bendfactor*( 0.1,\bendlength) + (0,-0.1)$);% |
| 248 |
\coordinate (ts-v-r2) at ($(ts-b-r2) + (-\bendlength,0) + \facefactor*\bendfactor*(-0.1,\bendlength) + (0, 0.1)$);% |
| 249 |
}{}% |
| 250 |
\iftoggle{double_bend}{% |
| 251 |
% \bendX and \bendY are absolut coords |
| 252 |
% make them relative to base |
| 253 |
\path (0,0);\pgfgetlastxy{\baseX}{\baseY}% absolut coord |
| 254 |
% calc bend position |
| 255 |
\coordinate (ts-b-f1) at ($(-\baseX,0) + (\frontBendX, 0.3) + \facefactor*\frontBendfactor*(-0.1,0)$);% |
| 256 |
\coordinate (ts-b-f2) at ($(-\baseX,0) + (\frontBendX,-0.3) + \facefactor*\frontBendfactor*( 0.1,0)$);% |
| 257 |
\coordinate (ts-b-r1) at ($(-\baseX,0) + (\rearBendX, 0.3) + (0,-\baseY) + (0,\rearBendY) + \facefactor*\rearBendfactor*( 0.1,0)$);% |
| 258 |
\coordinate (ts-b-r2) at ($(-\baseX,0) + (\rearBendX,-0.3) + (0,-\baseY) + (0,\rearBendY) + \facefactor*\rearBendfactor*(-0.1,0)$);% |
| 259 |
% calc length from bend to end with factor ~1.4142 at 45 degree to a projected length |
| 260 |
\pgfmathsetlengthmacro\bendlength{\facefactor*\objectlength - (\frontBendX - \rearBendX)*1.4142 - (\baseX - \frontBendX)}% |
| 261 |
\coordinate (ts-v-r1) at ($(ts-b-r1) + (-\bendlength,0) + \facefactor*\rearBendfactor*(-0.1,0)$);% |
| 262 |
\coordinate (ts-v-r2) at ($(ts-b-r2) + (-\bendlength,0) + \facefactor*\rearBendfactor*( 0.1,0)$);% |
| 263 |
}{}% |
| 264 |
%% |
| 265 |
%%%%%%%%%%%%%%%%%%%% |
| 266 |
%% 2. vehicle style |
| 267 |
\iftoggle{in_train_mode}{% train mode |
| 268 |
\iftoggle{train_is_a_ghost}{% ghost train |
| 269 |
\tikzset{every path/.style={draw=foreground, line width=0.8pt, dashed}};% |
| 270 |
}{% normal train |
| 271 |
\tikzset{every path/.style={draw=foreground, line width=1pt, fill=background}};% |
| 272 |
}% |
| 273 |
}{% shunting mode |
| 274 |
\tikzset{every path/.style={draw=foreground, double, double distance=0.5mm, line width=0.3pt, fill=background}};% |
| 275 |
}% |
| 276 |
%% |
| 277 |
%%%%%%%%%%%%%%%%%%%% |
| 278 |
%% 3. arrow shapes |
| 279 |
%% (order before vehicle shape due to background fill!) |
| 280 |
\iftoggle{is_shunting}{% arrow for shunting |
| 281 |
\iftoggle{in_shunting_mode}{% shunting mode |
| 282 |
\fill[draw=none,fill=background] ($\facefactor*(-0.3, 0.3)$) --% |
| 283 |
($\facefactor*(-0.1, 0.3)$) --% |
| 284 |
($\facefactor*( 0.2, 0 )$) --% |
| 285 |
($\facefactor*(-0.1,-0.3)$) --% |
| 286 |
($\facefactor*(-0.3,-0.3)$) -- cycle;% background fill |
| 287 |
\path[line cap=rect,fill=none] ($\facefactor*(-0.1, 0.3)$) --% |
| 288 |
($\facefactor*( 0.2, 0 )$) --% |
| 289 |
($\facefactor*(-0.1,-0.3)$);% arrow shape |
| 290 |
}{% train mode |
| 291 |
\pgfkeys{/errors/unknown choice value={/tikz/trackschematic/vehicle/movement}{movement can only be combined with shunting}}% |
| 292 |
}% |
| 293 |
}{}% end \iftoggle{shunting_movement} |
| 294 |
\ifdefstring{\trainrun}{none}{}{% DEFAULT no arrow for train |
| 295 |
\iftoggle{in_train_mode}{% train mode |
| 296 |
\ifdefstring{\trainrun}{slow}{% |
| 297 |
\fill[draw=none,fill=background] ($\facefactor*(-0.3, 0.3)$) --% |
| 298 |
($\facefactor*(-0.1, 0.3)$) --% |
| 299 |
($\facefactor*( 0.2, 0 )$) --% |
| 300 |
($\facefactor*(-0.1,-0.3)$) --% |
| 301 |
($\facefactor*(-0.3,-0.3)$) -- cycle;% background fill |
| 302 |
\path[fill=none] ($\facefactor*(-0.15, 0.3)$) --% |
| 303 |
($\facefactor*(-0.1 , 0.3)$) --% |
| 304 |
($\facefactor*( 0.2 , 0 )$) --% |
| 305 |
($\facefactor*(-0.1 ,-0.3)$) --% |
| 306 |
($\facefactor*(-0.15,-0.3)$);% arrow shape |
| 307 |
}{% |
| 308 |
\ifdefstring{\trainrun}{normal}{% |
| 309 |
\fill[draw=none,fill=background] ($\facefactor*(-0.3, 0.3)$) --% |
| 310 |
($\facefactor*( 0.1, 0.3)$) --% |
| 311 |
($\facefactor*( 0.4, 0 )$) --% |
| 312 |
($\facefactor*( 0.1,-0.3)$) --% |
| 313 |
($\facefactor*(-0.3,-0.3)$) -- cycle;% background fill |
| 314 |
\path[fill=none] ($\facefactor*(-0.15, 0.3)$) --% |
| 315 |
($\facefactor*(-0.1 , 0.3)$) --% |
| 316 |
($\facefactor*( 0.2 , 0 )$) --% |
| 317 |
($\facefactor*(-0.1 ,-0.3)$) --% |
| 318 |
($\facefactor*(-0.15,-0.3)$);% arrow shape part 1 |
| 319 |
\path[fill=none] ($\facefactor*( 0.05, 0.3)$) --% |
| 320 |
($\facefactor*( 0.1 , 0.3)$) --% |
| 321 |
($\facefactor*( 0.4 , 0 )$) --% |
| 322 |
($\facefactor*( 0.1 ,-0.3)$) --% |
| 323 |
($\facefactor*( 0.05,-0.3)$);% arrow shape part 2 |
| 324 |
% |
| 325 |
}{% |
| 326 |
\ifdefstring{\trainrun}{fast}{% |
| 327 |
\fill[draw=none,fill=background] ($\facefactor*(-0.3, 0.3)$) --% |
| 328 |
($\facefactor*( 0.3, 0.3)$) --% |
| 329 |
($\facefactor*( 0.6, 0 )$) --% |
| 330 |
($\facefactor*( 0.3,-0.3)$) --% |
| 331 |
($\facefactor*(-0.3,-0.3)$) -- cycle;% background fill |
| 332 |
\path[fill=none] ($\facefactor*(-0.15, 0.3)$) --% |
| 333 |
($\facefactor*(-0.1 , 0.3)$) --% |
| 334 |
($\facefactor*( 0.2 , 0 )$) --% |
| 335 |
($\facefactor*(-0.1 ,-0.3)$) --% |
| 336 |
($\facefactor*(-0.15,-0.3)$);% arrow shape part 1 |
| 337 |
\path[fill=none] ($\facefactor*( 0.05, 0.3)$) --% |
| 338 |
($\facefactor*( 0.1 , 0.3)$) --% |
| 339 |
($\facefactor*( 0.4 , 0 )$) --% |
| 340 |
($\facefactor*( 0.1 ,-0.3)$) --% |
| 341 |
($\facefactor*( 0.05,-0.3)$);% arrow shape part 2 |
| 342 |
\path[fill=none] ($\facefactor*( 0.25, 0.3)$) --% |
| 343 |
($\facefactor*( 0.3 , 0.3)$) --% |
| 344 |
($\facefactor*( 0.6 , 0 )$) --% |
| 345 |
($\facefactor*( 0.3 ,-0.3)$) --% |
| 346 |
($\facefactor*( 0.25,-0.3)$);% arrow shape part 3 |
| 347 |
% |
| 348 |
}{%error message |
| 349 |
\pgfkeys{/errors/unknown choice value={/tikz/trackschematic/vehicles/run}{“normal“, “slow“, “fast“ OR “none“ as key required}}% |
| 350 |
}% |
| 351 |
}% |
| 352 |
}% |
| 353 |
}{% shunting mode |
| 354 |
\pgfkeys{/errors/unknown choice value={/tikz/trackschematic/vehicle/run}{run can only be combined with train}}% |
| 355 |
}% end \iftoggle{in_train_mode} |
| 356 |
}% end \ifdefstring{\trainrun}{none} % end arrow shapes |
| 357 |
%% |
| 358 |
%%%%%%%%%%%%%%%%%%%% |
| 359 |
%% 4. vehicle shape |
| 360 |
\path (ts-v-f)% |
| 361 |
-- (ts-v-f1) -- (ts-b-f1) -- (ts-b-r1) -- (ts-v-r1)% |
| 362 |
-- (ts-v-r2) -- (ts-b-r2) -- (ts-b-f2) -- (ts-v-f2)% |
| 363 |
-- cycle;% vehicle shape |
| 364 |
%% |
| 365 |
%%%%%%%%%%%%%%%%%%%% |
| 366 |
%% 5. operation mode |
| 367 |
\iftoggle{is_parked}{}{% vehicle NOT parked |
| 368 |
\ifdefstring{\operationmode}{manual}{% |
| 369 |
\path[draw=none, fill=foreground] ($\facefactor*(-0.4,0)$) circle (0.15);% dot |
| 370 |
}{ |
| 371 |
\ifdefstring{\operationmode}{automatic}{% |
| 372 |
\path[draw=none, fill=foreground] ($\facefactor*(-0.15,0)$) -- ++($\facefactor*(-0.15,0) +(0,0.15)$) -- ++(0,-0.3) -- cycle;% triangle |
| 373 |
}{% |
| 374 |
\ifdefstring{\operationmode}{undefined}{}{% |
| 375 |
\pgfkeys{/errors/unknown choice value={/tikz/trackschematic/operation}{“manual“, “automatic“ OR “undefined“ as key required}}% |
| 376 |
}% |
| 377 |
}% end automatically_operated |
| 378 |
}% end manually_operated |
| 379 |
}% |
| 380 |
%% |
| 381 |
%%%%%%%%%%%%%%%%%%%% |
| 382 |
%% 6. label |
| 383 |
\iftoggle{is_parked}{% |
| 384 |
\coordinate (ts-v-l) at (0,0);% DEFAULT center |
| 385 |
}{% |
| 386 |
\coordinate (ts-v-l) at ($\facefactor*-0.5*(\objectlength,0)$);% DEFAULT center |
| 387 |
}% |
| 388 |
\iftoggle{train_is_a_ghost}{% ghost train |
| 389 |
\coordinate (ts-v-l) at ($(ts-v-l) + (0,0.16)$);% |
| 390 |
}{}% |
| 391 |
\ifdefstring{\operationmode}{manual}{% |
| 392 |
\coordinate (ts-v-l) at ($(ts-v-l) + \facefactor*(-0.25,0)$);% |
| 393 |
}{}% |
| 394 |
\ifdefstring{\operationmode}{automatic}{% |
| 395 |
\coordinate (ts-v-l) at ($(ts-v-l) + \facefactor*(-0.15,0)$);% |
| 396 |
}{}% |
| 397 |
\ifdefstring{\labelcoord}{(none)}{}{% initialize if NOT default |
| 398 |
\path let \p1=\labelcoord in coordinate (ts-v-l) at ($(ts-v-l)+(\x1,\y1)$);% |
| 399 |
}% |
| 400 |
\ifdefstring{\labelcontent}{}{}{% label NOT empty |
| 401 |
\ifdefstring{\labelalign}{center}{% DEFAULT label align center |
| 402 |
\def\labelanchor{center} |
| 403 |
}{% label align NOT default |
| 404 |
\ifdefstring{\labelalign}{left}{% label align left |
| 405 |
\def\labelanchor{east} |
| 406 |
}{% |
| 407 |
\ifdefstring{\labelalign}{right}{% label align left |
| 408 |
\def\labelanchor{west} |
| 409 |
}{% NOT center, left, or right |
| 410 |
\pgfkeys{/errors/unknown choice value={/tikz/trackschematic/label align}{“center“, “left“ OR “right“ as key required}}% |
| 411 |
}% \ifdefstring{\labelalign}{right} |
| 412 |
}% \ifdefstring{\labelalign}{left} |
| 413 |
}% \ifdefstring{\labelalign}{center} |
| 414 |
\node[text=foreground,anchor=\labelanchor,align=\labelalign] at (ts-v-l) {\footnotesize \labelcontent};% label |
| 415 |
}% |
| 416 |
}},% END pics/vehicles/.style args={#1/#2/#3} |
| 417 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 418 |
% symbology entry |
| 419 |
symbology_parked_vehicles/.pic = {% |
| 420 |
\secondarytrack (0,0) -- (6,0);% |
| 421 |
\parkedvehicles[] at (3,0) label ();% |
| 422 |
},% |
| 423 |
% symbology entry |
| 424 |
symbology_train_shunt_mode/.pic = {% |
| 425 |
\maintrack (0,0) -- (6,0);% |
| 426 |
\shunting[forward] at (5,0) label ();% |
| 427 |
},% |
| 428 |
% symbology entry |
| 429 |
symbology_train_shunting/.pic = {% |
| 430 |
\maintrack (0,0) -- (6,0);% |
| 431 |
\shunting[movement,forward] at (5,0) label ();% |
| 432 |
},% |
| 433 |
% symbology entry |
| 434 |
symbology_train/.pic = {% |
| 435 |
\maintrack (0,0) -- (6,0);% |
| 436 |
\train[forward] at (5,0) label ();% |
| 437 |
},% |
| 438 |
% symbology entry |
| 439 |
symbology_train_moving_slow/.pic = {% |
| 440 |
\maintrack (0,0) -- (6,0);% |
| 441 |
\train[run=slow,forward] at (5,0) label ();% |
| 442 |
},% |
| 443 |
% symbology entry |
| 444 |
symbology_train_moving/.pic = {% |
| 445 |
\maintrack (0,0) -- (6,0);% |
| 446 |
\train[run=normal,forward] at (5,0) label ();% |
| 447 |
},% |
| 448 |
% symbology entry |
| 449 |
symbology_train_moving_fast/.pic = {% |
| 450 |
\maintrack (0,0) -- (6,0);% |
| 451 |
\train[run=fast,forward] at (5,0) label ();% |
| 452 |
},% |
| 453 |
% symbology entry |
| 454 |
symbology_train_ghost/.pic = {% |
| 455 |
\maintrack (0,0) -- (6,0);% |
| 456 |
\train[ghost,forward] at (5,0) label ();% |
| 457 |
},% |
| 458 |
% symbology entry |
| 459 |
symbology_train_drive_automatic/.pic = {% |
| 460 |
\maintrack (0,0) -- (6,0);% |
| 461 |
\train[operation=automatic,forward] at (5,0) label ();% |
| 462 |
},% |
| 463 |
% symbology entry |
| 464 |
symbology_train_drive_human/.pic = {% |
| 465 |
\maintrack (0,0) -- (6,0);% |
| 466 |
\train[operation=manual,forward] at (5,0) label ();% |
| 467 |
},% |
| 468 |
}% |
| 469 |
% |
| 470 |
%%%%%%%%%%%%%%% |
| 471 |
\endinput% |
| 472 |
% |