summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/pgf/incoming/KarlheinzOchs/pgflibrarytikzsignalflowoperators.code.tex
blob: f94f0a8f8a72b7e19abe2e096a1244bd6506ea57 (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
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
% pgf/tikz library
% for signal flow diagrams
%
% Author: Dr. Karlheinz Ochs, Ruhr-University of Bochum, Germany
% Version: 0.1
% Date: 2007/01/05


%
% Styles for nodes, terminals, and operators.
%
% - nodes and terminals
\tikzstyle{node style}%
   = [draw=\pathdrawcolor,
      fill=\pathdrawcolor,
      minimum size=\nodesize]
\tikzstyle{terminal style}%
   = [draw=\pathdrawcolor,
      fill=\pathfillcolor,
      line width=\pathlinewidth,
      minimum size=\terminalsize]
\tikzstyle{node}%
   = [node shape,
      node style]
\tikzstyle{input}%
   = [input terminal shape,
      terminal style]
\tikzstyle{output}%
   = [output terminal shape,
      terminal style]
% - operators
\tikzstyle{operator color}%
   = [draw=\operatordrawcolor,
      fill=\operatorfillcolor]
\tikzstyle{operator style}%
   = [operator color,
      line width=\operatorlinewidth,
      minimum size=\operatorsize]
\tikzstyle{multiplier}%
   = [multiplier shape,
      operator style]
\tikzstyle{modulator}%
   = [modulator shape,
      operator style]
\tikzstyle{adder}%
   = [adder shape,
      operator style]
\tikzstyle{delay}%
   = [rectangle,
      operator style,
      minimum size=\delaysize]


%
% Circular shapes of operator symbols.
%
% #1 = additional inner symbol
\newcommand{\circularshape}[1]{%
  \savedanchor\centerpoint{\pgfpointorigin}
  % radius is half of maximum of \pgfshapeminwidth and \pgfshapeminheight
  \saveddimen\radius{%
    \setlength{\pgf@xa}{\pgfshapeminwidth}
    \setlength{\pgf@ya}{\pgfshapeminheight}
    \ifdim\pgf@xa>\pgf@ya
      \pgf@x=.5\pgf@xa
    \else
      \pgf@x=.5\pgf@ya
    \fi
  }
  \inheritanchor[from=circle]{center}
  \inheritanchorborder[from=circle]
  \inheritanchor[from=circle]{north}
  \inheritanchor[from=circle]{north east}
  \inheritanchor[from=circle]{east}
  \inheritanchor[from=circle]{south east}
  \inheritanchor[from=circle]{south}
  \inheritanchor[from=circle]{south west}
  \inheritanchor[from=circle]{west}
  \inheritanchor[from=circle]{north west}
  \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}
  % circular shaped frame
  \inheritbackgroundpath[from=circle]
  % additional inner symbol
  \foregroundpath{
    \centerpoint%
    \pgf@xc=\pgf@x%
    \pgf@yc=\pgf@y%
    \@tempdima=\radius%
    #1
  }
  % no text
  \nodeparts{}
}


%
% Anchors for default text box, see below.
%
\newcommand{\stdaboveanchor}{%
  \anchor{text}{%
    \centerpoint
    \advance\pgf@x by-0.5\wd\pgfnodeparttextbox%
    \advance\pgf@y by\radius
    \advance\pgf@y by+0.5mm
  }
}
\newcommand{\stdrightanchor}{%
  \anchor{text}{%
    \centerpoint
    \advance\pgf@x by\radius
    \advance\pgf@x by+0.5mm
    \advance\pgf@y by-0.5\ht\pgfnodeparttextbox%
    \advance\pgf@y by+0.5\dp\pgfnodeparttextbox%
  }
}
\newcommand{\stdbelowanchor}{%
  \anchor{text}{%
    \centerpoint
    \advance\pgf@x by-0.5\wd\pgfnodeparttextbox%
    \advance\pgf@y by-\ht\pgfnodeparttextbox%
    \advance\pgf@y by-\radius
    \advance\pgf@y by-0.5mm
  }
}
\newcommand{\stdleftanchor}{%
  \anchor{text}{%
    \centerpoint
    \advance\pgf@x by-\radius
    \advance\pgf@x by-\wd\pgfnodeparttextbox%
    \advance\pgf@x by-0.5mm
    \advance\pgf@y by-0.5\ht\pgfnodeparttextbox%
    \advance\pgf@y by+0.5\dp\pgfnodeparttextbox%
  }
}


%
% Circular shapes of operator symbols with default text box.
%
% #1 = place of the default text box
\newbox\pgfnodepartabovebox
\newbox\pgfnodepartrightbox
\newbox\pgfnodepartbelowbox
\newbox\pgfnodepartleftbox
\newcommand{\labelledcircularshape}[1]{%
  % node parts
  \nodeparts{text,above,right,below,left}
  % anchors
  \savedanchor\centerpoint{\pgfpointorigin}
  % radius is half of maximum of \pgfshapeminwidth and \pgfshapeminheight
  \saveddimen\radius{%
    \setlength{\pgf@xa}{\pgfshapeminwidth}
    \setlength{\pgf@ya}{\pgfshapeminheight}
    \ifdim\pgf@xa>\pgf@ya
      \pgf@x=.5\pgf@xa
    \else
      \pgf@x=.5\pgf@ya
    \fi
  }
  \inheritanchor[from=circle]{center}
  \inheritanchorborder[from=circle]
  \inheritanchor[from=circle]{north}
  \inheritanchor[from=circle]{north east}
  \inheritanchor[from=circle]{east}
  \inheritanchor[from=circle]{south east}
  \inheritanchor[from=circle]{south}
  \inheritanchor[from=circle]{south west}
  \inheritanchor[from=circle]{west}
  \inheritanchor[from=circle]{north west}
  \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}
  #1
  \anchor{above}{%
    \centerpoint
    \advance\pgf@x by-0.5\wd\pgfnodepartabovebox%
    \advance\pgf@y by\radius
    \advance\pgf@y by+0.5mm
  }
  \anchor{right}{%
    \centerpoint
    \advance\pgf@x by\radius
    \advance\pgf@x by+0.5mm
    \advance\pgf@y by-0.5\ht\pgfnodepartrightbox%
    \advance\pgf@y by+0.5\dp\pgfnodeparttextbox%
  }
  \anchor{below}{%
    \centerpoint
    \advance\pgf@x by-0.5\wd\pgfnodepartbelowbox%
    \advance\pgf@y by-\ht\pgfnodepartbelowbox%
    \advance\pgf@y by-\radius
    \advance\pgf@y by-0.5mm
  }
  \anchor{left}{%
    \centerpoint
    \advance\pgf@x by-\radius
    \advance\pgf@x by-\wd\pgfnodepartleftbox%
    \advance\pgf@x by-0.5mm
    \advance\pgf@y by-0.5\ht\pgfnodepartleftbox%
    \advance\pgf@y by+0.5\dp\pgfnodeparttextbox%
  }
  % circular shaped frame
  \inheritbackgroundpath[from=circle]
}


%
% Shape of a node.
%
\pgfdeclareshape{node shape}{\labelledcircularshape{\stdaboveanchor}}%

%
% Shape of an input terminal.
%
\pgfdeclareshape{input terminal shape}{\labelledcircularshape{\stdleftanchor}}%
%
% Shape of an output terminal.
%
\pgfdeclareshape{output terminal shape}{\labelledcircularshape{\stdrightanchor}}%
%
% Shape of a multiplier.
%
\pgfdeclareshape{multiplier shape}{\labelledcircularshape{\stdleftanchor}}%
%
% Shape of a modulator.
%
\pgfdeclareshape{modulator shape}{\circularshape{%
    \pgfpathmoveto{\pgfpointadd{\pgfpoint{\pgf@xc}{\pgf@yc}}
                  {\pgfpoint{-0.707107\@tempdima}{-0.707107\@tempdima}}}
    \pgfpathlineto{\pgfpointadd{\pgfpoint{\pgf@xc}{\pgf@yc}}
                  {\pgfpoint{0.707107\@tempdima}{0.707107\@tempdima}}}
    \pgfpathmoveto{\pgfpointadd{\pgfpoint{\pgf@xc}{\pgf@yc}}
                  {\pgfpoint{0.707107\@tempdima}{-0.707107\@tempdima}}}
    \pgfpathlineto{\pgfpointadd{\pgfpoint{\pgf@xc}{\pgf@yc}}
                  {\pgfpoint{-0.707107\@tempdima}{0.707107\@tempdima}}}
}}%
%
% Shape of an adder.
%
\pgfdeclareshape{adder shape}{\circularshape{%
    \pgfpathmoveto{\pgfpointadd{\pgfpoint{\pgf@xc}{\pgf@yc}}
                  {\pgfpoint{-0.5\@tempdima}{0\@tempdima}}}
    \pgfpathlineto{\pgfpointadd{\pgfpoint{\pgf@xc}{\pgf@yc}}
                  {\pgfpoint{0.5\@tempdima}{0\@tempdima}}}
    \pgfpathmoveto{\pgfpointadd{\pgfpoint{\pgf@xc}{\pgf@yc}}
                  {\pgfpoint{0\@tempdima}{-0.5\@tempdima}}}
    \pgfpathlineto{\pgfpointadd{\pgfpoint{\pgf@xc}{\pgf@yc}}
                  {\pgfpoint{0\@tempdima}{0.5\@tempdima}}}
}}%

\endinput