[Tex/LaTex] How to create a tikzstyle for special edges, like transfer and rest arcs

tikz-pgftikz-styles

I need for petri nets some special edges for arcs:

  1. Reset arc
    • which has an cross at Place
  2. Transfer arc
    • which has an dashed edge from place to place and an snaked edge from transition to dashed edge.

reset and transfer arc

This is what I have so far:

\documentclass{article}
\def\xcolorversion{2.00}
\def\xkeyvalversion{1.8}

% allows drawing of petri nets
\usepackage[version=0.96]{pgf}
\usepackage{tikz}
\usetikzlibrary{arrows,decorations.pathmorphing, decorations.markings,shapes,snakes,automata,backgrounds,petri}
% Petri net definition for tikz
\tikzstyle{place}=[circle,thick,draw=blue!75,fill=blue!20,minimum size=6mm]
\tikzstyle{transition}=[rectangle,thick,draw=black!75,
              fill=black!20,minimum size=4mm]
\tikzstyle{every label}=[red]

\pgfarrowsdeclare{x}{x}
{
\arrowsize=0.2pt
\advance\arrowsize by .5\pgflinewidth
\pgfarrowsleftextend{-4\arrowsize-.5\pgflinewidth}
\pgfarrowsrightextend{.5\pgflinewidth}
}
{
\arrowsize=0.2pt
\advance\arrowsize by .5\pgflinewidth
\pgfsetdash{}{0pt} % do not dash
\pgfsetroundjoin
% fix join
\pgfsetroundcap
% fix cap
\pgfpathmoveto{\pgfpoint{-6\arrowsize}{6\arrowsize}}
\pgfpatharc{180}{270}{6\arrowsize}
\pgfusepathqstroke
\pgfpathmoveto{\pgfpointorigin}
\pgfpatharc{90}{180}{6\arrowsize}
\pgfusepathqstroke
\pgfpathmoveto{\pgfpoint{6\arrowsize}{-6\arrowsize}}
\pgfpatharc{180}{270}{-6\arrowsize}
\pgfusepathqstroke
\pgfpathmoveto{\pgfpointorigin}
\pgfpatharc{90}{180}{-6\arrowsize}
\pgfusepathqstroke
}

\tikzstyle{normal}=[->]
\tikzstyle{read}=[-]
\tikzstyle{reset}=[-*]
\tikzstyle{inhibitor}=[-o]
\tikzstyle{transfer}=[-x]

\usepackage[latin1]{inputenc}
\begin{document}


\begin{tikzpicture}[node distance=1.3cm,>=stealth',bend angle=45,auto]
  \begin{scope}[xshift=10cm]
    \node [place,tokens=1]
                      (p1') [label=right:$p_1$]                 {};
    \node [place,tokens=1]
                      (p2') [below of=p1', label=left:$p_2$]    {};

    \node [transition] (t1') [right of=p1'] {}
      edge [pre, inhibitor, bend left]                  (p1')
      edge [post, bend left]                            (p2')
      edge [post, reset, bend right] node[swap]     {3} (p1');

    \node [transition] (t2') [left of=p2'] {}
      edge [pre, normal, bend left]     node [auto] {2} (p2')
      edge [post, read, bend right]         (p2')
      edge [post, transfer, bend left, snake=snake]     node [auto] {2} (p1');
  \end{scope}
\end{tikzpicture}

\end{document}

I'm very new to Latex and tikz. Hope someone can help me.

Regards.

Best Answer

For question 1, you can use markings:

reset arc/.style = {
        decoration={markings,mark=at position #1 with {
           \draw (-2pt,-2pt) -- (2pt,2pt);
           \draw (2pt,-2pt) -- (-2pt,2pt);
           }
           },
           postaction={decorate,draw}},

And for second, you have to declare a coordinate in the middle:

\draw[Dash] (a)   ->  (c) coordinate[midway] (d);

And then use that coordinate (d) as in

\draw [Snake] (d) -- +(-1cm,0);

And the styles will be:

Dash/.style={dashed,  
      -latex
   },
Snake/.style={
      decoration={snake, amplitude=+2pt, segment length=+2pt}, 
      decorate
   },

Full code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,decorations.pathmorphing, decorations.markings}

\tikzset{
    reset arc/.style = {
    decoration={markings,mark=at position #1 with {
       \draw (-2pt,-2pt) -- (2pt,2pt);
       \draw (2pt,-2pt) -- (-2pt,2pt);
       }
       },
       postaction={decorate,draw}},
    Dash/.style={dashed,  
          -latex
       },
    Snake/.style={
          decoration={snake, amplitude=+2pt, segment length=+2pt}, 
          decorate
       },
}

\begin{document}
\begin{tikzpicture}
\coordinate (a) at (0,0);
\coordinate (b) at (1,0);
\coordinate (c) at (0,1);
\draw[reset arc=.9] (a)   --  (b) ;
\draw[Dash] (a)   ->  (c) coordinate[midway] (d);
\draw [Snake] (d) -- +(-1cm,0);
\end{tikzpicture}

\end{document}

enter image description here