2021-01-02 14:04:05 +01:00
%!TEX TS-program = pdflatexmk
%!TEX root = ../test/test.tex
%
2018-12-19 15:23:27 +01:00
%% symbol library for TikZ track schematics
%
2022-01-06 20:17:51 +01:00
% Copyright (c) 2018 - 2022, Martin Scheidt (ISC license)
2019-07-21 19:28:30 +02:00
%
2018-12-19 15:23:27 +01:00
% 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.
2020-01-14 17:11:10 +01:00
%
\ProvidesFileRCS { tikzlibrarytrackschematic.topology.code.tex} %
%
%%%%%%%%%%%%%%%
% Requirements
%%%%%%%%%%%%%%%
2021-09-30 12:37:31 +02:00
\RequirePackage { tikz,etoolbox} %
2020-01-14 17:11:10 +01:00
\usetikzlibrary { calc,patterns} %
%
% https://tex.stackexchange.com/questions/56353/extract-x-y-coordinate-of-an-arbitrary-point-on-curve-in-tikz
\providecommand { \gettikzxy } [3]{ %
\tikz @scan@one@point\pgfutil @firstofone#1\relax %
\edef #2{ \the \pgf @x} %
\edef #3{ \the \pgf @y} %
} %
%
2019-09-30 15:16:20 +02:00
%%%%%%%%%%%%%%%
2020-01-14 17:11:10 +01:00
% tikz keys for multiple use
2019-09-30 15:16:20 +02:00
%%%%%%%%%%%%%%%
2020-01-14 17:11:10 +01:00
\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,%
} %
2021-01-02 14:04:05 +01:00
% options for turnout and slip turnout
2020-01-14 17:11:10 +01:00
\newtoggle { fouling_ point} \settoggle { fouling_ point} { false} %
%
2019-09-30 15:16:20 +02:00
%%%%%%%%%%%%%%%
% symbol track
%%%%%%%%%%%%%%%
2020-01-14 17:11:10 +01:00
%
2021-01-02 14:04:05 +01:00
% commands
2019-09-30 15:16:20 +02:00
\newcommand \maintrack { } % just for safety
2021-01-02 14:04:05 +01:00
\def \maintrack { \path [draw=\foreground,MainTrack] } % \maintrack (coord1) -- (coord2);
2019-09-30 15:16:20 +02:00
\newcommand \secondarytrack { } % just for safety
2021-01-02 14:04:05 +01:00
\def \secondarytrack { \path [draw=\foreground,SecondaryTrack] } % \secondarytrack (coord1) -- (coord2);
2019-09-30 15:16:20 +02:00
\newcommand \sidetrack { } % just for safety
\def \sidetrack { \path [draw,SecondaryTrack] } % alias for \secondarytrack
2020-01-14 17:11:10 +01:00
%
2021-01-02 14:04:05 +01:00
%% 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);} %
} %
2020-01-14 17:11:10 +01:00
%
2019-09-30 15:16:20 +02:00
%%%%%%%%%%%%%%%
% symbol track number
%%%%%%%%%%%%%%%
2020-01-14 17:11:10 +01:00
%
2019-09-30 15:16:20 +02:00
%% command
\newcommand \tracklabel { } % just for safety
2020-01-14 17:11:10 +01:00
\def \tracklabel #1(#2)#3(#4){ % \tracklabel at (coord) label (name);
\pic at (#2) { track_ label={ #1/#3/#4} } % symbol
2019-09-30 15:16:20 +02:00
} %
%% 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={ %
2020-01-14 17:11:10 +01:00
%% 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
\gettikzxy { \labelcoord } { \labelcoordX } { \labelcoordY } %
\coordinate (ts-tl-l) at ($ ( ts - tl - l ) + ( \labelcoordX , \labelcoordY ) $ );%
} %
\node at (ts-tl-l) { \labelcontent } ;%
} %
2021-01-02 14:04:05 +01:00
} } ,% 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);%
} ,%
2020-01-14 17:11:10 +01:00
} %
%
%%%%%%%%%%%%%%%
% 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
2021-01-02 14:04:05 +01:00
\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
2020-01-14 17:11:10 +01:00
\fill [\foreground] (0,0) circle (0.06);% track closure indicator
2021-01-02 14:04:05 +01:00
} %
} } ,% 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);%
} ,%
2019-07-21 19:28:30 +02:00
} %
2020-01-14 17:11:10 +01:00
%
2019-09-30 15:16:20 +02:00
%%%%%%%%%%%%%%%
2020-01-14 17:11:10 +01:00
% symbol track closure
2019-09-30 15:16:20 +02:00
%%%%%%%%%%%%%%%
2020-01-14 17:11:10 +01:00
%
2019-09-30 15:16:20 +02:00
%% command
2020-01-14 17:11:10 +01:00
\newcommand \trackclosure { } % just for safety
\def \trackclosure #1(#2){ % \trackclosure at (coord);
\pic at (#2) { track_ closure={ #1} } % symbol
} %
2021-01-02 14:04:05 +01:00
% symbol definition
2020-01-14 17:11:10 +01:00
\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
2021-01-02 14:04:05 +01:00
} } ,% END pics/track_closure/.style args={#1}
%
% symbology entry
symbology_ track_ closure/.pic = { %
\maintrack (0,0) -- (3,0);%
\trackclosure at (3,0);%
} ,%
2019-09-30 15:16:20 +02:00
} %
2020-01-14 17:11:10 +01:00
%
2019-09-30 15:16:20 +02:00
%%%%%%%%%%%%%%%
% symbol turnout
%%%%%%%%%%%%%%%
2020-01-14 17:11:10 +01:00
%
2019-09-30 15:16:20 +02:00
% command
\newcommand \turnout { } % just for safety
2020-01-14 17:11:10 +01:00
\def \turnout [#1] #2(#3)#4(#5){ % \turnout[options] at (coord) label (name);
\pic [operation=remote,#1] at (#3) { turnout={ #2/#4/#5} } % symbol
2019-09-30 15:16:20 +02:00
} %
% tikz keys
\pgfkeys { %
2020-01-14 17:11:10 +01:00
/tikz/trackschematic/topology/turnout/.is family,%
/tikz/trackschematic/topology/turnout/.cd,%
2019-09-30 15:16:20 +02:00
%% points
points/.store in=\points ,% moving, left, right OR none
points=none,% moving, left, right OR none
2020-01-14 17:11:10 +01:00
/tikz/points/.forward to=/tikz/trackschematic/topology/turnout/points,%
2019-09-30 15:16:20 +02:00
} %
% symbol definition
\tikzset { %
2020-01-14 17:11:10 +01:00
pics/turnout/.default=,%
pics/turnout/.style args={ #1/#2/#3} { code={ %
2019-09-30 15:16:20 +02:00
%% settings
2020-01-14 17:11:10 +01:00
\def \coordcommand { #1} % beware of leading and tailing spaces!
\def \labelcommand { #2} % beware of leading and tailing spaces!
\def \labelcontent { #3} %
2019-09-30 15:16:20 +02:00
%% face setup
\ifdefstring { \face } { forward} { % face
\pgfmathsetmacro { \facefactor } { 1} %
} { %
\ifdefstring { \face } { backward} { % face
\pgfmathsetmacro { \facefactor } { -1} %
} { % error message
2020-01-14 17:11:10 +01:00
\pgfkeys { /errors/unknown choice value={ /tikz/trackschematic/face} { “forward“ OR “backward“ as key required} } %
2019-09-30 15:16:20 +02:00
} %
} % end \ifdefstring{\face}
%% branch setup
\ifdefstring { \branch } { left} { % branch
2020-01-14 17:11:10 +01:00
\pgfmathsetmacro { \branchfactor } { 1} %
2019-09-30 15:16:20 +02:00
} { %
\ifdefstring { \branch } { right} { % branch
2020-01-14 17:11:10 +01:00
\pgfmathsetmacro { \branchfactor } { -1} %
2019-09-30 15:16:20 +02:00
} { % error message
2020-01-14 17:11:10 +01:00
\pgfkeys { /errors/unknown choice value={ /tikz/trackschematic/topology/branch} { “left“ OR “right“ as key required} } %
2019-09-30 15:16:20 +02:00
} %
} % end \ifdefstring{\branch}
%% turnout marker
2020-01-14 17:11:10 +01:00
\ifdefstring { \operationmode } { manual} { % operation=manual
\ifdefstring { \face } { forward} { %
\ifdefstring { \branch } { left} { % branch
\def \patterntype { north west lines} %
} { %
\def \patterntype { north east lines} %
} %
2019-09-30 15:16:20 +02:00
} { %
2020-01-14 17:11:10 +01:00
\ifdefstring { \branch } { right} { % branch
\def \patterntype { north west lines} %
} { %
\def \patterntype { north east lines} %
} %
2019-09-30 15:16:20 +02:00
} %
2020-01-14 17:11:10 +01:00
\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} } %
} %
}
2019-09-30 15:16:20 +02:00
} %
%
%% label
2020-01-14 17:11:10 +01:00
\ifdefstring { \labelcontent } { } { } { % label NOT empty
\tikzset { every node/.style={ text=\foreground } } ;%
\coordinate (ts-y-l) at ($ \branchfactor * ( 0 , - 8 pt ) $ );%
\ifdefstring { \labelcoord } { (none)} { } { % initialize if NOT default
\gettikzxy { \labelcoord } { \labelcoordX } { \labelcoordY } %
\coordinate (ts-y-l) at ($ ( ts - y - l ) + ( \labelcoordX , \labelcoordY ) $ );%
} %
\node at (ts-y-l) { \footnotesize \labelcontent } ;%
} %
2019-09-30 15:16:20 +02:00
%
%% fouling point indicator
\iftoggle { fouling_ point} { %
2020-01-14 17:11:10 +01:00
\path [draw=\foreground] ($ \facefactor * ( 0 . 7 , 0 ) $ ) -- ++($ \branchfactor * ( 0 , 0 . 7 ) $ );% fouling point indicator
2019-09-30 15:16:20 +02:00
} { } %
%
%% points
\ifdefstring { \points } { left} { % points left
\ifdefstring { \branch } { left} { %
2020-01-14 17:11:10 +01:00
\path [draw=\foreground,line width=1.5pt] ($ \facefactor * ( - 0 . 035 , 0 ) + ( 0 , 0 . 1 ) $ ) -- ++($ \facefactor * ( 0 . 2 , 0 ) + ( 0 , 0 . 2 ) $ );%
2019-09-30 15:16:20 +02:00
} { %
2020-01-14 17:11:10 +01:00
\path [draw=\foreground,line width=1.5pt] ($ \facefactor * ( 0 . 035 , 0 ) + ( 0 , 0 . 1 ) $ ) -- ++($ \facefactor * ( 0 . 265 , 0 ) $ );%
2019-09-30 15:16:20 +02:00
} %
} { %
\ifdefstring { \points } { right} { % points right
\ifdefstring { \branch } { left} { %
2020-01-14 17:11:10 +01:00
\path [draw=\foreground,line width=1.5pt] ($ \facefactor * ( 0 . 035 , 0 ) + ( 0 , - 0 . 1 ) $ ) -- ++($ \facefactor * ( 0 . 265 , 0 ) $ );%
2019-09-30 15:16:20 +02:00
} { %
2020-01-14 17:11:10 +01:00
\path [draw=\foreground,line width=1.5pt] ($ \facefactor * ( - 0 . 035 , 0 ) + ( 0 , - 0 . 1 ) $ ) -- ++($ \facefactor * ( 0 . 2 , 0 ) + ( 0 , - 0 . 2 ) $ );%
2019-09-30 15:16:20 +02:00
} %
} { %
\ifdefstring { \points } { moving} { % moving points
2020-01-14 17:11:10 +01:00
\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
2019-09-30 15:16:20 +02:00
} { % error message
\ifdefstring { \points } { none} { %
} { %
2020-01-14 17:11:10 +01:00
\pgfkeys { /errors/unknown choice value={ /tikz/trackschematic/topology/turnout/points} { “left“, “right“ OR “moving“ as key required} } %
2019-09-30 15:16:20 +02:00
} %
} %
} %
} % end \ifdefstring{\points}
%
2021-01-02 14:04:05 +01:00
} } ,% 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 ();%
} ,%
2019-09-30 15:16:20 +02:00
} %
2020-01-14 17:11:10 +01:00
%
2019-09-30 15:16:20 +02:00
%%%%%%%%%%%%%%%
% symbol slip switch turnout - using parts of turnout
%%%%%%%%%%%%%%%
2020-01-14 17:11:10 +01:00
%
2019-09-30 15:16:20 +02:00
\newcommand \slipturnout { } % just for safety
2020-01-14 17:11:10 +01:00
\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
2019-09-30 15:16:20 +02:00
} %
% tikz keys
\pgfkeys { %
2020-01-14 17:11:10 +01:00
/tikz/trackschematic/topology/slipturnout/.is family,%
/tikz/trackschematic/topology/slipturnout/.cd,%
2019-09-30 15:16:20 +02:00
%% points
forward points/.store in=\forwardpoints ,% moving, left, right OR none
forward points=none,% moving, left, right OR none
2020-01-14 17:11:10 +01:00
/tikz/forward points/.forward to=/tikz/trackschematic/topology/slipturnout/forward points,%
2019-09-30 15:16:20 +02:00
backward points/.store in=\backwardpoints ,% moving, left, right OR none
backward points=none,% moving, left, right OR none
2020-01-14 17:11:10 +01:00
/tikz/backward points/.forward to=/tikz/trackschematic/topology/slipturnout/backward points,%
2019-09-30 15:16:20 +02:00
%% slips
slip/.store in=\slip ,% double, left, right OR none
slip=none,% double, left, right OR none
2020-01-14 17:11:10 +01:00
/tikz/slip/.forward to=/tikz/trackschematic/topology/slipturnout/slip,%
2019-09-30 15:16:20 +02:00
} %
% symbol definition
\tikzset { %
2020-01-14 17:11:10 +01:00
pics/slipturnout/.default=,%
pics/slipturnout/.style args={ #1/#2/#3/#4} { code={ %
2019-09-30 15:16:20 +02:00
%% settings
2020-01-14 17:11:10 +01:00
\def \coordcommand { #1} % beware of leading and tailing spaces!
\def \labelcommand { #2} % beware of leading and tailing spaces!
\def \labelcontentleft { #3} %
\def \labelcontentright { #4} %
2019-09-30 15:16:20 +02:00
%% branch setup
\ifdefstring { \branch } { left} { % branch
\pgfmathsetmacro { \branchfactor } { 1} %
} { %
\ifdefstring { \branch } { right} { % branch
\pgfmathsetmacro { \branchfactor } { -1} %
} { % error message
2020-01-14 17:11:10 +01:00
\pgfkeys { /errors/unknown choice value={ /tikz/trackschematic/topology/branch} { “left“ OR “right“ as key required} } %
2019-09-30 15:16:20 +02:00
} %
} % end \ifdefstring{\branch}
%% turnout marker
2020-01-14 17:11:10 +01:00
\ifdefstring { \operationmode } { manual} { % operation=manual
2019-09-30 15:16:20 +02:00
\ifdefstring { \branch } { left} { % branch
\def \patterntype { north west lines} %
} { %
\def \patterntype { north east lines} %
} %
2020-01-14 17:11:10 +01:00
\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
2019-09-30 15:16:20 +02:00
} { % operated automaticly
2020-01-14 17:11:10 +01:00
\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} } %
} %
} %
} %
2019-09-30 15:16:20 +02:00
%% fouling point indicator
\iftoggle { fouling_ point} { %
2020-01-14 17:11:10 +01:00
\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
2019-09-30 15:16:20 +02:00
} { } %
%
%% points
\ifdefstring { \forwardpoints } { left} { % points left
\ifdefstring { \branch } { left} { %
2020-01-14 17:11:10 +01:00
\path [draw=\foreground,line width=1.5pt] (-0.035,0.1) -- ++(0.2,0.2);%
2019-09-30 15:16:20 +02:00
} { %
2020-01-14 17:11:10 +01:00
\path [draw=\foreground,line width=1.5pt] ( 0.035,0.1) -- ++(0.265,0);%
2019-09-30 15:16:20 +02:00
} %
} { %
\ifdefstring { \forwardpoints } { right} { % points right
\ifdefstring { \branch } { left} { %
2020-01-14 17:11:10 +01:00
\path [draw=\foreground,line width=1.5pt] ( 0.035,-0.1) -- ++(0.265,0);
2019-09-30 15:16:20 +02:00
} { %
2020-01-14 17:11:10 +01:00
\path [draw=\foreground,line width=1.5pt] (-0.035,-0.1) -- ++(0.2,-0.2);%
2019-09-30 15:16:20 +02:00
} %
} { %
\ifdefstring { \forwardpoints } { moving} { % moving points
2020-01-14 17:11:10 +01:00
\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
2019-09-30 15:16:20 +02:00
} { % error message
\ifdefstring { \forwardpoints } { none} { %
} { %
2020-01-14 17:11:10 +01:00
\pgfkeys { /errors/unknown choice value={ /tikz/trackschematic/topology/slipturnout/forward points} { “left“, “right“ OR “moving“ as key required} } %
2019-09-30 15:16:20 +02:00
} %
} %
} %
} % end of \ifdefstring{\forwardpoints}
\ifdefstring { \backwardpoints } { left} { % points left
\ifdefstring { \branch } { left} { %
2020-01-14 17:11:10 +01:00
\path [draw=\foreground,line width=1.5pt] (0.035,-0.1) -- ++(-0.2,-0.2);%
2019-09-30 15:16:20 +02:00
} { %
2020-01-14 17:11:10 +01:00
\path [draw=\foreground,line width=1.5pt] (-0.035,-0.1) -- ++(-0.265,0);%
2019-09-30 15:16:20 +02:00
} %
} { %
\ifdefstring { \backwardpoints } { right} { % points right
\ifdefstring { \branch } { left} { %
2020-01-14 17:11:10 +01:00
\path [draw=\foreground,line width=1.5pt] (-0.035,0.1) -- ++(-0.265,0);
2019-09-30 15:16:20 +02:00
} { %
2020-01-14 17:11:10 +01:00
\path [draw=\foreground,line width=1.5pt] (0.035,0.1) -- ++(-0.2,0.2);%
2019-09-30 15:16:20 +02:00
} %
} { %
\ifdefstring { \backwardpoints } { moving} { % moving points
2020-01-14 17:11:10 +01:00
\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
2019-09-30 15:16:20 +02:00
} { % error message
\ifdefstring { \backwardpoints } { none} { %
} { %
2020-01-14 17:11:10 +01:00
\pgfkeys { /errors/unknown choice value={ /tikz/trackschematic/topology/slipturnout/forward points} { “left“, “right“ OR “moving“ as key required} } %
2019-09-30 15:16:20 +02:00
} %
} %
} %
} % end of \ifdefstring{\backwardpoints}
%
%% slips
\ifdefstring { \slip } { double} { % slip
2020-01-14 17:11:10 +01:00
\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
2019-09-30 15:16:20 +02:00
} { %
\ifdefstring { \slip } { left} { %
2020-01-14 17:11:10 +01:00
\path [draw=\foreground,line width=0.75pt] ($ \branchfactor * ( - 0 . 4 , 0 ) + ( 0 , 0 . 1 ) $ ) -- ($ \branchfactor * ( 0 . 3 , 0 ) + ( 0 , 0 . 4 ) $ );% slip
2019-09-30 15:16:20 +02:00
} { %
\ifdefstring { \slip } { right} { %
2020-01-14 17:11:10 +01:00
\path [draw=\foreground,line width=0.75pt] ($ \branchfactor * ( 0 . 4 , 0 ) + ( 0 , - 0 . 1 ) $ ) -- ($ \branchfactor * ( - 0 . 3 , 0 ) + ( 0 , - 0 . 4 ) $ );% slip
2019-09-30 15:16:20 +02:00
} { %
\ifdefstring { \slip } { none} { %
%
} { %error message
2020-01-14 17:11:10 +01:00
\pgfkeys { /errors/unknown choice value={ /tikz/trackschematic/topology/slipturnout/slip} { “double“, “left“, “right“ OR “none“ as key required} } %
2019-09-30 15:16:20 +02:00
} %
} %
} %
} %
%
2021-01-02 14:04:05 +01:00
%% label
\tikzset { every node/.style={ text=\foreground } } ;%
\ifdefstring { \labelcontentleft } { } { } { % label NOT empty
\coordinate (ts-sy-l1) at ($ ( 2 pt, 0 ) + \branchfactor * ( 0 , 10 pt ) $ );%
\ifdefstring { \labelcoord } { (none)} { } { % initialize if NOT default
\gettikzxy { \labelcoord } { \labelcoordX } { \labelcoordY } %
\coordinate (ts-sy-l1) at ($ ( ts - sy - l 1 ) + ( \labelcoordX , \labelcoordY ) $ );%
} %
\node [left] at (ts-sy-l1) { \footnotesize \labelcontentleft } ;%
} %
\ifdefstring { \labelcontentright } { } { } { % label NOT empty
\coordinate (ts-sy-l2) at ($ ( 2 pt, 0 ) + \branchfactor * ( 0 , - 10 pt ) $ );%
\ifdefstring { \labelcoord } { (none)} { } { % initialize if NOT default
\gettikzxy { \labelcoord } { \labelcoordX } { \labelcoordY } %
\coordinate (ts-sy-l2) at ($ ( ts - sy - l 2 ) - ( \labelcoordX , \labelcoordY ) $ );%
} %
\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 ()();%
} ,%
2019-09-30 15:16:20 +02:00
} %
2020-01-14 17:11:10 +01:00
%
%%%%%%%%%%%%%%%
% symbol crossing - using parts of turnout
%%%%%%%%%%%%%%%
2021-01-02 14:04:05 +01:00
% command
2020-01-14 17:11:10 +01:00
\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 ($ ( 2 pt, 0 ) + \branchfactor * ( 0 , - 9 pt ) $ );%
\ifdefstring { \labelcoord } { (none)} { } { % initialize if NOT default
\gettikzxy { \labelcoord } { \labelcoordX } { \labelcoordY } %
\coordinate (ts-x-l) at ($ ( ts - x - l ) + ( \labelcoordX , \labelcoordY ) $ );%
} %
\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
} { } %
%
2021-01-02 14:04:05 +01:00
} } ,% 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 ();%
} ,%
2020-01-14 17:11:10 +01:00
} %
%
2019-09-30 15:16:20 +02:00
%%%%%%%%%%%%%%%
% symbol derailer
%%%%%%%%%%%%%%%
2020-01-14 17:11:10 +01:00
%
2019-09-30 15:16:20 +02:00
% command
\newcommand \derailer { } % just for safety
2020-01-14 17:11:10 +01:00
\def \derailer [#1] #2(#3)#4(#5){ % \derailer[options] at (coord) label (name);
\pic [#1] at (#3) { derailer={ #2/#4/#5} } % symbol
2019-09-30 15:16:20 +02:00
} %
% symbol definition
\tikzset { %
pics/derailer/.default=,%
pics/derailer/.style args={ #1/#2/#3} { code={ %
%% settings
2020-01-14 17:11:10 +01:00
\def \coordcommand { #1} % beware of leading and tailing spaces!
\def \labelcommand { #2} % beware of leading and tailing spaces!
\def \labelcontent { #3} %
2019-09-30 15:16:20 +02:00
%% face setup
\ifdefstring { \face } { forward} { % face
\pgfmathsetmacro { \facefactor } { 1} %
} { %
\ifdefstring { \face } { backward} { % face
\pgfmathsetmacro { \facefactor } { -1} %
} { % error message
2020-01-14 17:11:10 +01:00
\pgfkeys { /errors/unknown choice value={ /tikz/trackschematic/face} { “forward“ OR “backward“ as key required} } %
2019-09-30 15:16:20 +02:00
} %
} % 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
2020-01-14 17:11:10 +01:00
\pgfkeys { /errors/unknown choice value={ /tikz/trackschematic/topology/branch} { “left“ OR “right“ as key required} } %
2019-09-30 15:16:20 +02:00
} %
} % end \ifdefstring{\branch}
2020-01-14 17:11:10 +01:00
%
2019-09-30 15:16:20 +02:00
%% symbol
2020-01-14 17:11:10 +01:00
\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 , - 10 pt ) $ );%
\ifdefstring { \labelcoord } { (none)} { } { % initialize if NOT default
\gettikzxy { \labelcoord } { \labelcoordX } { \labelcoordY } %
\coordinate (ts-dr-l) at ($ ( ts - dr - l ) + ( \labelcoordX , \labelcoordY ) $ );%
2019-09-30 15:16:20 +02:00
} %
2020-01-14 17:11:10 +01:00
\node [right] at (ts-dr-l) { \footnotesize \labelcontent } ;%
} %
%
2021-01-02 14:04:05 +01:00
} } ,% 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 ();%
} ,%
2019-09-30 15:16:20 +02:00
} %
2020-01-14 17:11:10 +01:00
%
2019-09-30 15:16:20 +02:00
%%%%%%%%%%%%%%%
2020-01-14 17:11:10 +01:00
\endinput %
%