summaryrefslogtreecommitdiff
path: root/graphics/pgf/base/tex/tikzlibraryautomata.code.tex
blob: 690e0fd63a6da38d9c4a6a890e6d59bdc94a3f1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
% 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