I have defined 2 decorations with this code:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\thispagestyle{empty}
\usetikzlibrary{decorations}
\tikzset{%
pneumatic signal/.style={%
decoration={%
pneumatic signal decoration,
segment length=6pt,
amplitude=3pt
},
very thin,
decorate
}
}
\tikzset{%
system signal/.style={%
decoration={%
system signal decoration,
segment length=10pt,
amplitude=5pt
},
very thin,
decorate
}
}
\makeatletter
\pgfdeclaredecoration{pneumatic signal decoration}{line}
{%
\state{line}[width=+\pgfdecorationsegmentlength,next state=tick,%
switch if input segment less than=.5\pgfdecorationsegmentlength %
to segment 1,%
switch if input segment less than=+\pgfdecorationsegmentlength %
to segment 2]{%
\pgfpathlineto{\pgf@x=+\pgfdecorationsegmentlength \pgf@y=0pt}
}
\state{tick}[width=1.6\pgfdecorationsegmentamplitude,next state=line,
switch if input segment less than=1.2\pgfdecorationsegmentamplitude%
to segment 2]{%
\pgfpathlineto{\pgf@x=1.6\pgfdecorationsegmentamplitude \pgf@y=0pt}
\pgfpathmoveto{\pgf@x=0pt \pgf@y=-.5\pgfdecorationsegmentamplitude}
\pgfpathlineto{\pgf@x=+\pgfdecorationsegmentamplitude
\pgf@y=.5\pgfdecorationsegmentamplitude}
\pgfpathmoveto{\pgf@x=.6\pgfdecorationsegmentamplitude
\pgf@y=-.5\pgfdecorationsegmentamplitude}
\pgfpathlineto{\pgf@x=1.6\pgfdecorationsegmentamplitude
\pgf@y=.5\pgfdecorationsegmentamplitude}
\pgfpathmoveto{\pgf@x=1.6\pgfdecorationsegmentamplitude \pgf@y=0pt}
}
\state{segment 1}[next state=line,%
width=+\pgfdecoratedinputsegmentremainingdistance]{%
\pgfpathlineto{\pgfpointdecoratedinputsegmentlast}
}
\state{segment 2}[next state=segment 3,%
width=+\pgfdecoratedinputsegmentremainingdistance]{%
\pgfpathlineto{\pgfpointdecoratedinputsegmentlast}
}
\state{segment 3}[next state=tick,%
width=.2\pgfdecorationsegmentlength,
switch if input segment less than=.2\pgfdecorationsegmentlength %
to segment 2]{%
\pgfpathlineto{\pgf@x=.2\pgfdecorationsegmentlength \pgf@y=0pt}
}
\state{final}{%
\pgfpathlineto{\pgfpointdecoratedpathlast}
}
}
\pgfdeclaredecoration{system signal decoration}{line}
{%
\state{line}[width=+\pgfdecorationsegmentlength,next state=symbol,%
switch if input segment less than=.5\pgfdecorationsegmentlength %
to segment 1,%
switch if input segment less than=+\pgfdecorationsegmentlength %
to segment 2]{%
\pgfpathlineto{\pgf@x=+\pgfdecorationsegmentlength \pgf@y=0pt}
}
\state{symbol}[width=+\pgfdecorationsegmentamplitude,next state=line,
switch if input segment less than=+\pgfdecorationsegmentamplitude%
to segment 2]{%
\pgfpathcircle{\pgf@x=.5\pgfdecorationsegmentamplitude \pgf@y=0pt}
{.5\pgfdecorationsegmentamplitude}
\pgfpathcircle{\pgf@x=.5\pgfdecorationsegmentamplitude \pgf@y=0pt}
{.25\pgfdecorationsegmentamplitude}
\pgfpathmoveto{\pgf@x=+\pgfdecorationsegmentamplitude \pgf@y=0pt}
}
\state{segment 1}[next state=line,%
width=+\pgfdecoratedinputsegmentremainingdistance]{%
\pgfpathlineto{\pgfpointdecoratedinputsegmentlast}
}
\state{segment 2}[next state=segment 3,%
width=+\pgfdecoratedinputsegmentremainingdistance]{%
\pgfpathlineto{\pgfpointdecoratedinputsegmentlast}
}
\state{segment 3}[next state=symbol,%
width=.2\pgfdecorationsegmentlength,
switch if input segment less than=.2\pgfdecorationsegmentlength %
to segment 2]{%
\pgfpathlineto{\pgf@x=.2\pgfdecorationsegmentlength \pgf@y=0pt}
}
\state{final}{%
\pgfpathlineto{\pgfpointdecoratedpathlast}
}
}
\makeatother
\tikz\draw[->,pneumatic signal] (0,0) -- (2,0);
\tikz\draw[->,system signal] (0,0) -- (2,0);
\end{document}
My problem is that I can't draw a path terminated by an arrow with the "system signal" decoration. Although the code is quite the same, I do not understand why the "pneumatic signal" decoration is working and not the "system signal" one. What do I miss?
Edit: add missing MWE code as requested (sorry...)
Edit2: problematic decoration code added