diff options
author | Karl Berry <karl@freefriends.org> | 2022-04-06 20:07:08 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-04-06 20:07:08 +0000 |
commit | 414f745665e727b2ccca08603445e0e99cbffe7e (patch) | |
tree | ea5a602a738c0ecfceae9824833b50b0d2f0c7bb /Master/texmf-dist/tex/latex/tikz-trackschematic/tikzlibrarytrackschematic.trafficcontrol.code.tex | |
parent | 8e29dfd5c7ae138337a1707b1c2afab2423f4b2f (diff) |
tikz-trackschematic (6apr22)
git-svn-id: svn://tug.org/texlive/trunk@62966 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/tikz-trackschematic/tikzlibrarytrackschematic.trafficcontrol.code.tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/tikz-trackschematic/tikzlibrarytrackschematic.trafficcontrol.code.tex | 271 |
1 files changed, 199 insertions, 72 deletions
diff --git a/Master/texmf-dist/tex/latex/tikz-trackschematic/tikzlibrarytrackschematic.trafficcontrol.code.tex b/Master/texmf-dist/tex/latex/tikz-trackschematic/tikzlibrarytrackschematic.trafficcontrol.code.tex index 97978f5b072..253c5e21a97 100644 --- a/Master/texmf-dist/tex/latex/tikz-trackschematic/tikzlibrarytrackschematic.trafficcontrol.code.tex +++ b/Master/texmf-dist/tex/latex/tikz-trackschematic/tikzlibrarytrackschematic.trafficcontrol.code.tex @@ -1,6 +1,3 @@ -%!TEX TS-program = pdflatexmk -%!TEX root = ../test/test.tex -% %% symbol library for TikZ track schematics % % Copyright (c) 2018 - 2022, Martin Scheidt (ISC license) @@ -15,13 +12,6 @@ \RequirePackage{tikz,etoolbox}% \usetikzlibrary{calc}% % -% 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}% -}% -% %%%%%%%%%%%%%%% % tikz keys for multiple use %%%%%%%%%%%%%%% @@ -208,8 +198,7 @@ \ifdefstring{\labelcontent}{}{}{% label NOT empty \coordinate (ts-s-l) at ($\trafficfactor*\facefactor*(0,-0.4)$);% \ifdefstring{\labelcoord}{(none)}{}{% initialize if NOT default - \gettikzxy{\labelcoord}{\labelcoordX}{\labelcoordY}% - \coordinate (ts-s-l) at ($(ts-s-l)+(\labelcoordX,\labelcoordY)$);% + \path let \p1=\labelcoord in coordinate (ts-s-l) at ($(ts-s-l)+(\x1,\y1)$);% }% \node[\align] at (ts-s-l) {\footnotesize \labelcontent};% }% @@ -414,8 +403,7 @@ \tikzset{every node/.style={font=\sffamily,text=\foreground}};% \coordinate (ts-cp-l) at ($\trafficfactor*\facefactor*(0,0.25)$);% \ifdefstring{\labelcoord}{(none)}{}{% initialize if NOT default - \gettikzxy{\labelcoord}{\labelcoordX}{\labelcoordY}% - \coordinate (ts-cp-l) at ($(ts-cp-l)+(\labelcoordX,\labelcoordY)$);% + \path let \p1=\labelcoord in coordinate (ts-cp-l) at ($(ts-cp-l)+(\x1,\y1)$);% }% \node at (ts-cp-l) {\footnotesize \labelcontent};% }% @@ -438,25 +426,17 @@ }% % %%%%%%%%%%%%%%% -% symbol transmitter +% symbol trackloop %%%%%%%%%%%%%%% % command -\newcommand\transmitter{}% just for safety -\def\transmitter[#1]#2(#3)#4(#5){% \transmitter[options] at (coord) label (name); - \pic[#1] at (#3) {transmitter={#2/#4/#5}}% symbol -}% -\newcommand\balise{}% just for safety -\def\balise[#1]#2(#3)#4(#5){% \balise[options] at (coord) label (name); - \pic[type=balise,#1] at (#3) {transmitter={#2/#4/#5}}% symbol -}% \newcommand\trackloop{}% just for safety \def\trackloop[#1]#2(#3)#4(#5){% \trackloop[options] at (coord) label (name); - \pic[type=loop,#1] at (#3) {transmitter={#2/#4/#5}}% symbol + \pic[#1] at (#3) {trackloop={#2/#4/#5}}% symbol }% % symbol definition \tikzset{% - pics/transmitter/.default=,% - pics/transmitter/.style args={#1/#2/#3}{code={% + pics/trackloop/.default=,% + pics/trackloop/.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! @@ -473,62 +453,212 @@ }% end \ifdefstring{\trafficpractice} %% marker \tikzset{every path/.style={draw=\foreground}};% - \ifdefstring{\type}{balise}{% type balise - \path[line width=1pt,fill=\background] ($(-0.25,0)$) rectangle% - ($\trafficfactor*(0,-0.25) + (0.25,0)$);% balise marker - \ifdefstring{\face}{forward}{% face - \path ($\trafficfactor*(0,-0.05) + (0.1,0)$) -- ($\trafficfactor*(0,-0.125) + (0.2,0)$) --% - ($\trafficfactor*(0,-0.2) + (0.1,0)$) -- cycle;% arrow forward - }{% - \ifdefstring{\face}{backward}{% face - \path ($\trafficfactor*(0,-0.05) + (-0.1,0)$) -- ($\trafficfactor*(0,-0.125) + (-0.2,0)$) --% - ($\trafficfactor*(0,-0.2) + (-0.1,0)$) -- cycle;% arrow backward - }{ - \ifdefstring{\face}{bidirectional}{% face - \path ($\trafficfactor*(0,-0.05) + (0.1,0)$) -- ($\trafficfactor*(0,-0.125) + (0.2,0)$) --% - ($\trafficfactor*(0,-0.2) + (0.1,0)$) -- cycle;% arrow forward - \path ($\trafficfactor*(0,-0.05) + (-0.1,0)$) -- ($\trafficfactor*(0,-0.125) + (-0.2,0)$) --% - ($\trafficfactor*(0,-0.2) + (-0.1,0)$) -- cycle;% arrow backward - }{}% - }% - }% end \ifdefstring{\face} - }{% - \ifdefstring{\type}{loop}{% type loop - \path[line width=1pt] ($\trafficfactor*(0,-0.175)$) -- ++(-0.0625,-0.0625) -- ++(-0.2,0) -- ++(-0.125,0.125) -- ++(-0.1,0) -- ++(0,-0.125) -- ++(0.1,0) -- ++(0.125,0.125) -- ++(0.2,0) -- ++(0.125,-0.125) -- ++(0.2,0) -- ++(0.125,0.125) -- ++(0.1,0) -- ++(0,-0.125) -- ++(-0.1,0) -- ++(-0.125,0.125) -- ++(-0.2,0) -- cycle;% loop marker - }{% error message - \pgfkeys{/errors/unknown choice value={/tikz/trackschematic/trafficcontrol/transmitter/type}{“balise“ OR “loop“ as key required}}% - }% - }% end \ifdefstring{\type} + \path[line width=1pt] ($\trafficfactor*(0,-0.175)$) -- ++(-0.0625,-0.0625) -- ++(-0.2,0) -- ++(-0.125,0.125) -- ++(-0.1,0) -- ++(0,-0.125) -- ++(0.1,0) -- ++(0.125,0.125) -- ++(0.2,0) -- ++(0.125,-0.125) -- ++(0.2,0) -- ++(0.125,0.125) -- ++(0.1,0) -- ++(0,-0.125) -- ++(-0.1,0) -- ++(-0.125,0.125) -- ++(-0.2,0) -- cycle;% loop marker %% label \ifdefstring{\labelcontent}{}{}{% label NOT empty \tikzset{every node/.style={font=\sffamily,text=\foreground}};% \coordinate (ts-tm-l) at ($\trafficfactor*(0,0.25)$);% \ifdefstring{\labelcoord}{(none)}{}{% initialize if NOT default - \gettikzxy{\labelcoord}{\labelcoordX}{\labelcoordY}% - \coordinate (ts-tm-l) at ($(ts-tm-l) + (\labelcoordX,\labelcoordY)$);% + \path let \p1=\labelcoord in coordinate (ts-tm-l) at ($(ts-tm-l)+(\x1,\y1)$);% }% \node at (ts-tm-l) {\footnotesize \labelcontent};% }% }},% end pics/transmitter/.style args={#1/#2/#3} % symbology entry - symbology_transmitter/.pic = {% - \maintrack (0,0) -- (6,0);% - \balise[] at (3,0) label ();% - },% - % symbology entry - symbology_transmitter_forward/.pic = {% + symbology_trackloop/.pic = {% \maintrack (0,0) -- (6,0);% - \balise[forward] at (3,0) label ();% + \trackloop[forward] at (3,0) label ();% },% +}% +% +%%%%%%%%%%%%%%% +% symbol balise +%%%%%%%%%%%%%%% +% command +\newcommand\balise{}% just for safety +\def\balise[#1]#2(#3)#4(#5){% \balise[options] at (coord) label (name); + \pic[#1] at (#3) {balise={#2/#4/#5}}% symbol +}% +\pgfkeys{% + /tikz/trackschematic/trafficcontrol/.is family,% + /tikz/trackschematic/trafficcontrol/.cd,% + %% route signal type + switched/.value forbidden,% + switched/.code={\settoggle{switched}{true}},% + /tikz/switched/.forward to=/tikz/trackschematic/trafficcontrol/switched,% + %% balises along the direction + along/.store in=\along,% array of integer + along=none,% DEFAULT + /tikz/along/.forward to=/tikz/trackschematic/trafficcontrol/along,% + %% balises oppose the direction + oppose/.store in=\oppose,% array of integer + oppose=none,% DEFAULT + /tikz/oppose/.forward to=/tikz/trackschematic/trafficcontrol/oppose,% + %% balises along the direction + along switched/.store in=\alongswitched,% array of integer + along switched=none,% DEFAULT + /tikz/along switched/.forward to=/tikz/trackschematic/trafficcontrol/along switched,% + %% balises oppose the direction + oppose switched/.store in=\opposeswitched,% array of integer + oppose switched=none,% DEFAULT + /tikz/oppose switched/.forward to=/tikz/trackschematic/trafficcontrol/oppose switched,% + %% display index number + index number/.value forbidden,% + index number/.code={\settoggle{index_number}{true}},% + /tikz/index/.forward to=/tikz/trackschematic/trafficcontrol/index number,% +}% +% options +\newtoggle{unnumberd}\settoggle{unnumberd}{true}% DEFAULT +\newtoggle{switched}\settoggle{switched}{false}% +\newtoggle{index_number}\settoggle{index_number}{false}% +% symbol definition +\tikzset{% + pics/balise/.default=,% + pics/balise/.style args={#1/#2/#3}{code={% + %% + %%%%%%%[steps]%%%%%% + %% 0. setup settings + %% 1. draw marker + %% 2. draw label + %%%%%%%%%%%%%%%%%%%% + %% 0. 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} + %% + %% traffic practice setup + \ifdefstring{\trafficpractice}{left}{% branch + \pgfmathsetmacro{\trafficfactor}{-1}% + }{% + \ifdefstring{\trafficpractice}{right}{% branch + \pgfmathsetmacro{\trafficfactor}{1}% + }{% error message + \pgfkeys{/errors/unknown choice value={/tikz/trackschematic/trafficcontrol/traffic practice}{“left“ OR “right“ as key required}}% + }% + }% end \ifdefstring{\trafficpractice} + %% + %% number of balises known? + \ifdefstring{\along}{none}{}{% a number has been set + \settoggle{unnumberd}{false}% + }% + %% number of balises known? + \ifdefstring{\oppose}{none}{}{% a number has been set + \settoggle{unnumberd}{false}% + }% + %% number of balises known? + \ifdefstring{\alongswitched}{none}{}{% a number has been set + \settoggle{unnumberd}{false}% + }% + %% number of balises known? + \ifdefstring{\opposeswitched}{none}{}{% a number has been set + \settoggle{unnumberd}{false}% + }% + %% + %%%%%%%%%%%%%%%%%%%% + %% 1. marker + \tikzset{every path/.style={draw=\foreground,line width=0.75pt,rounded corners=0.2pt}};% + %% + \iftoggle{unnumberd}{% no number has been set + %% marker for undefined balises + \path[fill=\background] ($(-0.3,0)$) rectangle ($\trafficfactor*\facefactor*(0,-0.25) + (0.3,0)$);% balise marker + \iftoggle{switched}{% balises can be switched + \path[fill=\foreground] ($\trafficfactor*\facefactor*(0,-0.075) + (-0.225,0)$) rectangle% + ($\trafficfactor*\facefactor*(0,-0.175) + ( 0.225,0)$);% switch marker + }{}% + }{% a number has been set + %% marker for numbered balises + \ifdefstring{\along}{none}{}{ + \foreach \n in \along{% + \path[fill=\background] ($\n*\facefactor*(0.2,0)$) rectangle% + ($\n*\facefactor*(0.2,0) + (0.2 ,0) + \trafficfactor*\facefactor*(0,-0.25)$);% balise marker + \iftoggle{index_number}{% + \node[text=\foreground] at ($\n*\facefactor*(0.2,0) + (0.1,0) + \trafficfactor*\facefactor*(0,-0.125)$) {\tiny\n};% + }{}% + }% + }% + \ifdefstring{\oppose}{none}{}{ + \foreach \n in \oppose{% + \path[fill=\background] ($\n*\facefactor*(0.2,0)$) rectangle% + ($\n*\facefactor*(0.2,0) + (0.2 ,0) + \trafficfactor*\facefactor*(0,0.25)$);% balise marker + \iftoggle{index_number}{% + \node[text=\foreground] at ($\n*\facefactor*(0.2,0) + (0.1,0) + \trafficfactor*\facefactor*(0,0.125)$) {\tiny\n};% + }{}% + }% + }% + \ifdefstring{\alongswitched}{none}{}{ + \foreach \n in \alongswitched{% + \path[fill=\background] ($\n*\facefactor*(0.2,0)$) rectangle% + ($\n*\facefactor*(0.2,0) + (0.2 ,0) + \trafficfactor*\facefactor*(0,-0.25)$);% balise marker + \path[fill=\foreground] ($\n*\facefactor*(0.2,0) + (0.05,0) + \trafficfactor*\facefactor*(0,-0.05)$) rectangle% + ($\n*\facefactor*(0.2,0) + (0.15,0) + \trafficfactor*\facefactor*(0,-0.2)$);% switch marker + \iftoggle{index_number}{% + \node[text=\background] at ($\n*\facefactor*(0.2,0) + (0.1,0) + \trafficfactor*\facefactor*(0,-0.125)$) {\tiny\n};% + }{}% + }% + }% + \ifdefstring{\opposeswitched}{none}{}{ + \foreach \n in \opposeswitched{% + \path[fill=\background] ($\n*\facefactor*(0.2,0)$) rectangle% + ($\n*\facefactor*(0.2,0) + (0.2 ,0) + \trafficfactor*\facefactor*(0,0.25)$);% balise marker + \path[fill=\foreground] ($\n*\facefactor*(0.2,0) + (0.05,0) + \trafficfactor*\facefactor*(0,0.05)$) rectangle% + ($\n*\facefactor*(0.2,0) + (0.15,0) + \trafficfactor*\facefactor*(0,0.2)$);% switch marker + \iftoggle{index_number}{% + \node[text=\background] at ($\n*\facefactor*(0.2,0) + (0.1,0) + \trafficfactor*\facefactor*(0,0.125)$) {\tiny\n};% + }{}% + }% + }% + }% + %% + %%%%%%%%%%%%%%%%%%%% + %% 2. label + \ifdefstring{\labelcontent}{}{}{% label NOT empty + %% coord + \iftoggle{unnumberd}{% no number has been set + \coordinate (label-coord) at ($\trafficfactor*\facefactor*(0,-0.25)$);% + }{% + \coordinate (label-coord) at ($\trafficfactor*\facefactor*(0,-0.25) + (0.1,0)$);% + }% + \ifdefstring{\labelcoord}{(none)}{}{% initialize if NOT default + \path let \p1=\labelcoord in coordinate (label-coord) at ($(label-coord)+(\x1,\y1)$);% + }% + %% label style + \tikzset{every node/.style={font=\sffamily,text=\foreground}};% + % + \ifdefstring{\trafficpractice}{left}{% + \tikzset{every node/.append style={left,align=right}};% + }{% + \tikzset{every node/.append style={right,align=left}};% + }% + \ifdefstring{\face}{forward}{% + \tikzset{every node/.append style={rotate=270}};% + }{% + \tikzset{every node/.append style={rotate=90}};% + }% + %% label + \node at (label-coord) {\footnotesize \labelcontent};% + }% + }},% end pics/balise/.style args={#1/#2/#3} % symbology entry - symbology_transmitter_bidirectional/.pic = {% + symbology_balise_group/.pic = {% \maintrack (0,0) -- (6,0);% - \balise[bidirectional] at (3,0) label ();% + \balise[forward] at (2,0) label (A);% + \balise[forward,switched] at (4,0) label (B);% },% - % symbology entry - symbology_loop_transmitter/.pic = {% + symbology_balise_individual/.pic = {% \maintrack (0,0) -- (6,0);% - \transmitter[type=loop] at (3,0) label ();% + \balise[forward,along={0,1,2}] at (2,0) label (A);% + \balise[forward,along switched={0,1,2}] at (4,0) label (B);% },% }% % @@ -636,8 +766,7 @@ \tikzset{every node/.style={font=\sffamily,text=\foreground}};% \coordinate (ts-ma-l) at ($\trafficfactor*\facefactor*(0,-0.6) + \facefactor*(0.3,0)$);% \ifdefstring{\labelcoord}{(none)}{}{% initialize if NOT default - \gettikzxy{\labelcoord}{\labelcoordX}{\labelcoordY}% - \coordinate (ts-ma-l) at ($(ts-ma-l) + (\labelcoordX,\labelcoordY)$);% + \path let \p1=\labelcoord in coordinate (ts-ma-l) at ($(ts-ma-l)+(\x1,\y1)$);% }% \node[\align] at (ts-ma-l) {\footnotesize \labelcontent};% }% @@ -701,8 +830,7 @@ \tikzset{every node/.style={font=\sffamily,text=\foreground}};% \coordinate (ts-bp-l) at ($\trafficfactor*\facefactor*(0,-0.6) + \facefactor*(0.3,0)$);% \ifdefstring{\labelcoord}{(none)}{}{% initialize if NOT default - \gettikzxy{\labelcoord}{\labelcoordX}{\labelcoordY}% - \coordinate (ts-bp-l) at ($(ts-bp-l) + (\labelcoordX,\labelcoordY)$);% + \path let \p1=\labelcoord in coordinate (ts-bp-l) at ($(ts-bp-l)+(\x1,\y1)$);% }% \node[\align] at (ts-bp-l) {\footnotesize \labelcontent};% }% @@ -767,8 +895,7 @@ \tikzset{every node/.style={font=\sffamily,text=\foreground}};% \coordinate (ts-dp-l) at ($\trafficfactor*\facefactor*(0,0.25)$);% \ifdefstring{\labelcoord}{(none)}{}{% initialize if NOT default - \gettikzxy{\labelcoord}{\labelcoordX}{\labelcoordY}% - \coordinate (ts-dp-l) at ($(ts-dp-l)+(\labelcoordX,\labelcoordY)$);% + \path let \p1=\labelcoord in coordinate (ts-dp-l) at ($(ts-dp-l)+(\x1,\y1)$);% }% \node at (ts-dp-l) {\footnotesize \labelcontent};% }% |