-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
pgflibraryshapes.gates.pid.code.tex
168 lines (157 loc) · 5.39 KB
/
pgflibraryshapes.gates.pid.code.tex
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
% MIT License
%
% Copyright (c) 2018 Jelle Spijker
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
% of this software and associated documentation files (the "Software"), to deal
% in the Software without restriction, including without limitation the rights
% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
% copies of the Software, and to permit persons to whom the Software is
% furnished to do so, subject to the following conditions:
%
% The above copyright notice and this permission notice shall be included in all
% copies or substantial portions of the Software.
%
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
% SOFTWARE.
%
% Base shapes
%
% These shapes are identical to the shapes without "pid", only an "input"
% and an "output" anchor have been added at the left and right end.
\pgfdeclareshape{rectangle pid}
{
\inheritsavedanchors[from=rectangle]
\inheritanchorborder[from=rectangle]
\inheritanchor[from=rectangle]{north}
\inheritanchor[from=rectangle]{north west}
\inheritanchor[from=rectangle]{north east}
\inheritanchor[from=rectangle]{center}
\inheritanchor[from=rectangle]{west}
\inheritanchor[from=rectangle]{east}
\inheritanchor[from=rectangle]{mid}
\inheritanchor[from=rectangle]{mid west}
\inheritanchor[from=rectangle]{mid east}
\inheritanchor[from=rectangle]{base}
\inheritanchor[from=rectangle]{base west}
\inheritanchor[from=rectangle]{base east}
\inheritanchor[from=rectangle]{south}
\inheritanchor[from=rectangle]{south west}
\inheritanchor[from=rectangle]{south east}
\inheritbackgroundpath[from=rectangle]
\anchor{input}{
\pgf@process{\northeast}%
\pgf@ya=.5\pgf@y%
\pgf@process{\southwest}%
\pgf@y=.5\pgf@y%
\advance\pgf@y by \pgf@ya%
}
\anchor{output}{%
\pgf@process{\southwest}%
\pgf@ya=.5\pgf@y%
\pgf@process{\northeast}%
\pgf@y=.5\pgf@y%
\advance\pgf@y by \pgf@ya%
}
}
\pgfdeclareshape{circle pid}
{
\inheritsavedanchors[from=circle]
\inheritanchorborder[from=circle]
\inheritanchor[from=circle]{north}
\inheritanchor[from=circle]{north west}
\inheritanchor[from=circle]{north east}
\inheritanchor[from=circle]{center}
\inheritanchor[from=circle]{west}
\inheritanchor[from=circle]{east}
\inheritanchor[from=circle]{mid}
\inheritanchor[from=circle]{mid west}
\inheritanchor[from=circle]{mid east}
\inheritanchor[from=circle]{base}
\inheritanchor[from=circle]{base west}
\inheritanchor[from=circle]{base east}
\inheritanchor[from=circle]{south}
\inheritanchor[from=circle]{south west}
\inheritanchor[from=circle]{south east}
\inheritbackgroundpath[from=circle]
% New:
\anchor{input}{\centerpoint\advance\pgf@x by-\radius}
\anchor{output}{\centerpoint\advance\pgf@x by\radius}
}
% Flow direction indicator. This shape uses the current setting of
% the flow direction arrow tip for the arrow. The shape is a
% rectangle around the arrow tip.
\pgfdeclareshape{direction pid}
{
\savedanchor\northeast{
\pgf@x=0pt%
% Height is given by minimum height/2
\pgfmathsetlength{\pgf@y}{\pgfkeysvalueof{/pgf/minimum height}}%
\pgf@y=.5\pgf@y
}
\savedanchor\southwest{
% Left border is given by left extend
\pgfarrowtotallength{\pgfkeysvalueof{/pgf/direction pid arrow}}%
\pgf@x=-\pgf@x%
% Height is given by minimum height/2
\pgfmathsetlength{\pgf@y}{\pgfkeysvalueof{/pgf/minimum height}}%
\pgf@y=-.5\pgf@y
}
\inheritanchor[from=rectangle pid]{center}
\inheritanchor[from=rectangle pid]{north}
\inheritanchor[from=rectangle pid]{south}
\inheritanchor[from=rectangle pid]{east}
\inheritanchor[from=rectangle pid]{west}
\inheritanchor[from=rectangle pid]{north east}
\inheritanchor[from=rectangle pid]{north west}
\inheritanchor[from=rectangle pid]{south east}
\inheritanchor[from=rectangle pid]{south west}
\inheritanchor[from=rectangle pid]{input}
\inheritanchor[from=rectangle pid]{output}
\inheritanchorborder[from=rectangle pid]
\nodeparts{}% no text
\behindbackgroundpath{
\pgf@process{\southwest}
\pgf@xa=\pgf@x
\pgf@process{\northeast}
\pgf@xb=\pgf@x
\pgfpathmoveto{\pgfqpoint{\pgf@xa}{0pt}}
\pgfpathlineto{\pgfqpoint{\pgf@xb}{0pt}}
\pgfusepathqstroke
}
\beforebackgroundpath{
{
\pgfsys@beginscope
\pgfarrowdraw{\pgfkeysvalueof{/pgf/direction pid arrow}}%
\pgfsys@endscope
}
}
}
\pgfkeys{
/pgf/direction pid arrow/.initial=direction pid,
}
% Special arrow for pid directions:
\pgfarrowsdeclare{direction pid}{direction pid}
{
\pgfmathsetlength\pgfutil@tempdima{\pgfgetarrowoptions{direction pid}}%
\pgfutil@tempdima=.5\pgfutil@tempdima
\pgfarrowsleftextend{+-\pgfutil@tempdima}
\pgfarrowsrightextend{+\pgfutil@tempdima}
}
{
\pgfmathsetlength\pgfutil@tempdima{\pgfgetarrowoptions{direction pid}}%
\pgfsetdash{}{+0pt}
\pgfsetroundjoin
\pgfpathmoveto{\pgfqpoint{-0.5\pgfutil@tempdima}{0.38268343237\pgfutil@tempdima}}
\pgfpathlineto{\pgfqpoint{0.5\pgfutil@tempdima}{0\pgfutil@tempdima}}
\pgfpathlineto{\pgfqpoint{-0.5\pgfutil@tempdima}{-0.38268343237\pgfutil@tempdima}}
\pgfpathclose
\pgfusepathqfillstroke
}
\pgfsetarrowoptions{direction pid}{4pt}
\endinput