| 1 |
% Copyright 2018-2026 by Romano Giannetti |
| 2 |
% Copyright 2015-2026 by Stefan Lindner |
| 3 |
% Copyright 2013-2026 by Stefan Erhardt |
| 4 |
% Copyright 2007-2026 by Massimo Redaelli |
| 5 |
% |
| 6 |
% This file may be distributed and/or modified |
| 7 |
% |
| 8 |
% 1. under the LaTeX Project Public License and/or |
| 9 |
% 2. under the GNU Public License. |
| 10 |
% |
| 11 |
% See the files gpl-3.0_license.txt and lppl-1-3c_license.txt for more details. |
| 12 |
|
| 13 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 14 |
%% Chips and Rotary Switches |
| 15 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 16 |
|
| 17 |
% Definitions for Chips and Rotary switches (multipoles) %<<<1 |
| 18 |
% |
| 19 |
\ctikzset{multipoles/thickness/.initial=2} |
| 20 |
\ctikzset{multipoles/font/.initial=\pgf@circ@font@tiny} |
| 21 |
\ctikzset{multipoles/draw only pins/.initial={all}} |
| 22 |
\ctikzset{multipoles/draw only left pins/.initial={all}} |
| 23 |
\ctikzset{multipoles/draw only right pins/.initial={all}} |
| 24 |
\ctikzset{multipoles/draw only top pins/.initial={all}} |
| 25 |
\ctikzset{multipoles/draw only bottom pins/.initial={all}} |
| 26 |
\pgfqkeys{/tikz}{draw only pins/.add code={}{\ctikzset{multipoles/draw only pins={#1}}}} |
| 27 |
\pgfqkeys{/tikz}{draw only left pins/.add code={}{\ctikzset{multipoles/draw only left pins={#1}}}} |
| 28 |
\pgfqkeys{/tikz}{draw only right pins/.add code={}{\ctikzset{multipoles/draw only right pins={#1}}}} |
| 29 |
\pgfqkeys{/tikz}{draw only top pins/.add code={}{\ctikzset{multipoles/draw only top pins={#1}}}} |
| 30 |
\pgfqkeys{/tikz}{draw only bottom pins/.add code={}{\ctikzset{multipoles/draw only bottom pins={#1}}}} |
| 31 |
% DIP (dual in line package) chips |
| 32 |
\ctikzset{multipoles/dipchip/width/.initial=1.2} |
| 33 |
\ctikzset{multipoles/dipchip/num pins/.initial=8} |
| 34 |
\ctikzset{multipoles/dipchip/pin spacing/.initial=0.4} |
| 35 |
\pgfkeys{/tikz/num pins/.add code={}{\ctikzset{multipoles/dipchip/num pins=#1}}} |
| 36 |
% QFP (quad flat package) chips |
| 37 |
\ctikzset{multipoles/qfpchip/num pins/.initial=8} |
| 38 |
\ctikzset{multipoles/qfpchip/pin spacing/.initial=0.4} |
| 39 |
\pgfkeys{/tikz/num pins/.add code={}{\ctikzset{multipoles/qfpchip/num pins=#1}}} |
| 40 |
% chip numbers |
| 41 |
\newif\ifpgf@circuit@chip@shownumbers\pgf@circuit@chip@shownumberstrue |
| 42 |
\pgfkeys{/tikz/show numbers/.add code={}{\pgf@circuit@chip@shownumberstrue}} |
| 43 |
\ctikzset{show numbers/.add code={}{\pgf@circuit@chip@shownumberstrue}} |
| 44 |
\pgfkeys{/tikz/hide numbers/.add code={}{\pgf@circuit@chip@shownumbersfalse}} |
| 45 |
\ctikzset{hide numbers/.add code={}{\pgf@circuit@chip@shownumbersfalse}} |
| 46 |
\newif\ifpgf@circuit@chip@straightnumbers\pgf@circuit@chip@straightnumberstrue |
| 47 |
\pgfkeys{/tikz/straight numbers/.add code={}{\pgf@circuit@chip@straightnumberstrue}} |
| 48 |
\ctikzset{straight numbers/.add code={}{\pgf@circuit@chip@straightnumberstrue}} |
| 49 |
\pgfkeys{/tikz/rotated numbers/.add code={}{\pgf@circuit@chip@straightnumbersfalse}} |
| 50 |
\ctikzset{rotated numbers/.add code={}{\pgf@circuit@chip@straightnumbersfalse}} |
| 51 |
% external chip pins |
| 52 |
\ctikzset{multipoles/external pins thickness/.initial=1} |
| 53 |
\ctikzset{multipoles/external pins width/.initial=0.2} |
| 54 |
\ctikzset{multipoles/external pad fraction/.initial=0} |
| 55 |
\pgfkeys{/tikz/external pins width/.add code={}{\ctikzset{multipoles/external pins width=#1}}} |
| 56 |
\pgfkeys{/tikz/external pad fraction/.add code={}{\ctikzset{multipoles/external pad fraction=#1}}} |
| 57 |
% topmarks |
| 58 |
\newif\ifpgf@circuit@chip@topmark\pgf@circuit@chip@topmarktrue |
| 59 |
\pgfkeys{/tikz/topmark/.add code={}{\pgf@circuit@chip@topmarktrue}} |
| 60 |
\ctikzset{topmark/.add code={}{\pgf@circuit@chip@topmarktrue}} |
| 61 |
\pgfkeys{/tikz/no topmark/.add code={}{\pgf@circuit@chip@topmarkfalse}} |
| 62 |
\ctikzset{no topmark/.add code={}{\pgf@circuit@chip@topmarkfalse}} |
| 63 |
|
| 64 |
% rotary switch by Romano |
| 65 |
\ctikzset{multipoles/rotary/thickness/.initial=1} |
| 66 |
\ctikzset{multipoles/rotary/shape/.initial=ocirc} |
| 67 |
\ctikzset{multipoles/rotary/channels/.initial=5} |
| 68 |
\ctikzset{multipoles/rotary/angle/.initial=60} |
| 69 |
\ctikzset{multipoles/rotary/wiper/.initial=20} |
| 70 |
\ctikzset{multipoles/rotary/arrow/.is choice} |
| 71 |
\newif\ifpgf@circ@rotaryarrow\pgf@circ@rotaryarrowfalse |
| 72 |
\newif\ifpgf@circ@rotaryarrow@cw\pgf@circ@rotaryarrow@cwfalse |
| 73 |
\newif\ifpgf@circ@rotaryarrow@ccw\pgf@circ@rotaryarrow@ccwfalse |
| 74 |
\ctikzset{multipoles/rotary/arrow/none/.code={\pgf@circ@rotaryarrowfalse\pgf@circ@rotaryarrow@cwfalse\pgf@circ@rotaryarrow@ccwfalse}} |
| 75 |
\ctikzset{multipoles/rotary/arrow/both/.code={\pgf@circ@rotaryarrowtrue\pgf@circ@rotaryarrow@cwtrue\pgf@circ@rotaryarrow@ccwtrue}} |
| 76 |
\ctikzset{multipoles/rotary/arrow/cw/.code={\pgf@circ@rotaryarrowtrue\pgf@circ@rotaryarrow@cwtrue\pgf@circ@rotaryarrow@ccwfalse}} |
| 77 |
\ctikzset{multipoles/rotary/arrow/ccw/.code={\pgf@circ@rotaryarrowtrue\pgf@circ@rotaryarrow@cwfalse\pgf@circ@rotaryarrow@ccwtrue}} |
| 78 |
|
| 79 |
\tikzset{% |
| 80 |
rotary switch/.style args={#1in#2wiper#3}{% |
| 81 |
shape=rotaryswitch, |
| 82 |
/tikz/circuitikz/multipoles/rotary/channels=#1, |
| 83 |
/tikz/circuitikz/multipoles/rotary/angle=#2, |
| 84 |
/tikz/circuitikz/multipoles/rotary/wiper=#3, |
| 85 |
}, |
| 86 |
rotary switch -/.style args={#1in#2wiper#3}{ |
| 87 |
rotary switch=#1 in #2 wiper #3, |
| 88 |
/tikz/circuitikz/multipoles/rotary/arrow=none, |
| 89 |
}, |
| 90 |
rotary switch <-/.style args={#1in#2wiper#3}{ |
| 91 |
rotary switch=#1 in #2 wiper #3, |
| 92 |
/tikz/circuitikz/multipoles/rotary/arrow=ccw, |
| 93 |
}, |
| 94 |
rotary switch ->/.style args={#1in#2wiper#3}{ |
| 95 |
rotary switch=#1 in #2 wiper #3, |
| 96 |
/tikz/circuitikz/multipoles/rotary/arrow=cw, |
| 97 |
}, |
| 98 |
rotary switch <->/.style args={#1in#2wiper#3}{ |
| 99 |
rotary switch=#1 in #2 wiper #3, |
| 100 |
/tikz/circuitikz/multipoles/rotary/arrow=both, |
| 101 |
}, |
| 102 |
% Notice that these should be the same as the initial values of the keys |
| 103 |
rotary switch/.default={5 in 60 wiper 20}, |
| 104 |
rotary switch -/.default={5 in 60 wiper 20}, |
| 105 |
rotary switch <-/.default={5 in 60 wiper 20}, |
| 106 |
rotary switch ->/.default={5 in 60 wiper 20}, |
| 107 |
rotary switch <->/.default={5 in 60 wiper 20}, |
| 108 |
} |
| 109 |
%%>>> |
| 110 |
|
| 111 |
%% Nodes definitions for chips%<<< |
| 112 |
|
| 113 |
%%%%%%%%% |
| 114 |
%% Chips |
| 115 |
%%%%%%%%% |
| 116 |
|
| 117 |
% let's use the same shifts everywhere, no magic numbers |
| 118 |
\def\pgf@circ@dip@pin@shift{0.5} |
| 119 |
\def\pgf@circ@qfp@pin@shift{0.25} |
| 120 |
|
| 121 |
% derived from https://tex.stackexchange.com/a/146753/38080 |
| 122 |
% original author Mark Wibrow |
| 123 |
% Thanks also to John Kormylo https://tex.stackexchange.com/a/372996/38080 |
| 124 |
% a lot of thanks to @marmot for the un-rotation hint |
| 125 |
% https://tex.stackexchange.com/a/473571/38080 |
| 126 |
% modifications for 'draw only pins' by Jonathan P. Spratte |
| 127 |
|
| 128 |
% DIP (dual in line package) chips |
| 129 |
|
| 130 |
% helper macro to set the anchors inside a loop (to expand the current count) |
| 131 |
\pgfutil@protected\def\pgf@circ@make@dippin@anchor#1% |
| 132 |
{% |
| 133 |
\expandafter\gdef\csname pgf@anchor@dipchip@pin #1\endcsname |
| 134 |
{% |
| 135 |
\pgf@circ@if@num@in@list\pgf@circ@pins@list{#1} |
| 136 |
{\pgf@circ@dippinanchor{#1}{1}} |
| 137 |
{\pgf@circ@dippinanchor{#1}{0}}% |
| 138 |
}% |
| 139 |
\expandafter\gdef\csname pgf@anchor@dipchip@bpin #1\endcsname |
| 140 |
{\pgf@circ@dippinanchor{#1}{0}}% |
| 141 |
} |
| 142 |
|
| 143 |
\pgfdeclareshape{dipchip}{ |
| 144 |
\savedmacro{\ctikzclass}{\edef\ctikzclass{chips}} |
| 145 |
\saveddimen{\scaledRlen}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}} |
| 146 |
\savedmacro\numpins{% |
| 147 |
\pgf@circ@count@a=\ctikzvalof{multipoles/dipchip/num pins}% |
| 148 |
\def\numpins{\the\pgf@circ@count@a} |
| 149 |
} |
| 150 |
\savedmacro\pgf@circ@pins@list |
| 151 |
{% |
| 152 |
\pgfkeysgetvalue |
| 153 |
{\circuitikzbasekey/multipoles/draw only pins}\pgf@circ@temp |
| 154 |
\expandafter\pgf@circ@set@list |
| 155 |
\expandafter\pgf@circ@pins@list |
| 156 |
\expandafter{\pgf@circ@temp}% |
| 157 |
}% |
| 158 |
\savedanchor\textanchor{% |
| 159 |
\pgf@x=-.5\wd\pgfnodeparttextbox% |
| 160 |
\pgf@y=-.5\ht\pgfnodeparttextbox% |
| 161 |
\advance\pgf@y by+.5\dp\pgfnodeparttextbox% |
| 162 |
}% |
| 163 |
\savedanchor\origin{\pgfpoint{0pt}{0pt}} |
| 164 |
\anchor{center}{\origin} |
| 165 |
\anchor{text}{\textanchor}% to adjust text |
| 166 |
\saveddimen\height{% |
| 167 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 168 |
\pgfmathsetlength\pgf@x{((\numpins) |
| 169 |
*\ctikzvalof{multipoles/dipchip/pin spacing})*\pgf@circ@scaled@Rlen/2}% |
| 170 |
}% |
| 171 |
\saveddimen{\chipspacing}{ |
| 172 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 173 |
\pgfmathsetlength\pgf@x{\pgf@circ@scaled@Rlen*\ctikzvalof{multipoles/dipchip/pin spacing}}} |
| 174 |
\saveddimen{\width}{ |
| 175 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 176 |
\pgfmathsetlength\pgf@x{\pgf@circ@scaled@Rlen*\ctikzvalof{multipoles/dipchip/width}}} |
| 177 |
\saveddimen{\extshift}{ |
| 178 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 179 |
\pgfmathsetlength\pgf@x{\pgf@circ@scaled@Rlen*\ctikzvalof{multipoles/external pins width}}} |
| 180 |
% standard anchors |
| 181 |
\savedanchor\northwest{% |
| 182 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 183 |
\pgfmathsetlength\pgf@y{0.5*((\numpins) |
| 184 |
*\ctikzvalof{multipoles/dipchip/pin spacing})*\pgf@circ@scaled@Rlen/2}% |
| 185 |
\pgfmathsetlength\pgf@x{-0.5*\pgf@circ@scaled@Rlen*\ctikzvalof{multipoles/dipchip/width}} |
| 186 |
} |
| 187 |
\anchor{dot}{\northwest |
| 188 |
\pgfmathsetlength\pgf@x{\pgf@x + 0.3*\chipspacing} |
| 189 |
\pgfmathsetlength\pgf@y{\pgf@y - 0.3*\chipspacing} |
| 190 |
} |
| 191 |
\anchor{nw}{\northwest} |
| 192 |
\anchor{ne}{\northwest\pgf@x=-\pgf@x} |
| 193 |
\anchor{se}{\northwest\pgf@x=-\pgf@x\pgf@y=-\pgf@y} |
| 194 |
\anchor{sw}{\northwest\pgf@y=-\pgf@y} |
| 195 |
\anchor{north west}{\northwest} |
| 196 |
\anchor{north east}{\northwest\pgf@x=-\pgf@x} |
| 197 |
\anchor{south east}{\northwest\pgf@x=-\pgf@x \pgf@y=-\pgf@y} |
| 198 |
\anchor{south west}{\northwest\pgf@y=-\pgf@y} |
| 199 |
\anchor{n}{\northwest\pgf@x=0pt } |
| 200 |
\anchor{e}{\northwest\pgf@x=-\pgf@x\pgf@y=0pt } |
| 201 |
\anchor{s}{\northwest\pgf@x=0pt\pgf@y=-\pgf@y} |
| 202 |
\anchor{w}{\northwest\pgf@y=0pt } |
| 203 |
\anchor{north}{\northwest\pgf@x=0pt } |
| 204 |
\anchor{east}{\northwest\pgf@x=-\pgf@x\pgf@y=0pt } |
| 205 |
\anchor{south}{\northwest\pgf@x=0pt\pgf@y=-\pgf@y} |
| 206 |
\anchor{west}{\northwest\pgf@y=0pt } |
| 207 |
% start drawing |
| 208 |
\pgf@circ@draw@component{% |
| 209 |
\northwest |
| 210 |
\pgf@circ@res@up = \pgf@y |
| 211 |
\pgf@circ@res@down = -\pgf@y |
| 212 |
\pgf@circ@res@right = -\pgf@x |
| 213 |
\pgf@circ@res@left = \pgf@x |
| 214 |
\pgf@circ@scaled@Rlen=\scaledRlen |
| 215 |
\pgf@circ@res@step = \ctikzvalof{multipoles/dipchip/pin spacing}\pgf@circ@scaled@Rlen |
| 216 |
\pgf@circ@res@other = \ctikzvalof{multipoles/external pins width}\pgf@circ@scaled@Rlen |
| 217 |
\pgfscope% (for the line width) |
| 218 |
\pgf@circ@setlinewidth{multipoles}{\pgflinewidth} |
| 219 |
\pgfpathrectanglecorners{\pgfpoint{-\width/2}{-\height/2}}{\pgfpoint{\width/2}{\height/2}}% |
| 220 |
\pgf@circ@draworfill |
| 221 |
%% upside mark |
| 222 |
\ifpgf@circuit@chip@topmark |
| 223 |
\pgfpathmoveto{\pgfpoint{0.2*\pgf@circ@res@left}{\pgf@circ@res@up}} |
| 224 |
\pgfpatharc{0}{180}{0.2*\pgf@circ@res@left} |
| 225 |
\fi |
| 226 |
\pgfusepath{stroke}% |
| 227 |
\pgf@circ@setcolor |
| 228 |
% Adding the pin number |
| 229 |
\ifpgf@circuit@chip@shownumbers |
| 230 |
\pgf@circ@count@a=\numpins\relax |
| 231 |
\divide\pgf@circ@count@a by 2 \pgf@circ@count@b=\pgf@circ@count@a |
| 232 |
% thanks to @marmot: https://tex.stackexchange.com/a/473571/38080 |
| 233 |
\ifpgf@circuit@chip@straightnumbers |
| 234 |
\pgfgettransformentries\a\b\temp\temp\temp\temp |
| 235 |
\pgfmathsetmacro{\rot}{-atan2(\b,\a)} |
| 236 |
\pgfmathtruncatemacro{\quadrant}{mod(4+int(360+(\rot+45)/90),4)} |
| 237 |
\else |
| 238 |
\pgfmathsetmacro{\rot}{0} |
| 239 |
\pgfmathsetmacro{\quadrant}{0} |
| 240 |
\fi |
| 241 |
\def\pgf@circ@strut{\vrule width 0pt height 1em depth 0.4em\relax} |
| 242 |
\pgfscope\pgf@circ@text@strokecolor |
| 243 |
\def\mytext{\ctikzvalof{multipoles/font}\space\pgf@circ@strut\the\pgf@circ@count@c\space} |
| 244 |
\pgfmathloop% |
| 245 |
\ifnum\pgf@circ@count@a>0 |
| 246 |
\ifcase\quadrant % rotation 0 |
| 247 |
% left |
| 248 |
\pgf@circ@count@c=\pgf@circ@count@a |
| 249 |
\pgftext[left, |
| 250 |
at=\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}, |
| 251 |
rotate=\rot]{\mytext} |
| 252 |
% right |
| 253 |
\pgf@circ@count@c=\numexpr2*\pgf@circ@count@b-\pgf@circ@count@a+1\relax |
| 254 |
\pgftext[right, |
| 255 |
at=\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}, |
| 256 |
rotate=\rot]{\mytext} |
| 257 |
\or % rotation -90 |
| 258 |
% left |
| 259 |
\pgf@circ@count@c=\pgf@circ@count@a |
| 260 |
\pgftext[top, |
| 261 |
at=\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}, |
| 262 |
rotate=\rot]{\mytext} |
| 263 |
% right |
| 264 |
\pgf@circ@count@c=\numexpr2*\pgf@circ@count@b-\pgf@circ@count@a+1\relax |
| 265 |
\pgftext[bottom, |
| 266 |
at=\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}, |
| 267 |
rotate=\rot]{\mytext} |
| 268 |
\or %rotation 180 |
| 269 |
% left |
| 270 |
\pgf@circ@count@c=\pgf@circ@count@a |
| 271 |
\pgftext[right, |
| 272 |
at=\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}, |
| 273 |
rotate=\rot]{\mytext} |
| 274 |
% right |
| 275 |
\pgf@circ@count@c=\numexpr2*\pgf@circ@count@b-\pgf@circ@count@a+1\relax |
| 276 |
\pgftext[left, |
| 277 |
at=\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}, |
| 278 |
rotate=\rot]{\mytext} |
| 279 |
\or % rotation +90 |
| 280 |
% left |
| 281 |
\pgf@circ@count@c=\pgf@circ@count@a |
| 282 |
\pgftext[bottom, |
| 283 |
at=\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}, |
| 284 |
rotate=\rot]{\mytext} |
| 285 |
% right |
| 286 |
\pgf@circ@count@c=\numexpr2*\pgf@circ@count@b-\pgf@circ@count@a+1\relax |
| 287 |
\pgftext[top, |
| 288 |
at=\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}, |
| 289 |
rotate=\rot]{\mytext} |
| 290 |
\fi |
| 291 |
\advance\pgf@circ@count@a-1\relax% |
| 292 |
\repeatpgfmathloop |
| 293 |
\endpgfscope % for color of text |
| 294 |
\fi |
| 295 |
\endpgfscope |
| 296 |
% draw external pins or pads |
| 297 |
\ifdim\pgf@circ@res@other>0pt |
| 298 |
\ifpgfcirc@draw@input@leads |
| 299 |
\pgfscope |
| 300 |
\pgfsetlinewidth{\ctikzvalof{multipoles/external pins thickness}\pgflinewidth} |
| 301 |
\pgf@circ@count@a=\numpins\relax |
| 302 |
\divide\pgf@circ@count@a by 2 \pgf@circ@count@b=\pgf@circ@count@a |
| 303 |
\edef\padfrac{\ctikzvalof{multipoles/external pad fraction}} |
| 304 |
\ifnum\padfrac>0 |
| 305 |
\pgf@circ@res@temp=\pgf@circ@res@step\divide\pgf@circ@res@temp by \padfrac |
| 306 |
\fi |
| 307 |
\pgfmathloop% |
| 308 |
\ifnum\pgf@circ@count@a>0 |
| 309 |
% left side |
| 310 |
\pgf@circ@if@num@in@list\pgf@circ@pins@list\pgf@circ@count@a |
| 311 |
{% |
| 312 |
\ifnum\padfrac>0 |
| 313 |
% pads |
| 314 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 315 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 316 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 317 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 318 |
\else |
| 319 |
% pins |
| 320 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 321 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 322 |
\fi |
| 323 |
} |
| 324 |
{}% |
| 325 |
% right side |
| 326 |
\pgf@circ@if@num@in@list\pgf@circ@pins@list{\numpins+1-\pgf@circ@count@a} |
| 327 |
{% |
| 328 |
\ifnum\padfrac>0 |
| 329 |
% pads |
| 330 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 331 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 332 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 333 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 334 |
\else |
| 335 |
% pins |
| 336 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 337 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 338 |
\fi |
| 339 |
} |
| 340 |
{}% |
| 341 |
\advance\pgf@circ@count@a by -1\relax% |
| 342 |
\repeatpgfmathloop |
| 343 |
\pgfusepath{stroke} |
| 344 |
\endpgfscope |
| 345 |
\fi |
| 346 |
\fi |
| 347 |
}% |
| 348 |
\pgfutil@g@addto@macro\pgf@sh@s@dipchip{% |
| 349 |
\pgf@circ@count@a=\numpins |
| 350 |
\pgfmathloop |
| 351 |
\ifnum\pgf@circ@count@a>0 |
| 352 |
% we will create two anchors per pin: the "normal one" like `pin 1` for the |
| 353 |
% electrical contact, and the "border one" like `bpin 1` for labels. |
| 354 |
% they will coincide if `external pins width` is set to 0. |
| 355 |
% see the helper function above the start of the shape definition (by Jonathan P. Spratte) |
| 356 |
\expandafter\pgf@circ@make@dippin@anchor\expandafter{\the\pgf@circ@count@a}% |
| 357 |
\advance\pgf@circ@count@a by -1\relax |
| 358 |
\repeatpgfmathloop |
| 359 |
}% |
| 360 |
} |
| 361 |
|
| 362 |
% QFP (quad flat package) chips |
| 363 |
% helper macro to set the anchors inside a loop (to expand the current count) |
| 364 |
\pgfutil@protected\def\pgf@circ@make@qfppin@anchor#1% |
| 365 |
{% |
| 366 |
\expandafter\gdef\csname pgf@anchor@qfpchip@pin #1\endcsname |
| 367 |
{% |
| 368 |
\pgf@circ@if@num@in@list\pgf@circ@pins@list{#1} |
| 369 |
{\pgf@circ@qfppinanchor{#1}{1}} |
| 370 |
{\pgf@circ@qfppinanchor{#1}{0}}% |
| 371 |
}% |
| 372 |
\expandafter\gdef\csname pgf@anchor@qfpchip@bpin #1\endcsname |
| 373 |
{\pgf@circ@qfppinanchor{#1}{0}}% |
| 374 |
} |
| 375 |
|
| 376 |
\pgfdeclareshape{qfpchip}{ |
| 377 |
\savedmacro{\ctikzclass}{\edef\ctikzclass{chips}} |
| 378 |
\saveddimen{\scaledRlen}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}} |
| 379 |
\savedmacro\numpins{% |
| 380 |
\pgf@circ@count@a=\ctikzvalof{multipoles/qfpchip/num pins}% |
| 381 |
\def\numpins{\the\pgf@circ@count@a} |
| 382 |
} |
| 383 |
\savedmacro\pgf@circ@pins@list |
| 384 |
{% some magic here, thanks to Jonathan P. Spratte |
| 385 |
\pgfkeysgetvalue |
| 386 |
{\circuitikzbasekey/multipoles/draw only pins}\pgf@circ@temp |
| 387 |
\expandafter\pgf@circ@set@list |
| 388 |
\expandafter\pgf@circ@pins@list |
| 389 |
\expandafter{\pgf@circ@temp}% |
| 390 |
}% |
| 391 |
\savedanchor\textanchor{% |
| 392 |
\pgf@x=-.5\wd\pgfnodeparttextbox% |
| 393 |
\pgf@y=-.5\ht\pgfnodeparttextbox% |
| 394 |
\advance\pgf@y by+.5\dp\pgfnodeparttextbox% |
| 395 |
}% |
| 396 |
\savedanchor\origin{\pgfpoint{0pt}{0pt}} |
| 397 |
\anchor{center}{\origin} |
| 398 |
\anchor{text}{\textanchor}% to adjust text |
| 399 |
\saveddimen\height{% |
| 400 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 401 |
\pgfmathsetlength\pgf@x{((\numpins+2) |
| 402 |
*\ctikzvalof{multipoles/qfpchip/pin spacing})*\pgf@circ@scaled@Rlen/4}% |
| 403 |
}% |
| 404 |
\saveddimen\width{% |
| 405 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 406 |
\pgfmathsetlength\pgf@x{((\numpins+2) |
| 407 |
*\ctikzvalof{multipoles/qfpchip/pin spacing})*\pgf@circ@scaled@Rlen/4}% |
| 408 |
}% |
| 409 |
\saveddimen{\chipspacing}{ |
| 410 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 411 |
\pgfmathsetlength\pgf@x{\pgf@circ@scaled@Rlen*\ctikzvalof{multipoles/qfpchip/pin spacing}}} |
| 412 |
\saveddimen{\extshift}{ |
| 413 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 414 |
\pgfmathsetlength\pgf@x{\pgf@circ@scaled@Rlen*\ctikzvalof{multipoles/external pins width}}} |
| 415 |
% standard anchors |
| 416 |
\savedanchor\northwest{% |
| 417 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 418 |
\pgfmathsetlength\pgf@y{0.5*((\numpins+2) |
| 419 |
*\ctikzvalof{multipoles/qfpchip/pin spacing})*\pgf@circ@scaled@Rlen/4}% |
| 420 |
\pgf@x=-\pgf@y |
| 421 |
} |
| 422 |
\anchor{dot}{\northwest |
| 423 |
\pgfmathsetlength\pgf@x{\pgf@x + 0.3*\chipspacing} |
| 424 |
\pgfmathsetlength\pgf@y{\pgf@y - 0.3*\chipspacing} |
| 425 |
} |
| 426 |
\anchor{nw}{\northwest} |
| 427 |
\anchor{ne}{\northwest\pgf@x=-\pgf@x} |
| 428 |
\anchor{se}{\northwest\pgf@x=-\pgf@x\pgf@y=-\pgf@y} |
| 429 |
\anchor{sw}{\northwest\pgf@y=-\pgf@y} |
| 430 |
\anchor{north west}{\northwest} |
| 431 |
\anchor{north east}{\northwest\pgf@x=-\pgf@x} |
| 432 |
\anchor{south east}{\northwest\pgf@x=-\pgf@x \pgf@y=-\pgf@y} |
| 433 |
\anchor{south west}{\northwest\pgf@y=-\pgf@y} |
| 434 |
\anchor{n}{\northwest\pgf@x=0pt } |
| 435 |
\anchor{e}{\northwest\pgf@x=-\pgf@x\pgf@y=0pt } |
| 436 |
\anchor{s}{\northwest\pgf@x=0pt\pgf@y=-\pgf@y} |
| 437 |
\anchor{w}{\northwest\pgf@y=0pt } |
| 438 |
\anchor{north}{\northwest\pgf@x=0pt } |
| 439 |
\anchor{east}{\northwest\pgf@x=-\pgf@x\pgf@y=0pt } |
| 440 |
\anchor{south}{\northwest\pgf@x=0pt\pgf@y=-\pgf@y} |
| 441 |
\anchor{west}{\northwest\pgf@y=0pt } |
| 442 |
% start drawing |
| 443 |
\pgf@circ@draw@component{% |
| 444 |
\northwest |
| 445 |
\pgf@circ@res@up = \pgf@y |
| 446 |
\pgf@circ@res@down = -\pgf@y |
| 447 |
\pgf@circ@res@right = -\pgf@x |
| 448 |
\pgf@circ@res@left = \pgf@x |
| 449 |
\pgf@circ@scaled@Rlen=\scaledRlen |
| 450 |
\pgf@circ@res@step = \ctikzvalof{multipoles/qfpchip/pin spacing}\pgf@circ@scaled@Rlen |
| 451 |
\pgf@circ@res@other = \ctikzvalof{multipoles/external pins width}\pgf@circ@scaled@Rlen |
| 452 |
\pgfscope% (for the line width) |
| 453 |
\pgf@circ@setlinewidth{multipoles}{\pgflinewidth} |
| 454 |
%% upside mark |
| 455 |
\ifpgf@circuit@chip@topmark |
| 456 |
\pgfpathmoveto{\pgfpoint{-\width/2}{\height/2-\pgf@circ@res@step/2}} |
| 457 |
\pgfpathlineto{\pgfpoint{-\width/2+\pgf@circ@res@step/2}{\height/2}} |
| 458 |
\else |
| 459 |
\pgfpathmoveto{\pgfpoint{-\width/2}{\height/2}} |
| 460 |
\fi |
| 461 |
%% rest of the shape |
| 462 |
\pgfpathlineto{\pgfpoint{\width/2}{\height/2}} |
| 463 |
\pgfpathlineto{\pgfpoint{\width/2}{-\height/2}} |
| 464 |
\pgfpathlineto{\pgfpoint{-\width/2}{-\height/2}} |
| 465 |
\pgfpathclose |
| 466 |
\pgf@circ@draworfill |
| 467 |
% Adding the pin number |
| 468 |
\pgf@circ@setcolor |
| 469 |
\ifpgf@circuit@chip@shownumbers |
| 470 |
\pgf@circ@count@a=\numpins% |
| 471 |
\divide\pgf@circ@count@a by 4 \pgf@circ@count@b=\pgf@circ@count@a |
| 472 |
% thanks to @marmot: https://tex.stackexchange.com/a/473571/38080 |
| 473 |
\ifpgf@circuit@chip@straightnumbers |
| 474 |
\pgfgettransformentries\a\b\temp\temp\temp\temp |
| 475 |
\pgfmathsetmacro{\rot}{-atan2(\b,\a)} |
| 476 |
\pgfmathtruncatemacro{\quadrant}{mod(4+int(360+(\rot+45)/90),4)} |
| 477 |
\else |
| 478 |
\pgfmathsetmacro{\rot}{0} |
| 479 |
\pgfmathsetmacro{\quadrant}{0} |
| 480 |
\fi |
| 481 |
\def\pgf@circ@strut{\vrule width 0pt height 1em depth 0.4em\relax} |
| 482 |
\def\mytext{\ctikzvalof{multipoles/font}\space\pgf@circ@strut\the\pgf@circ@count@c\space} |
| 483 |
\pgfscope\pgf@circ@text@strokecolor |
| 484 |
\pgfmathloop% |
| 485 |
\ifnum\pgf@circ@count@a>0 |
| 486 |
\ifcase\quadrant % rotation 0 |
| 487 |
% left |
| 488 |
\pgf@circ@count@c=\pgf@circ@count@a |
| 489 |
\pgftext[left, |
| 490 |
at=\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}, |
| 491 |
rotate=\rot]{\mytext} |
| 492 |
% bottom |
| 493 |
\pgf@circ@count@c=\numexpr\pgf@circ@count@b+\pgf@circ@count@a\relax |
| 494 |
\pgftext[bottom, |
| 495 |
at=\pgfpoint{\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down}, |
| 496 |
rotate=\rot]{\mytext} |
| 497 |
% right |
| 498 |
\pgf@circ@count@c=\numexpr3*\pgf@circ@count@b-\pgf@circ@count@a+1\relax |
| 499 |
\pgftext[right, |
| 500 |
at=\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}, |
| 501 |
rotate=\rot]{\mytext} |
| 502 |
% top |
| 503 |
\pgf@circ@count@c=\numexpr3*\pgf@circ@count@b+\pgf@circ@count@a\relax |
| 504 |
\pgftext[top, |
| 505 |
at=\pgfpoint{\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up}, |
| 506 |
rotate=\rot]{\mytext} |
| 507 |
\or % rotation -90 |
| 508 |
% left |
| 509 |
\pgf@circ@count@c=\pgf@circ@count@a |
| 510 |
\pgftext[top, |
| 511 |
at=\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}, |
| 512 |
rotate=\rot]{\mytext} |
| 513 |
% bottom |
| 514 |
\pgf@circ@count@c=\numexpr\pgf@circ@count@b+\pgf@circ@count@a\relax |
| 515 |
\pgftext[left, |
| 516 |
at=\pgfpoint{\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down}, |
| 517 |
rotate=\rot]{\mytext} |
| 518 |
% right |
| 519 |
\pgf@circ@count@c=\numexpr3*\pgf@circ@count@b-\pgf@circ@count@a+1\relax |
| 520 |
\pgftext[bottom, |
| 521 |
at=\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}, |
| 522 |
rotate=\rot]{\mytext} |
| 523 |
% top |
| 524 |
\pgf@circ@count@c=\numexpr3*\pgf@circ@count@b+\pgf@circ@count@a\relax |
| 525 |
\pgftext[right, |
| 526 |
at=\pgfpoint{\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up}, |
| 527 |
rotate=\rot]{\mytext} |
| 528 |
\or %rotation 180 |
| 529 |
% left |
| 530 |
\pgf@circ@count@c=\pgf@circ@count@a |
| 531 |
\pgftext[right, |
| 532 |
at=\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}, |
| 533 |
rotate=\rot]{\mytext} |
| 534 |
% bottom |
| 535 |
\pgf@circ@count@c=\numexpr\pgf@circ@count@b+\pgf@circ@count@a\relax |
| 536 |
\pgftext[top, |
| 537 |
at=\pgfpoint{\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down}, |
| 538 |
rotate=\rot]{\mytext} |
| 539 |
% right |
| 540 |
\pgf@circ@count@c=\numexpr3*\pgf@circ@count@b-\pgf@circ@count@a+1\relax |
| 541 |
\pgftext[left, |
| 542 |
at=\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}, |
| 543 |
rotate=\rot]{\mytext} |
| 544 |
% top |
| 545 |
\pgf@circ@count@c=\numexpr3*\pgf@circ@count@b+\pgf@circ@count@a\relax |
| 546 |
\pgftext[bottom, |
| 547 |
at=\pgfpoint{\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up}, |
| 548 |
rotate=\rot]{\mytext} |
| 549 |
\or % rotation +90 |
| 550 |
% left |
| 551 |
\pgf@circ@count@c=\pgf@circ@count@a |
| 552 |
\pgftext[bottom, |
| 553 |
at=\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}, |
| 554 |
rotate=\rot]{\mytext} |
| 555 |
% bottom |
| 556 |
\pgf@circ@count@c=\numexpr\pgf@circ@count@b+\pgf@circ@count@a\relax |
| 557 |
\pgftext[right, |
| 558 |
at=\pgfpoint{\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down}, |
| 559 |
rotate=\rot]{\mytext} |
| 560 |
% right |
| 561 |
\pgf@circ@count@c=\numexpr3*\pgf@circ@count@b-\pgf@circ@count@a+1\relax |
| 562 |
\pgftext[top, |
| 563 |
at=\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}, |
| 564 |
rotate=\rot]{\mytext} |
| 565 |
% top |
| 566 |
\pgf@circ@count@c=\numexpr3*\pgf@circ@count@b+\pgf@circ@count@a\relax |
| 567 |
\pgftext[left, |
| 568 |
at=\pgfpoint{\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up}, |
| 569 |
rotate=\rot]{\mytext} |
| 570 |
\fi |
| 571 |
\advance\pgf@circ@count@a-1\relax% |
| 572 |
\repeatpgfmathloop |
| 573 |
\endpgfscope % for the text labels |
| 574 |
\fi |
| 575 |
\endpgfscope |
| 576 |
\ifdim\pgf@circ@res@other>0pt |
| 577 |
\ifpgfcirc@draw@input@leads |
| 578 |
\pgfscope |
| 579 |
\pgfsetlinewidth{\ctikzvalof{multipoles/external pins thickness}\pgflinewidth} |
| 580 |
\pgf@circ@count@a=\numpins% |
| 581 |
\divide\pgf@circ@count@a by 4 \pgf@circ@count@b=\pgf@circ@count@a |
| 582 |
\pgfmathloop% |
| 583 |
\ifnum\pgf@circ@count@a>0 |
| 584 |
\edef\padfrac{\ctikzvalof{multipoles/external pad fraction}} |
| 585 |
\ifnum\padfrac>0 |
| 586 |
\pgf@circ@res@temp=\pgf@circ@res@step\divide\pgf@circ@res@temp by \padfrac |
| 587 |
% left side pads |
| 588 |
\pgf@circ@if@num@in@list\pgf@circ@pins@list\pgf@circ@count@a |
| 589 |
{% |
| 590 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 591 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 592 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 593 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 594 |
}{}% |
| 595 |
% bottom side pads |
| 596 |
\pgf@circ@if@num@in@list\pgf@circ@pins@list{\numpins/4+\pgf@circ@count@a} |
| 597 |
{% |
| 598 |
\pgfpathmoveto{\pgfpoint{-\pgf@circ@res@temp+\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down}} |
| 599 |
\pgfpathlineto{\pgfpoint{-\pgf@circ@res@temp+\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down-\pgf@circ@res@other}} |
| 600 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down-\pgf@circ@res@other}} |
| 601 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down}} |
| 602 |
}{}% |
| 603 |
% right side pads |
| 604 |
\pgf@circ@if@num@in@list\pgf@circ@pins@list{3*\numpins/4+1-\pgf@circ@count@a} |
| 605 |
{% |
| 606 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 607 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 608 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 609 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 610 |
}{}% |
| 611 |
% top side pads |
| 612 |
\pgf@circ@if@num@in@list\pgf@circ@pins@list{3*\numpins/4+\pgf@circ@count@a} |
| 613 |
{% |
| 614 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up}} |
| 615 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up+\pgf@circ@res@other}} |
| 616 |
\pgfpathlineto{\pgfpoint{-\pgf@circ@res@temp+\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up+\pgf@circ@res@other}} |
| 617 |
\pgfpathlineto{\pgfpoint{-\pgf@circ@res@temp+\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up}} |
| 618 |
}{}% |
| 619 |
\else |
| 620 |
% left side pins |
| 621 |
\pgf@circ@if@num@in@list\pgf@circ@pins@list\pgf@circ@count@a |
| 622 |
{% |
| 623 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 624 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 625 |
}{}% |
| 626 |
% bottom side pins |
| 627 |
\pgf@circ@if@num@in@list\pgf@circ@pins@list{\numpins/4+\pgf@circ@count@a} |
| 628 |
{% |
| 629 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down}} |
| 630 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down-\pgf@circ@res@other}} |
| 631 |
}{}% |
| 632 |
% right side pins |
| 633 |
\pgf@circ@if@num@in@list\pgf@circ@pins@list{3*\numpins/4+1-\pgf@circ@count@a} |
| 634 |
{% |
| 635 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 636 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 637 |
}{}% |
| 638 |
% top side pins |
| 639 |
\pgf@circ@if@num@in@list\pgf@circ@pins@list{3*\numpins/4+\pgf@circ@count@a} |
| 640 |
{% |
| 641 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up}} |
| 642 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up+\pgf@circ@res@other}} |
| 643 |
}{}% |
| 644 |
\fi |
| 645 |
\advance\pgf@circ@count@a-1\relax% |
| 646 |
\repeatpgfmathloop |
| 647 |
\pgfusepath{stroke} |
| 648 |
\endpgfscope |
| 649 |
\fi |
| 650 |
\fi |
| 651 |
}% |
| 652 |
% \pgf@sh@s@<name of the shape here> contains all the code for the shape |
| 653 |
% and is executed just before a node is drawn. |
| 654 |
\pgfutil@g@addto@macro\pgf@sh@s@qfpchip{% |
| 655 |
% Start with the maximum pin number and go backwards. |
| 656 |
\pgf@circ@count@a=\numpins% |
| 657 |
\pgfmathloop% |
| 658 |
\ifnum\pgf@circ@count@a>0 |
| 659 |
\expandafter\pgf@circ@make@qfppin@anchor\expandafter{\the\pgf@circ@count@a}% |
| 660 |
\advance\pgf@circ@count@a-1\relax% |
| 661 |
\repeatpgfmathloop% |
| 662 |
}% |
| 663 |
} |
| 664 |
|
| 665 |
%% anchors for DIP |
| 666 |
\def\pgf@circ@dippinanchor#1#2{% #1: pin number #2: 0 for border pin, 1 for external pin |
| 667 |
\c@pgf@countc=\numpins\relax |
| 668 |
\divide\c@pgf@countc by 2 |
| 669 |
\ifnum #1 > \the\c@pgf@countc |
| 670 |
% right side |
| 671 |
\pgfpoint{\width/2+#2*\extshift}{-\height/2+(\pgf@circ@dip@pin@shift-\c@pgf@countc+#1-1)*\chipspacing} |
| 672 |
\else |
| 673 |
\pgfpoint{-\width/2-#2*\extshift}{\height/2+(\pgf@circ@dip@pin@shift-#1)*\chipspacing} |
| 674 |
\fi |
| 675 |
} |
| 676 |
|
| 677 |
%% anchors for QFP |
| 678 |
\def\pgf@circ@qfppinanchor#1#2{% #1: pin number #2: 0 for border pin, 1 for external pin |
| 679 |
\c@pgf@countc=\numpins\relax |
| 680 |
\divide\c@pgf@countc by 4 |
| 681 |
\ifnum #1 > \the\c@pgf@countc |
| 682 |
\c@pgf@countb=\c@pgf@countc \multiply \c@pgf@countb by 2 |
| 683 |
\ifnum #1 > \the\c@pgf@countb |
| 684 |
\c@pgf@countb=\c@pgf@countc \multiply \c@pgf@countb by 3 |
| 685 |
\ifnum #1 > \the\c@pgf@countb |
| 686 |
% 3*npins/4 < pin, top side |
| 687 |
\pgfpoint{\width/2+(\pgf@circ@qfp@pin@shift+\c@pgf@countb-#1)*\chipspacing}{\height/2+#2*\extshift}% |
| 688 |
\else |
| 689 |
% 2*npins/4 < pin <= 3*npins/4, right side |
| 690 |
\pgfpoint{\width/2+#2*\extshift}{\height/2+(\pgf@circ@qfp@pin@shift-\c@pgf@countb+#1-1)*\chipspacing}% |
| 691 |
\fi |
| 692 |
\else |
| 693 |
% npins/4 < pin <= 2*npins/4, bottom side |
| 694 |
\pgfpoint{\width/2+(\pgf@circ@qfp@pin@shift-\c@pgf@countb+#1-1)*\chipspacing}{-\height/2-#2*\extshift}% |
| 695 |
\fi |
| 696 |
\else |
| 697 |
% <= npins/4, left side |
| 698 |
\pgfpoint{-\width/2-#2*\extshift}{\height/2+(\pgf@circ@qfp@pin@shift-#1)*\chipspacing}% |
| 699 |
\fi |
| 700 |
}% %>>> |
| 701 |
|
| 702 |
%% Nodes definition for rotaryswitch%<<< |
| 703 |
|
| 704 |
%%%%%%%%%%%%%%%%% |
| 705 |
%% Rotary Switch |
| 706 |
%%%%%%%%%%%%%%%%% |
| 707 |
|
| 708 |
\pgfdeclareshape{rotaryswitch} |
| 709 |
{ |
| 710 |
\savedmacro{\ctikzclass}{\edef\ctikzclass{switches}} |
| 711 |
\saveddimen{\scaledRlen}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}} |
| 712 |
\savedanchor\northeast{% |
| 713 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 714 |
% this strange value makes the 2-pole rotary switch equal to the 2 poles cute spdt |
| 715 |
% the magic number is 0.25/cos(35) |
| 716 |
% try to recalculate it for the actual switch |
| 717 |
\pgf@circ@res@temp=\ctikzvalof{tripoles/spdt/width}\pgf@circ@scaled@Rlen |
| 718 |
\pgf@circ@res@temp=.3052\pgf@circ@res@temp |
| 719 |
\edef\a{\ctikzvalof{multipoles/rotary/angle}} |
| 720 |
\edef\r{\ctikzvalof{nodes width}} |
| 721 |
\pgfmathsetlength{\pgf@y}{\r*\pgf@circ@scaled@Rlen +(\a>90 ? 2 : 2*sin(\a))*\pgf@circ@res@temp} |
| 722 |
\pgfmathsetlength{\pgf@x}{\r*\pgf@circ@scaled@Rlen + \pgf@circ@res@temp} |
| 723 |
} |
| 724 |
\savedanchor\northwest{% |
| 725 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 726 |
% this strange value makes the 2-pole rotary switch equal to the 2 poles cute spdt |
| 727 |
% the magic number is 0.25/cos(35) |
| 728 |
% try to recalculate it for the actual switch |
| 729 |
\pgf@circ@res@temp=\ctikzvalof{tripoles/spdt/width}\pgf@circ@scaled@Rlen |
| 730 |
\pgf@circ@res@temp=.3052\pgf@circ@res@temp |
| 731 |
\edef\a{\ctikzvalof{multipoles/rotary/angle}} |
| 732 |
\edef\r{\ctikzvalof{nodes width}} |
| 733 |
\pgfmathsetlength{\pgf@y}{\r*\pgf@circ@scaled@Rlen +(\a>90 ? 2 : 2*sin(\a))*\pgf@circ@res@temp} |
| 734 |
\pgfmathsetlength{\pgf@x}{-\r*\pgf@circ@scaled@Rlen - (\a<90 ? 1 : 1-2*cos(\a))*\pgf@circ@res@temp} |
| 735 |
} |
| 736 |
\savedanchor\central{% |
| 737 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 738 |
% this strange value makes the 2-pole rotary switch equal to the 2 poles cute spdt |
| 739 |
% the magic number is 0.25/cos(35) |
| 740 |
% try to recalculate it for the actual switch |
| 741 |
\pgf@circ@res@temp=\ctikzvalof{tripoles/spdt/width}\pgf@circ@scaled@Rlen |
| 742 |
\pgf@circ@res@temp=.3052\pgf@circ@res@temp |
| 743 |
\edef\a{\ctikzvalof{multipoles/rotary/angle}} |
| 744 |
\edef\r{\ctikzvalof{nodes width}} |
| 745 |
\pgfmathsetlength{\pgf@y}{\r*\pgf@circ@scaled@Rlen +(\a>90 ? 2 : 2*sin(\a))*\pgf@circ@res@temp} |
| 746 |
\pgfmathsetlength{\pgf@x}{(\a<90 ? 0 : cos(\a))*\pgf@circ@res@temp} |
| 747 |
} |
| 748 |
% external square limits |
| 749 |
\savedanchor\extnorthwest{% |
| 750 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 751 |
\pgf@x=-\ctikzvalof{tripoles/spdt/width}\pgf@circ@scaled@Rlen |
| 752 |
% this strange value makes the 2-pole rotary switch equal to the 2 poles cute spdt |
| 753 |
\pgf@x=.3052\pgf@x % the magic number is 0.25/cos(35) |
| 754 |
\pgf@x=2.5\pgf@x % external square size |
| 755 |
\pgf@y=-\pgf@x %square thing when angle=180? |
| 756 |
} |
| 757 |
\saveddimen{\width}{ |
| 758 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 759 |
\pgfmathsetlength\pgf@x{0.3052*\pgf@circ@scaled@Rlen*\ctikzvalof{tripoles/spdt/width}}} |
| 760 |
% radius of the connector |
| 761 |
% This is the radius of the "ocirc" shape (see pgfcircshapes.tex) |
| 762 |
\saveddimen{\radius}{\pgfmathsetlength\pgf@x{\pgf@circ@Rlen*\ctikzvalof{nodes width}}} |
| 763 |
% shapename |
| 764 |
\savedmacro{\thisshape}{\def\thisshape{\tikz@fig@name}} |
| 765 |
% shape type |
| 766 |
\savedmacro{\cshape}{\def\cshape{\ctikzvalof{multipoles/rotary/shape}}} |
| 767 |
\savedmacro{\channels}{\def\channels{\ctikzvalof{multipoles/rotary/channels}}} |
| 768 |
\savedmacro{\angle}{\def\angle{\ctikzvalof{multipoles/rotary/angle}}} |
| 769 |
\savedmacro{\wiper}{\def\wiper{\ctikzvalof{multipoles/rotary/wiper}}} |
| 770 |
\savedmacro{\stepa}{\pgfmathsetmacro{\stepa}{2*\ctikzvalof{multipoles/rotary/angle}/(\ctikzvalof{multipoles/rotary/channels}-1)}} |
| 771 |
% mid of the lever, to stack switches |
| 772 |
%\anchor{mid}{\midlever} |
| 773 |
\anchor{mid}{\northwest |
| 774 |
\pgf@circ@res@temp=-\pgf@x |
| 775 |
\pgfmathsetlength{\pgf@x}{\pgf@circ@res@temp*(-1+cos(\wiper))} |
| 776 |
\pgfmathsetlength{\pgf@y}{\pgf@circ@res@temp*sin(\wiper)} |
| 777 |
} |
| 778 |
% |
| 779 |
% Notice that the "in" anchors must mimic "ext center", otherwise they are |
| 780 |
% wrong for angles > 90 degrees! |
| 781 |
% |
| 782 |
% center anchors |
| 783 |
\anchor{cin}{ \pgf@y=0pt \pgf@x=0pt \advance\pgf@x by -\width} |
| 784 |
% horizontal angles |
| 785 |
\anchor{in}{ \pgf@y=0pt \pgf@x=0pt \advance\pgf@x by -\width \advance\pgf@x by -\radius} |
| 786 |
\anchor{ain}{ \pgf@y=0pt \pgf@x=0pt \advance\pgf@x by -\width \advance\pgf@x by -\radius} |
| 787 |
|
| 788 |
\anchor{center}{ \central \pgf@y=0pt } |
| 789 |
\anchor{east}{ \northeast \pgf@y=0pt } |
| 790 |
\anchor{west}{ \northwest \pgf@y=0pt } |
| 791 |
\anchor{south}{ \central \pgf@y=-\pgf@y } |
| 792 |
\anchor{north}{ \central } |
| 793 |
\anchor{south west}{ \northwest \pgf@y=-\pgf@y } |
| 794 |
\anchor{north east}{ \northeast } |
| 795 |
\anchor{north west}{ \northwest } |
| 796 |
\anchor{south east}{ \northeast \pgf@y=-\pgf@y } |
| 797 |
|
| 798 |
\anchor{ext center}{ \pgf@y=0pt \pgf@x=0pt \advance\pgf@x by -\width} |
| 799 |
\anchor{ext east}{ \extnorthwest \pgf@y=0pt \pgf@x=-\pgf@x \advance\pgf@x by -\width} |
| 800 |
\anchor{ext west}{ \extnorthwest \pgf@y=0pt \advance\pgf@x by -\width} |
| 801 |
\anchor{ext south}{ \extnorthwest \pgf@x=0pt \pgf@y=-\pgf@y \advance\pgf@x by -\width} |
| 802 |
\anchor{ext north}{ \extnorthwest \pgf@x=0pt \advance\pgf@x by -\width} |
| 803 |
\anchor{ext south west}{ \extnorthwest \pgf@y=-\pgf@y \advance\pgf@x by -\width} |
| 804 |
\anchor{ext north east}{ \extnorthwest \pgf@x=-\pgf@x \advance\pgf@x by -\width} |
| 805 |
\anchor{ext north west}{ \extnorthwest \advance\pgf@x by -\width} |
| 806 |
\anchor{ext south east}{ \extnorthwest \pgf@x=-\pgf@x \pgf@y=-\pgf@y \advance\pgf@x by -\width} |
| 807 |
|
| 808 |
\pgf@circ@draw@component{ |
| 809 |
\pgf@circ@setcolor |
| 810 |
\pgf@circ@res@right = \width |
| 811 |
\pgf@circ@res@left = -\width |
| 812 |
|
| 813 |
\pgfscope %wiper |
| 814 |
% This is the radius of the "ocirc" shape (see pgfcircshapes.tex) |
| 815 |
\pgf@circ@res@temp=\radius\relax |
| 816 |
\pgf@circ@res@temp=\ctikzvalof{multipoles/rotary/thickness}\pgf@circ@res@temp |
| 817 |
\ifdim\pgf@circ@res@temp<0pt \else |
| 818 |
\pgfsetlinewidth{2\pgf@circ@res@temp} |
| 819 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}} |
| 820 |
\pgfpathlineto{\pgfpointadd{\pgfpoint{\pgf@circ@res@left}{0pt}}{\pgfpointpolar{\wiper}{2\pgf@circ@res@right}}} |
| 821 |
\pgfsetroundcap\pgfusepath{draw} |
| 822 |
\fi |
| 823 |
\endpgfscope |
| 824 |
|
| 825 |
\ifpgf@circ@rotaryarrow |
| 826 |
\pgfscope % arrow |
| 827 |
\pgfcirc@set@arrows{switch}{\ifpgf@circ@rotaryarrow@ccw latexslim\fi}{\ifpgf@circ@rotaryarrow@cw latexslim\fi} |
| 828 |
\pgf@circ@setlinewidth{bipoles}{\pgflinewidth} |
| 829 |
\pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}} % center of cin node |
| 830 |
\pgftransformrotate{\wiper} |
| 831 |
\pgfpathmoveto{\pgfpointpolar{50}{1.0\pgf@circ@res@right}} |
| 832 |
\pgfpatharc{50}{-50}{1.0\pgf@circ@res@right} |
| 833 |
\ifpgf@circ@rotaryarrow@ccw |
| 834 |
\ifpgf@circ@rotaryarrow@cw |
| 835 |
% both here, maintain values |
| 836 |
\relax |
| 837 |
\else |
| 838 |
% only ccw: remove end arrow |
| 839 |
\pgfsetarrowsend{} |
| 840 |
\fi |
| 841 |
\else |
| 842 |
\ifpgf@circ@rotaryarrow@cw |
| 843 |
% only cw: remove start arrow |
| 844 |
\pgfsetarrowsstart{} |
| 845 |
\else |
| 846 |
% none: shouldn't happen |
| 847 |
\relax |
| 848 |
\fi |
| 849 |
\fi |
| 850 |
\pgfusepath{draw} |
| 851 |
\endpgfscope |
| 852 |
\fi |
| 853 |
|
| 854 |
% \typeout{CHANNELS\space\channels\space ANGLE\space\angle STEPA\space\stepa} |
| 855 |
\pgf@circ@count@a=\channels\relax |
| 856 |
\pgfmathsetmacro{\currenta}{-\angle} |
| 857 |
\pgfmathloop% |
| 858 |
\ifnum\pgf@circ@count@a>0 |
| 859 |
% \typeout{LOOPIN\space\space\the\pgf@circ@count@a\space CURRENTA\space\currenta\space RIGHT\space\the\pgf@circ@res@right} |
| 860 |
\pgfscope |
| 861 |
\pgftransformshift{\pgfpointadd{\pgfpoint{\pgf@circ@res@left}{0pt}}{\pgfpointpolar{\currenta}{2\pgf@circ@res@right}}} |
| 862 |
\pgfnode{\cshape}{center}{}{\thisshape-out \the\pgf@circ@count@a}{\pgfusepath{stroke}} |
| 863 |
\endpgfscope |
| 864 |
\pgfmathsetmacro{\currenta}{\currenta+\stepa} |
| 865 |
% \typeout{LOOPOUT\space\the\pgf@circ@count@a\space CURRENTA\space\currenta\space RIGHT\space\the\pgf@circ@res@right} |
| 866 |
\advance\pgf@circ@count@a by -1\relax% |
| 867 |
\repeatpgfmathloop |
| 868 |
|
| 869 |
\pgfscope % input |
| 870 |
\pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}} |
| 871 |
\pgfnode{\cshape}{center}{}{\thisshape-in}{\pgfusepath{stroke}} |
| 872 |
\endpgfscope |
| 873 |
} |
| 874 |
% \pgf@sh@s@<name of the shape here> contains all the code for the shape |
| 875 |
% and is executed just before a node is drawn. |
| 876 |
\pgfutil@g@addto@macro\pgf@sh@s@rotaryswitch{% |
| 877 |
% Start with the maximum pin number and go backwards. |
| 878 |
\pgf@circ@count@a=\channels\relax |
| 879 |
\pgfmathloop% |
| 880 |
\ifnum\pgf@circ@count@a>0 |
| 881 |
% we will create two anchors per pin: the "normal one" like `pin 1` for the |
| 882 |
% electrical contact, and the "border one" like `bpin 1` for labels. |
| 883 |
% they will coincide if `external pins width` is set to 0. |
| 884 |
\expandafter\xdef\csname pgf@anchor@rotaryswitch@out\space\the\pgf@circ@count@a\endcsname{% |
| 885 |
\noexpand\pgf@circ@rotaryanchor{\the\pgf@circ@count@a}{1}{0}% |
| 886 |
} |
| 887 |
\expandafter\xdef\csname pgf@anchor@rotaryswitch@cout\space\the\pgf@circ@count@a\endcsname{% |
| 888 |
\noexpand\pgf@circ@rotaryanchor{\the\pgf@circ@count@a}{0}{0}% |
| 889 |
} |
| 890 |
\expandafter\xdef\csname pgf@anchor@rotaryswitch@aout\space\the\pgf@circ@count@a\endcsname{% |
| 891 |
\noexpand\pgf@circ@rotaryanchor{\the\pgf@circ@count@a}{0}{1}% |
| 892 |
} |
| 893 |
\expandafter\xdef\csname pgf@anchor@rotaryswitch@sqout\space\the\pgf@circ@count@a\endcsname{% |
| 894 |
\noexpand\pgf@circ@rotarysqanchor{\the\pgf@circ@count@a}% |
| 895 |
} |
| 896 |
\advance\pgf@circ@count@a by -1\relax% |
| 897 |
\repeatpgfmathloop% |
| 898 |
}% |
| 899 |
} |
| 900 |
|
| 901 |
\def\pgf@circ@rotaryanchor#1#2#3{% #1: numero del pin; #2: 1 - x pos, 0 - center; #3 0: inner, 1 outer |
| 902 |
\pgf@circ@res@temp=\width |
| 903 |
\pgfmathsetmacro{\myangle}{\angle-(#1-1)*\stepa} |
| 904 |
\pgfmathsetlength{\pgf@x}{2*(\pgf@circ@res@temp+#3*\radius/2)*cos(\myangle))+#2*\radius} |
| 905 |
\pgfmathsetlength{\pgf@y}{2*(\pgf@circ@res@temp+#3*\radius/2)*sin(\myangle)} |
| 906 |
\advance\pgf@x by -\pgf@circ@res@temp |
| 907 |
} |
| 908 |
|
| 909 |
\def\pgf@circ@rotarysqanchor#1{% external square anchors |
| 910 |
\pgf@circ@res@temp=\width |
| 911 |
\pgfmathsetmacro{\myangle}{\angle-(#1-1)*\stepa} |
| 912 |
\pgfpointborderrectangle{\pgfpointpolar{\myangle}{1pt}}{\pgfpoint{2.5\pgf@circ@res@temp}{2.5\pgf@circ@res@temp}} |
| 913 |
\advance\pgf@x by -\pgf@circ@res@temp |
| 914 |
}% %>>> |
| 915 |
|
| 916 |
%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 917 |
% Seven segments displays |
| 918 |
%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 919 |
|
| 920 |
% Definitions for seven segment displays by RGtti%<<<1 |
| 921 |
|
| 922 |
\newif\ifpgf@circ@sevenseg@dot |
| 923 |
\newif\ifpgf@circ@sevenseg@box |
| 924 |
\def\pgf@circ@sevenseg@dotstate{empty} |
| 925 |
\ctikzset{seven seg/.is family} |
| 926 |
\ctikzset{seven seg/dot/.is choice} |
| 927 |
% none means no dot, not space for it. Empty means no dot, but space |
| 928 |
\ctikzset{seven seg/dot/none/.code={\pgf@circ@sevenseg@dotfalse}} |
| 929 |
\ctikzset{seven seg/dot/empty/.code={\pgf@circ@sevenseg@dottrue\def\pgf@circ@sevenseg@dotstate{empty}}} |
| 930 |
\ctikzset{seven seg/dot/off/.code={\pgf@circ@sevenseg@dottrue\def\pgf@circ@sevenseg@dotstate{off}}} |
| 931 |
\ctikzset{seven seg/dot/on/.code={\pgf@circ@sevenseg@dottrue\def\pgf@circ@sevenseg@dotstate{on}}} |
| 932 |
% |
| 933 |
\ctikzset{seven seg/width/.initial=0.4}% relative to \pgf@circ@Rlen |
| 934 |
\ctikzset{seven seg/thickness/.initial=4pt}% segment thickness |
| 935 |
\ctikzset{seven seg/segment sep/.initial=0.2pt}% gap between segments |
| 936 |
\ctikzset{seven seg/box sep/.initial=1pt}% external box gap |
| 937 |
\ctikzset{seven seg/color on/.initial=red}% color for segment "on" |
| 938 |
\ctikzset{seven seg/color off/.initial=gray!20!white} % ...and "off" |
| 939 |
\ctikzset{seven seg/box/.is choice} |
| 940 |
\ctikzset{seven seg/box/off/.code={\pgf@circ@sevenseg@boxfalse}} |
| 941 |
\ctikzset{seven seg/box/on/.code={\pgf@circ@sevenseg@boxtrue}} |
| 942 |
|
| 943 |
\ctikzset{seven seg/bits/.initial=0000000} |
| 944 |
|
| 945 |
\ctikzset{seven seg/value/.code={% |
| 946 |
\edef\@@tmp{#1}% |
| 947 |
\edef\@@n{0} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1111110}\fi |
| 948 |
\edef\@@n{1} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=0110000}\fi |
| 949 |
\edef\@@n{2} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1101101}\fi |
| 950 |
\edef\@@n{3} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1111001}\fi |
| 951 |
\edef\@@n{4} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=0110011}\fi |
| 952 |
\edef\@@n{5} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1011011}\fi |
| 953 |
\edef\@@n{6} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1011111}\fi |
| 954 |
\edef\@@n{7} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1110000}\fi |
| 955 |
\edef\@@n{8} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1111111}\fi |
| 956 |
\edef\@@n{9} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1111011}\fi |
| 957 |
\edef\@@n{10}\ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1110111}\fi |
| 958 |
\edef\@@n{11}\ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=0011111}\fi |
| 959 |
\edef\@@n{12}\ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1001110}\fi |
| 960 |
\edef\@@n{13}\ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=0111101}\fi |
| 961 |
\edef\@@n{14}\ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1001111}\fi |
| 962 |
\edef\@@n{15}\ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1000111}\fi |
| 963 |
\edef\@@n{A} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1110111}\fi |
| 964 |
\edef\@@n{B} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=0011111}\fi |
| 965 |
\edef\@@n{C} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1001110}\fi |
| 966 |
\edef\@@n{D} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=0111101}\fi |
| 967 |
\edef\@@n{E} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1001111}\fi |
| 968 |
\edef\@@n{F} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1000111}\fi |
| 969 |
\edef\@@n{a} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1110111}\fi |
| 970 |
\edef\@@n{b} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=0011111}\fi |
| 971 |
\edef\@@n{c} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1001110}\fi |
| 972 |
\edef\@@n{d} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=0111101}\fi |
| 973 |
\edef\@@n{e} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1001111}\fi |
| 974 |
\edef\@@n{f} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1000111}\fi |
| 975 |
\edef\@@n{-} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=0000001}\fi |
| 976 |
}} |
| 977 |
|
| 978 |
\tikzset{% |
| 979 |
seven segment val/.style args={#1dot#2box#3}{% |
| 980 |
shape=bare7seg, |
| 981 |
/tikz/circuitikz/seven seg/value=#1, |
| 982 |
/tikz/circuitikz/seven seg/dot=#2, |
| 983 |
/tikz/circuitikz/seven seg/box=#3, |
| 984 |
}, |
| 985 |
seven segment bits/.style args={#1dot#2box#3}{% |
| 986 |
shape=bare7seg, |
| 987 |
/tikz/circuitikz/seven seg/bits=#1, |
| 988 |
/tikz/circuitikz/seven seg/dot=#2, |
| 989 |
/tikz/circuitikz/seven seg/box=#3, |
| 990 |
}, |
| 991 |
} |
| 992 |
%%>>> |
| 993 |
|
| 994 |
%% Nodes definitions for 7-segment display%<<< |
| 995 |
\pgfdeclareshape{bare7seg}{ |
| 996 |
\savedmacro{\ctikzclass}{\edef\ctikzclass{displays}} |
| 997 |
\saveddimen{\scaledRlen}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}} |
| 998 |
\savedmacro{\dotstatus}{\edef\dotstatus{\pgf@circ@sevenseg@dotstate}} |
| 999 |
\saveddimen{\dotspace}{% the dot is on the right, and occupy the same as the thickness |
| 1000 |
\ifpgf@circ@sevenseg@dot |
| 1001 |
\pgfmathsetlength{\pgf@x}{\ctikzvalof{seven seg/thickness}} |
| 1002 |
\else |
| 1003 |
\pgf@x=0pt |
| 1004 |
\fi |
| 1005 |
} |
| 1006 |
% The object extension is more or less (-width/2,-width) to (width/2,width) |
| 1007 |
% and adjusted for line thickness (both sides) and eventually the dot |
| 1008 |
\saveddimen{\width}{ |
| 1009 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 1010 |
\pgfmathsetlength{\pgf@x}{\ctikzvalof{seven seg/width}*\pgf@circ@scaled@Rlen}} |
| 1011 |
\saveddimen{\gap}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{seven seg/segment sep}}} |
| 1012 |
\saveddimen{\boxgap}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{seven seg/box sep}}} |
| 1013 |
\savedanchor{\southwest}{% both negative |
| 1014 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 1015 |
\pgfmathsetlength{\pgf@x}{-0.5*\ctikzvalof{seven seg/width}*\pgf@circ@scaled@Rlen |
| 1016 |
-0.5*\ctikzvalof{seven seg/thickness}-\ctikzvalof{seven seg/box sep}} |
| 1017 |
\pgfmathsetlength{\pgf@y}{-\ctikzvalof{seven seg/width}*\pgf@circ@scaled@Rlen |
| 1018 |
-0.5*\ctikzvalof{seven seg/thickness}-\ctikzvalof{seven seg/box sep}} |
| 1019 |
} |
| 1020 |
\savedanchor{\northeast}{% both positive |
| 1021 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 1022 |
\ifpgf@circ@sevenseg@dot |
| 1023 |
\pgfmathsetlength{\pgf@circ@res@other}{\ctikzvalof{seven seg/thickness}} |
| 1024 |
\else |
| 1025 |
\pgf@circ@res@other=0pt |
| 1026 |
\fi |
| 1027 |
\pgfmathsetlength{\pgf@x}{0.5*\ctikzvalof{seven seg/width}*\pgf@circ@scaled@Rlen |
| 1028 |
+0.5*\ctikzvalof{seven seg/thickness}+\pgf@circ@res@other+\ctikzvalof{seven seg/box sep}} |
| 1029 |
\pgfmathsetlength{\pgf@y}{\ctikzvalof{seven seg/width}*\pgf@circ@scaled@Rlen |
| 1030 |
+0.5*\ctikzvalof{seven seg/thickness}+\ctikzvalof{seven seg/box sep}} |
| 1031 |
} |
| 1032 |
\savedanchor{\topright}{% anchor without the box sep and the thickness |
| 1033 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 1034 |
\pgfmathsetlength{\pgf@x}{0.5*\ctikzvalof{seven seg/width}*\pgf@circ@scaled@Rlen} |
| 1035 |
\pgfmathsetlength{\pgf@y}{\ctikzvalof{seven seg/width}*\pgf@circ@scaled@Rlen} |
| 1036 |
} |
| 1037 |
\anchor{center}{\pgfpointorigin} |
| 1038 |
\anchor{north west}{\southwest\pgf@y=-\pgf@y} |
| 1039 |
\anchor{north east}{\northeast} |
| 1040 |
\anchor{south east}{\northeast\pgf@y=-\pgf@y} |
| 1041 |
\anchor{south west}{\southwest} |
| 1042 |
\anchor{north}{\northeast\pgf@x=0pt} |
| 1043 |
\anchor{east}{\northeast\pgf@y=0pt} |
| 1044 |
\anchor{south}{\southwest\pgf@x=0pt} |
| 1045 |
\anchor{west}{\southwest\pgf@y=0pt} |
| 1046 |
\anchor{a}{\topright\pgf@x=0pt} |
| 1047 |
\anchor{b}{\topright\pgf@y=0.5\pgf@y} |
| 1048 |
\anchor{c}{\topright\pgf@y=-0.5\pgf@y} |
| 1049 |
\anchor{d}{\topright\pgf@y=-\pgf@y\pgf@x=0pt} |
| 1050 |
\anchor{e}{\topright\pgf@x=-\pgf@x\pgf@y=-0.5\pgf@y} |
| 1051 |
\anchor{f}{\topright\pgf@x=-\pgf@x\pgf@y=0.5\pgf@y} |
| 1052 |
\anchor{g}{\pgfpointorigin} |
| 1053 |
\anchor{dot}{\topright\pgf@y=-\pgf@y\advance\pgf@x by \dotspace} |
| 1054 |
\pgf@circ@draw@component{% |
| 1055 |
\southwest % I do not want the dot here, it will stick out |
| 1056 |
\pgf@circ@res@up = -\pgf@y |
| 1057 |
\pgf@circ@res@down = \pgf@y |
| 1058 |
\pgf@circ@res@right = \pgf@x |
| 1059 |
\pgf@circ@res@left = -\pgf@x |
| 1060 |
\pgfscope |
| 1061 |
\pgf@circ@setlinewidth{multipoles}{\pgflinewidth} |
| 1062 |
\pgf@circ@setcolor |
| 1063 |
\pgfpathrectanglecorners% |
| 1064 |
{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}} |
| 1065 |
{\pgfpoint{\pgf@circ@res@left+\dotspace}{\pgf@circ@res@up}} |
| 1066 |
\ifpgf@circ@sevenseg@box |
| 1067 |
\pgf@circ@draworfill |
| 1068 |
\else |
| 1069 |
\pgf@circ@maybefill |
| 1070 |
\fi |
| 1071 |
\endpgfscope |
| 1072 |
\edef\bits{\ctikzvalof{seven seg/bits}} |
| 1073 |
\pgfscope |
| 1074 |
\pfg@circ@sseg@drawbits{\bits} |
| 1075 |
\endpgfscope |
| 1076 |
\pgfscope |
| 1077 |
\ifpgf@circ@sevenseg@dot |
| 1078 |
\pgf@circ@sseg@drawdots |
| 1079 |
\fi |
| 1080 |
\endpgfscope |
| 1081 |
} |
| 1082 |
} |
| 1083 |
|
| 1084 |
\def\pgf@circ@sseg@splitbits#1#2#3#4#5#6#7\relax{%split the seven bits |
| 1085 |
\edef\@@a{#1}\edef\@@b{#2}\edef\@@c{#3}\edef\@@d{#4}\edef\@@e{#5}\edef\@@f{#6}\edef\@@g{#7}% |
| 1086 |
} |
| 1087 |
\def\pgf@circ@sseg@drawone#1#2#3#4#5{% #1 on off the x1, y1, x2 , y2 |
| 1088 |
\ifnum #1 > 0\relax |
| 1089 |
\pgfsetcolor{\ctikzvalof{seven seg/color on}} |
| 1090 |
\else |
| 1091 |
\pgfsetcolor{\ctikzvalof{seven seg/color off}} |
| 1092 |
\fi |
| 1093 |
\pgfpathmoveto{\pgfpoint{#2}{#3}} |
| 1094 |
\pgfpathlineto{\pgfpoint{#4}{#5}} |
| 1095 |
\pgfusepath{draw} |
| 1096 |
} |
| 1097 |
\def\pfg@circ@sseg@drawbits#1{% #1 must be 7 bits |
| 1098 |
\expandafter\pgf@circ@sseg@splitbits#1\relax% a bit of magic... |
| 1099 |
\pgfmathsetlength{\pgf@circ@res@other}{0.5*\ctikzvalof{seven seg/thickness}} |
| 1100 |
\pgfsetlinewidth{\ctikzvalof{seven seg/thickness}} |
| 1101 |
% \pgfsetroundcap |
| 1102 |
\pgfsetarrowsstart{Triangle Cap[]} |
| 1103 |
\pgfsetarrowsend{Triangle Cap[]} |
| 1104 |
% segments |
| 1105 |
\pgf@circ@sseg@drawone{\@@a}{-\width/2+\gap}{\width}{\width/2-\gap}{\width} |
| 1106 |
\pgf@circ@sseg@drawone{\@@b}{\width/2}{\width-\gap}{\width/2}{0pt+\gap} |
| 1107 |
\pgf@circ@sseg@drawone{\@@c}{\width/2}{0pt-\gap}{\width/2}{-\width+\gap} |
| 1108 |
\pgf@circ@sseg@drawone{\@@d}{\width/2-\gap}{-\width}{-\width/2+\gap}{-\width} |
| 1109 |
\pgf@circ@sseg@drawone{\@@e}{-\width/2}{-\width+\gap}{-\width/2}{0pt-\gap} |
| 1110 |
\pgf@circ@sseg@drawone{\@@f}{-\width/2}{0pt+\gap}{-\width/2}{\width-\gap} |
| 1111 |
\pgf@circ@sseg@drawone{\@@g}{-\width/2+\gap}{0pt}{\width/2-\gap}{0pt} |
| 1112 |
} |
| 1113 |
\def\pgf@circ@sseg@drawdots{% dots |
| 1114 |
\edef\what{empty} |
| 1115 |
\ifx\what\pgf@circ@sevenseg@dotstate |
| 1116 |
% do nothing |
| 1117 |
\else |
| 1118 |
\pgfmathsetlength{\pgf@circ@res@other}{0.5*\ctikzvalof{seven seg/thickness}} |
| 1119 |
\edef\what{off} |
| 1120 |
\ifx\what\pgf@circ@sevenseg@dotstate |
| 1121 |
% dot off |
| 1122 |
\pgfsetfillcolor{\ctikzvalof{seven seg/color off}} |
| 1123 |
\pgfsetcolor{\ctikzvalof{seven seg/color off}} |
| 1124 |
\else |
| 1125 |
% dot on |
| 1126 |
\pgfsetfillcolor{\ctikzvalof{seven seg/color on}} |
| 1127 |
\pgfsetcolor{\ctikzvalof{seven seg/color on}} |
| 1128 |
\fi |
| 1129 |
\pgfpathcircle{\pgfpoint{\width/2+2*\pgf@circ@res@other}{-\width}}{\pgf@circ@res@other} |
| 1130 |
\pgfusepath{draw,fill} |
| 1131 |
\fi |
| 1132 |
} |
| 1133 |
% %>>> |
| 1134 |
|
| 1135 |
%%%%%%%%%%%%%%%%%%%%%%%% |
| 1136 |
%% Flip-flops and muxdemuxes |
| 1137 |
%%%%%%%%%%%%%%%%%%%%%%%% |
| 1138 |
|
| 1139 |
% Settings for flip flops and muxdemxes%<<<1 |
| 1140 |
|
| 1141 |
%% flip-flop specific keys (most others are the same as chips) |
| 1142 |
|
| 1143 |
\ctikzset{multipoles/flipflop/font/.initial=\pgf@circ@font@small} |
| 1144 |
\ctikzset{multipoles/flipflop/fontud/.initial=\pgf@circ@font@tiny} |
| 1145 |
\ctikzset{multipoles/flipflop/width/.initial=1.2} |
| 1146 |
\ctikzset{multipoles/flipflop/pin spacing/.initial=0.6} |
| 1147 |
\ctikzset{multipoles/flipflop/clock wedge size/.initial=0.2} |
| 1148 |
|
| 1149 |
%% muxdemuxes internal keys |
| 1150 |
|
| 1151 |
\ctikzset{multipoles/muxdemux/base len/.initial=0.4} |
| 1152 |
\ctikzset{multipoles/muxdemux/Lh/.initial=8.0} |
| 1153 |
\ctikzset{multipoles/muxdemux/Rh/.initial=6.0} |
| 1154 |
\ctikzset{multipoles/muxdemux/w/.initial=3.0} |
| 1155 |
\ctikzset{multipoles/muxdemux/inset w/.initial=0.0} |
| 1156 |
\ctikzset{multipoles/muxdemux/inset Lh/.initial=0.0} |
| 1157 |
\ctikzset{multipoles/muxdemux/inset Rh/.initial=0.0} |
| 1158 |
\ctikzset{multipoles/muxdemux/NL/.initial=8} |
| 1159 |
\ctikzset{multipoles/muxdemux/NR/.initial=1} |
| 1160 |
\ctikzset{multipoles/muxdemux/NB/.initial=3} |
| 1161 |
\ctikzset{multipoles/muxdemux/NT/.initial=0} |
| 1162 |
\ctikzset{multipoles/muxdemux/square pins/.initial=0}% |
| 1163 |
\ctikzset{multipoles/muxdemux/bgpicture/.code={}}% |
| 1164 |
|
| 1165 |
% Thanks to @marmot |
| 1166 |
% this should automatically create a key in this subfamily |
| 1167 |
\pgfkeys{\circuitikzbasekey/multipoles/muxdemux/label/.is family, |
| 1168 |
\circuitikzbasekey/multipoles/muxdemux/label, |
| 1169 |
.unknown/.code = { |
| 1170 |
\pgfkeyssetvalue{\pgfkeyscurrentpath/\pgfkeyscurrentname}{#1} |
| 1171 |
} |
| 1172 |
} |
| 1173 |
\tikzset{muxdemux def/.code=\pgfqkeys{\circuitikzbasekey/multipoles/muxdemux}{#1}} |
| 1174 |
\tikzset{muxdemux label/.code=\pgfqkeys{\circuitikzbasekey/multipoles/muxdemux/label}{#1}} |
| 1175 |
% external (class-like) muxdemux settings for labels |
| 1176 |
\ctikzset{muxdemux/inner label font/.initial=\pgf@circ@font@tiny} |
| 1177 |
\ctikzset{muxdemux/outer label font/.initial=\pgf@circ@font@tiny} |
| 1178 |
\ctikzset{muxdemux/border label font/.initial=\pgf@circ@font@tiny} |
| 1179 |
\ctikzset{muxdemux/inner label xsep/.initial=2pt} |
| 1180 |
\ctikzset{muxdemux/inner label ysep/.initial=2pt} |
| 1181 |
\ctikzset{muxdemux/outer label xsep/.initial=2pt} |
| 1182 |
\ctikzset{muxdemux/outer label ysep/.initial=2pt} |
| 1183 |
\ctikzset{muxdemux/border label xsep/.initial=2pt} |
| 1184 |
\ctikzset{muxdemux/border label ysep/.initial=2pt} |
| 1185 |
\ctikzset{muxdemux/inner label sep/.code={% |
| 1186 |
\ctikzset{muxdemux/inner label xsep=#1}% |
| 1187 |
\ctikzset{muxdemux/inner label ysep=#1}% |
| 1188 |
}} |
| 1189 |
\ctikzset{muxdemux/outer label sep/.code={% |
| 1190 |
\ctikzset{muxdemux/outer label xsep=#1}% |
| 1191 |
\ctikzset{muxdemux/outer label ysep=#1}% |
| 1192 |
}} |
| 1193 |
\ctikzset{muxdemux/border label sep/.code={% |
| 1194 |
\ctikzset{muxdemux/border label xsep=#1}% |
| 1195 |
\ctikzset{muxdemux/border label ysep=#1}% |
| 1196 |
}} |
| 1197 |
\ctikzset{muxdemux/clock wedge size/.initial=0.2} |
| 1198 |
%>>> |
| 1199 |
|
| 1200 |
%% Node shapes definitions for flip flops%<<< |
| 1201 |
|
| 1202 |
% Flip flops are a specialized kind of dipchip. |
| 1203 |
% they have a class by themselves |
| 1204 |
|
| 1205 |
%% flip flop definitions --- by default empty |
| 1206 |
%% pin texts |
| 1207 |
\ctikzset{multipoles/flipflop/t1/.initial={}} |
| 1208 |
\ctikzset{multipoles/flipflop/t2/.initial={}} |
| 1209 |
\ctikzset{multipoles/flipflop/t3/.initial={}} |
| 1210 |
\ctikzset{multipoles/flipflop/t4/.initial={}} |
| 1211 |
\ctikzset{multipoles/flipflop/t5/.initial={}} |
| 1212 |
\ctikzset{multipoles/flipflop/t6/.initial={}} |
| 1213 |
\ctikzset{multipoles/flipflop/tu/.initial={}} |
| 1214 |
\ctikzset{multipoles/flipflop/td/.initial={}} |
| 1215 |
% pin clock wedge flags |
| 1216 |
\ctikzset{multipoles/flipflop/c1/.initial={0}} |
| 1217 |
\ctikzset{multipoles/flipflop/c2/.initial={0}} |
| 1218 |
\ctikzset{multipoles/flipflop/c3/.initial={0}} |
| 1219 |
\ctikzset{multipoles/flipflop/c4/.initial={0}} |
| 1220 |
\ctikzset{multipoles/flipflop/c5/.initial={0}} |
| 1221 |
\ctikzset{multipoles/flipflop/c6/.initial={0}} |
| 1222 |
\ctikzset{multipoles/flipflop/cu/.initial={0}} |
| 1223 |
\ctikzset{multipoles/flipflop/cd/.initial={0}} |
| 1224 |
% pin negation circle flags |
| 1225 |
\ctikzset{multipoles/flipflop/n1/.initial={0}} |
| 1226 |
\ctikzset{multipoles/flipflop/n2/.initial={0}} |
| 1227 |
\ctikzset{multipoles/flipflop/n3/.initial={0}} |
| 1228 |
\ctikzset{multipoles/flipflop/n4/.initial={0}} |
| 1229 |
\ctikzset{multipoles/flipflop/n5/.initial={0}} |
| 1230 |
\ctikzset{multipoles/flipflop/n6/.initial={0}} |
| 1231 |
\ctikzset{multipoles/flipflop/nu/.initial={0}} |
| 1232 |
\ctikzset{multipoles/flipflop/nd/.initial={0}} |
| 1233 |
|
| 1234 |
|
| 1235 |
% Thanks to @marmot |
| 1236 |
\tikzset{flipflop def/.code=\pgfqkeys{\circuitikzbasekey/multipoles/flipflop}{#1}} |
| 1237 |
|
| 1238 |
% default set of flip flops |
| 1239 |
\tikzset{ |
| 1240 |
% async |
| 1241 |
latch/.style={flipflop, flipflop def={t1=D, t6=Q, t3=CLK, t4=\ctikztextnot{Q}}}, |
| 1242 |
flipflop SR/.style={flipflop, flipflop def={t1=S, t3=R, t6=Q, t4=\ctikztextnot{Q}}}, |
| 1243 |
% sync |
| 1244 |
flipflop D/.style={flipflop, flipflop def={t1=D, t6=Q, c3=1, t4=\ctikztextnot{Q}}}, |
| 1245 |
flipflop T/.style={flipflop, flipflop def={t1=T, t6=Q, c3=1, t4=\ctikztextnot{Q}}}, |
| 1246 |
flipflop JK/.style={flipflop, flipflop def={t1=J, t3=K, c2=1, t6=Q, t4=\ctikztextnot{Q}}}, |
| 1247 |
% additional features |
| 1248 |
add async SR/.style={flipflop def={tu={\ctikztextnot{SET}}, td={\ctikztextnot{RST}}}}, |
| 1249 |
dot on notQ/.style={flipflop def={t4={Q}, n4=1}}, |
| 1250 |
} |
| 1251 |
|
| 1252 |
% |
| 1253 |
% commodity macro to draw the clock wedges. They leave the size of the |
| 1254 |
% wedge in \pgf@circ@res@temp so that a possible label can be displaced. |
| 1255 |
% |
| 1256 |
\def\pgf@circ@do@wedge@left{ |
| 1257 |
\pgf@circ@res@temp=0pt\relax |
| 1258 |
\ifnum\ctikzvalof{multipoles/flipflop/c\the\pgf@circ@count@c}>0 |
| 1259 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step+\wedge}} |
| 1260 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left+\wedge}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 1261 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step-\wedge}} |
| 1262 |
\pgfusepath{stroke} |
| 1263 |
\pgf@circ@res@temp=\wedge |
| 1264 |
\fi |
| 1265 |
} |
| 1266 |
\def\pgf@circ@do@wedge@right{ |
| 1267 |
\pgf@circ@res@temp=0pt\relax |
| 1268 |
\ifnum\ctikzvalof{multipoles/flipflop/c\the\pgf@circ@count@c}>0 |
| 1269 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step+\wedge}} |
| 1270 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-\wedge}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 1271 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step-\wedge}} |
| 1272 |
\pgfusepath{stroke} |
| 1273 |
\pgf@circ@res@temp=-\wedge |
| 1274 |
\fi |
| 1275 |
} |
| 1276 |
\def\pgf@circ@do@wedge@up{ |
| 1277 |
\pgf@circ@res@temp=0pt\relax |
| 1278 |
\ifnum\ctikzvalof{multipoles/flipflop/cu}>0 |
| 1279 |
\pgfpathmoveto{\pgfpoint{-\wedge}{\pgf@circ@res@up}} |
| 1280 |
\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@up-\wedge}} |
| 1281 |
\pgfpathlineto{\pgfpoint{\wedge}{\pgf@circ@res@up}} |
| 1282 |
\pgfusepath{stroke} |
| 1283 |
\pgf@circ@res@temp=-\wedge |
| 1284 |
\fi |
| 1285 |
} |
| 1286 |
\def\pgf@circ@do@wedge@down{ |
| 1287 |
\pgf@circ@res@temp=0pt\relax |
| 1288 |
\ifnum\ctikzvalof{multipoles/flipflop/cd}>0 |
| 1289 |
\pgfpathmoveto{\pgfpoint{-\wedge}{\pgf@circ@res@down}} |
| 1290 |
\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@down+\wedge}} |
| 1291 |
\pgfpathlineto{\pgfpoint{\wedge}{\pgf@circ@res@down}} |
| 1292 |
\pgfusepath{stroke} |
| 1293 |
\pgf@circ@res@temp=\wedge |
| 1294 |
\fi |
| 1295 |
} |
| 1296 |
% generic flip-flop shape |
| 1297 |
\pgfdeclareshape{flipflop}{ |
| 1298 |
\savedmacro{\ctikzclass}{\edef\ctikzclass{flipflops}} |
| 1299 |
\saveddimen{\scaledRlen}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}} |
| 1300 |
\savedmacro{\thisshape}{\def\thisshape{\tikz@fig@name}} |
| 1301 |
\savedmacro\numpins{\def\numpins{6}} |
| 1302 |
\savedanchor\textanchor{% |
| 1303 |
\pgf@x=-.5\wd\pgfnodeparttextbox% |
| 1304 |
\pgf@y=-.5\ht\pgfnodeparttextbox% |
| 1305 |
\advance\pgf@y by+.5\dp\pgfnodeparttextbox% |
| 1306 |
}% |
| 1307 |
\savedanchor\origin{\pgfpoint{0pt}{0pt}} |
| 1308 |
\anchor{center}{\origin} |
| 1309 |
\anchor{text}{\textanchor}% to adjust text |
| 1310 |
\saveddimen\height{% |
| 1311 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 1312 |
\pgfmathsetlength\pgf@x{((\numpins) |
| 1313 |
*\ctikzvalof{multipoles/flipflop/pin spacing})*\pgf@circ@scaled@Rlen/2}% |
| 1314 |
}% |
| 1315 |
\saveddimen{\chipspacing}{ |
| 1316 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 1317 |
\pgfmathsetlength\pgf@x{\pgf@circ@scaled@Rlen*\ctikzvalof{multipoles/flipflop/pin spacing}}} |
| 1318 |
\saveddimen{\width}{ |
| 1319 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 1320 |
\pgfmathsetlength\pgf@x{\pgf@circ@scaled@Rlen*\ctikzvalof{multipoles/flipflop/width}}} |
| 1321 |
\saveddimen{\extshift}{ |
| 1322 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 1323 |
\pgfmathsetlength\pgf@x{\pgf@circ@scaled@Rlen*\ctikzvalof{multipoles/external pins width}}} |
| 1324 |
% standard anchors |
| 1325 |
\savedanchor\northwest{% |
| 1326 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 1327 |
\pgfmathsetlength\pgf@y{0.5*((\numpins) |
| 1328 |
*\ctikzvalof{multipoles/flipflop/pin spacing})*\pgf@circ@scaled@Rlen/2}% |
| 1329 |
\pgfmathsetlength\pgf@x{-0.5*\pgf@circ@scaled@Rlen*\ctikzvalof{multipoles/flipflop/width}} |
| 1330 |
} |
| 1331 |
\anchor{dot}{\northwest |
| 1332 |
\pgfmathsetlength\pgf@x{\pgf@x + 0.3*\chipspacing} |
| 1333 |
\pgfmathsetlength\pgf@y{\pgf@y - 0.3*\chipspacing} |
| 1334 |
} |
| 1335 |
\anchor{nw}{\northwest} |
| 1336 |
\anchor{ne}{\northwest\pgf@x=-\pgf@x} |
| 1337 |
\anchor{se}{\northwest\pgf@x=-\pgf@x\pgf@y=-\pgf@y} |
| 1338 |
\anchor{sw}{\northwest\pgf@y=-\pgf@y} |
| 1339 |
\anchor{north west}{\northwest} |
| 1340 |
\anchor{north east}{\northwest\pgf@x=-\pgf@x} |
| 1341 |
\anchor{south east}{\northwest\pgf@x=-\pgf@x \pgf@y=-\pgf@y} |
| 1342 |
\anchor{south west}{\northwest\pgf@y=-\pgf@y} |
| 1343 |
\anchor{n}{\northwest\pgf@x=0pt } |
| 1344 |
\anchor{e}{\northwest\pgf@x=-\pgf@x\pgf@y=0pt } |
| 1345 |
\anchor{s}{\northwest\pgf@x=0pt\pgf@y=-\pgf@y} |
| 1346 |
\anchor{w}{\northwest\pgf@y=0pt } |
| 1347 |
\anchor{north}{\northwest\pgf@x=0pt } |
| 1348 |
\anchor{east}{\northwest\pgf@x=-\pgf@x\pgf@y=0pt } |
| 1349 |
\anchor{south}{\northwest\pgf@x=0pt\pgf@y=-\pgf@y} |
| 1350 |
\anchor{west}{\northwest\pgf@y=0pt } |
| 1351 |
% upper and lower pin |
| 1352 |
\anchor{up}{\northwest\pgf@x=0pt\advance\pgf@y by\extshift } |
| 1353 |
\anchor{down}{\northwest\pgf@x=0pt\pgf@y=-\pgf@y\advance\pgf@y by-\extshift} |
| 1354 |
\anchor{bup}{\northwest\pgf@x=0pt } |
| 1355 |
\anchor{bdown}{\northwest\pgf@x=0pt\pgf@y=-\pgf@y} |
| 1356 |
% start drawing |
| 1357 |
\pgf@circ@draw@component{% |
| 1358 |
\northwest |
| 1359 |
\pgf@circ@res@up = \pgf@y |
| 1360 |
\pgf@circ@res@down = -\pgf@y |
| 1361 |
\pgf@circ@res@right = -\pgf@x |
| 1362 |
\pgf@circ@res@left = \pgf@x |
| 1363 |
\pgf@circ@scaled@Rlen=\scaledRlen |
| 1364 |
\pgf@circ@res@step = \ctikzvalof{multipoles/flipflop/pin spacing}\pgf@circ@scaled@Rlen |
| 1365 |
\pgf@circ@res@other = \ctikzvalof{multipoles/external pins width}\pgf@circ@scaled@Rlen |
| 1366 |
\pgf@circ@setcolor |
| 1367 |
\pgfscope% (for the line width) |
| 1368 |
\pgf@circ@setlinewidth{multipoles}{\pgflinewidth} |
| 1369 |
\pgfpathrectanglecorners{\pgfpoint{-\width/2}{-\height/2}}{\pgfpoint{\width/2}{\height/2}}% |
| 1370 |
\pgf@circ@draworfill |
| 1371 |
\pgfusepath{stroke}% |
| 1372 |
\endpgfscope |
| 1373 |
% Adding the pin number |
| 1374 |
\pgf@circ@count@a=\numpins\relax |
| 1375 |
\divide\pgf@circ@count@a by 2 \pgf@circ@count@b=\pgf@circ@count@a |
| 1376 |
% thanks to @marmot: https://tex.stackexchange.com/a/473571/38080 |
| 1377 |
\ifpgf@circuit@chip@straightnumbers |
| 1378 |
\pgfgettransformentries\a\b\temp\temp\temp\temp |
| 1379 |
\pgfmathsetmacro{\rot}{-atan2(\b,\a)} |
| 1380 |
\pgfmathtruncatemacro{\quadrant}{mod(4+int(360+(\rot+45)/90),4)} |
| 1381 |
\else |
| 1382 |
\pgfmathsetmacro{\rot}{0} |
| 1383 |
\pgfmathsetmacro{\quadrant}{0} |
| 1384 |
\fi |
| 1385 |
\def\pgf@circ@strut{\vrule width 0pt height 1em depth 0.4em\relax} |
| 1386 |
\pgfscope\pgf@circ@text@strokecolor |
| 1387 |
% text |
| 1388 |
\def\mytext{\ctikzvalof{multipoles/flipflop/font}\space |
| 1389 |
\ctikzvalof{multipoles/flipflop/t\the\pgf@circ@count@c}% |
| 1390 |
\pgf@circ@strut\space} |
| 1391 |
% \typeout{TEXT\space\mytext} |
| 1392 |
\pgfmathloop% |
| 1393 |
\def\wedge{\ctikzvalof{multipoles/flipflop/clock wedge size}\pgf@circ@res@step} |
| 1394 |
\pgf@circ@res@temp=0pt\relax |
| 1395 |
\ifnum\pgf@circ@count@a>0 |
| 1396 |
\ifcase\quadrant % rotation 0 |
| 1397 |
% left |
| 1398 |
\pgf@circ@count@c=\pgf@circ@count@a |
| 1399 |
\pgf@circ@do@wedge@left |
| 1400 |
% \typeout{TEXT Left Q1\space\mytext} |
| 1401 |
\pgftext[left, |
| 1402 |
at=\pgfpoint{\pgf@circ@res@left+\pgf@circ@res@temp}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}, |
| 1403 |
rotate=\rot]{\mytext} |
| 1404 |
% right |
| 1405 |
\pgf@circ@count@c=\numexpr2*\pgf@circ@count@b-\pgf@circ@count@a+1\relax |
| 1406 |
\pgf@circ@do@wedge@right |
| 1407 |
\pgftext[right, |
| 1408 |
at=\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@temp}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}, |
| 1409 |
rotate=\rot]{\mytext} |
| 1410 |
\or % rotation -90 |
| 1411 |
% left |
| 1412 |
\pgf@circ@count@c=\pgf@circ@count@a |
| 1413 |
\pgf@circ@do@wedge@left |
| 1414 |
\pgftext[top, |
| 1415 |
at=\pgfpoint{\pgf@circ@res@left+\pgf@circ@res@temp}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}, |
| 1416 |
rotate=\rot]{\mytext} |
| 1417 |
% right |
| 1418 |
\pgf@circ@count@c=\numexpr2*\pgf@circ@count@b-\pgf@circ@count@a+1\relax |
| 1419 |
\pgf@circ@do@wedge@right |
| 1420 |
\pgftext[bottom, |
| 1421 |
at=\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@temp}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}, |
| 1422 |
rotate=\rot]{\mytext} |
| 1423 |
\or %rotation 180 |
| 1424 |
% left |
| 1425 |
\pgf@circ@count@c=\pgf@circ@count@a |
| 1426 |
\pgf@circ@do@wedge@left |
| 1427 |
\pgftext[right, |
| 1428 |
at=\pgfpoint{\pgf@circ@res@left+\pgf@circ@res@temp}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}, |
| 1429 |
rotate=\rot]{\mytext} |
| 1430 |
% right |
| 1431 |
\pgf@circ@count@c=\numexpr2*\pgf@circ@count@b-\pgf@circ@count@a+1\relax |
| 1432 |
\pgf@circ@do@wedge@right |
| 1433 |
\pgftext[left, |
| 1434 |
at=\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@temp}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}, |
| 1435 |
rotate=\rot]{\mytext} |
| 1436 |
\or % rotation +90 |
| 1437 |
% left |
| 1438 |
\pgf@circ@count@c=\pgf@circ@count@a |
| 1439 |
\pgf@circ@do@wedge@left |
| 1440 |
\pgftext[bottom, |
| 1441 |
at=\pgfpoint{\pgf@circ@res@left+\pgf@circ@res@temp}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}, |
| 1442 |
rotate=\rot]{\mytext} |
| 1443 |
% right |
| 1444 |
\pgf@circ@count@c=\numexpr2*\pgf@circ@count@b-\pgf@circ@count@a+1\relax |
| 1445 |
\pgf@circ@do@wedge@right |
| 1446 |
\pgftext[top, |
| 1447 |
at=\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@temp}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}, |
| 1448 |
rotate=\rot]{\mytext} |
| 1449 |
\fi |
| 1450 |
\advance\pgf@circ@count@a-1\relax% |
| 1451 |
\repeatpgfmathloop |
| 1452 |
% Now the up and down text |
| 1453 |
% up |
| 1454 |
\def\mytext{\ctikzvalof{multipoles/flipflop/fontud}\space\pgf@circ@strut\ctikzvalof{multipoles/flipflop/tu}\space} |
| 1455 |
\pgf@circ@do@wedge@up |
| 1456 |
\ifcase\quadrant % rotation 0 |
| 1457 |
\pgftext[top, |
| 1458 |
at=\pgfpoint{0pt}{\pgf@circ@res@up+\pgf@circ@res@temp}, |
| 1459 |
rotate=\rot]{\mytext} |
| 1460 |
\or % rotation -90 |
| 1461 |
\pgftext[right, |
| 1462 |
at=\pgfpoint{0pt}{\pgf@circ@res@up+\pgf@circ@res@temp}, |
| 1463 |
rotate=\rot]{\mytext} |
| 1464 |
\or %rotation 180 |
| 1465 |
\pgftext[bottom, |
| 1466 |
at=\pgfpoint{0pt}{\pgf@circ@res@up+\pgf@circ@res@temp}, |
| 1467 |
rotate=\rot]{\mytext} |
| 1468 |
\or % rotation +90 |
| 1469 |
\pgftext[left, |
| 1470 |
at=\pgfpoint{0pt}{\pgf@circ@res@up+\pgf@circ@res@temp}, |
| 1471 |
rotate=\rot]{\mytext} |
| 1472 |
\fi |
| 1473 |
% down |
| 1474 |
\def\mytext{\ctikzvalof{multipoles/flipflop/fontud}\space\pgf@circ@strut\ctikzvalof{multipoles/flipflop/td}\space} |
| 1475 |
\pgf@circ@do@wedge@down |
| 1476 |
\ifcase\quadrant % rotation 0 |
| 1477 |
\pgftext[bottom, |
| 1478 |
at=\pgfpoint{0pt}{\pgf@circ@res@down+\pgf@circ@res@temp}, |
| 1479 |
rotate=\rot]{\mytext} |
| 1480 |
\or % rotation -90 |
| 1481 |
\pgftext[left, |
| 1482 |
at=\pgfpoint{0pt}{\pgf@circ@res@down+\pgf@circ@res@temp}, |
| 1483 |
rotate=\rot]{\mytext} |
| 1484 |
\or %rotation 180 |
| 1485 |
\pgftext[top, |
| 1486 |
at=\pgfpoint{0pt}{\pgf@circ@res@down+\pgf@circ@res@temp}, |
| 1487 |
rotate=\rot]{\mytext} |
| 1488 |
\or % rotation +90 |
| 1489 |
\pgftext[right, |
| 1490 |
at=\pgfpoint{0pt}{\pgf@circ@res@down+\pgf@circ@res@temp}, |
| 1491 |
rotate=\rot]{\mytext} |
| 1492 |
\fi |
| 1493 |
\endpgfscope % for text labels |
| 1494 |
% external pins |
| 1495 |
\ifdim\pgf@circ@res@other>0pt |
| 1496 |
\pgfscope |
| 1497 |
\pgfsetlinewidth{\ctikzvalof{multipoles/external pins thickness}\pgflinewidth} |
| 1498 |
\pgf@circ@count@a=\numpins\relax |
| 1499 |
\divide\pgf@circ@count@a by 2 \pgf@circ@count@b=\pgf@circ@count@a |
| 1500 |
\pgfmathloop% |
| 1501 |
\ifnum\pgf@circ@count@a>0 |
| 1502 |
% left side pins |
| 1503 |
\pgf@circ@count@c=\pgf@circ@count@a |
| 1504 |
%% we draw the pin only if it's defined either a text, a clock wedge or a not pin |
| 1505 |
%% Or'ing tests in core TeX is tough |
| 1506 |
\edef\@@or{0} |
| 1507 |
% Just expand the key the minimum needed |
| 1508 |
\edef\@@tmp{x\unexpandedvalueof{/tikz/circuitikz/multipoles/flipflop/t\the\pgf@circ@count@c}}\edef\@@x{x} |
| 1509 |
\ifx\@@tmp\@@x\else\edef\@@or{1}\fi |
| 1510 |
\edef\@@tmp{\ctikzvalof{multipoles/flipflop/c\the\pgf@circ@count@c}} |
| 1511 |
\ifnum\@@tmp>0\edef\@@or{1}\fi |
| 1512 |
\edef\@@tmp{\ctikzvalof{multipoles/flipflop/n\the\pgf@circ@count@c}} |
| 1513 |
\ifnum\@@tmp>0\edef\@@or{1}\fi |
| 1514 |
\ifnum\@@or>0 |
| 1515 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 1516 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 1517 |
\pgfusepath{stroke} |
| 1518 |
\fi |
| 1519 |
% right side pins |
| 1520 |
\pgf@circ@count@c=\numexpr2*\pgf@circ@count@b-\pgf@circ@count@a+1\relax |
| 1521 |
\edef\@@or{0} |
| 1522 |
\edef\@@tmp{x\unexpandedvalueof{/tikz/circuitikz/multipoles/flipflop/t\the\pgf@circ@count@c}}\edef\@@x{x} |
| 1523 |
\ifx\@@tmp\@@x\else\edef\@@or{1}\fi |
| 1524 |
\edef\@@tmp{\ctikzvalof{multipoles/flipflop/c\the\pgf@circ@count@c}} |
| 1525 |
\ifnum\@@tmp>0\edef\@@or{1}\fi |
| 1526 |
\edef\@@tmp{\ctikzvalof{multipoles/flipflop/n\the\pgf@circ@count@c}} |
| 1527 |
\ifnum\@@tmp>0\edef\@@or{1}\fi |
| 1528 |
% \typeout{TEST\space\@@tmp\space\@@x} |
| 1529 |
\ifnum\@@or>0 |
| 1530 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 1531 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 1532 |
\pgfusepath{stroke} |
| 1533 |
\fi |
| 1534 |
\advance\pgf@circ@count@a by -1\relax% |
| 1535 |
\repeatpgfmathloop |
| 1536 |
% up side |
| 1537 |
\edef\@@or{0} |
| 1538 |
\edef\@@tmp{x\unexpandedvalueof{/tikz/circuitikz/multipoles/flipflop/tu}}\edef\@@x{x} |
| 1539 |
\ifx\@@tmp\@@x\else\edef\@@or{1}\fi |
| 1540 |
\edef\@@tmp{\ctikzvalof{multipoles/flipflop/cu}} |
| 1541 |
\ifnum\@@tmp>0\edef\@@or{1}\fi |
| 1542 |
\edef\@@tmp{\ctikzvalof{multipoles/flipflop/nu}} |
| 1543 |
\ifnum\@@tmp>0\edef\@@or{1}\fi |
| 1544 |
% \typeout{TEST\space\@@tmp\space\@@x} |
| 1545 |
\ifnum\@@or>0 |
| 1546 |
\pgfpathmoveto{\pgfpoint{0pt}{\pgf@circ@res@up}} |
| 1547 |
\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@up+\pgf@circ@res@other}} |
| 1548 |
\pgfusepath{stroke} |
| 1549 |
\fi |
| 1550 |
% down side |
| 1551 |
\edef\@@or{0} |
| 1552 |
\edef\@@tmp{x\unexpandedvalueof{/tikz/circuitikz/multipoles/flipflop/td}}\edef\@@x{x} |
| 1553 |
\ifx\@@tmp\@@x\else\edef\@@or{1}\fi |
| 1554 |
\edef\@@tmp{\ctikzvalof{multipoles/flipflop/cd}} |
| 1555 |
\ifnum\@@tmp>0\edef\@@or{1}\fi |
| 1556 |
\edef\@@tmp{\ctikzvalof{multipoles/flipflop/nd}} |
| 1557 |
\ifnum\@@tmp>0\edef\@@or{1}\fi |
| 1558 |
% \typeout{TEST\space\@@tmp\space\@@x} |
| 1559 |
\ifnum\@@or>0 |
| 1560 |
\pgfpathmoveto{\pgfpoint{0pt}{\pgf@circ@res@down}} |
| 1561 |
\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@down-\pgf@circ@res@other}} |
| 1562 |
\pgfusepath{stroke} |
| 1563 |
\fi |
| 1564 |
\endpgfscope |
| 1565 |
\fi % external pin width >0 |
| 1566 |
% |
| 1567 |
% draw "inverting" circles on outputs, they must be last |
| 1568 |
% |
| 1569 |
\pgfscope |
| 1570 |
\ifpgf@circuit@ieeelogicport |
| 1571 |
\def\@@notcirc{notcirc} |
| 1572 |
\else |
| 1573 |
\ifpgf@circ@european@port@circle@ieee |
| 1574 |
\def\@@notcirc{notcirc} |
| 1575 |
\else |
| 1576 |
\def\@@notcirc{ocirc} |
| 1577 |
\fi |
| 1578 |
\fi |
| 1579 |
\pgfsetlinewidth{\ctikzvalof{multipoles/external pins thickness}\pgflinewidth} |
| 1580 |
\pgf@circ@count@a=\numpins\relax |
| 1581 |
\divide\pgf@circ@count@a by 2 \pgf@circ@count@b=\pgf@circ@count@a |
| 1582 |
\pgfmathloop% |
| 1583 |
\ifnum\pgf@circ@count@a>0 |
| 1584 |
% left side pins |
| 1585 |
\pgf@circ@count@c=\pgf@circ@count@a |
| 1586 |
\edef\@@tmp{\ctikzvalof{multipoles/flipflop/n\the\pgf@circ@count@c}} |
| 1587 |
\ifnum\@@tmp>0\pgfscope |
| 1588 |
\pgftransformshift{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 1589 |
\pgfnode{\@@notcirc}{east}{}{\thisshape-N\the\pgf@circ@count@c}{\pgfusepath{stroke}} |
| 1590 |
\endpgfscope\fi |
| 1591 |
% right side pins |
| 1592 |
\pgf@circ@count@c=\numexpr2*\pgf@circ@count@b-\pgf@circ@count@a+1\relax |
| 1593 |
\edef\@@tmp{\ctikzvalof{multipoles/flipflop/n\the\pgf@circ@count@c}} |
| 1594 |
\ifnum\@@tmp>0\pgfscope |
| 1595 |
\pgftransformshift{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 1596 |
\pgfnode{\@@notcirc}{west}{}{\thisshape-N\the\pgf@circ@count@c}{\pgfusepath{stroke}} |
| 1597 |
\endpgfscope\fi |
| 1598 |
\advance\pgf@circ@count@a by -1\relax% |
| 1599 |
\repeatpgfmathloop |
| 1600 |
% up side |
| 1601 |
\edef\@@tmp{\ctikzvalof{multipoles/flipflop/nu}} |
| 1602 |
\ifnum\@@tmp>0\pgfscope |
| 1603 |
\pgftransformshift{\pgfpoint{0pt}{\pgf@circ@res@up}} |
| 1604 |
\pgfnode{\@@notcirc}{south}{}{\thisshape-Nu}{\pgfusepath{stroke}} |
| 1605 |
\endpgfscope\fi |
| 1606 |
% down side |
| 1607 |
\edef\@@tmp{\ctikzvalof{multipoles/flipflop/nd}} |
| 1608 |
\ifnum\@@tmp>0\pgfscope |
| 1609 |
\pgftransformshift{\pgfpoint{0pt}{\pgf@circ@res@down}} |
| 1610 |
\pgfnode{\@@notcirc}{north}{}{\thisshape-Nd}{\pgfusepath{stroke}} |
| 1611 |
\endpgfscope\fi |
| 1612 |
\endpgfscope |
| 1613 |
}% |
| 1614 |
% \pgf@sh@s@<name of the shape here> contains all the code for the shape |
| 1615 |
% and is executed just before a node is drawn. |
| 1616 |
\pgfutil@g@addto@macro\pgf@sh@s@flipflop{% |
| 1617 |
% Start with the maximum pin number and go backwards. |
| 1618 |
\pgf@circ@count@a=\numpins\relax |
| 1619 |
\pgfmathloop% |
| 1620 |
\ifnum\pgf@circ@count@a>0 |
| 1621 |
% we will create two anchors per pin: the "normal one" like `pin 1` for the |
| 1622 |
% electrical contact, and the "border one" like `bpin 1` for labels. |
| 1623 |
% they will coincide if `external pins width` is set to 0. |
| 1624 |
\expandafter\xdef\csname pgf@anchor@flipflop@pin\space\the\pgf@circ@count@a\endcsname{% |
| 1625 |
\noexpand\pgf@circ@dippinanchor{\the\pgf@circ@count@a}{1}% |
| 1626 |
} |
| 1627 |
\expandafter\xdef\csname pgf@anchor@flipflop@bpin\space\the\pgf@circ@count@a\endcsname{% |
| 1628 |
\noexpand\pgf@circ@dippinanchor{\the\pgf@circ@count@a}{0}% |
| 1629 |
} |
| 1630 |
\advance\pgf@circ@count@a by -1\relax% |
| 1631 |
\repeatpgfmathloop% |
| 1632 |
}% |
| 1633 |
} |
| 1634 |
|
| 1635 |
% clock wedge shape, for using in other shapes like muxdemuxes |
| 1636 |
\pgfdeclareshape{clockwedge}{ |
| 1637 |
\savedmacro{\ctikzclass}{\edef\ctikzclass{flipflops}} |
| 1638 |
\saveddimen{\scaledRlen}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}} |
| 1639 |
\savedanchor{\northeast}{ |
| 1640 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 1641 |
\pgfmathsetlength{\pgf@circ@res@step}{\ctikzvalof{multipoles/flipflop/clock wedge size}*\ctikzvalof{multipoles/flipflop/pin spacing}*\pgf@circ@scaled@Rlen} |
| 1642 |
\pgf@y=\pgf@circ@res@step |
| 1643 |
\pgf@x=\pgf@circ@res@step |
| 1644 |
} |
| 1645 |
\anchor{center}{\pgfpointorigin} |
| 1646 |
\anchor{north west}{\northeast\pgf@x=0pt } |
| 1647 |
\anchor{north east}{\northeast} |
| 1648 |
\anchor{south east}{\northeast\pgf@y=-\pgf@y} |
| 1649 |
\anchor{south west}{\northeast\pgf@y=-\pgf@y\pgf@x=0pt } |
| 1650 |
\anchor{north}{\northeast\pgf@x=0.5\pgf@x } |
| 1651 |
\anchor{east}{\northeast\pgf@y=0pt } |
| 1652 |
\anchor{south}{\northeast\pgf@x=0.5\pgf@x\pgf@y=-\pgf@y} |
| 1653 |
\anchor{west}{\pgfpointorigin} |
| 1654 |
\anchor{nw}{\northeast\pgf@x=0pt } |
| 1655 |
\anchor{ne}{\northeast} |
| 1656 |
\anchor{se}{\northeast\pgf@y=-\pgf@y} |
| 1657 |
\anchor{sw}{\northeast\pgf@y=-\pgf@y\pgf@x=0pt } |
| 1658 |
\anchor{n}{\northeast\pgf@x=0.5\pgf@x } |
| 1659 |
\anchor{e}{\northeast\pgf@y=0pt } |
| 1660 |
\anchor{s}{\northeast\pgf@x=0.5\pgf@x\pgf@y=-\pgf@y} |
| 1661 |
\anchor{w}{\pgfpointorigin} |
| 1662 |
\anchor{left}{\pgfpointorigin} |
| 1663 |
\anchor{right}{\northeast\pgf@y=0pt } |
| 1664 |
\savedanchor{\textoffset}{% |
| 1665 |
\pgf@y=\dimexpr.5\dp\pgfnodeparttextbox-.5\ht\pgfnodeparttextbox\relax % (set) |
| 1666 |
} |
| 1667 |
\anchor{text}{\pgfextracty{\pgf@ya}{\textoffset} |
| 1668 |
\northeast\advance \pgf@x by 2pt |
| 1669 |
\pgf@y=\pgf@ya |
| 1670 |
} |
| 1671 |
\pgf@circ@draw@component{% |
| 1672 |
\northeast |
| 1673 |
\pgf@circ@res@up=\pgf@y |
| 1674 |
\pgf@circ@res@right=\pgf@x |
| 1675 |
\pgfpathmoveto{\pgfpoint{0pt}{\pgf@circ@res@up}} |
| 1676 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0pt}} |
| 1677 |
\pgfpathlineto{\pgfpoint{0pt}{-\pgf@circ@res@up}} |
| 1678 |
\pgfusepath{stroke} |
| 1679 |
} |
| 1680 |
} |
| 1681 |
|
| 1682 |
% %>>> |
| 1683 |
|
| 1684 |
%% Node shapes for mux-demuxes%<<< |
| 1685 |
|
| 1686 |
% |
| 1687 |
% MUX-DEMUXES |
| 1688 |
% |
| 1689 |
% predefined muxdemux shapes (see manual) |
| 1690 |
% |
| 1691 |
\tikzset{demux/.style={muxdemux, muxdemux def={Lh=4, Rh=8, NL=1, NB=3, NR=8}}} |
| 1692 |
\tikzset{one bit adder/.style={muxdemux, |
| 1693 |
muxdemux def={Lh=4, NL=2, Rh=2, NR=1, NB=1, w=1.5, |
| 1694 |
inset w=0.5, inset Lh=2, inset Rh=1.5}}} |
| 1695 |
\tikzset{ALU/.style={muxdemux, |
| 1696 |
muxdemux def={Lh=5, NL=2, Rh=2, NR=1, NB=2, NT=1, w=2, |
| 1697 |
inset w=1, inset Lh=2, inset Rh=0, square pins=1}}} |
| 1698 |
%generic mux-demux shape |
| 1699 |
% helper macros to set the anchors inside a loop (to expand the current count) |
| 1700 |
% left |
| 1701 |
\pgfutil@protected\def\pgf@circ@make@muxdemux@L@anchor#1% |
| 1702 |
{% |
| 1703 |
\expandafter\gdef\csname pgf@anchor@muxdemux@lpin #1\endcsname |
| 1704 |
{% |
| 1705 |
\pgf@circ@if@num@in@list\pgf@circ@Lpins@list{#1} |
| 1706 |
{\pgf@circ@muxdemux@L@anchor{#1}{1}} |
| 1707 |
{\pgf@circ@muxdemux@L@anchor{#1}{0}}% |
| 1708 |
}% |
| 1709 |
\expandafter\gdef\csname pgf@anchor@muxdemux@blpin #1\endcsname |
| 1710 |
{\pgf@circ@muxdemux@L@anchor{#1}{0}}% |
| 1711 |
} |
| 1712 |
% right |
| 1713 |
\pgfutil@protected\def\pgf@circ@make@muxdemux@R@anchor#1% |
| 1714 |
{% |
| 1715 |
\expandafter\gdef\csname pgf@anchor@muxdemux@rpin #1\endcsname |
| 1716 |
{% |
| 1717 |
\pgf@circ@if@num@in@list\pgf@circ@Rpins@list{#1} |
| 1718 |
{\pgf@circ@muxdemux@R@anchor{#1}{1}} |
| 1719 |
{\pgf@circ@muxdemux@R@anchor{#1}{0}}% |
| 1720 |
}% |
| 1721 |
\expandafter\gdef\csname pgf@anchor@muxdemux@brpin #1\endcsname |
| 1722 |
{\pgf@circ@muxdemux@R@anchor{#1}{0}}% |
| 1723 |
} |
| 1724 |
% bottom |
| 1725 |
\pgfutil@protected\def\pgf@circ@make@muxdemux@B@anchor#1% |
| 1726 |
{% |
| 1727 |
\expandafter\gdef\csname pgf@anchor@muxdemux@bpin #1\endcsname |
| 1728 |
{% |
| 1729 |
\pgf@circ@if@num@in@list\pgf@circ@Bpins@list{#1} |
| 1730 |
{\pgf@circ@muxdemux@B@anchor{#1}{1}} |
| 1731 |
{\pgf@circ@muxdemux@B@anchor{#1}{0}}% |
| 1732 |
}% |
| 1733 |
\expandafter\gdef\csname pgf@anchor@muxdemux@bbpin #1\endcsname |
| 1734 |
{\pgf@circ@muxdemux@B@anchor{#1}{0}}% |
| 1735 |
} |
| 1736 |
% top |
| 1737 |
\pgfutil@protected\def\pgf@circ@make@muxdemux@T@anchor#1% |
| 1738 |
{% |
| 1739 |
\expandafter\gdef\csname pgf@anchor@muxdemux@tpin #1\endcsname |
| 1740 |
{% |
| 1741 |
\pgf@circ@if@num@in@list\pgf@circ@Tpins@list{#1} |
| 1742 |
{\pgf@circ@muxdemux@T@anchor{#1}{1}} |
| 1743 |
{\pgf@circ@muxdemux@T@anchor{#1}{0}}% |
| 1744 |
}% |
| 1745 |
\expandafter\gdef\csname pgf@anchor@muxdemux@btpin #1\endcsname |
| 1746 |
{\pgf@circ@muxdemux@T@anchor{#1}{0}}% |
| 1747 |
} |
| 1748 |
%% put some label somewhere |
| 1749 |
\def\pgf@circ@muxdemux@label@xy#1#2#3#4#5#6#7{% |
| 1750 |
% #1: which label: L,R,T,B or the outer ones with U/D/R/L |
| 1751 |
% #2: rotation |
| 1752 |
% #3: scale pad x |
| 1753 |
% #4: scale pad y |
| 1754 |
% #5: text position |
| 1755 |
% #6: operation on label text |
| 1756 |
% #7: type: inner, outer, border |
| 1757 |
% uses external variables \pgf@circ@count@a unless it's zero, in which case omit it |
| 1758 |
\ifnum\pgf@circ@count@a=0 |
| 1759 |
\edef\@@thislabel{\circuitikzbasekey/multipoles/muxdemux/label/#1} |
| 1760 |
\else |
| 1761 |
\edef\@@thislabel{\circuitikzbasekey/multipoles/muxdemux/label/#1\the\pgf@circ@count@a} |
| 1762 |
\fi |
| 1763 |
\pgfkeysifdefined{\@@thislabel}{% |
| 1764 |
\pgfscope |
| 1765 |
\pgftransformrotate{#2} |
| 1766 |
\pgfmathsetlength\pgf@circ@res@zero{\pgfkeysvalueof{\circuitikzbasekey/muxdemux/#7 label xsep}} |
| 1767 |
\pgfmathsetlength\pgf@circ@res@other{\pgfkeysvalueof{\circuitikzbasekey/muxdemux/#7 label ysep}} |
| 1768 |
%%% temp is added when we have wedges; it's a bit of a hack but it works if #3,#4 are -1,0,+1 |
| 1769 |
\pgftransformxshift{(#3)*(\pgf@circ@res@zero+\pgf@circ@res@temp)} |
| 1770 |
\pgftransformyshift{(#4)*(\pgf@circ@res@other+\pgf@circ@res@temp)} |
| 1771 |
% Ok, now we have the point in the correct position, we add the label |
| 1772 |
\pgftext[#5]{\pgfkeysvalueof{\circuitikzbasekey/muxdemux/#7 label font}% |
| 1773 |
\expandafter\csname#6\endcsname{\pgfkeysvalueof{\@@thislabel}}} |
| 1774 |
\endpgfscope |
| 1775 |
}{} |
| 1776 |
} |
| 1777 |
%% put a clock wedge here |
| 1778 |
\def\pgf@circ@muxdemux@clockwedge#1#2{% |
| 1779 |
% #1: which label: cL,cR,cT,cB |
| 1780 |
% #2: rotation |
| 1781 |
% uses external variables \pgf@circ@count@a |
| 1782 |
\edef\@@thislabel{\circuitikzbasekey/multipoles/muxdemux/label/#1\the\pgf@circ@count@a} |
| 1783 |
\pgfkeysifdefined{\@@thislabel}{% |
| 1784 |
\edef\value{\pgfkeysvalueof{\@@thislabel}} |
| 1785 |
\ifnum\value=0 |
| 1786 |
\pgf@circ@res@temp=0pt |
| 1787 |
\else\pgfscope |
| 1788 |
\pgftransformrotate{#2} |
| 1789 |
\pgfpathmoveto{\pgfpoint{+0pt}{-\clockwedge}} |
| 1790 |
\pgfpathlineto{\pgfpoint{\clockwedge}{+0pt}} |
| 1791 |
\pgfpathlineto{\pgfpoint{+0pt}{\clockwedge}} |
| 1792 |
\pgfusepath{draw} |
| 1793 |
\endpgfscope |
| 1794 |
\pgf@circ@res@temp=\clockwedge |
| 1795 |
\fi |
| 1796 |
}{} |
| 1797 |
} |
| 1798 |
%% put a negation here |
| 1799 |
\def\pgf@circ@muxdemux@not@ball#1#2{% |
| 1800 |
% #1: which label: nL,nR,nT,nB |
| 1801 |
% #2: anchor |
| 1802 |
% uses external variables \pgf@circ@count@a |
| 1803 |
\edef\@@thislabel{\circuitikzbasekey/multipoles/muxdemux/label/#1\the\pgf@circ@count@a} |
| 1804 |
\pgfkeysifdefined{\@@thislabel}{% |
| 1805 |
\edef\value{\pgfkeysvalueof{\@@thislabel}} |
| 1806 |
\ifnum\value=0 |
| 1807 |
\else |
| 1808 |
\pgfnode{\@@notcirc}{#2}{}{\thisshape-#1\the\pgf@circ@count@a}{\pgfusepath{stroke}} |
| 1809 |
\fi |
| 1810 |
}{} |
| 1811 |
} |
| 1812 |
%% put a negation wedge here |
| 1813 |
\def\pgf@circ@muxdemux@not@wedge#1#2#3#4#5{% |
| 1814 |
% #1: which label: wi/wp with L,R,T,B |
| 1815 |
% #2: anchor |
| 1816 |
% #3: xscale |
| 1817 |
% #4: yscale |
| 1818 |
% #5: rotation |
| 1819 |
% uses external variables \pgf@circ@count@a |
| 1820 |
\edef\@@thislabel{\circuitikzbasekey/multipoles/muxdemux/label/#1\the\pgf@circ@count@a} |
| 1821 |
\pgfkeysifdefined{\@@thislabel}{% |
| 1822 |
\edef\value{\pgfkeysvalueof{\@@thislabel}} |
| 1823 |
\ifnum\value=0 |
| 1824 |
\else\pgfscope |
| 1825 |
\pgftransformrotate{#5} |
| 1826 |
\pgftransformxscale{#3} |
| 1827 |
\pgftransformyscale{#4} |
| 1828 |
\pgftransformyscale{\value}% to flip |
| 1829 |
\pgfnode{wedgeinv}{#2}{}{\thisshape-#1\the\pgf@circ@count@a}{\pgfusepath{stroke}} |
| 1830 |
\endpgfscope\fi |
| 1831 |
}{} |
| 1832 |
} |
| 1833 |
% |
| 1834 |
\pgfdeclareshape{muxdemux}{ |
| 1835 |
\savedmacro{\ctikzclass}{\edef\ctikzclass{muxdemuxes}} |
| 1836 |
\saveddimen{\scaledRlen}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}} |
| 1837 |
\savedmacro{\thisshape}{\def\thisshape{\tikz@fig@name}} |
| 1838 |
% pins on the four sides |
| 1839 |
\savedmacro\NL{\edef\NL{\ctikzvalof{multipoles/muxdemux/NL}}} |
| 1840 |
\savedmacro\NR{\edef\NR{\ctikzvalof{multipoles/muxdemux/NR}}} |
| 1841 |
\savedmacro\NT{\edef\NT{\ctikzvalof{multipoles/muxdemux/NT}}} |
| 1842 |
\savedmacro\NB{\edef\NB{\ctikzvalof{multipoles/muxdemux/NB}}} |
| 1843 |
\savedmacro\squarepins{\edef\squarepins{\ctikzvalof{multipoles/muxdemux/square pins}}} |
| 1844 |
% pin lists |
| 1845 |
\savedmacro\pgf@circ@Lpins@list |
| 1846 |
{% |
| 1847 |
\pgfkeysgetvalue |
| 1848 |
{\circuitikzbasekey/multipoles/draw only left pins}\pgf@circ@temp |
| 1849 |
\expandafter\pgf@circ@set@list |
| 1850 |
\expandafter\pgf@circ@Lpins@list |
| 1851 |
\expandafter{\pgf@circ@temp}% |
| 1852 |
}% |
| 1853 |
\savedmacro\pgf@circ@Rpins@list |
| 1854 |
{% |
| 1855 |
\pgfkeysgetvalue |
| 1856 |
{\circuitikzbasekey/multipoles/draw only right pins}\pgf@circ@temp |
| 1857 |
\expandafter\pgf@circ@set@list |
| 1858 |
\expandafter\pgf@circ@Rpins@list |
| 1859 |
\expandafter{\pgf@circ@temp}% |
| 1860 |
}% |
| 1861 |
\savedmacro\pgf@circ@Tpins@list |
| 1862 |
{% |
| 1863 |
\pgfkeysgetvalue |
| 1864 |
{\circuitikzbasekey/multipoles/draw only top pins}\pgf@circ@temp |
| 1865 |
\expandafter\pgf@circ@set@list |
| 1866 |
\expandafter\pgf@circ@Tpins@list |
| 1867 |
\expandafter{\pgf@circ@temp}% |
| 1868 |
}% |
| 1869 |
\savedmacro\pgf@circ@Bpins@list |
| 1870 |
{% |
| 1871 |
\pgfkeysgetvalue |
| 1872 |
{\circuitikzbasekey/multipoles/draw only bottom pins}\pgf@circ@temp |
| 1873 |
\expandafter\pgf@circ@set@list |
| 1874 |
\expandafter\pgf@circ@Bpins@list |
| 1875 |
\expandafter{\pgf@circ@temp}% |
| 1876 |
}% |
| 1877 |
% topleft and topright sizes |
| 1878 |
\savedanchor{\topleft}{% |
| 1879 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 1880 |
\pgfmathsetlength\pgf@y{\ctikzvalof{multipoles/muxdemux/base len}*\ctikzvalof{multipoles/muxdemux/Lh}*\pgf@circ@scaled@Rlen/2} |
| 1881 |
\pgfmathsetlength\pgf@x{-\ctikzvalof{multipoles/muxdemux/base len}*\ctikzvalof{multipoles/muxdemux/w}*\pgf@circ@scaled@Rlen/2} |
| 1882 |
} |
| 1883 |
\savedanchor{\topright}{% |
| 1884 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 1885 |
\pgfmathsetlength\pgf@y{\ctikzvalof{multipoles/muxdemux/base len}*\ctikzvalof{multipoles/muxdemux/Rh}*\pgf@circ@scaled@Rlen/2} |
| 1886 |
\pgfmathsetlength\pgf@x{\ctikzvalof{multipoles/muxdemux/base len}*\ctikzvalof{multipoles/muxdemux/w}*\pgf@circ@scaled@Rlen/2} |
| 1887 |
} |
| 1888 |
\savedanchor{\insetnortheast}{% |
| 1889 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 1890 |
\pgfmathsetlength\pgf@y{\ctikzvalof{multipoles/muxdemux/base len}*\ctikzvalof{multipoles/muxdemux/inset Lh}*\pgf@circ@scaled@Rlen/2} |
| 1891 |
\pgfmathsetlength\pgf@x{-\ctikzvalof{multipoles/muxdemux/base len}* |
| 1892 |
(\ctikzvalof{multipoles/muxdemux/w}-2*\ctikzvalof{multipoles/muxdemux/inset w})*\pgf@circ@scaled@Rlen/2} |
| 1893 |
} |
| 1894 |
\saveddimen{\insethright}{ |
| 1895 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 1896 |
\pgfmathsetlength\pgf@x{\ctikzvalof{multipoles/muxdemux/base len}*\ctikzvalof{multipoles/muxdemux/inset Rh}*\pgf@circ@scaled@Rlen/2}} |
| 1897 |
\saveddimen{\extshift}{ |
| 1898 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 1899 |
\pgfmathsetlength\pgf@x{\pgf@circ@scaled@Rlen*\ctikzvalof{multipoles/external pins width}}} |
| 1900 |
\savedanchor{\northwest}{% |
| 1901 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 1902 |
\pgfmathsetlength\pgf@y{\ctikzvalof{multipoles/muxdemux/base len}*max(\ctikzvalof{multipoles/muxdemux/Rh},\ctikzvalof{multipoles/muxdemux/Lh})*\pgf@circ@scaled@Rlen/2} |
| 1903 |
\pgfmathsetlength\pgf@x{-\ctikzvalof{multipoles/muxdemux/base len}*\ctikzvalof{multipoles/muxdemux/w}*\pgf@circ@scaled@Rlen/2} |
| 1904 |
} |
| 1905 |
\anchor{nw}{\northwest} |
| 1906 |
\anchor{ne}{\northwest\pgf@x=-\pgf@x} |
| 1907 |
\anchor{se}{\northwest\pgf@x=-\pgf@x\pgf@y=-\pgf@y} |
| 1908 |
\anchor{sw}{\northwest\pgf@y=-\pgf@y} |
| 1909 |
\anchor{north west}{\northwest} |
| 1910 |
\anchor{north east}{\northwest\pgf@x=-\pgf@x} |
| 1911 |
\anchor{south east}{\northwest\pgf@x=-\pgf@x \pgf@y=-\pgf@y} |
| 1912 |
\anchor{south west}{\northwest\pgf@y=-\pgf@y} |
| 1913 |
\anchor{n}{\northwest\pgf@x=0pt } |
| 1914 |
\anchor{e}{\northwest\pgf@x=-\pgf@x\pgf@y=0pt } |
| 1915 |
\anchor{s}{\northwest\pgf@x=0pt\pgf@y=-\pgf@y} |
| 1916 |
\anchor{w}{\northwest\pgf@y=0pt } |
| 1917 |
\anchor{north}{\northwest\pgf@x=0pt } |
| 1918 |
\anchor{east}{\northwest\pgf@x=-\pgf@x\pgf@y=0pt } |
| 1919 |
\anchor{south}{\northwest\pgf@x=0pt\pgf@y=-\pgf@y} |
| 1920 |
\anchor{west}{\northwest\pgf@y=0pt } |
| 1921 |
\anchor{center}{\pgfpointorigin} |
| 1922 |
\anchor{top right}{\topright} |
| 1923 |
\anchor{bottom right}{\topright\pgf@y=-\pgf@y} |
| 1924 |
\anchor{right}{\topright\pgf@y=0pt\relax} |
| 1925 |
\anchor{top left}{\topleft} |
| 1926 |
\anchor{bottom left}{\topleft\pgf@y=-\pgf@y} |
| 1927 |
\anchor{left}{\topleft\pgf@y=0pt\relax} |
| 1928 |
\anchor{top}{\topright\pgf@ya=\pgf@y \topleft \advance\pgf@y by \pgf@ya |
| 1929 |
\divide\pgf@y by 2 \pgf@x=0pt\relax} |
| 1930 |
\anchor{bottom}{\topright\pgf@ya=\pgf@y \topleft \advance\pgf@y by \pgf@ya |
| 1931 |
\divide\pgf@y by 2 \pgf@y=-\pgf@y \pgf@x=0pt\relax} |
| 1932 |
\anchor{inset top right}{\pgf@ya=\insethright\insetnortheast\advance\pgf@y by -0.5\pgf@ya} |
| 1933 |
\anchor{inset bottom right}{\pgf@ya=\insethright\insetnortheast\advance\pgf@y by -0.5\pgf@ya\pgf@y=-\pgf@y} |
| 1934 |
\anchor{inset right}{\insetnortheast\pgf@y=0pt\relax} |
| 1935 |
\anchor{inset top left}{\insetnortheast\pgf@ya=\pgf@y\topleft\pgf@y=\pgf@ya} |
| 1936 |
\anchor{inset bottom left}{\insetnortheast\pgf@ya=\pgf@y\topleft\pgf@y=-\pgf@ya} |
| 1937 |
\anchor{inset left}{\topleft\pgf@y=0pt\relax} |
| 1938 |
\anchor{inset bottom}{\topleft\pgf@xa=\pgf@x\pgf@ya=\insethright |
| 1939 |
\insetnortheast\pgf@xb=\pgf@x\pgf@yb=\pgf@x |
| 1940 |
\pgfpoint{(\pgf@xa+\pgf@xb)/2}{-\pgf@ya+\pgf@yb/2}} |
| 1941 |
\anchor{inset top}{\topleft\pgf@xa=\pgf@x\pgf@ya=\insethright |
| 1942 |
\insetnortheast\pgf@xb=\pgf@x\pgf@yb=\pgf@x |
| 1943 |
\pgfpoint{(\pgf@xa+\pgf@xb)/2}{\pgf@ya-\pgf@yb/2}} |
| 1944 |
\anchor{inset center}{\topleft\pgf@xa=\pgf@x\insetnortheast |
| 1945 |
\advance\pgf@x by \pgf@xa \divide\pgf@x by 2 \pgf@y=0pt\relax} |
| 1946 |
\anchor{narrow center}{\insetnortheast\pgf@xa=\pgf@x\topright |
| 1947 |
\advance\pgf@x by \pgf@xa \divide\pgf@x by 2\pgf@y=0pt\relax} |
| 1948 |
\anchor{center up}{\topright\pgf@ya=\pgf@y \topleft \advance\pgf@y by \pgf@ya |
| 1949 |
\divide\pgf@y by 2 |
| 1950 |
\pgf@yb = \insethright \advance\pgf@y by \pgf@yb |
| 1951 |
\divide\pgf@y by 2 \pgf@x=0pt\relax} |
| 1952 |
\anchor{center down}{\topright\pgf@ya=\pgf@y \topleft \advance\pgf@y by \pgf@ya |
| 1953 |
\divide\pgf@y by 2 |
| 1954 |
\pgf@yb = \insethright \advance\pgf@y by \pgf@yb |
| 1955 |
\divide\pgf@y by 2 \pgf@y=-\pgf@y \pgf@x=0pt\relax} |
| 1956 |
\savedanchor{\textanchor}{% |
| 1957 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 1958 |
\pgfmathsetlength\pgf@x{\ctikzvalof{multipoles/muxdemux/base len}* |
| 1959 |
\ctikzvalof{multipoles/muxdemux/inset w}*\pgf@circ@scaled@Rlen/2} |
| 1960 |
\advance\pgf@x by -.5\wd\pgfnodeparttextbox% |
| 1961 |
\pgf@y=-.5\ht\pgfnodeparttextbox% |
| 1962 |
\advance\pgf@y by+.5\dp\pgfnodeparttextbox% |
| 1963 |
}% |
| 1964 |
\anchor{text}{\textanchor} |
| 1965 |
\pgf@circ@draw@component{% |
| 1966 |
\topleft |
| 1967 |
\pgf@circ@res@up = \pgf@y |
| 1968 |
\pgf@circ@res@down = -\pgf@y |
| 1969 |
\pgf@circ@res@left = \pgf@x |
| 1970 |
\topright |
| 1971 |
\pgf@circ@res@other = \pgf@y |
| 1972 |
\pgf@circ@res@right = \pgf@x |
| 1973 |
\insetnortheast |
| 1974 |
\pgf@circ@res@step = \pgf@x |
| 1975 |
\pgf@circ@res@temp = \pgf@y |
| 1976 |
% |
| 1977 |
% draw the (user-selectable) background |
| 1978 |
% |
| 1979 |
\pgfscope |
| 1980 |
\pgfmathsetmacro{\@@scalex}{\pgf@circ@res@right/1cm} |
| 1981 |
% It's better not to change the scale in an asymmetric way |
| 1982 |
% \pgfmathsetmacro{\@@scaley}{\pgf@circ@res@up/1cm} |
| 1983 |
\pgftransformxscale{\@@scalex} |
| 1984 |
\pgftransformyscale{\@@scalex} |
| 1985 |
\pgf@circ@setlinewidth{multipoles}{\pgfstartlinewidth} |
| 1986 |
\pgfkeys{\circuitikzbasekey/multipoles/muxdemux/bgpicture} |
| 1987 |
\endpgfscope |
| 1988 |
% |
| 1989 |
% external block |
| 1990 |
% |
| 1991 |
\pgfscope% (for the line width) |
| 1992 |
\pgf@circ@setlinewidth{multipoles}{\pgflinewidth} |
| 1993 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}} |
| 1994 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@other}} |
| 1995 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{-\pgf@circ@res@other}} |
| 1996 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}} |
| 1997 |
% inset, starting down |
| 1998 |
\ifdim\pgf@circ@res@temp>0pt % inset |
| 1999 |
% \typeout{INSETw\space\the\pgf@circ@res@right\space x\space\the\pgf@circ@res@step\space y\space\the\pgf@circ@res@temp} |
| 2000 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{-\pgf@circ@res@temp}} |
| 2001 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{-\insethright}} |
| 2002 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{\insethright}} |
| 2003 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@temp}} |
| 2004 |
\fi |
| 2005 |
\pgfpathclose |
| 2006 |
\pgf@circ@draworfill |
| 2007 |
\endpgfscope |
| 2008 |
% now we have to draw the pins, if needed |
| 2009 |
\ifdim\extshift>0pt\ifpgfcirc@draw@input@leads\pgfscope % let's avoid too much indent |
| 2010 |
% Ok, we have to draw the leads (a.k.a. pins) |
| 2011 |
\pgfsetlinewidth{\ctikzvalof{multipoles/external pins thickness}\pgflinewidth} |
| 2012 |
% We mimic the anchors here --- probably there is a better way |
| 2013 |
% left pins |
| 2014 |
\ifnum\NL>0\relax % not indented, closed on \repeatpgfmathloop |
| 2015 |
\pgf@circ@count@a=\NL\relax |
| 2016 |
\pgf@circ@count@b=\NL \divide\pgf@circ@count@b by 2 % see https://tex.stackexchange.com/questions/146523/why-does-numexpr-integer-division-round-rather-than-truncate |
| 2017 |
\topleft\pgf@circ@res@left=\pgf@x \pgf@circ@res@up=\pgf@y |
| 2018 |
\insetnortheast\pgf@circ@res@right=\pgf@x \pgf@circ@res@down=\pgf@y |
| 2019 |
\ifdim\pgf@circ@res@down>0pt % check if we have an inset |
| 2020 |
% we have to check oddity |
| 2021 |
\ifodd\NL |
| 2022 |
\ifnum\NL=1 |
| 2023 |
% only centerpin, step should not be used, but anyway... |
| 2024 |
\pgfmathsetlength{\pgf@circ@res@step}{2*(\pgf@circ@res@up-\pgf@circ@res@down)/(\NL)} |
| 2025 |
\else |
| 2026 |
\pgfmathsetlength{\pgf@circ@res@step}{2*(\pgf@circ@res@up-\pgf@circ@res@down)/(\NL-1)} |
| 2027 |
\fi |
| 2028 |
\else |
| 2029 |
\pgfmathsetlength{\pgf@circ@res@step}{2*(\pgf@circ@res@up-\pgf@circ@res@down)/\NL} |
| 2030 |
\fi |
| 2031 |
\else % no inset |
| 2032 |
\pgfmathsetlength{\pgf@circ@res@step}{2*\pgf@circ@res@up/\NL} |
| 2033 |
\fi |
| 2034 |
\pgfmathloop% |
| 2035 |
\ifnum\pgf@circ@count@a>0 |
| 2036 |
%%%%% check if we want to draw this pin |
| 2037 |
\pgf@circ@if@num@in@list\pgf@circ@Lpins@list\pgf@circ@count@a{% |
| 2038 |
\ifdim\pgf@circ@res@down>0pt % check if we have an inset |
| 2039 |
\ifnum\pgf@circ@count@a>\pgf@circ@count@b\relax |
| 2040 |
% for lower pins we have to shift them down |
| 2041 |
% \typeout{DEBUGTEST1\space #1\space entering\space \NL} |
| 2042 |
\ifodd\NL |
| 2043 |
% odd number of pins |
| 2044 |
\ifnum\pgf@circ@count@a=\numexpr\the\pgf@circ@count@b+1\relax |
| 2045 |
% centerpin! |
| 2046 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}} |
| 2047 |
\ifnum\squarepins>0 |
| 2048 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\extshift}{0pt}} |
| 2049 |
\else |
| 2050 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-\extshift}{0pt}} |
| 2051 |
\fi |
| 2052 |
\else |
| 2053 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(0.5-\pgf@circ@count@a+1)*\pgf@circ@res@step-2*\pgf@circ@res@down}} |
| 2054 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\extshift}{\pgf@circ@res@up+(0.5-\pgf@circ@count@a+1)*\pgf@circ@res@step-2*\pgf@circ@res@down}} |
| 2055 |
\fi |
| 2056 |
\else |
| 2057 |
% even numer of pins: just go down |
| 2058 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(0.5-\pgf@circ@count@a)*\pgf@circ@res@step-2*\pgf@circ@res@down}} |
| 2059 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\extshift}{\pgf@circ@res@up+(0.5-\pgf@circ@count@a)*\pgf@circ@res@step-2*\pgf@circ@res@down}} |
| 2060 |
\fi |
| 2061 |
\else |
| 2062 |
% nothing need for #1<=NL/2 |
| 2063 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(0.5-\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 2064 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\extshift}{\pgf@circ@res@up+(0.5-\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 2065 |
\fi |
| 2066 |
\else |
| 2067 |
% no inset |
| 2068 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(0.5-\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 2069 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\extshift}{\pgf@circ@res@up+(0.5-\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 2070 |
\fi |
| 2071 |
%%%%% |
| 2072 |
}{}% close the pin list check |
| 2073 |
\advance\pgf@circ@count@a by -1\relax% |
| 2074 |
\repeatpgfmathloop\fi% |
| 2075 |
% right pins |
| 2076 |
\ifnum\NR>0\pgf@circ@count@a=\NR\relax |
| 2077 |
\pgfmathloop% |
| 2078 |
\topright\pgf@circ@res@right=\pgf@x \pgf@circ@res@up=\pgf@y |
| 2079 |
\pgfmathsetlength{\pgf@circ@res@step}{2*\pgf@circ@res@up/\NR} |
| 2080 |
\ifnum\pgf@circ@count@a>0 |
| 2081 |
%%%%% check if we want to draw this pin |
| 2082 |
\pgf@circ@if@num@in@list\pgf@circ@Rpins@list\pgf@circ@count@a{% |
| 2083 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up+(0.5-\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 2084 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\extshift}{\pgf@circ@res@up+(0.5-\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 2085 |
}{}% |
| 2086 |
\advance\pgf@circ@count@a by -1\relax% |
| 2087 |
\repeatpgfmathloop\fi% |
| 2088 |
% bottom pins |
| 2089 |
\ifnum\NB>0\pgf@circ@count@a=\NB\relax %%% |
| 2090 |
\pgfmathloop% |
| 2091 |
\topleft\pgf@circ@res@left=\pgf@x \pgf@circ@res@up=\pgf@y |
| 2092 |
\topright\pgf@circ@res@right=\pgf@x \pgf@circ@res@down=\pgf@y |
| 2093 |
\pgfmathsetlength{\pgf@circ@res@step}{2*\pgf@circ@res@right/\NB} |
| 2094 |
\pgfmathsetlength{\pgf@circ@res@other}{(\pgf@circ@res@down-\pgf@circ@res@up)/(\pgf@circ@res@right-\pgf@circ@res@left)*\pgf@circ@res@step} |
| 2095 |
\ifnum\pgf@circ@count@a>0 |
| 2096 |
%%%%% check if we want to draw this pin |
| 2097 |
\pgf@circ@if@num@in@list\pgf@circ@Bpins@list\pgf@circ@count@a{% |
| 2098 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left+(\pgf@circ@[email protected])*\pgf@circ@res@step} |
| 2099 |
{-\pgf@circ@res@down+(\NB-\pgf@circ@count@a+0.5)*\pgf@circ@res@other}} |
| 2100 |
\ifnum\squarepins>0 |
| 2101 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left+(\pgf@circ@[email protected])*\pgf@circ@res@step} |
| 2102 |
{-max(\pgf@circ@res@down, \pgf@circ@res@up)-\extshift}} |
| 2103 |
\else |
| 2104 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left+(\pgf@circ@[email protected])*\pgf@circ@res@step} |
| 2105 |
{-\pgf@circ@res@down+(\NB-\pgf@circ@count@a+0.5)*\pgf@circ@res@other-\extshift}} |
| 2106 |
\fi |
| 2107 |
}{}% |
| 2108 |
\advance\pgf@circ@count@a by -1\relax% |
| 2109 |
\repeatpgfmathloop\fi% |
| 2110 |
% top pins |
| 2111 |
\ifnum\NT>0\pgf@circ@count@a=\NT\relax |
| 2112 |
\pgfmathloop% |
| 2113 |
\topleft\pgf@circ@res@left=\pgf@x \pgf@circ@res@up=\pgf@y |
| 2114 |
\topright\pgf@circ@res@right=\pgf@x \pgf@circ@res@down=\pgf@y |
| 2115 |
\pgfmathsetlength{\pgf@circ@res@step}{2*\pgf@circ@res@right/\NT} |
| 2116 |
\pgfmathsetlength{\pgf@circ@res@other}{(\pgf@circ@res@down-\pgf@circ@res@up)/(\pgf@circ@res@right-\pgf@circ@res@left)*\pgf@circ@res@step} |
| 2117 |
\ifnum\pgf@circ@count@a>0 |
| 2118 |
%%%%% check if we want to draw this pin |
| 2119 |
\pgf@circ@if@num@in@list\pgf@circ@Tpins@list\pgf@circ@count@a{% |
| 2120 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left+(\pgf@circ@[email protected])*\pgf@circ@res@step} |
| 2121 |
{\pgf@circ@res@down-(\NT-\pgf@circ@count@a+0.5)*\pgf@circ@res@other}} |
| 2122 |
\ifnum\squarepins>0 |
| 2123 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left+(\pgf@circ@[email protected])*\pgf@circ@res@step} |
| 2124 |
{max(\pgf@circ@res@down, \pgf@circ@res@up)+\extshift}} |
| 2125 |
\else |
| 2126 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left+(\pgf@circ@[email protected])*\pgf@circ@res@step} |
| 2127 |
{\pgf@circ@res@down-(\NT-\pgf@circ@count@a+0.5)*\pgf@circ@res@other+\extshift}} |
| 2128 |
\fi |
| 2129 |
}{}% |
| 2130 |
\advance\pgf@circ@count@a by -1\relax% |
| 2131 |
\repeatpgfmathloop\fi% |
| 2132 |
% end drawing pins; stroke them |
| 2133 |
\pgfusepath{stroke} |
| 2134 |
\endpgfscope\fi\fi |
| 2135 |
%%%% Labels. Added by Romano 14/10/2023. |
| 2136 |
% manage labels. This is independent from the drawing of pins; redo the loops. Surely |
| 2137 |
% there is a better way; but it's complex to factor out code. Let's go the KISS way. |
| 2138 |
\ifpgf@circuit@chip@straightnumbers |
| 2139 |
\pgfgettransformentries\a\b\temp\temp\temp\temp |
| 2140 |
\pgfmathsetmacro{\rot}{-atan2(\b,\a)} |
| 2141 |
\pgfmathtruncatemacro{\quadrant}{mod(4+int(360+(\rot+45)/90),4)} |
| 2142 |
\else |
| 2143 |
\pgfmathsetmacro{\rot}{0} |
| 2144 |
\pgfmathsetmacro{\quadrant}{0} |
| 2145 |
\fi |
| 2146 |
% clockwedge size |
| 2147 |
\pgfmathsetlength{\pgf@circ@res@temp}{\ctikzvalof{muxdemux/clock wedge size}*\ctikzvalof{multipoles/muxdemux/base len}*\scaledRlen} |
| 2148 |
\edef\clockwedge{\the\pgf@circ@res@temp} |
| 2149 |
% select which negation ball to use |
| 2150 |
\ifpgf@circuit@ieeelogicport |
| 2151 |
\def\@@notcirc{circleinv} |
| 2152 |
\else |
| 2153 |
\ifpgf@circ@european@port@circle@ieee |
| 2154 |
\def\@@notcirc{circleinv} |
| 2155 |
\else |
| 2156 |
\def\@@notcirc{ocirc} |
| 2157 |
\fi |
| 2158 |
\fi |
| 2159 |
%% border labels |
| 2160 |
\pgf@circ@res@temp=0pt |
| 2161 |
\pgf@circ@count@a=0 |
| 2162 |
% go to north |
| 2163 |
\topleft\pgf@circ@res@left=\pgf@x \pgf@circ@res@up=\pgf@y |
| 2164 |
\pgfscope |
| 2165 |
\pgftransformshift{\pgfpoint{0pt}{\pgf@circ@res@up}} |
| 2166 |
\ifnum\quadrant=2 |
| 2167 |
\pgf@circ@muxdemux@label@xy{N}{180}{0}{-1}{top}{pgfcirc@nop}{border}% type, rot, pad x, pad y, text pos, op, type |
| 2168 |
\pgf@circ@muxdemux@label@xy{Ni}{180}{0}{1}{bottom}{pgfcirc@nop}{border}% |
| 2169 |
\else |
| 2170 |
\pgf@circ@muxdemux@label@xy{N}{0}{0}{1}{bottom}{pgfcirc@nop}{border}% |
| 2171 |
\pgf@circ@muxdemux@label@xy{Ni}{0}{0}{-1}{top}{pgfcirc@nop}{border}% |
| 2172 |
\fi |
| 2173 |
\endpgfscope |
| 2174 |
% go south! |
| 2175 |
\pgfscope |
| 2176 |
\pgftransformshift{\pgfpoint{0pt}{-\pgf@circ@res@up}} |
| 2177 |
\ifnum\quadrant=2 |
| 2178 |
\pgf@circ@muxdemux@label@xy{S}{180}{0}{1}{bottom}{pgfcirc@nop}{border}% type, rot, pad x, pad y, text pos, op, type |
| 2179 |
\pgf@circ@muxdemux@label@xy{Si}{180}{0}{-1}{top}{pgfcirc@nop}{border}% |
| 2180 |
\else |
| 2181 |
\pgf@circ@muxdemux@label@xy{S}{0}{0}{-1}{top}{pgfcirc@nop}{border}% type, rot, pad x, pad y, text pos, op, type |
| 2182 |
\pgf@circ@muxdemux@label@xy{Si}{0}{0}{1}{bottom}{pgfcirc@nop}{border}% |
| 2183 |
\fi |
| 2184 |
\endpgfscope |
| 2185 |
% go west! |
| 2186 |
\pgfscope |
| 2187 |
\pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}} |
| 2188 |
\ifnum\quadrant=3 |
| 2189 |
\pgf@circ@muxdemux@label@xy{W}{-90}{0}{-1}{top}{pgfcirc@nop}{border}% type, rot, pad x, pad y, text pos, op, type |
| 2190 |
\pgf@circ@muxdemux@label@xy{Wi}{-90}{0}{1}{bottom}{pgfcirc@nop}{border}% |
| 2191 |
\else |
| 2192 |
\pgf@circ@muxdemux@label@xy{W}{90}{0}{1}{bottom}{pgfcirc@nop}{border}% |
| 2193 |
\pgf@circ@muxdemux@label@xy{Wi}{90}{0}{-1}{top}{pgfcirc@nop}{border}% |
| 2194 |
\fi |
| 2195 |
\endpgfscope |
| 2196 |
% go east! |
| 2197 |
\pgfscope |
| 2198 |
\pgftransformshift{\pgfpoint{-\pgf@circ@res@left}{0pt}} |
| 2199 |
\ifnum\quadrant=3 |
| 2200 |
\pgf@circ@muxdemux@label@xy{E}{-90}{0}{1}{bottom}{pgfcirc@nop}{border}% type, rot, pad x, pad y, text pos, op, type |
| 2201 |
\pgf@circ@muxdemux@label@xy{Ei}{-90}{0}{-1}{top}{pgfcirc@nop}{border}% |
| 2202 |
\else |
| 2203 |
\pgf@circ@muxdemux@label@xy{E}{90}{0}{-1}{top}{pgfcirc@nop}{border}% |
| 2204 |
\pgf@circ@muxdemux@label@xy{Ei}{90}{0}{1}{bottom}{pgfcirc@nop}{border}% |
| 2205 |
\fi |
| 2206 |
\endpgfscope |
| 2207 |
% start exploring all the pins. We repeat the steps to position the coordinate on every pin. |
| 2208 |
% left pins |
| 2209 |
\ifnum\NL>0\relax |
| 2210 |
\pgf@circ@count@a=\NL\relax |
| 2211 |
\pgf@circ@count@b=\NL \divide\pgf@circ@count@b by 2 % see https://tex.stackexchange.com/questions/146523/why-does-numexpr-integer-division-round-rather-than-truncate |
| 2212 |
\topleft\pgf@circ@res@left=\pgf@x \pgf@circ@res@up=\pgf@y |
| 2213 |
\insetnortheast\pgf@circ@res@right=\pgf@x \pgf@circ@res@down=\pgf@y |
| 2214 |
\ifdim\pgf@circ@res@down>0pt % check if we have an inset |
| 2215 |
% we have to check oddity |
| 2216 |
\ifodd\NL |
| 2217 |
\ifnum\NL=1 |
| 2218 |
% only centerpin, step should not be used, but anyway... |
| 2219 |
\pgfmathsetlength{\pgf@circ@res@step}{2*(\pgf@circ@res@up-\pgf@circ@res@down)/(\NL)} |
| 2220 |
\else |
| 2221 |
\pgfmathsetlength{\pgf@circ@res@step}{2*(\pgf@circ@res@up-\pgf@circ@res@down)/(\NL-1)} |
| 2222 |
\fi |
| 2223 |
\else |
| 2224 |
\pgfmathsetlength{\pgf@circ@res@step}{2*(\pgf@circ@res@up-\pgf@circ@res@down)/\NL} |
| 2225 |
\fi |
| 2226 |
\else % no inset |
| 2227 |
\pgfmathsetlength{\pgf@circ@res@step}{2*\pgf@circ@res@up/\NL} |
| 2228 |
\fi |
| 2229 |
\pgfmathloop% |
| 2230 |
\ifnum\pgf@circ@count@a>0 |
| 2231 |
\pgfscope |
| 2232 |
\ifdim\pgf@circ@res@down>0pt % check if we have an inset |
| 2233 |
\ifnum\pgf@circ@count@a>\pgf@circ@count@b\relax |
| 2234 |
% for lower pins we have to shift them down |
| 2235 |
\ifodd\NL |
| 2236 |
% odd number of pins |
| 2237 |
\ifnum\pgf@circ@count@a=\numexpr\the\pgf@circ@count@b+1\relax |
| 2238 |
% centerpin! |
| 2239 |
\pgftransformshift{\pgfpoint{\pgf@circ@res@right}{0pt}} |
| 2240 |
\else |
| 2241 |
\pgftransformshift{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(0.5-\pgf@circ@count@a+1)*\pgf@circ@res@step-2*\pgf@circ@res@down}} |
| 2242 |
\fi |
| 2243 |
\else |
| 2244 |
% even numer of pins: just go down |
| 2245 |
\pgftransformshift{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(0.5-\pgf@circ@count@a)*\pgf@circ@res@step-2*\pgf@circ@res@down}} |
| 2246 |
\fi |
| 2247 |
\else |
| 2248 |
% nothing need for #1<=NL/2 |
| 2249 |
\pgftransformshift{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(0.5-\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 2250 |
\fi |
| 2251 |
\else |
| 2252 |
% no inset |
| 2253 |
\pgftransformshift{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(0.5-\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 2254 |
\fi |
| 2255 |
% put the not ball/wedges if needed |
| 2256 |
\pgf@circ@muxdemux@not@ball{nL}{east} |
| 2257 |
\pgf@circ@muxdemux@not@wedge{wiL}{east}{1}{1}{0} |
| 2258 |
\pgf@circ@muxdemux@not@wedge{woL}{west}{-1}{1}{0} |
| 2259 |
% \fi |
| 2260 |
\pgf@circ@muxdemux@clockwedge{cL}{0} |
| 2261 |
%% put the labels |
| 2262 |
\ifcase\quadrant % rotation 0; left label are at the left |
| 2263 |
\pgf@circ@muxdemux@label@xy{L}{0}{1}{0}{left}{pgfcirc@nop}{inner}% type, rot, pad x, pad y, text pos, op, type |
| 2264 |
\pgf@circ@res@temp=0pt |
| 2265 |
\pgf@circ@muxdemux@label@xy{LU}{0}{-1}{1}{bottom}{llap}{outer}% |
| 2266 |
\pgf@circ@muxdemux@label@xy{LD}{0}{-1}{-1}{top}{llap}{outer}% |
| 2267 |
\or %rotation -90; left labels are at the top |
| 2268 |
\pgf@circ@muxdemux@label@xy{L}{90}{0}{-1}{top}{pgfcirc@nop}{inner}% type, rot, pad x, pad y, text pos, op, type |
| 2269 |
\pgf@circ@res@temp=0pt |
| 2270 |
\pgf@circ@muxdemux@label@xy{LU}{90}{-1}{1}{bottom}{llap}{outer}% |
| 2271 |
\pgf@circ@muxdemux@label@xy{LD}{90}{1}{1}{bottom}{rlap}{outer}% |
| 2272 |
\or %rotation 180; left labels are at the right |
| 2273 |
\pgf@circ@muxdemux@label@xy{L}{180}{-1}{0}{right}{pgfcirc@nop}{inner}% type, rot, pad x, pad y, text pos, op, type |
| 2274 |
\pgf@circ@res@temp=0pt |
| 2275 |
\pgf@circ@muxdemux@label@xy{LU}{180}{1}{1}{bottom}{rlap}{outer}% |
| 2276 |
\pgf@circ@muxdemux@label@xy{LD}{180}{1}{-1}{top}{rlap}{outer}% |
| 2277 |
\or %rotation +90; left labels are at the bottom |
| 2278 |
\pgf@circ@muxdemux@label@xy{L}{-90}{0}{1}{bottom}{pgfcirc@nop}{inner}% type, rot, pad x, pad y, text pos, op, type |
| 2279 |
\pgf@circ@res@temp=0pt |
| 2280 |
\pgf@circ@muxdemux@label@xy{LU}{-90}{-1}{-1}{top}{llap}{outer}% |
| 2281 |
\pgf@circ@muxdemux@label@xy{LD}{-90}{1}{-1}{top}{rlap}{outer}% |
| 2282 |
\fi |
| 2283 |
\endpgfscope |
| 2284 |
\advance\pgf@circ@count@a by -1\relax% |
| 2285 |
\repeatpgfmathloop |
| 2286 |
\fi |
| 2287 |
%% right pins |
| 2288 |
\ifnum\NR>0\pgf@circ@count@a=\NR\relax |
| 2289 |
\pgfmathloop% |
| 2290 |
\topright\pgf@circ@res@right=\pgf@x \pgf@circ@res@up=\pgf@y |
| 2291 |
\pgfmathsetlength{\pgf@circ@res@step}{2*\pgf@circ@res@up/\NR} |
| 2292 |
\ifnum\pgf@circ@count@a>0 |
| 2293 |
\pgfscope |
| 2294 |
\pgftransformshift{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up+(0.5-\pgf@circ@count@a)*\pgf@circ@res@step}} |
| 2295 |
% put the not ball/wedge if needed |
| 2296 |
\pgf@circ@muxdemux@not@ball{nR}{west} |
| 2297 |
\pgf@circ@muxdemux@not@wedge{wiR}{east}{-1}{1}{0} |
| 2298 |
\pgf@circ@muxdemux@not@wedge{woR}{west}{1}{1}{0} |
| 2299 |
% put the clock wedge if needed |
| 2300 |
\pgf@circ@muxdemux@clockwedge{cR}{180} |
| 2301 |
\ifcase\quadrant % rotation 0; right label are at the right |
| 2302 |
\pgf@circ@muxdemux@label@xy{R}{0}{-1}{0}{right}{pgfcirc@nop}{inner}% type, rot, pad x, pad y, text pos, op, type |
| 2303 |
\pgf@circ@res@temp=0pt |
| 2304 |
\pgf@circ@muxdemux@label@xy{RU}{0}{1}{1}{bottom}{rlap}{outer}% |
| 2305 |
\pgf@circ@muxdemux@label@xy{RD}{0}{1}{-1}{top}{rlap}{outer}% |
| 2306 |
\or %rotation -90; right labels are at the bottom |
| 2307 |
\pgf@circ@muxdemux@label@xy{R}{90}{0}{1}{bottom}{pgfcirc@nop}{inner}% type, rot, pad x, pad y, text pos, op, type |
| 2308 |
\pgf@circ@res@temp=0pt |
| 2309 |
\pgf@circ@muxdemux@label@xy{RU}{90}{-1}{-1}{top}{llap}{outer}% |
| 2310 |
\pgf@circ@muxdemux@label@xy{RD}{90}{1}{-1}{top}{rlap}{outer}% |
| 2311 |
\or %rotation 180; right labels are at the left |
| 2312 |
\pgf@circ@muxdemux@label@xy{R}{180}{1}{0}{left}{pgfcirc@nop}{inner}% type, rot, pad x, pad y, text pos, op, type |
| 2313 |
\pgf@circ@res@temp=0pt |
| 2314 |
\pgf@circ@muxdemux@label@xy{RU}{180}{-1}{1}{bottom}{llap}{outer}% |
| 2315 |
\pgf@circ@muxdemux@label@xy{RD}{180}{-1}{-1}{top}{llap}{outer}% |
| 2316 |
\or %rotation +90; right labels are at the top |
| 2317 |
\pgf@circ@muxdemux@label@xy{R}{-90}{0}{-1}{top}{pgfcirc@nop}{inner}% type, rot, pad x, pad y, text pos, op, type |
| 2318 |
\pgf@circ@res@temp=0pt |
| 2319 |
\pgf@circ@muxdemux@label@xy{RU}{-90}{-1}{1}{bottom}{llap}{outer}% |
| 2320 |
\pgf@circ@muxdemux@label@xy{RD}{-90}{1}{1}{bottom}{rlap}{outer}% |
| 2321 |
\fi |
| 2322 |
\endpgfscope |
| 2323 |
\advance\pgf@circ@count@a by -1\relax% |
| 2324 |
\repeatpgfmathloop |
| 2325 |
\fi |
| 2326 |
%% bottom pins |
| 2327 |
\ifnum\NB>0\pgf@circ@count@a=\NB\relax %%% |
| 2328 |
\pgfmathloop% |
| 2329 |
\topleft\pgf@circ@res@left=\pgf@x \pgf@circ@res@up=\pgf@y |
| 2330 |
\topright\pgf@circ@res@right=\pgf@x \pgf@circ@res@down=\pgf@y |
| 2331 |
\pgfmathsetlength{\pgf@circ@res@step}{2*\pgf@circ@res@right/\NB} |
| 2332 |
\pgfmathsetlength{\pgf@circ@res@other}{(\pgf@circ@res@down-\pgf@circ@res@up)/(\pgf@circ@res@right-\pgf@circ@res@left)*\pgf@circ@res@step} |
| 2333 |
\ifnum\pgf@circ@count@a>0 |
| 2334 |
\pgfscope |
| 2335 |
\pgftransformshift{\pgfpoint{\pgf@circ@res@left+(\pgf@circ@[email protected])*\pgf@circ@res@step} |
| 2336 |
{-\pgf@circ@res@down+(\NB-\pgf@circ@count@a+0.5)*\pgf@circ@res@other}} |
| 2337 |
% put the not ball/wedge if needed |
| 2338 |
\pgf@circ@muxdemux@not@ball{nB}{north} |
| 2339 |
\pgf@circ@muxdemux@not@wedge{wiB}{east}{1}{1}{90} |
| 2340 |
\pgf@circ@muxdemux@not@wedge{woB}{west}{-1}{1}{90} |
| 2341 |
% put the clock wedge if needed |
| 2342 |
\pgf@circ@muxdemux@clockwedge{cB}{90} |
| 2343 |
\ifcase\quadrant % rotation 0; bottom label are at the bottom |
| 2344 |
\pgf@circ@muxdemux@label@xy{B}{0}{0}{1}{bottom}{pgfcirc@nop}{inner}% type, rot, pad x, pad y, text pos, op, type |
| 2345 |
\pgf@circ@res@temp=0pt |
| 2346 |
\pgf@circ@muxdemux@label@xy{BL}{0}{-1}{-1}{top}{llap}{outer}% |
| 2347 |
\pgf@circ@muxdemux@label@xy{BR}{0}{1}{-1}{top}{rlap}{outer}% |
| 2348 |
\or %rotation -90; bottom labels are at the left |
| 2349 |
\pgf@circ@muxdemux@label@xy{B}{90}{1}{0}{left}{pgfcirc@nop}{inner}% type, rot, pad x, pad y, text pos, op, type |
| 2350 |
\pgf@circ@res@temp=0pt |
| 2351 |
\pgf@circ@muxdemux@label@xy{BL}{90}{-1}{1}{bottom}{llap}{outer}% |
| 2352 |
\pgf@circ@muxdemux@label@xy{BR}{90}{-1}{-1}{top}{llap}{outer}% |
| 2353 |
\or %rotation 180; bottom labels are at the top |
| 2354 |
\pgf@circ@muxdemux@label@xy{B}{180}{0}{-1}{top}{pgfcirc@nop}{inner}% type, rot, pad x, pad y, text pos, op, type |
| 2355 |
\pgf@circ@res@temp=0pt |
| 2356 |
\pgf@circ@muxdemux@label@xy{BL}{180}{-1}{1}{bottom}{llap}{outer}% |
| 2357 |
\pgf@circ@muxdemux@label@xy{BR}{180}{1}{1}{bottom}{rlap}{outer}% |
| 2358 |
\or %rotation +90; bottom labels are at the right |
| 2359 |
\pgf@circ@muxdemux@label@xy{B}{-90}{-1}{0}{right}{pgfcirc@nop}{inner}% type, rot, pad x, pad y, text pos, op, type |
| 2360 |
\pgf@circ@res@temp=0pt |
| 2361 |
\pgf@circ@muxdemux@label@xy{BL}{-90}{1}{1}{bottom}{rlap}{outer}% |
| 2362 |
\pgf@circ@muxdemux@label@xy{BR}{-90}{1}{-1}{top}{rlap}{outer}% |
| 2363 |
\fi |
| 2364 |
\endpgfscope |
| 2365 |
\advance\pgf@circ@count@a by -1\relax% |
| 2366 |
\repeatpgfmathloop |
| 2367 |
\fi |
| 2368 |
%% top pins |
| 2369 |
\ifnum\NT>0\pgf@circ@count@a=\NT\relax |
| 2370 |
\pgfmathloop% |
| 2371 |
\topleft\pgf@circ@res@left=\pgf@x \pgf@circ@res@up=\pgf@y |
| 2372 |
\topright\pgf@circ@res@right=\pgf@x \pgf@circ@res@down=\pgf@y |
| 2373 |
\pgfmathsetlength{\pgf@circ@res@step}{2*\pgf@circ@res@right/\NT} |
| 2374 |
\pgfmathsetlength{\pgf@circ@res@other}{(\pgf@circ@res@down-\pgf@circ@res@up)/(\pgf@circ@res@right-\pgf@circ@res@left)*\pgf@circ@res@step} |
| 2375 |
\ifnum\pgf@circ@count@a>0 |
| 2376 |
\pgfscope |
| 2377 |
\pgftransformshift{\pgfpoint{\pgf@circ@res@left+(\pgf@circ@[email protected])*\pgf@circ@res@step} |
| 2378 |
{\pgf@circ@res@down-(\NT-\pgf@circ@count@a+0.5)*\pgf@circ@res@other}} |
| 2379 |
% put the not ball/wedge if needed |
| 2380 |
\pgf@circ@muxdemux@not@ball{nT}{south} |
| 2381 |
\pgf@circ@muxdemux@not@wedge{wiT}{east}{1}{-1}{-90} |
| 2382 |
\pgf@circ@muxdemux@not@wedge{woT}{west}{-1}{-1}{-90} |
| 2383 |
% put the clock wedge if needed |
| 2384 |
\pgf@circ@muxdemux@clockwedge{cT}{-90} |
| 2385 |
\ifcase\quadrant % rotation 0; top label are at the top |
| 2386 |
\pgf@circ@muxdemux@label@xy{T}{0}{0}{-1}{top}{pgfcirc@nop}{inner}% type, rot, pad x, pad y, text pos, op, type |
| 2387 |
\pgf@circ@res@temp=0pt |
| 2388 |
\pgf@circ@muxdemux@label@xy{TL}{0}{-1}{1}{bottom}{llap}{outer}% |
| 2389 |
\pgf@circ@muxdemux@label@xy{TR}{0}{1}{1}{bottom}{rlap}{outer}% |
| 2390 |
\or %rotation -90; top labels are at the right |
| 2391 |
\pgf@circ@muxdemux@label@xy{T}{90}{-1}{0}{right}{pgfcirc@nop}{inner}% type, rot, pad x, pad y, text pos, op, type |
| 2392 |
\pgf@circ@res@temp=0pt |
| 2393 |
\pgf@circ@muxdemux@label@xy{TL}{90}{1}{1}{bottom}{rlap}{outer}% |
| 2394 |
\pgf@circ@muxdemux@label@xy{TR}{90}{1}{-1}{top}{rlap}{outer}% |
| 2395 |
\or %rotation 180; top labels are at the bottom |
| 2396 |
\pgf@circ@muxdemux@label@xy{T}{180}{0}{1}{bottom}{pgfcirc@nop}{inner}% type, rot, pad x, pad y, text pos, op, type |
| 2397 |
\pgf@circ@res@temp=0pt |
| 2398 |
\pgf@circ@muxdemux@label@xy{TL}{180}{-1}{-1}{top}{llap}{outer}% |
| 2399 |
\pgf@circ@muxdemux@label@xy{TR}{180}{1}{-1}{top}{rlap}{outer}% |
| 2400 |
\or %rotation +90; top labels are at the left |
| 2401 |
\pgf@circ@muxdemux@label@xy{T}{-90}{1}{0}{left}{pgfcirc@nop}{inner}% type, rot, pad x, pad y, text pos, op, type |
| 2402 |
\pgf@circ@res@temp=0pt |
| 2403 |
\pgf@circ@muxdemux@label@xy{TL}{-90}{-1}{1}{bottom}{llap}{outer}% |
| 2404 |
\pgf@circ@muxdemux@label@xy{TR}{-90}{-1}{-1}{top}{llap}{outer}% |
| 2405 |
\fi |
| 2406 |
\endpgfscope |
| 2407 |
\advance\pgf@circ@count@a by -1\relax% |
| 2408 |
\repeatpgfmathloop |
| 2409 |
\fi |
| 2410 |
} |
| 2411 |
% let's start adding anchors |
| 2412 |
\pgfutil@g@addto@macro\pgf@sh@s@muxdemux{% |
| 2413 |
% left side anchors |
| 2414 |
\pgf@circ@count@a=\NL\relax |
| 2415 |
% \typeout{STARTGENERATINGLEFT\space\the\pgf@circ@count@a\space FOR\space\thisshape\space\NL} |
| 2416 |
\pgfmathloop% |
| 2417 |
\ifnum\pgf@circ@count@a>0 |
| 2418 |
% \typeout{GENERATINGLEFT\space\the\pgf@circ@count@a\space FOR\space\thisshape\space\NL} |
| 2419 |
% we will create two anchors per pin: the "normal one" like `lpin 1` for the |
| 2420 |
% external leads, and the "border one" like `blpin 1` for internal ones. |
| 2421 |
% they will coincide if `external pins width` is set to 0. |
| 2422 |
\expandafter\pgf@circ@make@muxdemux@L@anchor\expandafter{\the\pgf@circ@count@a}% |
| 2423 |
\advance\pgf@circ@count@a by -1\relax% |
| 2424 |
\repeatpgfmathloop% |
| 2425 |
% right anchors |
| 2426 |
\pgf@circ@count@a=\NR\relax |
| 2427 |
\pgfmathloop% |
| 2428 |
\ifnum\pgf@circ@count@a>0 |
| 2429 |
% we will create two anchors per pin: the "normal one" like `rpin 1` for the |
| 2430 |
% external leads, and the "border one" like `brpin 1` for internal ones. |
| 2431 |
% they will coincide if `external pins width` is set to 0. |
| 2432 |
\expandafter\pgf@circ@make@muxdemux@R@anchor\expandafter{\the\pgf@circ@count@a}% |
| 2433 |
\advance\pgf@circ@count@a by -1\relax% |
| 2434 |
\repeatpgfmathloop% |
| 2435 |
% bottom anchors |
| 2436 |
\pgf@circ@count@a=\NB\relax |
| 2437 |
\pgfmathloop% |
| 2438 |
\ifnum\pgf@circ@count@a>0 |
| 2439 |
% we will create two anchors per pin: the "normal one" like `bpin 1` for the |
| 2440 |
% external leads, and the "border one" like `bbpin 1` for internal ones. |
| 2441 |
% they will coincide if `external pins width` is set to 0. |
| 2442 |
\expandafter\pgf@circ@make@muxdemux@B@anchor\expandafter{\the\pgf@circ@count@a}% |
| 2443 |
\advance\pgf@circ@count@a by -1\relax% |
| 2444 |
\repeatpgfmathloop% |
| 2445 |
% top anchors |
| 2446 |
\pgf@circ@count@a=\NT\relax |
| 2447 |
\pgfmathloop% |
| 2448 |
\ifnum\pgf@circ@count@a>0 |
| 2449 |
% we will create two anchors per pin: the "normal one" like `tpin 1` for the |
| 2450 |
% external leads, and the "border one" like `btpin 1` for internal ones. |
| 2451 |
% they will coincide if `external pins width` is set to 0. |
| 2452 |
\expandafter\pgf@circ@make@muxdemux@T@anchor\expandafter{\the\pgf@circ@count@a}% |
| 2453 |
\advance\pgf@circ@count@a by -1\relax% |
| 2454 |
\repeatpgfmathloop% |
| 2455 |
}% |
| 2456 |
} |
| 2457 |
|
| 2458 |
%% left anchors for muxdemux |
| 2459 |
|
| 2460 |
\def\pgf@circ@muxdemux@L@anchor#1#2{% #1: pin number #2: 0 for border pin, 1 for external pin |
| 2461 |
\topleft |
| 2462 |
\pgf@xa=\pgf@x |
| 2463 |
\pgf@ya=\pgf@y |
| 2464 |
\insetnortheast |
| 2465 |
\pgf@xb=\pgf@x |
| 2466 |
\pgf@yb=\pgf@y |
| 2467 |
\ifnum#1>\NL |
| 2468 |
\PackageError{circuitikz}{% |
| 2469 |
You requested left pin #1 for mux/demux shape \thisshape\space \MessageBreak |
| 2470 |
which has been defined with \NL\space left pins% |
| 2471 |
}{Please check the manual about mux/demux shapes; if you press return I'll try to continue} |
| 2472 |
\fi |
| 2473 |
\pgf@circ@count@a=\NL \divide\pgf@circ@count@a by 2 % see https://tex.stackexchange.com/questions/146523/why-does-numexpr-integer-division-round-rather-than-truncate |
| 2474 |
% \typeout{LEFT \the\pgf@xa \space \the\pgf@ya \space \NL} |
| 2475 |
\ifnum\NL>1 |
| 2476 |
\ifdim\pgf@yb>0pt % check if we have an inset |
| 2477 |
% we have to check oddity |
| 2478 |
\ifodd\NL |
| 2479 |
\pgfmathsetlength{\pgf@circ@res@step}{2*(\pgf@ya-\pgf@yb)/(\NL-1)} |
| 2480 |
\else |
| 2481 |
\pgfmathsetlength{\pgf@circ@res@step}{2*(\pgf@ya-\pgf@yb)/\NL} |
| 2482 |
\fi |
| 2483 |
\else % no inset |
| 2484 |
\pgfmathsetlength{\pgf@circ@res@step}{2*\pgf@ya/\NL} |
| 2485 |
\fi |
| 2486 |
\ifdim\pgf@yb>0pt % check if we have an inset |
| 2487 |
\ifnum#1>\pgf@circ@count@a\relax |
| 2488 |
% for lower pins we have to shift them down |
| 2489 |
% \typeout{DEBUGTEST1\space #1\space entering\space \NL} |
| 2490 |
\ifodd\NL |
| 2491 |
% odd number of pins |
| 2492 |
\ifnum#1=\numexpr\the\pgf@circ@count@a+1\relax |
| 2493 |
% centerpin! |
| 2494 |
\ifnum#2=0\relax |
| 2495 |
\pgfpoint{\pgf@xb}{0pt} |
| 2496 |
\else |
| 2497 |
\ifnum\squarepins>0 |
| 2498 |
\pgfpoint{\pgf@xa-#2*\extshift}{0pt} |
| 2499 |
\else |
| 2500 |
\pgfpoint{\pgf@xb-#2*\extshift}{0pt} |
| 2501 |
\fi |
| 2502 |
\fi |
| 2503 |
\else |
| 2504 |
\pgfpoint{\pgf@xa-#2*\extshift}{\pgf@ya+(0.5-#1+1)*\pgf@circ@res@step-2*\pgf@yb} |
| 2505 |
\fi |
| 2506 |
\else |
| 2507 |
% even numer of pins: just go down |
| 2508 |
\pgfpoint{\pgf@xa-#2*\extshift}{\pgf@ya+(0.5-#1)*\pgf@circ@res@step-2*\pgf@yb} |
| 2509 |
\fi |
| 2510 |
\else |
| 2511 |
% nothing need for #1<=NL/2 |
| 2512 |
\pgfpoint{\pgf@xa-#2*\extshift}{\pgf@ya+(0.5-#1)*\pgf@circ@res@step} |
| 2513 |
\fi |
| 2514 |
\else |
| 2515 |
% no inset |
| 2516 |
\pgfpoint{\pgf@xa-#2*\extshift}{\pgf@ya+(0.5-#1)*\pgf@circ@res@step} |
| 2517 |
\fi |
| 2518 |
\else |
| 2519 |
\pgfpoint{\pgf@xa-#2*\extshift}{0pt} |
| 2520 |
\fi |
| 2521 |
} |
| 2522 |
|
| 2523 |
% right anchors |
| 2524 |
\def\pgf@circ@muxdemux@R@anchor#1#2{% #1: pin number #2: 0 for border pin, 1 for external pin |
| 2525 |
\topright |
| 2526 |
\pgf@xa=\pgf@x |
| 2527 |
\pgf@ya=\pgf@y |
| 2528 |
\ifnum#1>\NR |
| 2529 |
\PackageError{circuitikz}{% |
| 2530 |
You requested right pin #1 for mux/demux shape \thisshape\space \MessageBreak |
| 2531 |
which has been defined with \NR\space right pins% |
| 2532 |
}{Please check the manual about mux/demux shapes; if you press return I'll try to continue} |
| 2533 |
\fi |
| 2534 |
\ifnum\NR>1 |
| 2535 |
\pgfmathsetlength{\pgf@circ@res@step}{2*\pgf@ya/\NR} |
| 2536 |
\pgfpoint{\pgf@xa+#2*\extshift}{\pgf@ya+(0.5-#1)*\pgf@circ@res@step} |
| 2537 |
\else |
| 2538 |
\pgfpoint{\pgf@xa+#2*\extshift}{0pt} |
| 2539 |
\fi |
| 2540 |
} |
| 2541 |
|
| 2542 |
% bottom anchors |
| 2543 |
\def\pgf@circ@muxdemux@B@anchor#1#2{% #1: pin number #2: 0 for border pin, 1 for external pin |
| 2544 |
\topleft |
| 2545 |
\pgf@xa=\pgf@x |
| 2546 |
\pgf@ya=\pgf@y |
| 2547 |
\topright |
| 2548 |
\pgf@xb=\pgf@x |
| 2549 |
\pgf@yb=\pgf@y |
| 2550 |
\ifnum#1>\NB |
| 2551 |
\PackageError{circuitikz}{% |
| 2552 |
You requested bottom pin #1 for mux/demux shape \thisshape\space \MessageBreak |
| 2553 |
which has been defined with \NB\space bottom pins% |
| 2554 |
}{Please check the manual about mux/demux shapes; if you press return I'll try to continue} |
| 2555 |
\fi |
| 2556 |
\ifnum\NB>0 |
| 2557 |
% \typeout{DEBUGTESTtopleft\space\the\pgf@ya \space topright\space\the\pgf@yb \space\NB} |
| 2558 |
\pgfmathsetlength{\pgf@circ@res@step}{2*\pgf@xb/\NB} |
| 2559 |
\pgfmathsetlength{\pgf@circ@res@other}{(\pgf@yb-\pgf@ya)/(\pgf@xb-\pgf@xa)*\pgf@circ@res@step} |
| 2560 |
\pgfmathsetlength\pgf@x{\pgf@xa+(#1-0.5)*\pgf@circ@res@step} |
| 2561 |
\ifnum#2=0\relax |
| 2562 |
\pgfmathsetlength\pgf@y{-\pgf@yb+(\NB-#1+0.5)*\pgf@circ@res@other} |
| 2563 |
\else |
| 2564 |
\ifnum\squarepins>0\relax |
| 2565 |
\pgfmathsetlength\pgf@y{-max(\pgf@ya,\pgf@yb)-\extshift} |
| 2566 |
\else |
| 2567 |
\pgfmathsetlength\pgf@y{-\pgf@yb+(\NB-#1+0.5)*\pgf@circ@res@other-\extshift} |
| 2568 |
\fi |
| 2569 |
\fi |
| 2570 |
\else |
| 2571 |
% should not happen, give the same as pin 1 anyway |
| 2572 |
\ifnum#2=0\relax |
| 2573 |
\pgfpoint{0pt}{-\pgf@yb+(\pgf@yb-\pgf@ya)/2} |
| 2574 |
\else |
| 2575 |
\pgfpoint{0pt}{-max(\pgf@ya,\pgf@yb)-\extshift} |
| 2576 |
\fi |
| 2577 |
\fi |
| 2578 |
} |
| 2579 |
|
| 2580 |
% top anchors |
| 2581 |
\def\pgf@circ@muxdemux@T@anchor#1#2{% #1: pin number #2: 0 for border pin, 1 for external pin |
| 2582 |
\topleft |
| 2583 |
\pgf@xa=\pgf@x |
| 2584 |
\pgf@ya=\pgf@y |
| 2585 |
\topright |
| 2586 |
\pgf@xb=\pgf@x |
| 2587 |
\pgf@yb=\pgf@y |
| 2588 |
\ifnum#1>\NT |
| 2589 |
\PackageError{circuitikz}{% |
| 2590 |
You requested top pin #1 for mux/demux shape \thisshape\space \MessageBreak |
| 2591 |
which has been defined with \NT\space top pins% |
| 2592 |
}{Please check the manual about mux/demux shapes; if you press return I'll try to continue} |
| 2593 |
\fi |
| 2594 |
\ifnum\NT>0 |
| 2595 |
\pgfmathsetlength{\pgf@circ@res@step}{2*\pgf@xb/\NT} |
| 2596 |
\pgfmathsetlength{\pgf@circ@res@other}{(\pgf@yb-\pgf@ya)/(\pgf@xb-\pgf@xa)*\pgf@circ@res@step} |
| 2597 |
\pgfmathsetlength\pgf@x{\pgf@xa+(#1-0.5)*\pgf@circ@res@step} |
| 2598 |
\ifnum#2=0\relax |
| 2599 |
\pgfmathsetlength\pgf@y{\pgf@yb-(\NT-#1+0.5)*\pgf@circ@res@other} |
| 2600 |
\else |
| 2601 |
\ifnum\squarepins>0 |
| 2602 |
\pgfmathsetlength\pgf@y{max(\pgf@ya,\pgf@yb)+\extshift} |
| 2603 |
\else |
| 2604 |
\pgfmathsetlength\pgf@y{\pgf@yb-(\NT-#1+0.5)*\pgf@circ@res@other+\extshift} |
| 2605 |
\fi |
| 2606 |
\fi |
| 2607 |
\else |
| 2608 |
% should not happen, give the same as pin 1 anyway |
| 2609 |
\ifnum#2=0\relax |
| 2610 |
\pgfpoint{0pt}{\pgf@yb-(\pgf@yb-\pgf@ya)/2} |
| 2611 |
\else |
| 2612 |
\pgfpoint{0pt}{max(\pgf@ya,\pgf@yb)+\extshift} |
| 2613 |
\fi |
| 2614 |
\fi |
| 2615 |
} |
| 2616 |
% %>>> |
| 2617 |
|
| 2618 |
%% definitions and shape for wedgeinv and circleinv%<<< |
| 2619 |
|
| 2620 |
\ctikzset{wedge inversion mark/width/.initial = 0.2} |
| 2621 |
\ctikzset{wedge inversion mark/height/.initial = 0.1} |
| 2622 |
\pgfdeclareshape{wedgeinv}{ |
| 2623 |
\savedmacro{\ctikzclass}{\edef\ctikzclass{muxdemuxes}} |
| 2624 |
\saveddimen{\scaledRlen}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}} |
| 2625 |
\savedanchor\northeast{% |
| 2626 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 2627 |
\pgf@y=\ctikzvalof{wedge inversion mark/height}\pgf@circ@scaled@Rlen |
| 2628 |
\pgf@x=\ctikzvalof{wedge inversion mark/width}\pgf@circ@scaled@Rlen |
| 2629 |
} |
| 2630 |
\anchor{center}{\pgfpointorigin} |
| 2631 |
\anchor{top}{\northeast\pgf@x=0pt\relax} |
| 2632 |
\anchor{apex}{\northeast\pgf@y=0pt\relax} |
| 2633 |
\anchor{base}{\pgfpointorigin} |
| 2634 |
\anchor{mid}{\northeast\pgf@x=0.5\pgf@x\pgf@y=0.5\pgf@y} |
| 2635 |
% not standard geoanchors, south west is the same as 0,0... |
| 2636 |
\anchor{right}{\northeast\pgf@y=0pt\relax} |
| 2637 |
\anchor{east}{\northeast\pgf@y=0pt\relax} |
| 2638 |
\anchor{e}{\northeast\pgf@y=0pt\relax} |
| 2639 |
\anchor{left}{\pgfpointorigin} |
| 2640 |
\anchor{west}{\pgfpointorigin} |
| 2641 |
\anchor{w}{\pgfpointorigin} |
| 2642 |
\anchor{south}{\northeast\pgf@y=0pt\pgf@x=0.5\pgf@x} |
| 2643 |
\anchor{s}{\northeast\pgf@y=0pt\pgf@x=0.5\pgf@x} |
| 2644 |
\anchor{north}{\northeast\pgf@x=0.5\pgf@x} |
| 2645 |
\anchor{n}{\northeast\pgf@x=0.5\pgf@x} |
| 2646 |
\anchor{south west}{\pgfpointorigin} |
| 2647 |
\anchor{sw}{\pgfpointorigin} |
| 2648 |
\anchor{north east}{\northeast} |
| 2649 |
\anchor{ne}{\northeast} |
| 2650 |
\anchor{north west}{\northeast\pgf@x=0pt\relax} |
| 2651 |
\anchor{nw}{\northeast\pgf@x=0pt\relax} |
| 2652 |
\anchor{south east}{\northeast\pgf@y=0pt\relax} |
| 2653 |
\anchor{se}{\northeast\pgf@y=0pt\relax} |
| 2654 |
% |
| 2655 |
\pgf@circ@draw@component{ |
| 2656 |
\northeast\pgf@circ@res@up=\pgf@y\pgf@circ@res@right=\pgf@x |
| 2657 |
\pgfsetbeveljoin % otherwise it sticks often "inside" the component |
| 2658 |
\pgfpathmoveto{\pgfpointorigin} |
| 2659 |
\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@up}} |
| 2660 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0pt}} |
| 2661 |
\pgfpathclose |
| 2662 |
\pgfusepath{draw} |
| 2663 |
} |
| 2664 |
} |
| 2665 |
% this is *almost* the same as notcirc, but scales with muxdemuxes and |
| 2666 |
% has the default anchor to the left side |
| 2667 |
\pgfdeclareshape{circleinv}{ |
| 2668 |
\savedmacro{\ctikzclass}{\edef\ctikzclass{muxdemuxes}} |
| 2669 |
\savedanchor\northwest{% |
| 2670 |
\pgf@circ@notradius |
| 2671 |
\pgf@y=\pgf@circ@res@temp |
| 2672 |
\pgf@x=-\pgf@y |
| 2673 |
} |
| 2674 |
\pgfcirc@northwest@symmetric@geoanchors |
| 2675 |
%% use the left side as default anchor |
| 2676 |
\anchor{center}{\northwest\pgf@y=0pt} |
| 2677 |
\anchor{geocenter}{\pgfpointorigin} |
| 2678 |
\anchor{base}{\northwest\pgf@y=0pt} |
| 2679 |
\anchor{apex}{\northwest\pgf@y=0pt\pgf@x=-\pgf@x} |
| 2680 |
\anchor{mid}{\northwest\pgf@x=0pt} |
| 2681 |
\anchor{top}{\northwest\pgf@x=0pt} |
| 2682 |
\anchor{bottom}{\northwest\pgf@x=0pt\pgf@y=-\pgf@y} |
| 2683 |
\anchorborder{ |
| 2684 |
\pgf@circ@res@left=\pgf@x |
| 2685 |
\pgf@circ@res@up=\pgf@y |
| 2686 |
\northwest\pgf@circ@res@temp=\pgf@y |
| 2687 |
\pgfpointborderellipse{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}% |
| 2688 |
{\pgfpoint{\pgf@circ@res@temp}{\pgf@circ@res@temp}} |
| 2689 |
} |
| 2690 |
\pgf@circ@draw@component{ |
| 2691 |
\pgfscope |
| 2692 |
\northwest\pgf@circ@res@temp=\pgf@y |
| 2693 |
\pgf@circ@setcolor |
| 2694 |
\pgf@circ@setlinewidth{multipoles}{\pgflinewidth} |
| 2695 |
\pgfpathcircle{\pgfpointorigin}{\pgf@circ@res@temp} |
| 2696 |
\ifx\tikz@fillcolor\pgfutil@empty |
| 2697 |
% set the default fill color to white |
| 2698 |
\pgfsetfillcolor{white} |
| 2699 |
% ...but override it if the class is defined! |
| 2700 |
\pgf@circ@setifdefinedfill{draw, fill}{draw, fill} |
| 2701 |
\else |
| 2702 |
\pgfsetfillcolor{\tikz@fillcolor} |
| 2703 |
\fi |
| 2704 |
\pgfusepath{draw,fill} |
| 2705 |
\endpgfscope |
| 2706 |
} |
| 2707 |
} |
| 2708 |
%% %>>> |
| 2709 |
|
| 2710 |
% vim: set fdm=marker fmr=%<<<,%>>>: |