%!TEX TS-program = pdflatexmk

% Copyright 2021 Martin Scheidt (Attribution 4.0 International, CC-BY 4.0)
% You are free to copy and redistribute the material in any medium or format. You are free to remix, transform, and build upon the material for any purpose, even commercially. You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits. No warranties are given.

\documentclass{beamer}
\usepackage[
  size=a4,
]{beamerposter}
\beamertemplatenavigationsymbolsempty

\def\ROOT{./..}

\usepackage{material}
\input{\ROOT/handout/figures/signal_aspects.tikz}

\newlength{\trainlength}\setlength{\trainlength}{20cm}
\newlength{\trainheight}\setlength{\trainheight}{3cm}
\newlength{\trainwidth}\setlength{\trainwidth}{4cm}

\tikzset{
  lever_positions/.pic={
    \draw[->,>=latex,line width=1.5pt,green] ( 1.5,0)  .. controls ( 2,-0.5) and ( 3,-0.5) .. ( 3.5,0);
    \draw[->,>=latex,line width=1.5pt,green] ( 4.5,0)  .. controls ( 5,-0.5) and ( 6,-0.5) .. ( 6.5,0);
    \draw[->,>=latex,line width=1.5pt,green] ( 7.5,0)  .. controls ( 8,-0.5) and ( 9,-0.5) .. ( 9.5,0);
    \draw[->,>=latex,line width=1.5pt,green] (10.5,0)  .. controls (11,-0.5) and (12,-0.5) .. (12.5,0);
    \draw[->,>=latex,line width=1.5pt,green] (13.5,0)  .. controls (14,-0.5) and (15,-0.5) .. (15.5,0);
    %
    \draw[<-,>=latex,line width=1.5pt,green] ( 1.5,2)  .. controls ( 2,2.5) and ( 3,2.5) .. ( 3.5,2);
    \draw[<-,>=latex,line width=1.5pt,green] ( 4.5,2)  .. controls ( 5,2.5) and ( 6,2.5) .. ( 6.5,2);
    \draw[<-,>=latex,line width=1.5pt,green] ( 7.5,2)  .. controls ( 8,2.5) and ( 9,2.5) .. ( 9.5,2);
    \draw[<-,>=latex,line width=1.5pt,green] (10.5,2)  .. controls (11,2.5) and (12,2.5) .. (12.5,2);
    \draw[<-,>=latex,line width=1.5pt,green] (13.5,2)  .. controls (14,2.5) and (15,2.5) .. (15.5,2);
    % lever positiions
    \foreach \x in {0,6,12,15}
      \draw [fill=white] (\x,0) rectangle ++(2,2);
    \foreach \x in {3,9} {
      \draw [fill=white] (\x,1.1) rectangle ++(2,0.9);
      \draw [fill=white] (\x,0  ) rectangle ++(2,0.9);
    };
    % labels
    \node[align=center] at ( 1,1.6) {\si{\kilo\metre\per\hour}};
    \node[align=center] at ( 1,1  ) {\Huge $0$};
    \node[align=center] at ( 1,0.3) {\Large \color{blue} $0$
      \IfLanguage{english}{fields}
      \IfLanguage{ngerman}{Felder}
    };
    \node[align=center] at ( 4,0.5) {\Large \color{blue} $0$
      \IfLanguage{english}{fields}
      \IfLanguage{ngerman}{Felder}
    };
    \node[align=center] at ( 4,1.5) {\Large \color{blue} $1$
      \IfLanguage{english}{field}
      \IfLanguage{ngerman}{Feld}
    };
    \node[align=center] at ( 7,1.6) {\si{\kilo\metre\per\hour}};
    \node[align=center] at ( 7,1  ) {\Huge $40$};
    \node[align=center] at ( 7,0.3) {\Large \color{blue} $1$
      \IfLanguage{english}{field}
      \IfLanguage{ngerman}{Feld}
    };
    \node[align=center] at (10,0.5) {\Large \color{blue} $1$
      \IfLanguage{english}{field}
      \IfLanguage{ngerman}{Feld}
    };
    \node[align=center] at (10,1.5) {\Large \color{blue} $2$
      \IfLanguage{english}{fields}
      \IfLanguage{ngerman}{Felder}
    };
    \node[align=center] at (13,1.6) {\si{\kilo\metre\per\hour}};
    \node[align=center] at (13,1  ) {\Huge $80$};
    \node[align=center] at (13,0.3) {\Large \color{blue} $2$
      \IfLanguage{english}{fields}
      \IfLanguage{ngerman}{Felder}
    };
    \node[align=center] at (16,1.6) {\si{\kilo\metre\per\hour}};
    \node[align=center] at (16,1  ) {\Huge $120$};
    \node[align=center] at (16,0.3) {\Large \color{blue} $3$
      \IfLanguage{english}{fields}
      \IfLanguage{ngerman}{Felder}
    };
  };
}

\begin{document}
  \selectlanguage{ngerman} % currently supported: english, ngerman
  \tikzset{every path/.style={ultra thick}}
  \begin{frame}
    \begin{tikzpicture}[font=\sffamily]
      \coordinate (base) at (0,0);
      % coordinates
      \path ([shift={(base)}] 0,0) coordinate (A3)
            -- ++(0,-\trainheight) coordinate (A4)
            -- ++(\trainlength, 0) coordinate (A1)
            -- ++(0, \trainheight) coordinate (A2);
      \path (A2) -- ++ ( 1,-1) coordinate (A5);
      \path (A1) -- ++ ( 1, 1) coordinate (A6);
      \path ([shift={(base)}] 0,0) coordinate (B3)
            -- ++(0, \trainwidth)  coordinate (B4)
            -- ++(-\trainheight,0) coordinate (B7)
            -- ++(0,-\trainwidth)  coordinate (B8);
      \path (B4) -- ++ (-1, 1) coordinate (B5);
      \path (B7) -- ++ ( 1, 1) coordinate (B6);
      \path (B8) -- ++ ( 1,-1) coordinate (B1);
      \path (B3) -- ++ (-1,-1) coordinate (B2);
      \path ([shift={(base)}] 0,0) coordinate (C3)
            -- ++(0, \trainwidth)  coordinate (C4)
            -- ++(\trainlength, 0) coordinate (C1)
            -- ++( 0.375\trainwidth,-0.5\trainwidth) coordinate (C5)
            -- ++(-0.375\trainwidth,-0.5\trainwidth) coordinate (C2);
      \path (C4)                    coordinate (D4)
            -- ++(0, \trainheight)  coordinate (D3)
            -- ++(\trainlength, 0)  coordinate (D2)
            -- ++(0,-\trainheight)  coordinate (D1);
      \path (D1)                    coordinate (E1)
            -- ++(0, \trainheight)  coordinate (E2)
            -- ++(0.625\trainwidth, 0) coordinate (E3)
            -- ++(0,-\trainheight)  coordinate (E4)
            -- ++(-1,-1)       coordinate (E5);
      \path (E1) -- ++ ( 1,-1) coordinate (E6);
      \path (E4)                    coordinate (F4)
            -- ++(0, \trainheight)  coordinate (F3)
            -- ++(0.625\trainwidth, 0) coordinate (F2)
            -- ++(0,-\trainheight)  coordinate (F1)
            -- ++(-1,-1)       coordinate (F6);
      \path (F4) -- ++ ( 1,-1) coordinate (F5);
      % drawing
      \draw (A2) rectangle (A4);
      \draw (B4) rectangle (B8);
      \draw (C2) -- (C3) -- (C4) -- (C1) -- (C5) -- cycle;
      \draw (D1) rectangle (D3);
      \draw (E2) rectangle (E4);
      \draw (F2) rectangle (F4);
      % labels
      \pic[scale=0.75] at (0.1\trainlength,0.35\trainwidth) {lever_positions};
      \draw ([shift={(base)}] 1,0)
            -- (0,0.5\trainwidth)
            -- (1,\trainwidth)
            -- cycle;
      \node[rotate=90] at (0.03\trainlength,0.5\trainwidth) {
        \IfLanguage{english}{\Large Coupling}
        \IfLanguage{ngerman}{\Large Kupplung}
      };
      % adhesive edge
      \tikzset{every path/.style={thin,base1}}
      \draw (A2) -- (A5) -- (A6) -- (A1);
      \draw (B4) -- (B5) -- (B6) -- (B7);
      \draw (B8) -- (B1) -- (B2) -- (B3);
      \draw (E1) -- (E6) -- (E5) -- (E4);
      \draw (F1) -- (F6) -- (F5) -- (F4);
      %
    \end{tikzpicture}
    \input{\ROOT/handout/frontmatter/copyright.tex}
  \end{frame}
  \begin{frame}
    \begin{tikzpicture}[font=\sffamily]
      \coordinate (base) at (0,0);
      % coordinates
      \path ([shift={(base)}] 0,0) coordinate (A3)
            -- ++(0,-\trainheight) coordinate (A4)
            -- ++(\trainlength, 0) coordinate (A1)
            -- ++(0, \trainheight) coordinate (A2);
      \path ([shift={(base)}] 0,0) coordinate (B3)
            -- ++(0, \trainwidth)  coordinate (B4)
            -- ++(-\trainheight,0) coordinate (B7)
            -- ++(0,-\trainwidth)  coordinate (B8);
      \path (B4) -- ++ (-1, 1) coordinate (B5);
      \path (B7) -- ++ ( 1, 1) coordinate (B6);
      \path (B8) -- ++ ( 1,-1) coordinate (B1);
      \path (B3) -- ++ (-1,-1) coordinate (B2);
      \path ([shift={(base)}] 0,0) coordinate (C3)
            -- ++(0, \trainwidth)  coordinate (C4)
            -- ++(\trainlength, 0) coordinate (C1)
            -- ++(0,-\trainwidth)  coordinate (C2);
      \path (C2) coordinate (D2)
            -- ++(0, \trainwidth)  coordinate (D1)
            -- ++( \trainheight,0) coordinate (D6)
            -- ++(0,-\trainwidth)  coordinate (D5);
      \path (D6) -- ++ (-1, 1) coordinate (D7);
      \path (D1) -- ++ ( 1, 1) coordinate (D8);
      \path (D2) -- ++ ( 1,-1) coordinate (D3);
      \path (D5) -- ++ (-1,-1) coordinate (D4);
      \path (C4)                    coordinate (E4)
            -- ++(0, \trainheight)  coordinate (E3)
            -- ++(\trainlength, 0)  coordinate (E2)
            -- ++(0,-\trainheight)  coordinate (E1);
      % drawing
      \draw (A2) rectangle (A4);
      \draw (B4) rectangle (B8);
      \draw (C2) rectangle (C4);
      \draw (D1) rectangle (D5);
      \draw (E2) rectangle (E4);
      % labels
      \pic at (-0.5\trainheight,0.5\trainwidth) {end_of_train};
      \draw ([shift={(base)}] \trainlength,0.5\trainwidth)
            -- ++(-1,0.5\trainwidth)
            -- ++(0,-\trainwidth)
            -- cycle;
      \node[rotate=-90] at (0.97\trainlength,0.5\trainwidth) {
        \IfLanguage{english}{\Large Coupling}
        \IfLanguage{ngerman}{\Large Kupplung}
      };
      % adhesive edge
      \tikzset{every path/.style={thin,base1}}
      \draw (B4) -- (B5) -- (B6) -- (B7);
      \draw (B8) -- (B1) -- (B2) -- (B3);
      \draw (D2) -- (D3) -- (D4) -- (D5);
      \draw (D1) -- (D8) -- (D7) -- (D6);
      %
    \end{tikzpicture}
  \end{frame}
  \begin{frame}
    \IfLanguage{english}{\Huge \textcolor{blue}{Control Lever:}}
    \IfLanguage{ngerman}{\Huge \textcolor{blue}{Schalthebelpositionen:}}\\
    \begin{tikzpicture}[font=\sffamily]
      \begin{scope}[scale=1.5,transform shape]
        \pic at (0,0) {lever_positions};
     \end{scope}
    \end{tikzpicture}
    \vfill\input{\ROOT/handout/tables/game_procedure.tex}
  \end{frame}
\end{document}