% Copyright 2018 by Till Tantau
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.
%
% See the file doc/generic/pgf/licenses/LICENSE for more details.

\ProvidesFileRCS{tikzlibraryautomata.code.tex}

\usetikzlibrary{shapes.multipart}%

% Styles for states:

\tikzset{every state/.style=           {}}%

\tikzset{state without output/.style=  {circle,draw,minimum size=2.5em,every state}}%
\tikzset{state with output/.style=     {circle split,draw,minimum size=2.5em,every state}}%

\tikzset{accepting by arrow/.style=    {after node path=
{
  {
    [to path=
    {
      [->,double=none,every accepting by arrow]
      --
      ([shift=(\tikz@accepting@angle:\tikz@accepting@distance)]\tikztostart.\tikz@accepting@angle)
          node [shape=rectangle,anchor=\tikz@accepting@anchor] {\tikz@accepting@text}
      }]
    edge ()
  }
}}}%
\tikzset{every accepting by arrow/.style={}}%
\tikzset{accepting by double/.style= {double,outer sep=.5\pgflinewidth+.3pt}} % .3pt is half double width distance

\tikzset{initial by arrow/.style=    {after node path=
{
  {
    [to path=
    {
      [->,double=none,every initial by arrow]
      ([shift=(\tikz@initial@angle:\tikz@initial@distance)]\tikztostart.\tikz@initial@angle)
          node [shape=rectangle,anchor=\tikz@initial@anchor] {\tikz@initial@text}
        -- (\tikztostart)}]
    edge ()
  }
}}}%
\tikzset{every initial by arrow/.style={}}%

\tikzset{initial by diamond/.style={shape=diamond}}%


\tikzoption{initial text}{\tikzaddafternodepathoption{\def\tikz@initial@text{#1}}}%
\tikzoption{accepting text}{\tikzaddafternodepathoption{\def\tikz@accepting@text{#1}}}%

\tikzoption{initial where}{\tikzaddafternodepathoption{\csname tikz@initial@compute@#1\endcsname}}%
\tikzoption{accepting where}{\tikzaddafternodepathoption{\csname tikz@accepting@compute@#1\endcsname}}%

\tikzoption{initial distance}{\tikzaddafternodepathoption{\def\tikz@initial@distance{#1}}}%
\tikzoption{accepting distance}{\tikzaddafternodepathoption{\def\tikz@accepting@distance{#1}}}%

\def\tikz@initial@text{start}%
\def\tikz@accepting@text{}%

\def\tikz@initial@distance{3ex}%
\def\tikz@accepting@distance{3ex}%

\def\tikz@initial@compute@above{\def\tikz@initial@angle{90}\def\tikz@initial@anchor{south}}%
\def\tikz@initial@compute@below{\def\tikz@initial@angle{270}\def\tikz@initial@anchor{north}}%
\def\tikz@initial@compute@left{\def\tikz@initial@angle{180}\def\tikz@initial@anchor{east}}%
\def\tikz@initial@compute@right{\def\tikz@initial@angle{0}\def\tikz@initial@anchor{west}}%

\def\tikz@initial@angle{180}%
\def\tikz@initial@anchor{east}%

\def\tikz@accepting@compute@above{\def\tikz@accepting@angle{90}\def\tikz@accepting@anchor{south}}%
\def\tikz@accepting@compute@below{\def\tikz@accepting@angle{270}\def\tikz@accepting@anchor{north}}%
\def\tikz@accepting@compute@left{\def\tikz@accepting@angle{180}\def\tikz@accepting@anchor{east}}%
\def\tikz@accepting@compute@right{\def\tikz@accepting@angle{0}\def\tikz@accepting@anchor{west}}%

\def\tikz@accepting@angle{0}%
\def\tikz@accepting@anchor{west}%


\tikzset{initial above/.style=        {initial by arrow,initial where=above}}%
\tikzset{initial below/.style=        {initial by arrow,initial where=below}}%
\tikzset{initial left/.style=         {initial by arrow,initial where=left}}%
\tikzset{initial right/.style=        {initial by arrow,initial where=right}}%

\tikzset{accepting above/.style=      {accepting by arrow,accepting where=above}}%
\tikzset{accepting below/.style=      {accepting by arrow,accepting where=below}}%
\tikzset{accepting left/.style=       {accepting by arrow,accepting where=left}}%
\tikzset{accepting right/.style=      {accepting by arrow,accepting where=right}}%


% Defaults:

\tikzset{state/.style=                {state without output}}%
\tikzset{accepting/.style=            {accepting by double}}%
\tikzset{initial/.style=              {initial by arrow}}%



\endinput
