| 1 |
% Copyright 2018 by Mark Wibrow |
| 2 |
% |
| 3 |
% This file may be distributed and/or modified |
| 4 |
% |
| 5 |
% 1. under the LaTeX Project Public License and/or |
| 6 |
% 2. under the GNU Public License. |
| 7 |
% |
| 8 |
% See the file doc/generic/pgf/licenses/LICENSE for more details. |
| 9 |
|
| 10 |
\usepgflibrary{shapes.gates.logic}% |
| 11 |
|
| 12 |
\pgfkeys{/pgf/.cd, |
| 13 |
and gate IEC symbol/.initial=$\char`\&$, |
| 14 |
nand gate IEC symbol/.initial=$\char`\&$, |
| 15 |
or gate IEC symbol/.initial=$\geq1$, |
| 16 |
nor gate IEC symbol/.initial=$\geq1$, |
| 17 |
xor gate IEC symbol/.initial={$=1$}, |
| 18 |
xnor gate IEC symbol/.initial={$=1$}, |
| 19 |
not gate IEC symbol/.initial=1, |
| 20 |
buffer gate IEC symbol/.initial=1, |
| 21 |
logic gate IEC symbol align/.initial=top, |
| 22 |
logic gate IEC symbol color/.initial=% no value |
| 23 |
}% |
| 24 |
|
| 25 |
\pgfkeys{/pgf/logic gate IEC symbol align/.cd, |
| 26 |
top/.code=\pgftransformyshift{\innerhalfheight}, |
| 27 |
bottom/.code=\pgftransformyshift{-\innerhalfheight}, |
| 28 |
left/.code=\pgftransformxshift{-\innerhalfwidth}, |
| 29 |
right/.code=\pgftransformxshift{\innerhalfwidth}, |
| 30 |
}% |
| 31 |
|
| 32 |
\def\pgf@lib@sh@logicgates@IEC@foregroundpath#1{% |
| 33 |
\dimensions% |
| 34 |
{% |
| 35 |
\pgftransformshift{\centerpoint}% |
| 36 |
\edef\pgf@lib@sh@temp{\pgfkeysvalueof{/pgf/logic gate IEC symbol align}}% |
| 37 |
\edef\pgf@lib@sh@@temp{/pgf/logic gate IEC symbol align/.cd, \pgf@lib@sh@temp}% |
| 38 |
\expandafter\pgfkeys\expandafter{\pgf@lib@sh@@temp}% |
| 39 |
\expandafter\pgftext\expandafter[\pgf@lib@sh@temp]{% |
| 40 |
\pgfkeysgetvalue{/pgf/logic gate IEC symbol color}{\pgf@lib@sh@temp}% |
| 41 |
\ifx\pgf@lib@sh@temp\pgfutil@empty% |
| 42 |
\else% |
| 43 |
\expandafter\color\expandafter{\pgf@lib@sh@temp}% |
| 44 |
\fi% |
| 45 |
\pgfkeysvalueof{/pgf/#1 gate IEC symbol}% |
| 46 |
}% |
| 47 |
}% |
| 48 |
}% |
| 49 |
|
| 50 |
|
| 51 |
\def\pgf@lib@sh@logicgates@dimensions@IEC#1{% |
| 52 |
\[email protected]\wd\pgfnodeparttextbox% |
| 53 |
\[email protected]\ht\pgfnodeparttextbox% |
| 54 |
\advance\[email protected]\dp\pgfnodeparttextbox% |
| 55 |
% |
| 56 |
% Adjust for the width of the gate symbol. |
| 57 |
% |
| 58 |
\setbox\pgf@hbox\hbox{% |
| 59 |
% wrap in `\pgfinterruptpicture' to restore font, like how `\pgfnode` sets |
| 60 |
% `\pgfnodeparttextbox` |
| 61 |
\pgfinterruptpicture |
| 62 |
{\pgfkeysvalueof{/pgf/#1 gate IEC symbol}}% add braces as color-aftergroup-fix TT |
| 63 |
\endpgfinterruptpicture |
| 64 |
}% |
| 65 |
\[email protected]\wd\pgf@hbox% |
| 66 |
\[email protected]\ht\pgf@hbox% |
| 67 |
\advance\[email protected]\dp\pgf@hbox% |
| 68 |
\ifdim\pgf@x<\pgf@xa% |
| 69 |
\pgf@x\pgf@xa% |
| 70 |
\fi% |
| 71 |
\ifdim\pgf@y<\pgf@ya% |
| 72 |
\pgf@y\pgf@ya% |
| 73 |
\fi% |
| 74 |
\pgfmathaddtolength\pgf@x{\pgfkeysvalueof{/pgf/inner xsep}}% |
| 75 |
\pgfmathaddtolength\pgf@y{\pgfkeysvalueof{/pgf/inner ysep}}% |
| 76 |
% |
| 77 |
% Adjust for minimum height and width. |
| 78 |
% |
| 79 |
\pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/minimum width}}% |
| 80 |
\pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/minimum height}}% |
| 81 |
\ifdim\pgf@x<.5\pgf@xa% |
| 82 |
\[email protected]\pgf@xa% |
| 83 |
\fi% |
| 84 |
\ifdim\pgf@y<.5\pgf@ya% |
| 85 |
\[email protected]\pgf@ya% |
| 86 |
\fi% |
| 87 |
% |
| 88 |
% Adjust the height for the number of inputs. |
| 89 |
% |
| 90 |
\c@pgf@counta\pgf@lib@sh@logicgate@numinputs% |
| 91 |
\advance\c@pgf@counta1\relax% |
| 92 |
\pgfmathsetlength\pgf@yb{\pgfkeysvalueof{/pgf/logic gate inverted radius}}% |
| 93 |
\[email protected]\pgf@yb% |
| 94 |
\advance\pgf@yb\pgflinewidth% |
| 95 |
\pgfmathsetlength\pgf@yc{\pgfkeysvalueof{/pgf/logic gate input sep}}% |
| 96 |
\edef\inputsep{\the\pgf@yc}% |
| 97 |
\addtosavedmacro\inputsep% |
| 98 |
\ifdim\pgf@yb<\pgf@yc% |
| 99 |
\pgf@yb\pgf@yc% |
| 100 |
\fi% |
| 101 |
\multiply\pgf@yb\c@pgf@counta% |
| 102 |
\ifdim\pgf@y<.5\pgf@yb% |
| 103 |
\[email protected]\pgf@yb% |
| 104 |
\fi% |
| 105 |
% |
| 106 |
\pgf@xa\pgf@x% |
| 107 |
\pgfmathaddtolength\pgf@xa{-\pgfkeysvalueof{/pgf/inner xsep}}% |
| 108 |
\edef\innerhalfwidth{\the\pgf@xa}% |
| 109 |
\addtosavedmacro\innerhalfwidth% |
| 110 |
% |
| 111 |
\pgf@ya\pgf@y% |
| 112 |
\pgfmathaddtolength\pgf@ya{-\pgfkeysvalueof{/pgf/inner ysep}}% |
| 113 |
\edef\innerhalfheight{\the\pgf@ya}% |
| 114 |
\addtosavedmacro\innerhalfheight% |
| 115 |
% |
| 116 |
% Take into account the outer sep. |
| 117 |
% |
| 118 |
\pgfmathaddtolength\pgf@x{\pgfkeysvalueof{/pgf/outer xsep}}% |
| 119 |
\pgfmathaddtolength\pgf@y{\pgfkeysvalueof{/pgf/outer ysep}}% |
| 120 |
% |
| 121 |
\edef\halfwidth{\the\pgf@x}% |
| 122 |
\edef\halfheight{\the\pgf@y}% |
| 123 |
\addtosavedmacro\halfwidth% |
| 124 |
\addtosavedmacro\halfheight% |
| 125 |
}% |
| 126 |
|
| 127 |
\def\pgf@lib@sh@logicgate@IEC@inputanchor#1{% |
| 128 |
\dimensions% |
| 129 |
\centerpoint% |
| 130 |
\advance\pgf@x-\halfwidth% |
| 131 |
\expandafter\ifx\expandafter\pgf@lib@sh@itext\csname input-#1\endcsname% |
| 132 |
\advance\pgf@x-\invertedradius% |
| 133 |
\advance\pgf@x-\outerinvertedradius% |
| 134 |
\fi% |
| 135 |
% |
| 136 |
\pgfutil@tempdima\halfheight% |
| 137 |
\multiply\pgfutil@tempdima2\relax% |
| 138 |
\c@pgf@counta\numinputs% |
| 139 |
\advance\c@pgf@counta1\relax% |
| 140 |
\divide\pgfutil@tempdima\c@pgf@counta% |
| 141 |
\multiply\pgfutil@tempdima#1\relax% |
| 142 |
\advance\pgf@y\halfheight% |
| 143 |
\advance\pgf@y-\pgfutil@tempdima% |
| 144 |
}% |
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
% Shape and gate IEC |
| 149 |
% |
| 150 |
\pgfdeclareshape{and gate IEC}{% |
| 151 |
\expandafter\pgfutil@g@addto@macro\csname pgf@sh@s@and gate IEC\endcsname{% |
| 152 |
\pgf@lib@sh@logicgate@parseinputs{1024}% Maximum 1024 (!) inputs. |
| 153 |
% |
| 154 |
\pgfmathloop% |
| 155 |
\ifnum\pgfmathcounter>\pgf@lib@sh@logicgate@numinputs% |
| 156 |
\else% |
| 157 |
\pgfutil@ifundefined{pgf@anchor@and gate IEC@input \pgfmathcounter}{% |
| 158 |
\expandafter\xdef\csname pgf@anchor@and gate IEC@input \pgfmathcounter\endcsname{% |
| 159 |
\noexpand\pgf@lib@sh@logicgate@IEC@inputanchor{\pgfmathcounter}% |
| 160 |
}% |
| 161 |
}{}% |
| 162 |
\repeatpgfmathloop% |
| 163 |
\ifnum\pgf@lib@sh@logicgate@numinputs<2\relax% |
| 164 |
\pgferror{An and gate must have at least two inputs}% |
| 165 |
\fi% |
| 166 |
}% |
| 167 |
\savedmacro\numinputs{\let\numinputs\pgf@lib@sh@logicgate@numinputs}% |
| 168 |
\saveddimen\invertedradius{% |
| 169 |
\pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/logic gate inverted radius}}% |
| 170 |
}% |
| 171 |
\saveddimen\outerinvertedradius{% |
| 172 |
\pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/logic gate inverted radius}}% |
| 173 |
\advance\[email protected]\pgflinewidth% |
| 174 |
}% |
| 175 |
\savedmacro\dimensions{% |
| 176 |
\pgf@lib@sh@logicgates@dimensions@IEC{and}% |
| 177 |
}% |
| 178 |
\savedanchor\centerpoint{% |
| 179 |
\[email protected]\wd\pgfnodeparttextbox% |
| 180 |
\[email protected]\ht\pgfnodeparttextbox% |
| 181 |
\advance\[email protected]\dp\pgfnodeparttextbox% |
| 182 |
}% |
| 183 |
\savedanchor\midpoint{% |
| 184 |
\[email protected]\wd\pgfnodeparttextbox% |
| 185 |
\pgfmathsetlength\pgf@y{+0.5ex}% |
| 186 |
}% |
| 187 |
\savedanchor\basepoint{% |
| 188 |
\[email protected]\wd\pgfnodeparttextbox% |
| 189 |
\pgf@y0pt% |
| 190 |
}% |
| 191 |
\anchor{center}{\centerpoint}% |
| 192 |
\anchor{mid}{\midpoint}% |
| 193 |
\anchor{mid west}{% |
| 194 |
\dimensions% |
| 195 |
\midpoint% |
| 196 |
\advance\pgf@x-\halfwidth}% |
| 197 |
\anchor{mid east}{% |
| 198 |
\dimensions% |
| 199 |
\midpoint% |
| 200 |
\advance\pgf@x\halfwidth}% |
| 201 |
\anchor{base}{\basepoint}% |
| 202 |
\anchor{base west}{% |
| 203 |
\dimensions% |
| 204 |
\basepoint% |
| 205 |
\advance\pgf@x-\halfwidth}% |
| 206 |
\anchor{base east}{% |
| 207 |
\dimensions% |
| 208 |
\basepoint% |
| 209 |
\advance\pgf@x\halfwidth}% |
| 210 |
\anchor{north}{\dimensions\centerpoint\advance\pgf@y\halfheight}% |
| 211 |
\anchor{south}{\dimensions\centerpoint\advance\pgf@y-\halfheight}% |
| 212 |
\anchor{east}{\dimensions\centerpoint\advance\pgf@x\halfwidth}% |
| 213 |
\anchor{west}{\dimensions\centerpoint\advance\pgf@x-\halfwidth}% |
| 214 |
\anchor{north east}{\dimensions\centerpoint\advance\pgf@x\halfwidth\advance\pgf@y\halfheight}% |
| 215 |
\anchor{north west}{\dimensions\centerpoint\advance\pgf@x-\halfwidth\advance\pgf@y\halfheight}% |
| 216 |
\anchor{south east}{\dimensions\centerpoint\advance\pgf@x\halfwidth\advance\pgf@y-\halfheight}% |
| 217 |
\anchor{south west}{\dimensions\centerpoint\advance\pgf@x-\halfwidth\advance\pgf@y-\halfheight}% |
| 218 |
\anchor{output}{\dimensions\centerpoint\advance\pgf@x\halfwidth}% |
| 219 |
\backgroundpath{% |
| 220 |
\dimensions% |
| 221 |
\pgf@xc\halfwidth% |
| 222 |
\pgf@yc\halfheight% |
| 223 |
\pgfmathaddtolength\pgf@xc{-\pgfkeysvalueof{/pgf/outer xsep}}% |
| 224 |
\pgfmathaddtolength\pgf@yc{-\pgfkeysvalueof{/pgf/outer xsep}}% |
| 225 |
{% |
| 226 |
\pgftransformshift{\centerpoint}% |
| 227 |
\pgfpathrectangle{\pgfqpoint{-\pgf@xc}{-\pgf@yc}}% |
| 228 |
{% |
| 229 |
\[email protected]\pgf@xc% |
| 230 |
\[email protected]\pgf@yc% |
| 231 |
\pgfqpoint{\pgf@xc}{\pgf@yc}% |
| 232 |
}% |
| 233 |
\pgfpathclose% |
| 234 |
% |
| 235 |
% Draw inputs. |
| 236 |
% |
| 237 |
\pgf@xc-\halfwidth% |
| 238 |
\advance\pgf@xc-\invertedradius% |
| 239 |
\pgf@yc\halfheight% |
| 240 |
\[email protected]\pgf@yc% |
| 241 |
\c@pgf@counta\numinputs% |
| 242 |
\advance\c@pgf@counta1\relax% |
| 243 |
\divide\pgfutil@tempdima\c@pgf@counta% |
| 244 |
\pgfmathloop% |
| 245 |
\ifnum\pgfmathcounter>\numinputs% |
| 246 |
\else% |
| 247 |
\advance\pgf@yc-\pgfutil@tempdima% |
| 248 |
\expandafter\ifx\expandafter\pgf@lib@sh@itext\csname input-\pgfmathcounter\endcsname% |
| 249 |
{% |
| 250 |
\pgfpathcircle{\pgfqpoint{\pgf@xc}{\pgf@yc}}{\invertedradius}% |
| 251 |
}% |
| 252 |
\fi% |
| 253 |
\repeatpgfmathloop% |
| 254 |
}% |
| 255 |
}% |
| 256 |
\foregroundpath{\pgf@lib@sh@logicgates@IEC@foregroundpath{and}}% |
| 257 |
\anchorborder{% |
| 258 |
\pgfextract@process\externalpoint{}% |
| 259 |
\dimensions% |
| 260 |
\pgfpointadd{\centerpoint}{\pgfpointborderrectangle{\externalpoint}{\pgfqpoint{\halfwidth}{\halfheight}}}% |
| 261 |
}% |
| 262 |
}% |
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
% Shape nand gate IEC |
| 269 |
% |
| 270 |
\pgfdeclareshape{nand gate IEC}{% |
| 271 |
\expandafter\pgfutil@g@addto@macro\csname pgf@sh@s@nand gate IEC\endcsname{% |
| 272 |
\pgf@lib@sh@logicgate@parseinputs{1024}% Maximum 1024 (!) inputs. |
| 273 |
% |
| 274 |
\pgfmathloop% |
| 275 |
\ifnum\pgfmathcounter>\pgf@lib@sh@logicgate@numinputs% |
| 276 |
\else% |
| 277 |
\pgfutil@ifundefined{pgf@anchor@nand gate IEC@input \pgfmathcounter}{% |
| 278 |
\expandafter\xdef\csname pgf@anchor@nand gate IEC@input \pgfmathcounter\endcsname{% |
| 279 |
\noexpand\pgf@lib@sh@logicgate@IEC@inputanchor{\pgfmathcounter}% |
| 280 |
}% |
| 281 |
}{}% |
| 282 |
\repeatpgfmathloop% |
| 283 |
\ifnum\pgf@lib@sh@logicgate@numinputs<2\relax% |
| 284 |
\pgferror{A nand gate must have at least two inputs}% |
| 285 |
\fi% |
| 286 |
}% |
| 287 |
\savedmacro\numinputs{\let\numinputs\pgf@lib@sh@logicgate@numinputs}% |
| 288 |
\saveddimen\invertedradius{% |
| 289 |
\pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/logic gate inverted radius}}% |
| 290 |
}% |
| 291 |
\saveddimen\outerinvertedradius{% |
| 292 |
\pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/logic gate inverted radius}}% |
| 293 |
\advance\[email protected]\pgflinewidth% |
| 294 |
}% |
| 295 |
\savedmacro\dimensions{% |
| 296 |
\pgf@lib@sh@logicgates@dimensions@IEC{nand}% |
| 297 |
}% |
| 298 |
\savedanchor\centerpoint{% |
| 299 |
\[email protected]\wd\pgfnodeparttextbox% |
| 300 |
\[email protected]\ht\pgfnodeparttextbox% |
| 301 |
\advance\[email protected]\dp\pgfnodeparttextbox% |
| 302 |
}% |
| 303 |
\savedanchor\midpoint{% |
| 304 |
\[email protected]\wd\pgfnodeparttextbox% |
| 305 |
\pgfmathsetlength\pgf@y{+0.5ex}% |
| 306 |
}% |
| 307 |
\savedanchor\basepoint{% |
| 308 |
\[email protected]\wd\pgfnodeparttextbox% |
| 309 |
\pgf@y0pt% |
| 310 |
}% |
| 311 |
\inheritanchor[from=and gate IEC]{center}% |
| 312 |
\inheritanchor[from=and gate IEC]{mid}% |
| 313 |
\inheritanchor[from=and gate IEC]{mid west}% |
| 314 |
\inheritanchor[from=and gate IEC]{mid east}% |
| 315 |
\inheritanchor[from=and gate IEC]{base}% |
| 316 |
\inheritanchor[from=and gate IEC]{base west}% |
| 317 |
\inheritanchor[from=and gate IEC]{base east}% |
| 318 |
\inheritanchor[from=and gate IEC]{north}% |
| 319 |
\inheritanchor[from=and gate IEC]{south}% |
| 320 |
\inheritanchor[from=and gate IEC]{east}% |
| 321 |
\inheritanchor[from=and gate IEC]{west}% |
| 322 |
\inheritanchor[from=and gate IEC]{north east}% |
| 323 |
\inheritanchor[from=and gate IEC]{north west}% |
| 324 |
\inheritanchor[from=and gate IEC]{south east}% |
| 325 |
\inheritanchor[from=and gate IEC]{south west}% |
| 326 |
\anchor{output}{% |
| 327 |
\csname pgf@anchor@and gate IEC@east\endcsname% |
| 328 |
\advance\pgf@x\invertedradius% |
| 329 |
\advance\pgf@x\outerinvertedradius% |
| 330 |
}% |
| 331 |
\backgroundpath{% |
| 332 |
\csname pgf@sh@bg@and gate IEC\endcsname% |
| 333 |
\pgfpathcircle{% |
| 334 |
\centerpoint% |
| 335 |
\advance\pgf@x\halfwidth% |
| 336 |
\advance\pgf@x\invertedradius% |
| 337 |
}{+\invertedradius}% |
| 338 |
}% |
| 339 |
\foregroundpath{\pgf@lib@sh@logicgates@IEC@foregroundpath{nand}}% |
| 340 |
\inheritanchorborder[from=and gate IEC]% |
| 341 |
}% |
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
% Shape or gate IEC |
| 348 |
% |
| 349 |
\pgfdeclareshape{or gate IEC}{% |
| 350 |
\expandafter\pgfutil@g@addto@macro\csname pgf@sh@s@or gate IEC\endcsname{% |
| 351 |
\pgf@lib@sh@logicgate@parseinputs{1024}% Maximum 1024 (!) inputs. |
| 352 |
% |
| 353 |
\pgfmathloop% |
| 354 |
\ifnum\pgfmathcounter>\pgf@lib@sh@logicgate@numinputs% |
| 355 |
\else% |
| 356 |
\pgfutil@ifundefined{pgf@anchor@or gate IEC@input \pgfmathcounter}{% |
| 357 |
\expandafter\xdef\csname pgf@anchor@or gate IEC@input \pgfmathcounter\endcsname{% |
| 358 |
\noexpand\pgf@lib@sh@logicgate@IEC@inputanchor{\pgfmathcounter}% |
| 359 |
}% |
| 360 |
}{}% |
| 361 |
\repeatpgfmathloop% |
| 362 |
\ifnum\pgf@lib@sh@logicgate@numinputs<2\relax% |
| 363 |
\pgferror{An or gate must have at least two inputs}% |
| 364 |
\fi% |
| 365 |
}% |
| 366 |
\savedmacro\numinputs{\let\numinputs\pgf@lib@sh@logicgate@numinputs}% |
| 367 |
\saveddimen\invertedradius{% |
| 368 |
\pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/logic gate inverted radius}}% |
| 369 |
}% |
| 370 |
\saveddimen\outerinvertedradius{% |
| 371 |
\pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/logic gate inverted radius}}% |
| 372 |
\advance\[email protected]\pgflinewidth% |
| 373 |
}% |
| 374 |
\savedmacro\dimensions{% |
| 375 |
\pgf@lib@sh@logicgates@dimensions@IEC{or}% |
| 376 |
}% |
| 377 |
\savedanchor\centerpoint{% |
| 378 |
\[email protected]\wd\pgfnodeparttextbox% |
| 379 |
\[email protected]\ht\pgfnodeparttextbox% |
| 380 |
\advance\[email protected]\dp\pgfnodeparttextbox% |
| 381 |
}% |
| 382 |
\savedanchor\midpoint{% |
| 383 |
\[email protected]\wd\pgfnodeparttextbox% |
| 384 |
\pgfmathsetlength\pgf@y{+0.5ex}% |
| 385 |
}% |
| 386 |
\savedanchor\basepoint{% |
| 387 |
\[email protected]\wd\pgfnodeparttextbox% |
| 388 |
\pgf@y0pt% |
| 389 |
}% |
| 390 |
\inheritanchor[from=and gate IEC]{center}% |
| 391 |
\inheritanchor[from=and gate IEC]{mid}% |
| 392 |
\inheritanchor[from=and gate IEC]{mid west}% |
| 393 |
\inheritanchor[from=and gate IEC]{mid east}% |
| 394 |
\inheritanchor[from=and gate IEC]{base}% |
| 395 |
\inheritanchor[from=and gate IEC]{base west}% |
| 396 |
\inheritanchor[from=and gate IEC]{base east}% |
| 397 |
\inheritanchor[from=and gate IEC]{north}% |
| 398 |
\inheritanchor[from=and gate IEC]{south}% |
| 399 |
\inheritanchor[from=and gate IEC]{east}% |
| 400 |
\inheritanchor[from=and gate IEC]{west}% |
| 401 |
\inheritanchor[from=and gate IEC]{north east}% |
| 402 |
\inheritanchor[from=and gate IEC]{north west}% |
| 403 |
\inheritanchor[from=and gate IEC]{south east}% |
| 404 |
\inheritanchor[from=and gate IEC]{south west}% |
| 405 |
\inheritanchor[from=and gate IEC]{output}% |
| 406 |
\inheritbackgroundpath[from=and gate IEC]% |
| 407 |
\foregroundpath{\pgf@lib@sh@logicgates@IEC@foregroundpath{or}}% |
| 408 |
\inheritanchorborder[from=and gate IEC]% |
| 409 |
}% |
| 410 |
|
| 411 |
|
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
% Shape nor gate IEC |
| 416 |
% |
| 417 |
\pgfdeclareshape{nor gate IEC}{% |
| 418 |
\expandafter\pgfutil@g@addto@macro\csname pgf@sh@s@nor gate IEC\endcsname{% |
| 419 |
\pgf@lib@sh@logicgate@parseinputs{1024}% Maximum 1024 (!) inputs. |
| 420 |
% |
| 421 |
\pgfmathloop% |
| 422 |
\ifnum\pgfmathcounter>\pgf@lib@sh@logicgate@numinputs% |
| 423 |
\else% |
| 424 |
\pgfutil@ifundefined{pgf@anchor@nor gate IEC@input \pgfmathcounter}{% |
| 425 |
\expandafter\xdef\csname pgf@anchor@nor gate IEC@input \pgfmathcounter\endcsname{% |
| 426 |
\noexpand\pgf@lib@sh@logicgate@IEC@inputanchor{\pgfmathcounter}% |
| 427 |
}% |
| 428 |
}{}% |
| 429 |
\repeatpgfmathloop% |
| 430 |
\ifnum\pgf@lib@sh@logicgate@numinputs<2\relax% |
| 431 |
\pgferror{A nor gate must have at least two inputs}% |
| 432 |
\fi% |
| 433 |
}% |
| 434 |
\savedmacro\numinputs{\let\numinputs\pgf@lib@sh@logicgate@numinputs}% |
| 435 |
\saveddimen\invertedradius{% |
| 436 |
\pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/logic gate inverted radius}}% |
| 437 |
}% |
| 438 |
\saveddimen\outerinvertedradius{% |
| 439 |
\pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/logic gate inverted radius}}% |
| 440 |
\advance\[email protected]\pgflinewidth% |
| 441 |
}% |
| 442 |
\savedmacro\dimensions{% |
| 443 |
\pgf@lib@sh@logicgates@dimensions@IEC{nor}% |
| 444 |
}% |
| 445 |
\savedanchor\centerpoint{% |
| 446 |
\[email protected]\wd\pgfnodeparttextbox% |
| 447 |
\[email protected]\ht\pgfnodeparttextbox% |
| 448 |
\advance\[email protected]\dp\pgfnodeparttextbox% |
| 449 |
}% |
| 450 |
\savedanchor\midpoint{% |
| 451 |
\[email protected]\wd\pgfnodeparttextbox% |
| 452 |
\pgfmathsetlength\pgf@y{+0.5ex}% |
| 453 |
}% |
| 454 |
\savedanchor\basepoint{% |
| 455 |
\[email protected]\wd\pgfnodeparttextbox% |
| 456 |
\pgf@y0pt% |
| 457 |
}% |
| 458 |
\inheritanchor[from=and gate IEC]{center}% |
| 459 |
\inheritanchor[from=and gate IEC]{mid}% |
| 460 |
\inheritanchor[from=and gate IEC]{mid west}% |
| 461 |
\inheritanchor[from=and gate IEC]{mid east}% |
| 462 |
\inheritanchor[from=and gate IEC]{base}% |
| 463 |
\inheritanchor[from=and gate IEC]{base west}% |
| 464 |
\inheritanchor[from=and gate IEC]{base east}% |
| 465 |
\inheritanchor[from=and gate IEC]{north}% |
| 466 |
\inheritanchor[from=and gate IEC]{south}% |
| 467 |
\inheritanchor[from=and gate IEC]{east}% |
| 468 |
\inheritanchor[from=and gate IEC]{west}% |
| 469 |
\inheritanchor[from=and gate IEC]{north east}% |
| 470 |
\inheritanchor[from=and gate IEC]{north west}% |
| 471 |
\inheritanchor[from=and gate IEC]{south east}% |
| 472 |
\inheritanchor[from=and gate IEC]{south west}% |
| 473 |
\inheritanchor[from=nand gate IEC]{output}%% |
| 474 |
\inheritbackgroundpath[from=nand gate IEC]% |
| 475 |
\foregroundpath{\pgf@lib@sh@logicgates@IEC@foregroundpath{nor}}% |
| 476 |
\inheritanchorborder[from=and gate IEC]% |
| 477 |
}% |
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
% Shape xor gate IEC |
| 484 |
% |
| 485 |
\pgfdeclareshape{xor gate IEC}{% |
| 486 |
\expandafter\pgfutil@g@addto@macro\csname pgf@sh@s@xor gate IEC\endcsname{% |
| 487 |
\pgf@lib@sh@logicgate@parseinputs{2}% Maximum 1024 (!) inputs. |
| 488 |
% |
| 489 |
\pgfmathloop% |
| 490 |
\ifnum\pgfmathcounter>\pgf@lib@sh@logicgate@numinputs% |
| 491 |
\else% |
| 492 |
\pgfutil@ifundefined{pgf@anchor@xor gate IEC@input \pgfmathcounter}{% |
| 493 |
\expandafter\xdef\csname pgf@anchor@xor gate IEC@input \pgfmathcounter\endcsname{% |
| 494 |
\noexpand\pgf@lib@sh@logicgate@IEC@inputanchor{\pgfmathcounter}% |
| 495 |
}% |
| 496 |
}{}% |
| 497 |
\repeatpgfmathloop% |
| 498 |
\ifnum\pgf@lib@sh@logicgate@numinputs<2\relax% |
| 499 |
\pgferror{An xor gate must have two inputs}% |
| 500 |
\fi% |
| 501 |
}% |
| 502 |
\savedmacro\numinputs{\let\numinputs\pgf@lib@sh@logicgate@numinputs}% |
| 503 |
\saveddimen\invertedradius{% |
| 504 |
\pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/logic gate inverted radius}}% |
| 505 |
}% |
| 506 |
\saveddimen\outerinvertedradius{% |
| 507 |
\pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/logic gate inverted radius}}% |
| 508 |
\advance\[email protected]\pgflinewidth% |
| 509 |
}% |
| 510 |
\savedmacro\dimensions{% |
| 511 |
\pgf@lib@sh@logicgates@dimensions@IEC{xor}% |
| 512 |
}% |
| 513 |
\savedanchor\centerpoint{% |
| 514 |
\[email protected]\wd\pgfnodeparttextbox% |
| 515 |
\[email protected]\ht\pgfnodeparttextbox% |
| 516 |
\advance\[email protected]\dp\pgfnodeparttextbox% |
| 517 |
}% |
| 518 |
\savedanchor\midpoint{% |
| 519 |
\[email protected]\wd\pgfnodeparttextbox% |
| 520 |
\pgfmathsetlength\pgf@y{+0.5ex}% |
| 521 |
}% |
| 522 |
\savedanchor\basepoint{% |
| 523 |
\[email protected]\wd\pgfnodeparttextbox% |
| 524 |
\pgf@y0pt% |
| 525 |
}% |
| 526 |
\inheritanchor[from=and gate IEC]{center}% |
| 527 |
\inheritanchor[from=and gate IEC]{mid}% |
| 528 |
\inheritanchor[from=and gate IEC]{mid west}% |
| 529 |
\inheritanchor[from=and gate IEC]{mid east}% |
| 530 |
\inheritanchor[from=and gate IEC]{base}% |
| 531 |
\inheritanchor[from=and gate IEC]{base west}% |
| 532 |
\inheritanchor[from=and gate IEC]{base east}% |
| 533 |
\inheritanchor[from=and gate IEC]{north}% |
| 534 |
\inheritanchor[from=and gate IEC]{south}% |
| 535 |
\inheritanchor[from=and gate IEC]{east}% |
| 536 |
\inheritanchor[from=and gate IEC]{west}% |
| 537 |
\inheritanchor[from=and gate IEC]{north east}% |
| 538 |
\inheritanchor[from=and gate IEC]{north west}% |
| 539 |
\inheritanchor[from=and gate IEC]{south east}% |
| 540 |
\inheritanchor[from=and gate IEC]{south west}% |
| 541 |
\inheritanchor[from=and gate IEC]{output}% |
| 542 |
\inheritbackgroundpath[from=and gate IEC]% |
| 543 |
\foregroundpath{\pgf@lib@sh@logicgates@IEC@foregroundpath{xor}}% |
| 544 |
\inheritanchorborder[from=and gate IEC]% |
| 545 |
}% |
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
% Shape xnor gate IEC |
| 551 |
% |
| 552 |
|
| 553 |
\pgfdeclareshape{xnor gate IEC}{% |
| 554 |
\expandafter\pgfutil@g@addto@macro\csname pgf@sh@s@xnor gate IEC\endcsname{% |
| 555 |
\pgf@lib@sh@logicgate@parseinputs{1024}% Maximum 1024 (!) inputs. |
| 556 |
% |
| 557 |
\pgfmathloop% |
| 558 |
\ifnum\pgfmathcounter>\pgf@lib@sh@logicgate@numinputs% |
| 559 |
\else% |
| 560 |
\pgfutil@ifundefined{pgf@anchor@xnor gate IEC@input \pgfmathcounter}{% |
| 561 |
\expandafter\xdef\csname pgf@anchor@xnor gate IEC@input \pgfmathcounter\endcsname{% |
| 562 |
\noexpand\pgf@lib@sh@logicgate@IEC@inputanchor{\pgfmathcounter}% |
| 563 |
}% |
| 564 |
}{}% |
| 565 |
\repeatpgfmathloop% |
| 566 |
\ifnum\pgf@lib@sh@logicgate@numinputs<2\relax% |
| 567 |
\pgferror{A xnor gate must have two inputs}% |
| 568 |
\fi% |
| 569 |
}% |
| 570 |
\savedmacro\numinputs{\let\numinputs\pgf@lib@sh@logicgate@numinputs}% |
| 571 |
\saveddimen\invertedradius{% |
| 572 |
\pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/logic gate inverted radius}}% |
| 573 |
}% |
| 574 |
\saveddimen\outerinvertedradius{% |
| 575 |
\pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/logic gate inverted radius}}% |
| 576 |
\advance\[email protected]\pgflinewidth% |
| 577 |
}% |
| 578 |
\savedmacro\dimensions{% |
| 579 |
\pgf@lib@sh@logicgates@dimensions@IEC{xnor}% |
| 580 |
}% |
| 581 |
\savedanchor\centerpoint{% |
| 582 |
\[email protected]\wd\pgfnodeparttextbox% |
| 583 |
\[email protected]\ht\pgfnodeparttextbox% |
| 584 |
\advance\[email protected]\dp\pgfnodeparttextbox% |
| 585 |
}% |
| 586 |
\savedanchor\midpoint{% |
| 587 |
\[email protected]\wd\pgfnodeparttextbox% |
| 588 |
\pgfmathsetlength\pgf@y{+0.5ex}% |
| 589 |
}% |
| 590 |
\savedanchor\basepoint{% |
| 591 |
\[email protected]\wd\pgfnodeparttextbox% |
| 592 |
\pgf@y0pt% |
| 593 |
}% |
| 594 |
\inheritanchor[from=and gate IEC]{center}% |
| 595 |
\inheritanchor[from=and gate IEC]{mid}% |
| 596 |
\inheritanchor[from=and gate IEC]{mid west}% |
| 597 |
\inheritanchor[from=and gate IEC]{mid east}% |
| 598 |
\inheritanchor[from=and gate IEC]{base}% |
| 599 |
\inheritanchor[from=and gate IEC]{base west}% |
| 600 |
\inheritanchor[from=and gate IEC]{base east}% |
| 601 |
\inheritanchor[from=and gate IEC]{north}% |
| 602 |
\inheritanchor[from=and gate IEC]{south}% |
| 603 |
\inheritanchor[from=and gate IEC]{east}% |
| 604 |
\inheritanchor[from=and gate IEC]{west}% |
| 605 |
\inheritanchor[from=and gate IEC]{north east}% |
| 606 |
\inheritanchor[from=and gate IEC]{north west}% |
| 607 |
\inheritanchor[from=and gate IEC]{south east}% |
| 608 |
\inheritanchor[from=and gate IEC]{south west}% |
| 609 |
\inheritanchor[from=nand gate IEC]{output}% |
| 610 |
\inheritbackgroundpath[from=nand gate IEC]% |
| 611 |
\foregroundpath{\pgf@lib@sh@logicgates@IEC@foregroundpath{xnor}}% |
| 612 |
\inheritanchorborder[from=and gate IEC]% |
| 613 |
}% |
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
|
| 618 |
% Shape buffer gate IEC |
| 619 |
% |
| 620 |
\pgfdeclareshape{buffer gate IEC}{% |
| 621 |
\expandafter\pgfutil@g@addto@macro\csname pgf@sh@s@buffer gate IEC\endcsname{% |
| 622 |
\pgf@lib@sh@logicgate@parseinputs{1}% Maximum 1 input. |
| 623 |
% |
| 624 |
\expandafter\gdef\csname pgf@anchor@buffer gate IEC@input\endcsname{% |
| 625 |
\pgf@lib@sh@logicgate@IEC@inputanchor{1}% |
| 626 |
}% |
| 627 |
\ifnum\pgf@lib@sh@logicgate@numinputs=0\relax% |
| 628 |
\pgferror{A buffer gate must have one inputs}% |
| 629 |
\fi% |
| 630 |
}% |
| 631 |
\savedmacro\numinputs{\let\numinputs\pgf@lib@sh@logicgate@numinputs}% |
| 632 |
\saveddimen\invertedradius{% |
| 633 |
\pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/logic gate inverted radius}}% |
| 634 |
}% |
| 635 |
\saveddimen\outerinvertedradius{% |
| 636 |
\pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/logic gate inverted radius}}% |
| 637 |
\advance\[email protected]\pgflinewidth% |
| 638 |
}% |
| 639 |
\savedmacro\dimensions{% |
| 640 |
\pgf@lib@sh@logicgates@dimensions@IEC{xor}% |
| 641 |
}% |
| 642 |
\savedanchor\centerpoint{% |
| 643 |
\[email protected]\wd\pgfnodeparttextbox% |
| 644 |
\[email protected]\ht\pgfnodeparttextbox% |
| 645 |
\advance\[email protected]\dp\pgfnodeparttextbox% |
| 646 |
}% |
| 647 |
\savedanchor\midpoint{% |
| 648 |
\[email protected]\wd\pgfnodeparttextbox% |
| 649 |
\pgfmathsetlength\pgf@y{+0.5ex}% |
| 650 |
}% |
| 651 |
\savedanchor\basepoint{% |
| 652 |
\[email protected]\wd\pgfnodeparttextbox% |
| 653 |
\pgf@y0pt% |
| 654 |
}% |
| 655 |
\inheritanchor[from=and gate IEC]{center}% |
| 656 |
\inheritanchor[from=and gate IEC]{mid}% |
| 657 |
\inheritanchor[from=and gate IEC]{mid west}% |
| 658 |
\inheritanchor[from=and gate IEC]{mid east}% |
| 659 |
\inheritanchor[from=and gate IEC]{base}% |
| 660 |
\inheritanchor[from=and gate IEC]{base west}% |
| 661 |
\inheritanchor[from=and gate IEC]{base east}% |
| 662 |
\inheritanchor[from=and gate IEC]{north}% |
| 663 |
\inheritanchor[from=and gate IEC]{south}% |
| 664 |
\inheritanchor[from=and gate IEC]{east}% |
| 665 |
\inheritanchor[from=and gate IEC]{west}% |
| 666 |
\inheritanchor[from=and gate IEC]{north east}% |
| 667 |
\inheritanchor[from=and gate IEC]{north west}% |
| 668 |
\inheritanchor[from=and gate IEC]{south east}% |
| 669 |
\inheritanchor[from=and gate IEC]{south west}% |
| 670 |
\inheritanchor[from=and gate IEC]{output}% |
| 671 |
\inheritbackgroundpath[from=and gate IEC]% |
| 672 |
\foregroundpath{\pgf@lib@sh@logicgates@IEC@foregroundpath{buffer}}% |
| 673 |
\inheritanchorborder[from=and gate IEC]% |
| 674 |
}% |
| 675 |
|
| 676 |
|
| 677 |
|
| 678 |
|
| 679 |
|
| 680 |
% Shape not gate IEC |
| 681 |
% |
| 682 |
\pgfdeclareshape{not gate IEC}{% |
| 683 |
\expandafter\pgfutil@g@addto@macro\csname pgf@sh@s@not gate IEC\endcsname{% |
| 684 |
\pgf@lib@sh@logicgate@parseinputs{1}% |
| 685 |
% |
| 686 |
\pgfutil@ifundefined{pgf@anchor@not gate IEC@input}{% |
| 687 |
\expandafter\gdef\csname pgf@anchor@not gate IEC@input\endcsname{% |
| 688 |
\pgf@lib@sh@logicgate@IEC@inputanchor{1}% |
| 689 |
}}{}% |
| 690 |
\ifnum\pgf@lib@sh@logicgate@numinputs=0\relax% |
| 691 |
\pgferror{A not gate must have one input}% |
| 692 |
\fi% |
| 693 |
}% |
| 694 |
\savedmacro\numinputs{\let\numinputs\pgf@lib@sh@logicgate@numinputs}% |
| 695 |
\saveddimen\invertedradius{% |
| 696 |
\pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/logic gate inverted radius}}% |
| 697 |
}% |
| 698 |
\saveddimen\outerinvertedradius{% |
| 699 |
\pgfmathsetlength\pgf@x{\pgfkeysvalueof{/pgf/logic gate inverted radius}}% |
| 700 |
\advance\[email protected]\pgflinewidth% |
| 701 |
}% |
| 702 |
\savedmacro\dimensions{% |
| 703 |
\pgf@lib@sh@logicgates@dimensions@IEC{not}% |
| 704 |
}% |
| 705 |
\savedanchor\centerpoint{% |
| 706 |
\[email protected]\wd\pgfnodeparttextbox% |
| 707 |
\[email protected]\ht\pgfnodeparttextbox% |
| 708 |
\advance\[email protected]\dp\pgfnodeparttextbox% |
| 709 |
}% |
| 710 |
\savedanchor\midpoint{% |
| 711 |
\[email protected]\wd\pgfnodeparttextbox% |
| 712 |
\pgfmathsetlength\pgf@y{+0.5ex}% |
| 713 |
}% |
| 714 |
\savedanchor\basepoint{% |
| 715 |
\[email protected]\wd\pgfnodeparttextbox% |
| 716 |
\pgf@y0pt% |
| 717 |
}% |
| 718 |
\inheritanchor[from=and gate IEC]{center}% |
| 719 |
\inheritanchor[from=and gate IEC]{mid}% |
| 720 |
\inheritanchor[from=and gate IEC]{mid west}% |
| 721 |
\inheritanchor[from=and gate IEC]{mid east}% |
| 722 |
\inheritanchor[from=and gate IEC]{base}% |
| 723 |
\inheritanchor[from=and gate IEC]{base west}% |
| 724 |
\inheritanchor[from=and gate IEC]{base east}% |
| 725 |
\inheritanchor[from=and gate IEC]{north}% |
| 726 |
\inheritanchor[from=and gate IEC]{south}% |
| 727 |
\inheritanchor[from=and gate IEC]{east}% |
| 728 |
\inheritanchor[from=and gate IEC]{west}% |
| 729 |
\inheritanchor[from=and gate IEC]{north east}% |
| 730 |
\inheritanchor[from=and gate IEC]{north west}% |
| 731 |
\inheritanchor[from=and gate IEC]{south east}% |
| 732 |
\inheritanchor[from=and gate IEC]{south west}% |
| 733 |
\inheritanchor[from=nand gate IEC]{output}% |
| 734 |
\inheritbackgroundpath[from=nand gate IEC]% |
| 735 |
\foregroundpath{\pgf@lib@sh@logicgates@IEC@foregroundpath{not}}% |
| 736 |
\inheritanchorborder[from=and gate IEC]% |
| 737 |
}% |
| 738 |
|
| 739 |
\endinput |