summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/tikz-trackschematic/tikzlibrarytrackschematic.topology.code.tex
blob: 4d98af5fb19650ae8c2da9723f0470762b1ddfe1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
%% symbol library for TikZ track schematics
%
% Copyright (c) 2018 - 2022, Martin Scheidt (ISC license)
%
% 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.
%
\ProvidesFileRCS{tikzlibrarytrackschematic.topology.code.tex}%
%
%%%%%%%%%%%%%%%
% Requirements
%%%%%%%%%%%%%%%
\RequirePackage{tikz,etoolbox}%
\usetikzlibrary{calc,patterns}%
%
%%%%%%%%%%%%%%%
% tikz keys for multiple use
%%%%%%%%%%%%%%%
\pgfkeys{%
  /tikz/trackschematic/.is family,%
  /tikz/trackschematic/.cd,%
  %% color foreground
  foreground/.store in=\foreground,%
  foreground=black,% DEFAULT
  /tikz/foreground/.forward to=/tikz/trackschematic/foreground,%
  %% color background
  background/.store in=\background,%
  background=white,% DEFAULT
  /tikz/background/.forward to=/tikz/trackschematic/background,%
  %% face
  face/.value required,% forward OR backward
  face/.store in=\face,%
  /tikz/face/.forward to=/tikz/trackschematic/face,%
  /tikz/forward/.code={\pgfkeys{/tikz/trackschematic/face=forward}},%
  /tikz/backward/.code={\pgfkeys{/tikz/trackschematic/face=backward}},%
  /tikz/bidirectional/.code={\pgfkeys{/tikz/trackschematic/face=bidirectional}},%
  %% operation
  operation mode/.store in=\operationmode,% manual, remote OR none
  operation mode=none,% DEFAULT
  /tikz/operation/.forward to=/tikz/trackschematic/operation mode,%
  %% label
  shift label/.store in=\labelcoord,% (coord)
  shift label=(none),% DEFAULT
  /tikz/shift label/.forward to=/tikz/trackschematic/shift label,%
}%
\pgfkeys{%
  /tikz/trackschematic/topology/.is family,%
  /tikz/trackschematic/topology/.cd,%
  %% branch
  branch/.value required,% left OR right
  branch/.store in=\branch,% left OR right
  /tikz/branch/.forward to=/tikz/trackschematic/topology/branch,%
  %% fouling point
  fouling point/.value forbidden,%
  fouling point/.code={\settoggle{fouling_point}{true}},%
  /tikz/fouling point/.forward to=/tikz/trackschematic/topology/fouling point,%
  %% points
  points/.store in=\points,% moving, left, right OR none
  points=none,% DEFAULT
  /tikz/points/.forward to=/tikz/trackschematic/topology/points,%
}%
% options for turnout and slip turnout
\newtoggle{fouling_point}\settoggle{fouling_point}{false}%
%
%%%%%%%%%%%%%%%
% symbol track
%%%%%%%%%%%%%%%
%
% commands
\newcommand\maintrack{}% just for safety
\def\maintrack{\path[draw=\foreground,MainTrack]}% \maintrack (coord1) -- (coord2);
\newcommand\secondarytrack{}% just for safety
\def\secondarytrack{\path[draw=\foreground,SecondaryTrack]}% \secondarytrack (coord1) -- (coord2);
\newcommand\sidetrack{}% just for safety
\def\sidetrack{\path[draw=\foreground,SecondaryTrack]}% alias for \secondarytrack
%
%% symbol definition
\tikzset{%
  MainTrack/.style={line width=2pt},%
  % symbology entry
  symbology_main_track/.pic = {\maintrack (0,0) -- (6,0);}%
}%
\tikzset{%
  SecondaryTrack/.style={line width=0.7pt},%
  % symbology entry
  symbology_secondary_track/.pic = {\secondarytrack (0,0) -- (6,0);}%
}%
%
%%%%%%%%%%%%%%%
% symbol track number
%%%%%%%%%%%%%%%
%
%% command
\newcommand\tracklabel{}% just for safety
\def\tracklabel#1(#2)#3(#4){% \tracklabel at (coord) label (name);
  \pic at (#2) {track_label={#1/#3/#4}}% symbol
}%
%% tikz keys
% \pgfkeys{%
%   /tikz/trackschematic/.is family,%
%   /tikz/trackschematic/.cd,%
% }%
%% symbol definition
\tikzset{%
  pics/track_label/.default=,%
  pics/track_label/.style args={#1/#2/#3}{code={%
    %% settings
    \def\coordcommand{#1} % beware of leading and tailing spaces!
    \def\labelcommand{#2} % beware of leading and tailing spaces!
    \def\labelcontent{#3}
    %% label
    \ifdefstring{\labelcontent}{}{}{% label NOT empty
      \tikzset{every node/.style={fill=\background,text=\foreground}};%
      \coordinate (ts-tl-l) at (0,0);%
      \ifdefstring{\labelcoord}{(none)}{% default coord
      }{% initialize if NOT default
        \path let \p1=\labelcoord in coordinate (ts-tl-l) at ($(ts-tl-l)+(\x1,\y1)$);%
      }%
      \node at (ts-tl-l) {\labelcontent};%
    }%
  }},% END pics/track_label/.style args={#1/#2/#3}
  %
  % symbology entry
  symbology_track_label/.pic = {%
    \maintrack (0,0) -- (6,0);%
    \tracklabel at (3,0) label (label);%
  },%
}%
%
%%%%%%%%%%%%%%%
% symbol buffer stop
%%%%%%%%%%%%%%%
%
% command
\newcommand\bufferstop{}% just for safety
\def\bufferstop[#1]#2(#3){% \bufferstop[options] at (coord);
  \pic[#1] at (#3) {bufferstop={#2}}% symbol
}%
\newlength{\friction}\setlength{\friction}{0.5cm}
% tikz keys
\pgfkeys{%
  /tikz/trackschematic/topology/bufferstop/.is family,%
  /tikz/trackschematic/topology/bufferstop/.cd,%
  %% friction
  friction/.store in=\friction,% length OR none
  friction=none,% length OR none
  /tikz/friction/.forward to=/tikz/trackschematic/topology/bufferstop/friction,%
}%
% symbol definition
\tikzset{%
  pics/bufferstop/.default=,%
  pics/bufferstop/.style args={#1}{code={%
    %% settings
    \def\coordcommand{#1} % beware of leading and tailing spaces!
    %% face setup
    \ifdefstring{\face}{forward}{% face
      \pgfmathsetmacro{\facefactor}{1}%
    }{%
      \ifdefstring{\face}{backward}{% face
        \pgfmathsetmacro{\facefactor}{-1}%
      }{% error message
        \pgfkeys{/errors/unknown choice value={/tikz/trackschematic/face}{“forward“ OR “backward“ as key required}}%
      }%
    }% end \ifdefstring{\face}
    %% symbol
    \ifdefstring{\friction}{none}{% none friction
      \path[draw=\foreground, line width=1pt]%
        ($\facefactor*(-0.1,0) + (0,0.2)$) --  ++($\facefactor*( 0.1,0)$) -- ++(0,-0.4) -- ++ ($\facefactor*(-0.1,0)$);% bufferstop marker
    }{% friction
      \path[draw=\foreground, line width=1pt]%
        ($\facefactor*(-\friction,0) + \facefactor*(-0.05,0) + (0,0.2)$) --  ++($\facefactor*(0.1,0)$) -- ++(0,-0.4) -- ++ ($\facefactor*(-0.1,0)$);% bufferstop marker
      \fill[\foreground] (0,0) circle (0.06);% track closure indicator
    }%
  }},% END pics/bufferstop/.style args={#1}
  %
  % symbology entry
  symbology_bufferstop/.pic = {%
    \secondarytrack (0,0) -- (3,0);%
    \bufferstop[forward] at (3,0);%
  },%
  % symbology entry
  symbology_friction_bufferstop/.pic = {%
    \maintrack (0,0) -- (3,0);%
    \bufferstop[forward,friction=.5] at (3,0);%
  },%
}%
%
%%%%%%%%%%%%%%%
% symbol track closure
%%%%%%%%%%%%%%%
%
%% command
\newcommand\trackclosure{}% just for safety
\def\trackclosure#1(#2){% \trackclosure at (coord);
  \pic at (#2) {track_closure={#1}}% symbol
}%
% symbol definition
\tikzset{%
  pics/track_closure/.default=,%
  pics/track_closure/.style args={#1}{code={%
    %% settings
    \def\coordcommand{#1} % beware of leading and tailing spaces!
    %%
    \fill[\foreground] (0,0) circle (0.06);% track closure indicator
    % \path[fill=\foreground] (0.04,0.02) -- (0.04,-0.02) -- (0.02,-0.04) -- (-0.02,-0.04) -- (-0.04,-0.02) -- (-0.04,0.02) -- (-0.02,0.04) -- (0.02,0.04) -- cycle;% label
  }},% END pics/track_closure/.style args={#1}
  %
  % symbology entry
  symbology_track_closure/.pic = {%
    \maintrack (0,0) -- (3,0);%
    \trackclosure at (3,0);%
  },%
}%
%
%%%%%%%%%%%%%%%
% symbol turnout
%%%%%%%%%%%%%%%
%
% command
\newcommand\turnout{}% just for safety
\def\turnout[#1]#2(#3)#4(#5){% \turnout[options] at (coord) label (name);
  \pic[operation=remote,#1] at (#3) {turnout={#2/#4/#5}}% symbol
}%
% tikz keys
\pgfkeys{%
  /tikz/trackschematic/topology/turnout/.is family,%
  /tikz/trackschematic/topology/turnout/.cd,%
  %% points
  points/.store in=\points,% moving, left, right OR none
  points=none,% moving, left, right OR none
  /tikz/points/.forward to=/tikz/trackschematic/topology/turnout/points,%
}%
% symbol definition
\tikzset{%
  pics/turnout/.default=,%
  pics/turnout/.style args={#1/#2/#3}{code={%
    %% settings
    \def\coordcommand{#1}% beware of leading and tailing spaces!
    \def\labelcommand{#2}% beware of leading and tailing spaces!
    \def\labelcontent{#3}%
    %% face setup
    \ifdefstring{\face}{forward}{% face
      \pgfmathsetmacro{\facefactor}{1}%
    }{%
      \ifdefstring{\face}{backward}{% face
        \pgfmathsetmacro{\facefactor}{-1}%
      }{% error message
        \pgfkeys{/errors/unknown choice value={/tikz/trackschematic/face}{“forward“ OR “backward“ as key required}}%
      }%
    }% end \ifdefstring{\face}
    %% branch setup
    \ifdefstring{\branch}{left}{% branch
      \pgfmathsetmacro{\branchfactor}{1}%
    }{%
      \ifdefstring{\branch}{right}{% branch
        \pgfmathsetmacro{\branchfactor}{-1}%
      }{% error message
        \pgfkeys{/errors/unknown choice value={/tikz/trackschematic/topology/branch}{“left“ OR “right“ as key required}}%
      }%
    }% end \ifdefstring{\branch}
    %% turnout marker
    \ifdefstring{\operationmode}{manual}{% operation=manual
      \ifdefstring{\face}{forward}{%
        \ifdefstring{\branch}{left}{% branch
          \def\patterntype{north west lines}%
        }{%
          \def\patterntype{north east lines}%
        }%
      }{%
        \ifdefstring{\branch}{right}{% branch
          \def\patterntype{north west lines}%
        }{%
          \def\patterntype{north east lines}%
        }%
      }%
      \path[draw=\foreground,pattern=\patterntype, pattern color=\foreground] (0,0) -- ++($\facefactor*(0.4,0)$) -- ++($\branchfactor*(0,0.4)$) -- cycle;% turnout marker
    }{%
      \ifdefstring{\operationmode}{remote}{% operation=remote
        \path[fill=\foreground] (0,0) -- ++($\facefactor*(0.4,0)$) -- ++($\branchfactor*(0,0.4)$) -- cycle;% turnout marker
      }{%
        \ifdefstring{\operationmode}{none}{
          \path[draw=\foreground] (0,0) -- ++($\facefactor*(0.4,0)$) -- ++($\branchfactor*(0,0.4)$) -- cycle;% turnout marker
        }{%
          \pgfkeys{/errors/unknown choice value={/tikz/trackschematic/operation}{“manual“, “remote“ OR “none“ as key required}}%
        }%
      }
    }%
    %
    %% label
    \ifdefstring{\labelcontent}{}{}{% label NOT empty
      \tikzset{every node/.style={text=\foreground}};%
      \coordinate (ts-y-l) at ($\branchfactor*(0,-8pt)$);%
      \ifdefstring{\labelcoord}{(none)}{}{% initialize if NOT default
        \path let \p1=\labelcoord in coordinate (ts-y-l) at ($(ts-y-l)+(\x1,\y1)$);%
      }%
      \node at (ts-y-l) {\footnotesize \labelcontent};%
    }%
    %
    %% fouling point indicator
    \iftoggle{fouling_point}{%
      \path[draw=\foreground] ($\facefactor*(0.7,0)$) -- ++($\branchfactor*(0,0.7)$);% fouling point indicator
    }{}%
    %
    %% points
    \ifdefstring{\points}{left}{% points left
      \ifdefstring{\branch}{left}{%
        \path[draw=\foreground,line width=1.5pt] ($\facefactor*(-0.035,0)+(0,0.1)$) -- ++($\facefactor*(0.2,0)+(0,0.2)$);%
      }{%
        \path[draw=\foreground,line width=1.5pt] ($\facefactor*( 0.035,0)+(0,0.1)$) -- ++($\facefactor*( 0.265,0  )$);%
      }%
    }{%
      \ifdefstring{\points}{right}{% points right
        \ifdefstring{\branch}{left}{%
          \path[draw=\foreground,line width=1.5pt] ($\facefactor*( 0.035,0)+(0,-0.1)$) -- ++($\facefactor*( 0.265,0  )$);%
        }{%
          \path[draw=\foreground,line width=1.5pt] ($\facefactor*(-0.035,0)+(0,-0.1)$) -- ++($\facefactor*(0.2,0)+(0,-0.2)$);%
        }%
      }{%
        \ifdefstring{\points}{moving}{% moving points
          \fill[\foreground] ($\facefactor*(0.075,0) + \branchfactor*(0,-0.1 )$) circle (0.05);% points indicator left
          \fill[\foreground] ($\facefactor*(0.225,0) + \branchfactor*(0,-0.1 )$) circle (0.05);% points indicator left
          \fill[\foreground] ($\facefactor*(0.015,0) + \branchfactor*(0, 0.15)$) circle (0.05);% points indicator right
          \fill[\foreground] ($\facefactor*(0.115,0) + \branchfactor*(0, 0.25)$) circle (0.05);% points indicator right
        }{% error message
          \ifdefstring{\points}{none}{%
          }{%
            \pgfkeys{/errors/unknown choice value={/tikz/trackschematic/topology/turnout/points}{“left“, “right“ OR “moving“ as key required}}%
          }%
        }%
      }%
    }% end \ifdefstring{\points}
    %
  }},% END pics/turnout/.style args={#1/#2/#3}
  % symbology entry
  symbology_turnout/.pic = {%
    \maintrack (0,0) -- (6,0);%
    \maintrack (3,0) -- ++(0.8,0.8);%
    \turnout[forward,branch=left] at (3,0) label ();%
  },%
  symbology_turnout_fouling/.pic = {%
    \maintrack (0,0) -- (6,0);%
    \maintrack (3,0) -- ++(0.8,0.8);%
    \turnout[forward,branch=left,fouling point] at (3,0) label ();%
  },%
  symbology_turnout_manually/.pic = {%
    \secondarytrack (0,0) -- (6,0);%
    \secondarytrack (3,0) -- ++(0.8,0.8);%
    \turnout[forward,branch=left,operation=manual] at (3,0) label ();%
  },%
  symbology_turnout_points_right/.pic = {%
    \maintrack (0,0) -- (6,0);%
    \maintrack (3,0) -- ++(0.8,0.8);%
    \turnout[forward,branch=left,points=right] at (3,0) label ();%
  },%
  symbology_turnout_points_left/.pic = {%
    \maintrack (0,0) -- (6,0);%
    \maintrack (3,0) -- ++(0.8,0.8);%
    \turnout[forward,branch=left,points=left] at (3,0) label ();%
  },%
  symbology_turnout_points_moving/.pic = {%
    \maintrack (0,0) -- (6,0);%
    \maintrack (3,0) -- ++(0.8,0.8);%
    \turnout[forward,branch=left,points=moving] at (3,0) label ();%
  },%
}%
%
%%%%%%%%%%%%%%%
% symbol slip switch turnout - using parts of turnout
%%%%%%%%%%%%%%%
%
\newcommand\slipturnout{}% just for safety
\def\slipturnout[#1]#2(#3)#4(#5)(#6){% \slipturnout[options] at (coord) label (name1)(name2);
  \pic[operation=remote,slip=double,#1] at (#3) {slipturnout={#2/#4/#5/#6}}% symbol
}%
% tikz keys
\pgfkeys{%
  /tikz/trackschematic/topology/slipturnout/.is family,%
  /tikz/trackschematic/topology/slipturnout/.cd,%
  %% points
  forward points/.store in=\forwardpoints,% moving, left, right OR none
  forward points=none,% moving, left, right OR none
  /tikz/forward points/.forward to=/tikz/trackschematic/topology/slipturnout/forward points,%
  backward points/.store in=\backwardpoints,% moving, left, right OR none
  backward points=none,% moving, left, right OR none
  /tikz/backward points/.forward to=/tikz/trackschematic/topology/slipturnout/backward points,%
  %% slips
  slip/.store in=\slip,% double, left, right OR none
  slip=none,% double, left, right OR none
  /tikz/slip/.forward to=/tikz/trackschematic/topology/slipturnout/slip,%
}%
% symbol definition
\tikzset{%
  pics/slipturnout/.default=,%
  pics/slipturnout/.style args={#1/#2/#3/#4}{code={%
    %% settings
    \def\coordcommand{#1}% beware of leading and tailing spaces!
    \def\labelcommand{#2}% beware of leading and tailing spaces!
    \def\labelcontentleft{#3}%
    \def\labelcontentright{#4}%
    %% branch setup
    \ifdefstring{\branch}{left}{% branch
      \pgfmathsetmacro{\branchfactor}{1}%
    }{%
      \ifdefstring{\branch}{right}{% branch
        \pgfmathsetmacro{\branchfactor}{-1}%
      }{% error message
        \pgfkeys{/errors/unknown choice value={/tikz/trackschematic/topology/branch}{“left“ OR “right“ as key required}}%
      }%
    }% end \ifdefstring{\branch}
    %% turnout marker
    \ifdefstring{\operationmode}{manual}{% operation=manual
      \ifdefstring{\branch}{left}{% branch
        \def\patterntype{north west lines}%
      }{%
        \def\patterntype{north east lines}%
      }%
      \path[draw,pattern=\patterntype, pattern color=\foreground] (0,0) -- ++($( 0.4,0)$) -- ++($\branchfactor*(0, 0.4)$) -- cycle;% turnout marker
      \path[draw,pattern=\patterntype, pattern color=\foreground] (0,0) -- ++($(-0.4,0)$) -- ++($\branchfactor*(0,-0.4)$) -- cycle;% turnout marker
    }{% operated automaticly
      \ifdefstring{\operationmode}{remote}{% operation=remote
        \path[fill=\foreground] (0,0) -- ++($( 0.4,0)$) -- ++($\branchfactor*(0, 0.4)$) -- cycle;% turnout marker
        \path[fill=\foreground] (0,0) -- ++($(-0.4,0)$) -- ++($\branchfactor*(0,-0.4)$) -- cycle;% turnout marker
      }{%
        \ifdefstring{\operationmode}{none}{}{%
          \pgfkeys{/errors/unknown choice value={/tikz/trackschematic/operation}{“manual“, “remote“ OR “none“ as key required}}%
        }%
      }%
    }%
    %% fouling point indicator
    \iftoggle{fouling_point}{%
      \path[draw=\foreground] ( 0.7,0) -- ++($\branchfactor*(0, 0.7)$);% fouling point indicator
      \path[draw=\foreground] (-0.7,0) -- ++($\branchfactor*(0,-0.7)$);% fouling point indicator
    }{}%
    %
    %% points
    \ifdefstring{\forwardpoints}{left}{% points left
      \ifdefstring{\branch}{left}{%
        \path[draw=\foreground,line width=1.5pt] (-0.035,0.1) -- ++(0.2,0.2);%
      }{%
        \path[draw=\foreground,line width=1.5pt] ( 0.035,0.1) -- ++(0.265,0);%
      }%
    }{%
      \ifdefstring{\forwardpoints}{right}{% points right
        \ifdefstring{\branch}{left}{%
          \path[draw=\foreground,line width=1.5pt] ( 0.035,-0.1) -- ++(0.265,0);
        }{%
          \path[draw=\foreground,line width=1.5pt] (-0.035,-0.1) -- ++(0.2,-0.2);%
        }%
      }{%
        \ifdefstring{\forwardpoints}{moving}{% moving points
          \fill[\foreground] ($(0.075,0) + \branchfactor*(0,-0.1 )$) circle (0.05);% points indicator left
          \fill[\foreground] ($(0.225,0) + \branchfactor*(0,-0.1 )$) circle (0.05);% points indicator left
          \fill[\foreground] ($(0.015,0) + \branchfactor*(0, 0.15)$) circle (0.05);% points indicator right
          \fill[\foreground] ($(0.115,0) + \branchfactor*(0, 0.25)$) circle (0.05);% points indicator right
        }{% error message
          \ifdefstring{\forwardpoints}{none}{%
          }{%
            \pgfkeys{/errors/unknown choice value={/tikz/trackschematic/topology/slipturnout/forward points}{“left“, “right“ OR “moving“ as key required}}%
          }%
        }%
      }%
    }% end of  \ifdefstring{\forwardpoints}
    \ifdefstring{\backwardpoints}{left}{% points left
      \ifdefstring{\branch}{left}{%
        \path[draw=\foreground,line width=1.5pt] (0.035,-0.1) -- ++(-0.2,-0.2);%
      }{%
        \path[draw=\foreground,line width=1.5pt] (-0.035,-0.1) -- ++(-0.265,0);%
      }%
    }{%
      \ifdefstring{\backwardpoints}{right}{% points right
        \ifdefstring{\branch}{left}{%
          \path[draw=\foreground,line width=1.5pt] (-0.035,0.1) -- ++(-0.265,0);
        }{%
          \path[draw=\foreground,line width=1.5pt] (0.035,0.1) -- ++(-0.2,0.2);%
        }%
      }{%
        \ifdefstring{\backwardpoints}{moving}{% moving points
          \fill[\foreground] ($(-0.075,0) + \branchfactor*(0, 0.1 )$) circle (0.05);% points indicator left
          \fill[\foreground] ($(-0.225,0) + \branchfactor*(0, 0.1 )$) circle (0.05);% points indicator left
          \fill[\foreground] ($(-0.015,0) + \branchfactor*(0,-0.15)$) circle (0.05);% points indicator right
          \fill[\foreground] ($(-0.115,0) + \branchfactor*(0,-0.25)$) circle (0.05);% points indicator right
        }{% error message
          \ifdefstring{\backwardpoints}{none}{%
          }{%
            \pgfkeys{/errors/unknown choice value={/tikz/trackschematic/topology/slipturnout/forward points}{“left“, “right“ OR “moving“ as key required}}%
          }%
        }%
      }%
    }% end of  \ifdefstring{\backwardpoints}
    %
    %% slips
    \ifdefstring{\slip}{double}{% slip
      \path[draw=\foreground,line width=0.75pt] ($\branchfactor*(-0.4,0) + (0, 0.1)$) --  ($\branchfactor*( 0.3,0) + (0, 0.4)$);% slip
      \path[draw=\foreground,line width=0.75pt] ($\branchfactor*( 0.4,0) + (0,-0.1)$) --  ($\branchfactor*(-0.3,0) + (0,-0.4)$);% slip
    }{%
      \ifdefstring{\slip}{left}{%
        \path[draw=\foreground,line width=0.75pt] ($\branchfactor*(-0.4,0) + (0,0.1)$) --  ($\branchfactor*(0.3,0) + (0,0.4)$);% slip
      }{%
        \ifdefstring{\slip}{right}{%
          \path[draw=\foreground,line width=0.75pt] ($\branchfactor*(0.4,0) + (0,-0.1)$) --  ($\branchfactor*(-0.3,0) + (0,-0.4)$);% slip
        }{%
          \ifdefstring{\slip}{none}{%
            %
          }{%error message
            \pgfkeys{/errors/unknown choice value={/tikz/trackschematic/topology/slipturnout/slip}{“double“, “left“, “right“ OR “none“ as key required}}%
          }%
        }%
      }%
    }%
    %
    %% label
    \tikzset{every node/.style={text=\foreground}};%
    \ifdefstring{\labelcontentleft}{}{}{% label NOT empty
      \coordinate (ts-sy-l1) at ($(2pt,0) + \branchfactor*(0, 10pt)$);%
      \ifdefstring{\labelcoord}{(none)}{}{% initialize if NOT default
        \path let \p1=\labelcoord in coordinate (ts-sy-l1) at ($(ts-sy-l1)+(\x1,\y1)$);%
      }%
      \node[left]  at (ts-sy-l1) {\footnotesize \labelcontentleft};%
    }%
    \ifdefstring{\labelcontentright}{}{}{% label NOT empty
      \coordinate (ts-sy-l2) at ($(2pt,0) + \branchfactor*(0,-10pt)$);%
      \ifdefstring{\labelcoord}{(none)}{}{% initialize if NOT default
        \path let \p1=\labelcoord in coordinate (ts-sy-l2) at ($(ts-sy-l2)+(\x1,\y1)$);%
      }%
      \node[right] at (ts-sy-l2) {\footnotesize \labelcontentright};%
    }%
    %
  }},% END of  pics/slipturnout/.style args={#1/#2/#3/#4}
  % symbology entry
  symbology_slip_turnout/.pic = {%
    \maintrack (0,0) -- (6,0);%
    \maintrack (3,0) -- ++(0.8,0.8);%
    \maintrack (3,0) -- ++(-0.8,-0.8);%
    \slipturnout[branch=left] at (3,0) label ()();%
  },%
}%
%
%%%%%%%%%%%%%%%
% symbol crossing - using parts of turnout
%%%%%%%%%%%%%%%
% command
\newcommand\crossing{}% just for safety
\def\crossing[#1]#2(#3)#4(#5){% \crossing[options] at (coord) label (name);
  \pic[#1] at (#3) {crossing={#2/#4/#5}}% symbol
}%
% symbol definition
\tikzset{%
  pics/crossing/.default=,%
  pics/crossing/.style args={#1/#2/#3}{code={%
    %% settings
    \def\coordcommand{#1}% beware of leading and tailing spaces!
    \def\labelcommand{#2}% beware of leading and tailing spaces!
    \def\labelcontent{#3}%
    %% face setup
    %% branch setup
    \ifdefstring{\branch}{left}{% branch
      \pgfmathsetmacro{\branchfactor}{1}%
    }{%
      \ifdefstring{\branch}{right}{% branch
        \pgfmathsetmacro{\branchfactor}{-1}%
      }{% error message
        \pgfkeys{/errors/unknown choice value={/tikz/trackschematic/topology/branch}{“left“ OR “right“ as key required}}%
      }%
    }%
    %
    %% crossing marker
    \path[draw=\foreground] (0,0) -- ++( 0.4,0) -- ++($\branchfactor*(0, 0.4)$) -- cycle;% turnout marker
    \path[draw=\foreground] (0,0) -- ++(-0.4,0) -- ++($\branchfactor*(0,-0.4)$) -- cycle;% turnout marker
    %
    %% label
    \ifdefstring{\labelcontent}{}{}{% label NOT empty
      \tikzset{every node/.style={text=\foreground}};%
      \coordinate (ts-x-l) at ($(2pt,0) + \branchfactor*(0,-9pt)$);%
      \ifdefstring{\labelcoord}{(none)}{}{% initialize if NOT default
        \path let \p1=\labelcoord in coordinate (ts-x-l) at ($(ts-x-l)+(\x1,\y1)$);%
      }%
      \node[right] at (ts-x-l) {\footnotesize \labelcontent};%
    }%
    %
    %% fouling point indicator
    \iftoggle{fouling_point}{%
      \path[draw=\foreground] ( 0.7,0) -- ++($\branchfactor*(0, 0.7)$);% fouling point indicator
      \path[draw=\foreground] (-0.7,0) -- ++($\branchfactor*(0,-0.7)$);% fouling point indicator
    }{}%
    %
  }},% end of  pics/crossing/.style args={#1/#2/#3}
  % symbology entry
  symbology_diamond_crossing/.pic = {%
    \maintrack (0,0) -- (6,0);%
    \maintrack (3,0) -- ++(0.8,0.8);%
    \maintrack (3,0) -- ++(-0.8,-0.8);%
    \crossing[branch=left] at (3,0) label ();%
  },%
}%
%
%%%%%%%%%%%%%%%
% symbol derailer
%%%%%%%%%%%%%%%
%
% command
\newcommand\derailer{}% just for safety
\def\derailer[#1]#2(#3)#4(#5){% \derailer[options] at (coord) label (name);
  \pic[#1] at (#3) {derailer={#2/#4/#5}}% symbol
}%
% symbol definition
\tikzset{%
  pics/derailer/.default=,%
  pics/derailer/.style args={#1/#2/#3}{code={%
    %% settings
    \def\coordcommand{#1}% beware of leading and tailing spaces!
    \def\labelcommand{#2}% beware of leading and tailing spaces!
    \def\labelcontent{#3}%
    %% face setup
    \ifdefstring{\face}{forward}{% face
      \pgfmathsetmacro{\facefactor}{1}%
    }{%
      \ifdefstring{\face}{backward}{% face
        \pgfmathsetmacro{\facefactor}{-1}%
      }{% error message
        \pgfkeys{/errors/unknown choice value={/tikz/trackschematic/face}{“forward“ OR “backward“ as key required}}%
      }%
    }% end \ifdefstring{\face}
    %% branch setup
    \ifdefstring{\branch}{left}{% branch
      \ifdefstring{\face}{forward}{%
        \pgfmathsetmacro{\branchfactor}{1}%
      }{%
        \pgfmathsetmacro{\branchfactor}{-1}%
      }%
    }{%
      \ifdefstring{\branch}{right}{% branch
        \ifdefstring{\face}{forward}{%
          \pgfmathsetmacro{\branchfactor}{-1}%
        }{%
          \pgfmathsetmacro{\branchfactor}{1}%
        }%
      }{% error message
        \pgfkeys{/errors/unknown choice value={/tikz/trackschematic/topology/branch}{“left“ OR “right“ as key required}}%
      }%
    }% end \ifdefstring{\branch}
    %
    %% symbol
    \path[draw=\foreground, line width=1pt] (0,0.1) -- ++(0,-0.2);% derailer marker
    \path[draw=\foreground,->,>=latex,line width=1pt,dashed] (0,0) -- ++($\facefactor*(0.4,0) + \branchfactor*(0,0.4)$);% derailer arrow
    %
    %% label
    \ifdefstring{\labelcontent}{}{}{% label NOT empty
      \tikzset{every node/.style={text=\foreground}};%
      \coordinate (ts-dr-l) at ($\branchfactor*(0,-0.3)$);%
      \ifdefstring{\labelcoord}{(none)}{}{% initialize if NOT default
        \path let \p1=\labelcoord in coordinate (ts-dr-l) at ($(ts-dr-l)+(\x1,\y1)$);%
      }%
      \node at (ts-dr-l) {\footnotesize \labelcontent};%
    }%
    %
  }},% END pics/derailer/.style args={#1/#2/#3}
  % symbology entry
  symbology_derailer/.pic = {%
    \secondarytrack (0,0) -- (6,0);%
    \derailer[forward,branch=left] at (3,0) label ();%
  },%
}%
%
%%%%%%%%%%%%%%%
\endinput%
%