Debian Codegraph @

texmf-dist/tex/latex/tikz-sfc/tikzlibrarycircuits.plc.sfc.code.tex

raw
1 %% This is file `tikzlibrarycircuits.plc.sfc.code.tex'
2 %% Version: 1.0.1
3 %% Version date: 2018-12-15
4 %%
5 %% Copyright (C) 2018 by Luis Paulo Laus, [email protected]
6 %%
7 %% This package can be redistributed and/or modified under the terms
8 %% of the LaTeX Project Public License distributed from CTAN
9 %% archives in directory macros/latex/base/lppl.txt; either
10 %% version 1 of the License, or (at your option) any later version,
11 %% with `The Package' referring to the software
12 %% `tikzlibrarycircuits.plc.sfc.code.tex'
13 %% and its accompanying documentation and `The Copyright Holder'
14 %% referring to the person Luis Paulo Laus.
15 %%
16 %%
17 %% IMPORTANT NOTICE:
18 %%
19 %% For error reports, comments or suggestions in case of UNCHANGED
20 %% versions send mail to:
21 %% [email protected]
22 %%
23 %%
24 %% Change History:
25 %% 1.0: 16 January 2018: Original Version
26 %% 1.0.1: 15 December 2018: correction and extension of documentation
27 %% including a new full example.
28 %%
29 \usetikzlibrary{circuits}
30 \usepgflibrary{shapes.gates.ee}
31 \makeatletter
32 \newcount\sfc@act@pos
33 \def\tikz@lib@sfc@lct@plain[#1]#2\pgf@stop{\tikzset{label={[label position=center,every info/.try,#1]#2}}}
34 \def\tikz@lib@sfc@lrg@plain[#1]#2\pgf@stop{\tikzset{label={[label position=right,every info/.try,#1]#2}}}
35 \def\tikz@lib@sfc@llf@plain[#1]#2\pgf@stop{\tikzset{label={[label position=left,every info'/.try,#1]#2}}}
36 \def\tikz@lib@sfc@action@lrg@plain[#1]#2\pgf@stop{\tikzset{sfc@actcommentopt/.style={#1},sfc@actcomment=#2}}
37 \def\tikz@lib@sfc@action@lct@plain[#1]#2\pgf@stop{\tikzset{sfc@actnameopt/.style={#1},sfc@actname=#2}}
38
39 \pgfdeclareshape{sfcstepi}
40 {
41 \inheritsavedanchors[from=rectangle]
42 \inheritanchorborder[from=rectangle]
43 \inheritanchor[from=rectangle]{north}
44 \inheritanchor[from=rectangle]{north west}
45 \inheritanchor[from=rectangle]{north east}
46 \inheritanchor[from=rectangle]{center}
47 \inheritanchor[from=rectangle]{west}
48 \inheritanchor[from=rectangle]{east}
49 \inheritanchor[from=rectangle]{mid}
50 \inheritanchor[from=rectangle]{mid west}
51 \inheritanchor[from=rectangle]{mid east}
52 \inheritanchor[from=rectangle]{base}
53 \inheritanchor[from=rectangle]{base west}
54 \inheritanchor[from=rectangle]{base east}
55 \inheritanchor[from=rectangle]{south}
56 \inheritanchor[from=rectangle]{south west}
57 \inheritanchor[from=rectangle]{south east}
58 \inheritbackgroundpath[from=rectangle]
59 \behindbackgroundpath{
60 \pgfpathrectanglecorners
61 {\pgfpointadd{\southwest}{\pgfpoint{6*\pgfkeysvalueof{/pgf/inner xsep}}{6*\pgfkeysvalueof{/pgf/inner ysep}}}}
62 {\pgfpointadd{\northeast}{\pgfpointscale{-1}{\pgfpoint{6*\pgfkeysvalueof{/pgf/inner xsep}}{6*\pgfkeysvalueof{/pgf/inner ysep}}}}}
63 }
64 }
65
66 %% Really dirt trick to customize info and info' keys in an action.
67 \def\sfc@copycode#1#2{
68 \pgfkeyssetvalue{/tikz/#1/.@cmd}{\expandafter\pgfkeysvalueof{/tikz/#2/.@cmd}}%
69 \pgfkeyssetvalue{/tikz/#1/.@body}{\expandafter\pgfkeysvalueof{/tikz/#2/.@body}}%
70 }
71
72 \tikzset{
73 circuit plc sfc/.style=
74 {
75 circuit,
76 circuit declare symbol=sfctransition,
77 sfc@actinfo/.code={\pgfutil@ifnextchar[\tikz@lib@sfc@action@lct@plain{\tikz@lib@sfc@action@lct@plain[]}##1\pgf@stop},
78 sfc@actinfo'/.code={\pgfutil@ifnextchar[\tikz@lib@sfc@action@lrg@plain{\tikz@lib@sfc@action@lrg@plain[]}##1\pgf@stop},
79 set sfctransition graphic={draw,fill,shape=rectangle,circuit symbol size=width 1 height 0,
80 info/.code={\pgfutil@ifnextchar[\tikz@lib@sfc@lrg@plain{\tikz@lib@sfc@lrg@plain[]}####1\pgf@stop},
81 info'/.code={\pgfutil@ifnextchar[\tikz@lib@sfc@llf@plain{\tikz@lib@sfc@llf@plain[]}####1\pgf@stop}},
82 sfcaqw/.initial=0\tikzcircuitssizeunit, % qualifier width
83 sfcanw/.initial=2.6\tikzcircuitssizeunit, % action name width
84 sfcah/.initial=2.6\tikzcircuitssizeunit, % action height
85 time/.initial=, % action duration to be used with qualifier D, L, DS, SD, LS
86 qualifier/.initial=, % action qualifier
87 sfc@actname/.initial=, % action name
88 sfc@actnameopt/.style=, % action name options
89 sfc@actcomment/.initial=, % action comment
90 sfc@actcommentopt/.style=, % action comment options
91 circuit declare symbol=sfcstep,
92 set sfcstep graphic={draw,shape=rectangle,minimum size=2.6\tikzcircuitssizeunit,
93 /utils/exec={\global\sfc@act@pos=0},
94 info/.code={\pgfutil@ifnextchar[\tikz@lib@sfc@lct@plain{\tikz@lib@sfc@lct@plain[]}####1\pgf@stop},
95 info'/.code={\pgfutil@ifnextchar[\tikz@lib@sfc@llf@plain{\tikz@lib@sfc@llf@plain[]}####1\pgf@stop}},
96 circuit declare symbol=sfcstepi,
97 set sfcstepi graphic={draw,shape=sfcstepi,minimum size=2.6\tikzcircuitssizeunit,
98 /utils/exec={\global\sfc@act@pos=0},
99 info/.code={\pgfutil@ifnextchar[\tikz@lib@sfc@lct@plain{\tikz@lib@sfc@lct@plain[]}####1\pgf@stop},
100 info'/.code={\pgfutil@ifnextchar[\tikz@lib@sfc@llf@plain{\tikz@lib@sfc@llf@plain[]}####1\pgf@stop}},
101 circuit declare symbol=sfcstar,
102 set sfcstar graphic={shape=circle,label={center:$*$},minimum size=1.2ex},
103 sfcaction/.style={
104 append after command={%
105 \bgroup
106 [current point is local=true]
107 [every circuit annotation/.try]
108 [annotation arrow,-]
109 [label distance=2\tikzcircuitssizeunit]
110 [/utils/exec={\sfc@copycode{info}{sfc@actinfo}\sfc@copycode{info'}{sfc@actinfo'}}]
111 [/utils/exec={\pgftransformresetnontranslations}]
112 edge[every sfcaction/.try, ##1, to path={%
113 \ifnum\sfc@act@pos=0%
114 (\tikzlastnode.east) -- ++(\tikz@label@distance,0)
115 \else%
116 ($(\tikzlastnode.east) + (\tikz@label@distance,-\the\sfc@act@pos*\pgfkeysvalueof{/tikz/sfcah})$)
117 \fi%
118 \pgfextra{\edef\pgf@testq{\pgfkeysvalueof{/tikz/qualifier}} \edef\pgf@testt{\pgfkeysvalueof{/tikz/time}} \edef\pgf@testc{\pgfkeysvalueof{/tikz/sfc@actcomment}}}%
119 \ifx\pgf@testq\pgfutil@empty
120 node[/utils/exec={\global\advance\sfc@act@pos by1\relax},##1,every sfcactionname/.try,sfc@actnameopt/.try,draw,right,minimum height=\pgfkeysvalueof{/tikz/sfcah},
121 minimum width=\pgfkeysvalueof{/tikz/sfcaqw}+\pgfkeysvalueof{/tikz/sfcanw}]{\pgfkeysvalueof{/tikz/sfc@actname}}
122 \ifx\pgf@testc\pgfutil@empty \else
123 node[every info'/.try,sfc@actcommentopt/.try,right,xshift=\pgfkeysvalueof{/tikz/sfcaqw}+\pgfkeysvalueof{/tikz/sfcanw}]{\pgfkeysvalueof{/tikz/sfc@actcomment}}
124 \fi
125 \else
126 \ifx\pgf@testt\pgfutil@empty
127 node[/utils/exec={\global\advance\sfc@act@pos by1\relax},every sfcactionname/.try,##1,sfc@actnameopt/.try,draw,right,xshift=\pgfkeysvalueof{/tikz/sfcaqw},
128 minimum height=\pgfkeysvalueof{/tikz/sfcah},minimum width=\pgfkeysvalueof{/tikz/sfcanw}]{\pgfkeysvalueof{/tikz/sfc@actname}}
129 node[every sfcqualifier/.try,##1,draw,right,minimum height=\pgfkeysvalueof{/tikz/sfcah},
130 minimum width=\pgfkeysvalueof{/tikz/sfcaqw}]{\pgfkeysvalueof{/tikz/qualifier}}
131 \ifx\pgf@testc\pgfutil@empty \else
132 node[every info'/.try,sfc@actcommentopt/.try,right,xshift=\pgfkeysvalueof{/tikz/sfcaqw}+\pgfkeysvalueof{/tikz/sfcanw}]{\pgfkeysvalueof{/tikz/sfc@actcomment}}
133 \fi
134 \else
135 node[/utils/exec={\global\advance\sfc@act@pos by2\relax},##1,draw,right,yshift=-0.5*\pgfkeysvalueof{/tikz/sfcah}),
136 minimum height=2*\pgfkeysvalueof{/tikz/sfcah},minimum width=\pgfkeysvalueof{/tikz/sfcaqw}]{}
137 node[every sfcactionname/.try,##1,sfc@actnameopt/.try,draw,right,xshift=\pgfkeysvalueof{/tikz/sfcaqw},yshift=-0.5*\pgfkeysvalueof{/tikz/sfcah},
138 minimum height=2*\pgfkeysvalueof{/tikz/sfcah},minimum width=\pgfkeysvalueof{/tikz/sfcanw}]{\pgfkeysvalueof{/tikz/sfc@actname}}
139 node[every sfcqualifier/.try,right,minimum height=\pgfkeysvalueof{/tikz/sfcah},
140 minimum width=\pgfkeysvalueof{/tikz/sfcaqw}]{\pgfkeysvalueof{/tikz/qualifier}}
141 node[every sfctime/.try,right,yshift=-\pgfkeysvalueof{/tikz/sfcah},minimum height=\pgfkeysvalueof{/tikz/sfcah},
142 minimum width=\pgfkeysvalueof{/tikz/sfcaqw}]{\pgfkeysvalueof{/tikz/time}}
143 \ifx\pgf@testc\pgfutil@empty \else
144 node[every info'/.try,sfc@actcommentopt/.try,right,xshift=\pgfkeysvalueof{/tikz/sfcaqw}+\pgfkeysvalueof{/tikz/sfcanw},
145 yshift=-0.5*\pgfkeysvalueof{/tikz/sfcah}]{\pgfkeysvalueof{/tikz/sfc@actcomment}}
146 \fi
147 \fi
148 \fi
149 }] ()
150 \tikz@after@path%
151 \egroup%
152 }
153 },
154 circuit declare symbol=flow direction,
155 circuit declare symbol=flow direction',
156 set flow direction graphic = flow direction sfc graphic,
157 set flow direction' graphic = flow direction' sfc graphic,
158 flow direction sfc graphic/.style = {
159 shape=direction ee,
160 circuit symbol filled,
161 flow direction arrow,
162 minimum width = .5*\the\tikzcircuitssizeunit+.3*\the\pgflinewidth,
163 minimum height = .5*\the\tikzcircuitssizeunit+.3*\the\pgflinewidth,
164 transform shape
165 },
166 flow direction' sfc graphic/.style = {
167 flow direction sfc graphic,
168 rotate=180
169 },
170 flow direction arrow/.style = {
171 /utils/exec={\pgfsetarrowoptions{direction ee}{1.3065*.5*\the\tikzcircuitssizeunit+1.3065*.3*\the\pgflinewidth}},
172 >=direction ee,
173 direction ee arrow = direction ee,
174 },
175 every circuit plc sfc/.try
176 }
177 }
178 \makeatother
179
180 \endinput