| 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 |
% This file has folding marks for vim (See last line). |
| 14 |
% |
| 15 |
|
| 16 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 17 |
%% Other shapes |
| 18 |
|
| 19 |
%% Nothing: empty shape%<<< |
| 20 |
|
| 21 |
\pgfdeclareshape{emptyshape}{ |
| 22 |
\savedanchor{\northeast}{% |
| 23 |
\pgf@x=.5\wd\pgfnodeparttextbox% |
| 24 |
\pgf@y=.5\ht\pgfnodeparttextbox% |
| 25 |
} |
| 26 |
% geo anchors based on north-east |
| 27 |
\pgfcirc@northeast@symmetric@geoanchors |
| 28 |
\savedanchor{\textanchor}{\pgfpoint{-.5\wd\pgfnodeparttextbox}{\dimexpr.5\dp\pgfnodeparttextbox-.5\ht\pgfnodeparttextbox}} |
| 29 |
\anchor{text}{\textanchor} |
| 30 |
\anchor{center}{ |
| 31 |
\pgfpointorigin |
| 32 |
} |
| 33 |
}% |
| 34 |
%>>> |
| 35 |
|
| 36 |
%% Poles%<<< |
| 37 |
% |
| 38 |
% Provision for changing opacity. Only expert use, see the manual. |
| 39 |
% |
| 40 |
\ctikzset{poles/open fill opacity/.initial=1.0}% better not touch it |
| 41 |
\tikzset{open poles opacity/.code={% |
| 42 |
\ctikzset{poles/open fill opacity=#1}% |
| 43 |
}} |
| 44 |
\ctikzset{poles/full fill opacity/.initial=1.0}% better not touch it |
| 45 |
\tikzset{full poles opacity/.code={% |
| 46 |
\ctikzset{poles/full fill opacity=#1}% |
| 47 |
|
| 48 |
}} |
| 49 |
|
| 50 |
% |
| 51 |
% Provision for changing default background |
| 52 |
% |
| 53 |
|
| 54 |
\ctikzset{open poles fill/.initial={white}} |
| 55 |
|
| 56 |
%% Full terminal |
| 57 |
|
| 58 |
\pgfdeclareshape{circ}{ |
| 59 |
\anchor{center}{ |
| 60 |
\pgfpointorigin |
| 61 |
} |
| 62 |
\savedanchor\northwest{% |
| 63 |
\pgf@y=\ctikzvalof{nodes width}\pgf@circ@Rlen |
| 64 |
\pgf@x=-\pgf@y |
| 65 |
} |
| 66 |
\anchor{center}{ \pgf@y=0pt \pgf@x=0pt } |
| 67 |
% geo anchors based on north-west |
| 68 |
\pgfcirc@northwest@symmetric@geoanchors |
| 69 |
\anchorborder{ |
| 70 |
\pgf@circ@res@left=\pgf@x |
| 71 |
\pgf@circ@res@up=\pgf@y |
| 72 |
\pgfpointborderellipse{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up} |
| 73 |
}{\pgfpoint{\ctikzvalof{nodes width}*\pgf@circ@Rlen}{\ctikzvalof{nodes width}*\pgf@circ@Rlen}} |
| 74 |
} |
| 75 |
\pgf@circ@draw@component{ |
| 76 |
\pgfpathcircle{\pgfpointorigin}{\ctikzvalof{nodes width}*\pgf@circ@Rlen} |
| 77 |
\pgf@circ@setcolor |
| 78 |
\pgf@circ@fill@strokecolor |
| 79 |
\pgfsetfillopacity{\ctikzvalof{poles/full fill opacity}}% normally 1.0 |
| 80 |
\pgfusepath{draw,fill} |
| 81 |
} |
| 82 |
} |
| 83 |
|
| 84 |
%% Empty round terminal |
| 85 |
|
| 86 |
\pgfdeclareshape{ocirc}{ |
| 87 |
\anchor{center}{ |
| 88 |
\pgfpointorigin |
| 89 |
} |
| 90 |
\savedanchor\northwest{% |
| 91 |
\pgf@y=\ctikzvalof{nodes width}\pgf@circ@Rlen |
| 92 |
\pgf@x=-\pgf@y |
| 93 |
} |
| 94 |
\anchor{center}{ \pgf@y=0pt \pgf@x=0pt } |
| 95 |
% geo anchors based on north-west |
| 96 |
\pgfcirc@northwest@symmetric@geoanchors |
| 97 |
\anchorborder{ |
| 98 |
\pgf@circ@res@left=\pgf@x |
| 99 |
\pgf@circ@res@up=\pgf@y |
| 100 |
\pgfpointborderellipse{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up} |
| 101 |
}{\pgfpoint{\ctikzvalof{nodes width}*\pgf@circ@Rlen}{\ctikzvalof{nodes width}*\pgf@circ@Rlen}} |
| 102 |
} |
| 103 |
\pgf@circ@draw@component{ |
| 104 |
\pgfpathcircle{\pgfpointorigin}{\ctikzvalof{nodes width}*\pgf@circ@Rlen} |
| 105 |
\pgf@circ@setcolor |
| 106 |
\pgfsetfillopacity{\ctikzvalof{poles/open fill opacity}}% normally 1.0 |
| 107 |
\ifx\tikz@fillcolor\pgfutil@empty |
| 108 |
% set the default fill color to white |
| 109 |
\pgfsetfillcolor{\ctikzvalof{open poles fill}} |
| 110 |
% ...but override it if the class is defined! |
| 111 |
% note that this element has no class, but will inherit it when used |
| 112 |
% into another component |
| 113 |
\pgf@circ@setifdefinedfill{draw, fill}{draw, fill} |
| 114 |
\else |
| 115 |
\pgfsetfillcolor{\tikz@fillcolor} |
| 116 |
\fi |
| 117 |
\pgfusepath{draw,fill} |
| 118 |
} |
| 119 |
} |
| 120 |
|
| 121 |
%% Diamond terminal |
| 122 |
|
| 123 |
\pgfdeclareshape{diamondpole}{ |
| 124 |
\anchor{center}{ |
| 125 |
\pgfpointorigin |
| 126 |
} |
| 127 |
\savedanchor\northwest{% |
| 128 |
\pgfmathsetlength{\pgf@y}{sqrt(2)*\ctikzvalof{nodes width}*\pgf@circ@Rlen} |
| 129 |
\pgf@x=-\pgf@y |
| 130 |
} |
| 131 |
\anchor{center}{ \pgf@y=0pt \pgf@x=0pt } |
| 132 |
% geo anchors based on north-west |
| 133 |
\pgfcirc@northwest@symmetric@geoanchors |
| 134 |
\anchorborder{ |
| 135 |
% \typeout{IN\space X:\the\pgf@x\space Y:\the\pgf@y} |
| 136 |
\pgfmathsetmacro{\@@switchx}{ifthenelse(\pgf@x>0,1,-1)} |
| 137 |
\pgfmathsetmacro{\@@switchy}{ifthenelse(\pgf@y>0,1,-1)} |
| 138 |
\pgfmathsetlength{\pgf@xa}{abs(\pgf@x)} |
| 139 |
\pgfmathsetlength{\pgf@ya}{abs(\pgf@y)} |
| 140 |
\pgfextracty{\pgf@circ@res@up}{\northwest} |
| 141 |
% \typeout{MID\space X:\the\pgf@xa\space Y:\the\pgf@ya\space L:\the\pgf@circ@res@up} |
| 142 |
% \typeout{MID\space SX:\@@switchx\space SY:\@@switchy} |
| 143 |
\pgfpointintersectionoflines |
| 144 |
{\pgfpointorigin}{\pgfqpoint{\pgf@xa}{\pgf@ya}} |
| 145 |
{\pgfqpoint{0pt}{\pgf@circ@res@up}}{\pgfqpoint{\pgf@circ@res@up}{0pt}} |
| 146 |
% \typeout{CROSS \space X:\the\pgf@x\space Y:\the\pgf@y} |
| 147 |
\pgf@x=\@@switchx\pgf@x |
| 148 |
\pgf@y=\@@switchy\pgf@y |
| 149 |
} |
| 150 |
\pgf@circ@draw@component{ |
| 151 |
\pgfmathsetlength{\pgf@circ@res@temp}{\ctikzvalof{nodes width}*\pgf@circ@Rlen} |
| 152 |
\pgftransformrotate{45} |
| 153 |
\pgfpathrectanglecorners |
| 154 |
{\pgfpoint{-\pgf@circ@res@temp}{-\pgf@circ@res@temp}} |
| 155 |
{\pgfpoint{\pgf@circ@res@temp}{\pgf@circ@res@temp}} |
| 156 |
\pgf@circ@setcolor |
| 157 |
\pgf@circ@fill@strokecolor |
| 158 |
\pgfsetfillopacity{\ctikzvalof{poles/full fill opacity}}% normally 1.0 |
| 159 |
\pgfusepath{draw,fill} |
| 160 |
} |
| 161 |
} |
| 162 |
|
| 163 |
%% Diamond terminal, unfilled |
| 164 |
|
| 165 |
\pgfdeclareshape{odiamondpole}{ |
| 166 |
\anchor{center}{ |
| 167 |
\pgfpointorigin |
| 168 |
} |
| 169 |
\savedanchor\northwest{% |
| 170 |
\pgfmathsetlength{\pgf@y}{sqrt(2)*\ctikzvalof{nodes width}*\pgf@circ@Rlen} |
| 171 |
\pgf@x=-\pgf@y |
| 172 |
} |
| 173 |
\anchor{center}{ \pgf@y=0pt \pgf@x=0pt } |
| 174 |
% geo anchors based on north-west |
| 175 |
\pgfcirc@northwest@symmetric@geoanchors |
| 176 |
\anchorborder{ |
| 177 |
% \typeout{IN\space X:\the\pgf@x\space Y:\the\pgf@y} |
| 178 |
\pgfmathsetmacro{\@@switchx}{ifthenelse(\pgf@x>0,1,-1)} |
| 179 |
\pgfmathsetmacro{\@@switchy}{ifthenelse(\pgf@y>0,1,-1)} |
| 180 |
\pgfmathsetlength{\pgf@xa}{abs(\pgf@x)} |
| 181 |
\pgfmathsetlength{\pgf@ya}{abs(\pgf@y)} |
| 182 |
\pgfextracty{\pgf@circ@res@up}{\northwest} |
| 183 |
% \typeout{MID\space X:\the\pgf@xa\space Y:\the\pgf@ya\space L:\the\pgf@circ@res@up} |
| 184 |
% \typeout{MID\space SX:\@@switchx\space SY:\@@switchy} |
| 185 |
\pgfpointintersectionoflines |
| 186 |
{\pgfpointorigin}{\pgfqpoint{\pgf@xa}{\pgf@ya}} |
| 187 |
{\pgfqpoint{0pt}{\pgf@circ@res@up}}{\pgfqpoint{\pgf@circ@res@up}{0pt}} |
| 188 |
% \typeout{CROSS \space X:\the\pgf@x\space Y:\the\pgf@y} |
| 189 |
\pgf@x=\@@switchx\pgf@x |
| 190 |
\pgf@y=\@@switchy\pgf@y |
| 191 |
} |
| 192 |
\pgf@circ@draw@component{ |
| 193 |
\pgfmathsetlength{\pgf@circ@res@temp}{\ctikzvalof{nodes width}*\pgf@circ@Rlen} |
| 194 |
\pgftransformrotate{45} |
| 195 |
\pgfpathrectanglecorners |
| 196 |
{\pgfpoint{-\pgf@circ@res@temp}{-\pgf@circ@res@temp}} |
| 197 |
{\pgfpoint{\pgf@circ@res@temp}{\pgf@circ@res@temp}} |
| 198 |
\pgf@circ@setcolor |
| 199 |
\pgfsetfillopacity{\ctikzvalof{poles/open fill opacity}}% normally 1.0 |
| 200 |
\ifx\tikz@fillcolor\pgfutil@empty |
| 201 |
% set the default fill color to white |
| 202 |
\pgfsetfillcolor{\ctikzvalof{open poles fill}} |
| 203 |
% ...but override it if the class is defined! |
| 204 |
% note that this element has no class, but will inherit it when used |
| 205 |
% into another component |
| 206 |
\pgf@circ@setifdefinedfill{draw, fill}{draw, fill} |
| 207 |
\else |
| 208 |
\pgfsetfillcolor{\tikz@fillcolor} |
| 209 |
\fi |
| 210 |
\pgfusepath{draw,fill} |
| 211 |
} |
| 212 |
} |
| 213 |
|
| 214 |
%% square terminal, filled |
| 215 |
|
| 216 |
\pgfdeclareshape{squarepole}{ |
| 217 |
\anchor{center}{ |
| 218 |
\pgfpointorigin |
| 219 |
} |
| 220 |
\savedanchor\northwest{% |
| 221 |
\pgfmathsetlength{\pgf@y}{\ctikzvalof{nodes width}*\pgf@circ@Rlen} |
| 222 |
\pgf@x=-\pgf@y |
| 223 |
} |
| 224 |
\anchor{center}{ \pgf@y=0pt \pgf@x=0pt } |
| 225 |
% geo anchors based on north-west |
| 226 |
\pgfcirc@northwest@symmetric@geoanchors |
| 227 |
\anchorborder{ |
| 228 |
\pgf@xa=\pgf@x |
| 229 |
\pgf@ya=\pgf@y |
| 230 |
\pgfextracty{\pgf@circ@res@up}{\northwest} |
| 231 |
\pgfpointborderrectangle |
| 232 |
{\pgfqpoint{\pgf@xa}{\pgf@ya}} |
| 233 |
{\pgfqpoint{\pgf@circ@res@up}{\pgf@circ@res@up}} |
| 234 |
} |
| 235 |
\pgf@circ@draw@component{ |
| 236 |
\pgfmathsetlength{\pgf@circ@res@temp}{\ctikzvalof{nodes width}*\pgf@circ@Rlen} |
| 237 |
\pgfpathrectanglecorners |
| 238 |
{\pgfpoint{-\pgf@circ@res@temp}{-\pgf@circ@res@temp}} |
| 239 |
{\pgfpoint{\pgf@circ@res@temp}{\pgf@circ@res@temp}} |
| 240 |
\pgf@circ@setcolor |
| 241 |
\pgf@circ@fill@strokecolor |
| 242 |
\pgfsetfillopacity{\ctikzvalof{poles/full fill opacity}}% normally 1.0 |
| 243 |
\pgfusepath{draw,fill} |
| 244 |
} |
| 245 |
} |
| 246 |
%% square terminal, unfilled |
| 247 |
|
| 248 |
\pgfdeclareshape{osquarepole}{ |
| 249 |
\anchor{center}{ |
| 250 |
\pgfpointorigin |
| 251 |
} |
| 252 |
\savedanchor\northwest{% |
| 253 |
\pgfmathsetlength{\pgf@y}{\ctikzvalof{nodes width}*\pgf@circ@Rlen} |
| 254 |
\pgf@x=-\pgf@y |
| 255 |
} |
| 256 |
\anchor{center}{ \pgf@y=0pt \pgf@x=0pt } |
| 257 |
% geo anchors based on north-west |
| 258 |
\pgfcirc@northwest@symmetric@geoanchors |
| 259 |
\anchorborder{ |
| 260 |
\pgf@xa=\pgf@x |
| 261 |
\pgf@ya=\pgf@y |
| 262 |
\pgfextracty{\pgf@circ@res@up}{\northwest} |
| 263 |
\pgfpointborderrectangle |
| 264 |
{\pgfqpoint{\pgf@xa}{\pgf@ya}} |
| 265 |
{\pgfqpoint{\pgf@circ@res@up}{\pgf@circ@res@up}} |
| 266 |
} |
| 267 |
\pgf@circ@draw@component{ |
| 268 |
\pgfmathsetlength{\pgf@circ@res@temp}{\ctikzvalof{nodes width}*\pgf@circ@Rlen} |
| 269 |
\pgfpathrectanglecorners |
| 270 |
{\pgfpoint{-\pgf@circ@res@temp}{-\pgf@circ@res@temp}} |
| 271 |
{\pgfpoint{\pgf@circ@res@temp}{\pgf@circ@res@temp}} |
| 272 |
\pgf@circ@setcolor |
| 273 |
\pgfsetfillopacity{\ctikzvalof{poles/open fill opacity}}% normally 1.0 |
| 274 |
\ifx\tikz@fillcolor\pgfutil@empty |
| 275 |
% set the default fill color to white |
| 276 |
\pgfsetfillcolor{\ctikzvalof{open poles fill}} |
| 277 |
% ...but override it if the class is defined! |
| 278 |
% note that this element has no class, but will inherit it when used |
| 279 |
% into another component |
| 280 |
\pgf@circ@setifdefinedfill{draw, fill}{draw, fill} |
| 281 |
\else |
| 282 |
\pgfsetfillcolor{\tikz@fillcolor} |
| 283 |
\fi |
| 284 |
\pgfusepath{draw,fill} |
| 285 |
} |
| 286 |
} |
| 287 |
|
| 288 |
%% Fill for correct rectangular joins |
| 289 |
|
| 290 |
\pgfdeclareshape{rectjoinfill}{ |
| 291 |
\savedanchor{\northeast}{% |
| 292 |
\pgf@x=.5\pgflinewidth% |
| 293 |
\pgf@y=.5\pgflinewidth% |
| 294 |
} |
| 295 |
% geo anchors based on north-east |
| 296 |
\pgfcirc@northeast@symmetric@geoanchors |
| 297 |
\anchor{center}{ |
| 298 |
\pgfpointorigin |
| 299 |
} |
| 300 |
\anchorborder{ |
| 301 |
\pgf@circ@res@left=\pgf@x |
| 302 |
\pgf@circ@res@up=\pgf@y |
| 303 |
} |
| 304 |
\pgf@circ@draw@component{ |
| 305 |
\pgfpathrectanglecorners |
| 306 |
{\pgfpoint{0}{.5\pgflinewidth}} |
| 307 |
{\pgfpoint{0}{-.5\pgflinewidth}} |
| 308 |
\pgf@circ@setcolor |
| 309 |
\pgf@circ@fill@strokecolor |
| 310 |
\pgfusepath{draw,fill} |
| 311 |
} |
| 312 |
} |
| 313 |
% %>>> |
| 314 |
|
| 315 |
%% Arrows%<<< |
| 316 |
%% transistor arrow |
| 317 |
|
| 318 |
\def\pgf@circ@find@linescale{ |
| 319 |
% find the scale inverse of the scale factor: line width do not scale |
| 320 |
% with scale=..., transform shape so we have to counteract it. |
| 321 |
\iftikz@fullytransformed % this is true if `transform shape` is active |
| 322 |
% from @Circumscribe https://tex.stackexchange.com/a/474035/38080 |
| 323 |
% Note that this trick is not working inside a `spy` environment... |
| 324 |
\pgfgettransformentries{\scaleA}{\scaleB}{\scaleC}{\scaleD}{\whatevs}{\whatevs}% |
| 325 |
\pgfmathsetmacro{\@@factor}{1.0/sqrt(abs(\scaleA*\scaleD-\scaleB*\scaleC))}% |
| 326 |
\else |
| 327 |
\pgfmathsetmacro{\@@factor}{1.0} |
| 328 |
\fi |
| 329 |
} |
| 330 |
|
| 331 |
\pgfdeclareshape{trarrow}{% |
| 332 |
% this arrow is only filled but grows with the linewidth, more or less |
| 333 |
% like currarrow do |
| 334 |
\savedanchor{\northeast}{% |
| 335 |
\pgf@circ@res@step = \pgf@circ@Rlen |
| 336 |
\pgf@circ@find@linescale |
| 337 |
\divide \pgf@circ@res@step by \ctikzvalof{current arrow scale} |
| 338 |
\pgfpoint{0.7*\pgf@circ@res@step +0.5*\@@factor*\pgflinewidth} |
| 339 |
{0.8*\pgf@circ@res@step+0.7593*\@@factor*\pgflinewidth} |
| 340 |
} |
| 341 |
% The arrow size should be more or less the same of a currarrow, which is |
| 342 |
% both filled and stroke, for backward output compatibility (more or less) |
| 343 |
% |
| 344 |
% angle \beta W is \pgf@circ@Rlen/\ctikzvalof{current arrow scale} |
| 345 |
% |-\__ currarrow as the tip at (W,0) |
| 346 |
% | | and the upper tail at (-0.7*W, 0.8*W) |
| 347 |
% | \__ it then "overshoot" do to the linew width L |
| 348 |
% | \__ xangle \alpha |
| 349 |
% ---0-------> |
| 350 |
% |
| 351 |
% \beta = atan(0.7/0.8) \alpha=atan(0.8/1.7) |
| 352 |
% tip overshoot is (L/2)/sin(\alpha) = 1.743*L only in x direction |
| 353 |
% tail overshoot is -(L/2) in x, and (L/2)/sin(\beta) = 0.7539*L in y |
| 354 |
% |
| 355 |
\savedanchor{\northwest}{% |
| 356 |
\pgf@circ@res@step = \pgf@circ@Rlen |
| 357 |
\divide \pgf@circ@res@step by \ctikzvalof{current arrow scale} |
| 358 |
\pgf@circ@find@linescale |
| 359 |
\pgfpoint{-0.7*\pgf@circ@res@step -0.5*\@@factor*\pgflinewidth} |
| 360 |
{0.8*\pgf@circ@res@step+0.7593*\@@factor*\pgflinewidth} |
| 361 |
} |
| 362 |
\savedanchor{\tip}{% |
| 363 |
\pgf@circ@res@step = \pgf@circ@Rlen |
| 364 |
\divide \pgf@circ@res@step by \ctikzvalof{current arrow scale} |
| 365 |
\pgf@circ@find@linescale |
| 366 |
\pgfpoint{\pgf@circ@res@step + 1.743*\@@factor*\pgflinewidth}{0pt} |
| 367 |
} |
| 368 |
\anchor{north}{\northeast\pgf@x=0cm\relax} |
| 369 |
\anchor{east}{\northeast\pgf@y=0cm\relax} |
| 370 |
\anchor{south}{\northeast\pgf@y=-\pgf@y \pgf@x=0cm\relax} |
| 371 |
\anchor{west}{\northeast\pgf@y=0cm\pgf@x=-\pgf@x} |
| 372 |
\anchor{north east}{\northeast} |
| 373 |
\anchor{north west}{\northeast\pgf@x=-\pgf@x} |
| 374 |
\anchor{south east}{\northeast\pgf@y=-\pgf@y} |
| 375 |
\anchor{south west}{\northeast\pgf@y=-\pgf@y\pgf@x=-\pgf@x} |
| 376 |
\anchor{center}{ |
| 377 |
\pgfpointorigin |
| 378 |
} |
| 379 |
\anchor{tip}{ |
| 380 |
\tip |
| 381 |
} |
| 382 |
\anchor{btip}{% this anchor is behind the tip of half a linewidth |
| 383 |
\tip |
| 384 |
\pgf@circ@find@linescale |
| 385 |
\pgf@circ@res@temp=\@@factor\pgflinewidth |
| 386 |
\advance\pgf@x by -.5\pgf@circ@res@temp |
| 387 |
} |
| 388 |
\pgf@circ@draw@component{ |
| 389 |
\northwest |
| 390 |
\pgf@circ@res@up=\pgf@y |
| 391 |
\pgf@circ@res@left=\pgf@x |
| 392 |
\tip |
| 393 |
\pgf@circ@res@step = \pgf@x |
| 394 |
% |
| 395 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}} |
| 396 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}} |
| 397 |
\pgfpathlineto{\pgfpoint{1\pgf@circ@res@step}{0pt}} |
| 398 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{-\pgf@circ@res@up}} |
| 399 |
\pgfpathclose |
| 400 |
\pgf@circ@fill@strokecolor |
| 401 |
\pgfusepath{fill} % just fill |
| 402 |
} |
| 403 |
} |
| 404 |
|
| 405 |
%% Current arrow |
| 406 |
|
| 407 |
%% we need a phantom version of this shape for advanced v-i-f |
| 408 |
%% use strange names to keep ot private |
| 409 |
\newif\ifpgfcirc@really@draw@currarrow\pgfcirc@really@draw@currarrowtrue |
| 410 |
\ctikzset{phantom@currarrow/.code=\pgfcirc@really@draw@currarrowfalse} |
| 411 |
\ctikzset{normal@currarrow/.code=\pgfcirc@really@draw@currarrowtrue} |
| 412 |
|
| 413 |
\pgfdeclareshape{currarrow}{ |
| 414 |
\savedanchor{\northeast}{% |
| 415 |
\pgf@circ@res@step = \pgf@circ@Rlen |
| 416 |
\divide \pgf@circ@res@step by \ctikzvalof{current arrow scale} |
| 417 |
\pgf@x=.5\pgf@circ@res@step |
| 418 |
\pgf@y=\pgf@x% |
| 419 |
} |
| 420 |
\anchor{north}{\northeast\pgf@x=0cm\relax} |
| 421 |
\anchor{east}{\northeast\pgf@y=0cm\relax} |
| 422 |
\anchor{south}{\northeast\pgf@y=-\pgf@y \pgf@x=0cm\relax} |
| 423 |
\anchor{west}{\northeast\pgf@y=0cm\pgf@x=-\pgf@x} |
| 424 |
\anchor{north east}{\northeast} |
| 425 |
\anchor{north west}{\northeast\pgf@x=-\pgf@x} |
| 426 |
\anchor{south east}{\northeast\pgf@y=-\pgf@y} |
| 427 |
\anchor{south west}{\northeast\pgf@y=-\pgf@y\pgf@x=-\pgf@x} |
| 428 |
\anchor{center}{ |
| 429 |
\pgfpointorigin |
| 430 |
} |
| 431 |
\anchor{tip}{ |
| 432 |
\pgfpointorigin |
| 433 |
\pgf@circ@res@step = \pgf@circ@Rlen |
| 434 |
\divide \pgf@circ@res@step by \ctikzvalof{current arrow scale} |
| 435 |
\pgf@x =\pgf@circ@res@step |
| 436 |
} |
| 437 |
\pgf@circ@draw@component{ |
| 438 |
\ifpgfcirc@really@draw@currarrow |
| 439 |
\pgf@circ@reset@arrows@rounded |
| 440 |
\pgf@circ@res@step = \pgf@circ@Rlen |
| 441 |
\divide \pgf@circ@res@step by \ctikzvalof{current arrow scale} |
| 442 |
|
| 443 |
\pgfpathmoveto{\pgfpoint{-.7\pgf@circ@res@step}{0pt}} |
| 444 |
\pgfpathlineto{\pgfpoint{-.7\pgf@circ@res@step}{-.8\pgf@circ@res@step}} |
| 445 |
\pgfpathlineto{\pgfpoint{1\pgf@circ@res@step}{0pt}} |
| 446 |
\pgfpathlineto{\pgfpoint{-.7\pgf@circ@res@step}{.8\pgf@circ@res@step}} |
| 447 |
\pgfpathclose |
| 448 |
\pgf@circ@setcolor |
| 449 |
\pgf@circ@fill@strokecolor |
| 450 |
\pgfusepath{draw,fill} |
| 451 |
\fi |
| 452 |
} |
| 453 |
} |
| 454 |
|
| 455 |
%% Flow arrow |
| 456 |
%% we need a phantom version of this shape for advanced v-i-f |
| 457 |
%% use strange names to keep ot private |
| 458 |
\newif\ifpgfcirc@really@draw@flowarrow\pgfcirc@really@draw@flowarrowtrue |
| 459 |
\ctikzset{phantom@flowarrow/.code=\pgfcirc@really@draw@flowarrowfalse} |
| 460 |
\ctikzset{normal@flowarrow/.code=\pgfcirc@really@draw@flowarrowtrue} |
| 461 |
|
| 462 |
\pgfdeclareshape{flowarrow}{ |
| 463 |
\savedanchor{\northeast}{% |
| 464 |
\pgf@circ@res@step = \pgf@circ@Rlen |
| 465 |
\divide \pgf@circ@res@step by \ctikzvalof{current arrow scale} |
| 466 |
\pgf@y=.5\pgf@circ@res@step |
| 467 |
\pgf@circ@res@step = \pgf@circ@Rlen |
| 468 |
\divide \pgf@circ@res@step by 4 |
| 469 |
\pgf@x=\pgf@circ@res@step% |
| 470 |
} |
| 471 |
\anchor{north}{\northeast\pgf@x=0cm\relax} |
| 472 |
\anchor{east}{\northeast\pgf@y=0cm\relax} |
| 473 |
\anchor{south}{\northeast\pgf@y=-\pgf@y \pgf@x=0cm\relax} |
| 474 |
\anchor{west}{\northeast\pgf@y=0cm\pgf@x=-\pgf@x} |
| 475 |
\anchor{north east}{\northeast} |
| 476 |
\anchor{north west}{\northeast\pgf@x=-\pgf@x} |
| 477 |
\anchor{south east}{\northeast\pgf@y=-\pgf@y} |
| 478 |
\anchor{south west}{\northeast\pgf@y=-\pgf@y\pgf@x=-\pgf@x} |
| 479 |
\savedanchor{\textanchor}{% |
| 480 |
% text centered above |
| 481 |
\pgfpointorigin |
| 482 |
\pgfpoint{-.5\wd\pgfnodeparttextbox}{\dimexpr.5\dp\pgfnodeparttextbox+.5\ht\pgfnodeparttextbox} |
| 483 |
} |
| 484 |
\anchor{text}{\textanchor} |
| 485 |
\anchor{center}{ |
| 486 |
\pgfpointorigin |
| 487 |
} |
| 488 |
\anchor{tip}{ |
| 489 |
\pgfpointorigin |
| 490 |
\pgf@circ@res@step = \pgf@circ@Rlen |
| 491 |
\divide \pgf@circ@res@step by \ctikzvalof{current arrow scale} |
| 492 |
\pgf@x =\pgf@circ@res@step |
| 493 |
} |
| 494 |
\pgf@circ@draw@component{ |
| 495 |
\ifpgfcirc@really@draw@flowarrow |
| 496 |
\pgf@circ@reset@arrows@rounded |
| 497 |
\pgf@circ@res@step = \pgf@circ@Rlen |
| 498 |
\divide \pgf@circ@res@step by 4 |
| 499 |
\pgfpathmoveto{\pgfpoint{-\pgf@circ@res@step}{0pt}} |
| 500 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{0pt}} |
| 501 |
\pgf@circ@setcolor |
| 502 |
\pgfusepath{draw} |
| 503 |
\pgf@circ@fill@strokecolor |
| 504 |
\pgftransformshift{\pgfpoint{\pgf@circ@res@step}{0pt}} |
| 505 |
\pgfnode{currarrow}{tip}{}{}{\pgfusepath{fill}} |
| 506 |
\fi |
| 507 |
} |
| 508 |
} |
| 509 |
|
| 510 |
%% Input arrow |
| 511 |
|
| 512 |
\pgfdeclareshape{inputarrow}{ |
| 513 |
\savedanchor{\northeast}{% this is really not northeast, really -northwest |
| 514 |
\pgf@circ@res@step = \pgf@circ@Rlen |
| 515 |
\divide \pgf@circ@res@step by \ctikzvalof{current arrow scale} |
| 516 |
\pgf@y=.5\pgf@circ@res@step |
| 517 |
\pgf@x=1.7\pgf@circ@res@step |
| 518 |
} |
| 519 |
\anchor{north}{\northeast\pgf@x=0cm\relax} |
| 520 |
\anchor{east}{\northeast\pgf@y=0cm\relax\pgf@x=0cm\relax} |
| 521 |
\anchor{south}{\northeast\pgf@y=-\pgf@y \pgf@x=0cm\relax} |
| 522 |
\anchor{west}{\northeast\pgf@y=0cm\pgf@x=-\pgf@x} |
| 523 |
\anchor{north east}{\northeast\pgf@x=0cm\relax} |
| 524 |
\anchor{north west}{\northeast\pgf@x=-\pgf@x} |
| 525 |
\anchor{south east}{\northeast\pgf@y=-\pgf@y\pgf@x=0cm\relax} |
| 526 |
\anchor{south west}{\northeast\pgf@y=-\pgf@y\pgf@x=-\pgf@x} |
| 527 |
\savedanchor{\tip}{ |
| 528 |
\pgfpointorigin |
| 529 |
} |
| 530 |
\anchor{center}{ |
| 531 |
\tip |
| 532 |
} |
| 533 |
\anchor{tip}{ |
| 534 |
\tip |
| 535 |
} |
| 536 |
\pgf@circ@draw@component{ |
| 537 |
\pgf@circ@reset@arrows@rounded |
| 538 |
\pgf@circ@res@step = \pgf@circ@Rlen |
| 539 |
\divide \pgf@circ@res@step by 16 |
| 540 |
\pgfpathmoveto{\pgfpoint{-1.7\pgf@circ@res@step}{0pt}} |
| 541 |
\pgfpathlineto{\pgfpoint{-1.7\pgf@circ@res@step}{-.8\pgf@circ@res@step}} |
| 542 |
\pgfpathlineto{\pgfpoint{0pt}{0pt}} |
| 543 |
\pgfpathlineto{\pgfpoint{-1.7\pgf@circ@res@step}{.8\pgf@circ@res@step}} |
| 544 |
\pgfpathclose |
| 545 |
\pgf@circ@setcolor |
| 546 |
\pgf@circ@fill@strokecolor |
| 547 |
\pgfusepath{fill} |
| 548 |
} |
| 549 |
} |
| 550 |
% %>>> |
| 551 |
|
| 552 |
%% boxes%<<< |
| 553 |
%% box |
| 554 |
|
| 555 |
\pgfdeclareshape{box}{ |
| 556 |
\anchor{center}{ |
| 557 |
\pgfpointorigin |
| 558 |
} |
| 559 |
\pgf@circ@draw@component{ |
| 560 |
\pgf@circ@res@step = \ctikzvalof{bipoles/twoport/width}\pgf@circ@Rlen |
| 561 |
\pgf@circ@res@step = 0.5\pgf@circ@res@step |
| 562 |
\pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth} |
| 563 |
\pgfpathrectanglecorners{\pgfpoint{-\pgf@circ@res@step}{\pgf@circ@res@step}}{\pgfpoint{\pgf@circ@res@step}{-\pgf@circ@res@step}} |
| 564 |
\pgf@circ@draworfill |
| 565 |
} |
| 566 |
} |
| 567 |
|
| 568 |
%% box scaled with blocks |
| 569 |
|
| 570 |
\pgfdeclareshape{blockbox}{ |
| 571 |
\saveddimen{\scaledRlen}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{blocks/scale}\pgf@circ@Rlen}} |
| 572 |
\anchor{center}{ |
| 573 |
\pgfpointorigin |
| 574 |
} |
| 575 |
\pgf@circ@draw@component{ |
| 576 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{blocks/scale}\pgf@circ@Rlen} |
| 577 |
\pgf@circ@res@step = \ctikzvalof{bipoles/twoport/width}\pgf@circ@scaled@Rlen |
| 578 |
\pgf@circ@res@step = 0.5\pgf@circ@res@step |
| 579 |
\pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth} |
| 580 |
\pgfpathrectanglecorners{\pgfpoint{-\pgf@circ@res@step}{\pgf@circ@res@step}}{\pgfpoint{\pgf@circ@res@step}{-\pgf@circ@res@step}} |
| 581 |
\pgf@circ@draworfill |
| 582 |
} |
| 583 |
} |
| 584 |
% %>>> |
| 585 |
|
| 586 |
%% crossings%<<< |
| 587 |
% full nodes for wire crossing |
| 588 |
% styling for the vertical wire (default: do none) |
| 589 |
\ctikzset{crossing vertical/relative thickness/.initial=1} |
| 590 |
\ctikzset{crossing vertical/color/.initial=default} |
| 591 |
\ctikzset{crossing vertical/dash/.initial=default} |
| 592 |
|
| 593 |
\pgfdeclareshape{jump crossing} |
| 594 |
{ |
| 595 |
\savedanchor\northwest{% |
| 596 |
\pgf@y=\ctikzvalof{bipoles/crossing/size}\pgf@circ@Rlen |
| 597 |
\pgf@y=.5\pgf@y |
| 598 |
\pgf@x=-\pgf@y |
| 599 |
} |
| 600 |
\anchor{center}{ \pgf@y=0pt \pgf@x=0pt } |
| 601 |
\pgfcirc@northwest@symmetric@geoanchors |
| 602 |
\pgf@circ@draw@component{ |
| 603 |
\northwest |
| 604 |
\pgf@circ@res@up = \pgf@y |
| 605 |
\pgf@circ@res@down = -\pgf@y |
| 606 |
\pgf@circ@res@right = -\pgf@x |
| 607 |
\pgf@circ@res@left = \pgf@x |
| 608 |
% horizontal jumper |
| 609 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}} |
| 610 |
\pgfpathlineto{\pgfpoint{0.4\pgf@circ@res@left}{0pt}} |
| 611 |
\pgfpatharc{0}{-180}{0.4*\pgf@circ@res@left} |
| 612 |
\pgfsetbeveljoin |
| 613 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0pt}} |
| 614 |
\pgfusepath{draw} |
| 615 |
% vertical, broken path |
| 616 |
% styling of vertical line |
| 617 |
\pgfsetlinewidth{\ctikzvalof{crossing vertical/relative thickness}\pgflinewidth} |
| 618 |
\pgf@circ@subset@color@dash{crossing vertical} |
| 619 |
% |
| 620 |
\pgfpathmoveto{\pgfpoint{0pt}{\pgf@circ@res@up}} |
| 621 |
\pgfpathlineto{\pgfpoint{0pt}{0.5\pgf@circ@res@up}} |
| 622 |
\pgfpathmoveto{\pgfpoint{0pt}{0.3\pgf@circ@res@up}} |
| 623 |
\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@down}} |
| 624 |
\pgfusepath{draw} |
| 625 |
} |
| 626 |
} |
| 627 |
\pgfdeclareshape{plain crossing} |
| 628 |
{ |
| 629 |
\savedanchor\northwest{% |
| 630 |
\pgf@y=\ctikzvalof{bipoles/crossing/size}\pgf@circ@Rlen |
| 631 |
\pgf@y=.5\pgf@y |
| 632 |
\pgf@x=-\pgf@y |
| 633 |
} |
| 634 |
\anchor{center}{ \pgf@y=0pt \pgf@x=0pt } |
| 635 |
\pgfcirc@northwest@symmetric@geoanchors |
| 636 |
\pgf@circ@draw@component{ |
| 637 |
\northwest |
| 638 |
\pgf@circ@res@up = \pgf@y |
| 639 |
\pgf@circ@res@down = -\pgf@y |
| 640 |
\pgf@circ@res@right = -\pgf@x |
| 641 |
\pgf@circ@res@left = \pgf@x |
| 642 |
% horizontal jumper |
| 643 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}} |
| 644 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0pt}} |
| 645 |
\pgfusepath{draw} |
| 646 |
% vertical, broken path |
| 647 |
% styling of vertical line |
| 648 |
\pgfsetlinewidth{\ctikzvalof{crossing vertical/relative thickness}\pgflinewidth} |
| 649 |
\pgf@circ@subset@color@dash{crossing vertical} |
| 650 |
% |
| 651 |
\pgfpathmoveto{\pgfpoint{0pt}{\pgf@circ@res@up}} |
| 652 |
\pgfpathlineto{\pgfpoint{0pt}{0.1\pgf@circ@res@up}} |
| 653 |
\pgfpathmoveto{\pgfpoint{0pt}{0.1\pgf@circ@res@down}} |
| 654 |
\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@down}} |
| 655 |
\pgfusepath{draw} |
| 656 |
} |
| 657 |
} |
| 658 |
% %>>> |
| 659 |
|
| 660 |
%% Connectors (BNC and IEC connectors; see https://github.com/circuitikz/circuitikz/issues/611)%<<< |
| 661 |
|
| 662 |
% define new class |
| 663 |
\ctikzset{connectors/scale/.initial=1.0} |
| 664 |
\ctikzset{connectors/fill/.initial=none} |
| 665 |
\ctikzset{connectors/thickness/.initial=none} |
| 666 |
% parameters. To have round sockets, 3*height==2*width |
| 667 |
\ctikzset{bipoles/iecconn/height/.initial=.2} |
| 668 |
\ctikzset{bipoles/iecconn/width/.initial=.3} |
| 669 |
% objects |
| 670 |
\pgfcircdeclarebipolescaled{connectors} |
| 671 |
{ |
| 672 |
\anchor{plug center}{\northeast\pgf@y=0pt\divide\pgf@x by 3 } |
| 673 |
\anchor{socket center}{\northeast\pgf@y=0pt\pgf@x=-0.333333\pgf@x} |
| 674 |
% put the node text above and centered |
| 675 |
\savedanchor{\textoffset}{% |
| 676 |
\pgfpoint{-.5\wd\pgfnodeparttextbox}{.5\ht\pgfnodeparttextbox} |
| 677 |
} |
| 678 |
\anchor{text}{\pgfextractx{\pgf@xa}{\textoffset}\pgfextracty{\pgf@ya}{\textoffset}% |
| 679 |
\pgfextracty{\pgf@circ@res@up}{\northeast}% |
| 680 |
\pgfpoint{\pgf@xa}{\pgf@ya+\pgf@circ@res@up}% |
| 681 |
} |
| 682 |
} |
| 683 |
{\ctikzvalof{bipoles/iecconn/height}}%symmetrical |
| 684 |
{iecconn} |
| 685 |
{\ctikzvalof{bipoles/iecconn/height}} |
| 686 |
{\ctikzvalof{bipoles/iecconn/width}} |
| 687 |
{ |
| 688 |
\pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth} |
| 689 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left/3}{\pgf@circ@res@up}} |
| 690 |
\pgfpatharc{90}{-90}{0.66666\pgf@circ@res@left and \pgf@circ@res@up} |
| 691 |
\pgfusepath{draw} |
| 692 |
\pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left/3}{\pgf@circ@res@up/2}}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down/2}} |
| 693 |
\pgf@circ@fill@strokecolor |
| 694 |
\pgfusepath{draw, fill} |
| 695 |
} |
| 696 |
\pgfcirc@activate@bipole@simple{l}{iecconn} |
| 697 |
\pgfcirc@style@to@style{iecconn}{iec connector} |
| 698 |
|
| 699 |
\long\def\pgfcirc@declare@iecsocket#1#2#3{% #1 name, #2 anchors, #3 drawing code |
| 700 |
\pgfdeclareshape{#1}{% |
| 701 |
\savedmacro{\ctikzclass}{\edef\ctikzclass{connectors}} |
| 702 |
\saveddimen{\scaledRlen}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}} |
| 703 |
\savedanchor\northwest{% |
| 704 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 705 |
\pgf@y=\ctikzvalof{bipoles/iecconn/height}\pgf@circ@scaled@Rlen |
| 706 |
\pgf@y=.5\pgf@y |
| 707 |
\pgf@x=-\ctikzvalof{bipoles/iecconn/width}\pgf@circ@scaled@Rlen |
| 708 |
\divide\pgf@x by 6 |
| 709 |
} |
| 710 |
\pgfcirc@northwest@symmetric@geoanchors |
| 711 |
#2% |
| 712 |
\pgf@circ@draw@component{% |
| 713 |
\pgf@circ@scaled@Rlen=\scaledRlen |
| 714 |
\pgfstartlinewidth=\pgflinewidth |
| 715 |
\northwest |
| 716 |
\pgf@circ@res@up=\pgf@y |
| 717 |
\pgf@circ@res@left=\pgf@x |
| 718 |
\pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth} |
| 719 |
#3% |
| 720 |
\pgfusepath{draw} |
| 721 |
} |
| 722 |
} |
| 723 |
} |
| 724 |
|
| 725 |
\long\def\pgfcirc@declare@iecplug#1#2{% #1 name, #2 anchors (drawing code is the same) |
| 726 |
\pgfdeclareshape{#1}{% |
| 727 |
\savedmacro{\ctikzclass}{\edef\ctikzclass{connectors}} |
| 728 |
\saveddimen{\scaledRlen}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}} |
| 729 |
\savedanchor\northwest{% |
| 730 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 731 |
\pgf@y=\ctikzvalof{bipoles/iecconn/height}\pgf@circ@scaled@Rlen |
| 732 |
\pgf@y=.25\pgf@y |
| 733 |
\pgf@x=-\ctikzvalof{bipoles/iecconn/width}\pgf@circ@scaled@Rlen |
| 734 |
\divide\pgf@x by 3 |
| 735 |
} |
| 736 |
\pgfcirc@northwest@symmetric@geoanchors |
| 737 |
\anchor{plug center}{\pgfpointorigin} |
| 738 |
#2% |
| 739 |
\pgf@circ@draw@component{% |
| 740 |
\pgf@circ@scaled@Rlen=\scaledRlen |
| 741 |
\pgfstartlinewidth=\pgflinewidth |
| 742 |
\northwest |
| 743 |
\pgf@circ@res@up=\pgf@y |
| 744 |
\pgf@circ@res@left=\pgf@x |
| 745 |
\pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth} |
| 746 |
\pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{-\pgf@circ@res@left}{-\pgf@circ@res@up}} |
| 747 |
\pgf@circ@setcolor |
| 748 |
\pgf@circ@fill@strokecolor |
| 749 |
\pgfusepath{draw, fill} |
| 750 |
} |
| 751 |
} |
| 752 |
} |
| 753 |
|
| 754 |
\pgfcirc@declare@iecsocket{iecsocketR}{% |
| 755 |
% notice: center is on the left side |
| 756 |
\anchor{center}{\northwest\pgf@y=0pt} |
| 757 |
\anchor{socket center}{\northwest\pgf@y=0pt} |
| 758 |
% put the node text above and to the left, ignore depth |
| 759 |
\savedanchor{\textoffset}{% |
| 760 |
\pgfpoint{-.5\wd\pgfnodeparttextbox}{.5\ht\pgfnodeparttextbox} |
| 761 |
} |
| 762 |
\anchor{text}{\pgfextracty{\pgf@ya}{\textoffset}% |
| 763 |
\pgfextractx{\pgf@circ@res@left}{\northwest} |
| 764 |
\pgfextracty{\pgf@circ@res@up}{\northwest} |
| 765 |
\pgfpoint{-\pgf@circ@res@left}{% |
| 766 |
\pgf@ya+\pgf@circ@res@up |
| 767 |
}% |
| 768 |
}% |
| 769 |
}{% drawing |
| 770 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}} |
| 771 |
\pgfpatharc{90}{270}{2\pgf@circ@res@left and \pgf@circ@res@up} |
| 772 |
} |
| 773 |
\pgfcirc@declare@iecsocket{iecsocketL}{% |
| 774 |
% notice: center is on the left side |
| 775 |
\anchor{center}{\northwest\pgf@y=0pt} |
| 776 |
\anchor{socket center}{\northwest\pgf@y=0pt\pgf@x=-\pgf@x} |
| 777 |
% put the node text above and to the left, ignore depth |
| 778 |
\savedanchor{\textoffset}{% |
| 779 |
\pgfpoint{-\wd\pgfnodeparttextbox}{.5\ht\pgfnodeparttextbox} |
| 780 |
} |
| 781 |
\anchor{text}{\pgfextractx{\pgf@xa}{\textoffset}\pgfextracty{\pgf@ya}{\textoffset}% |
| 782 |
\pgfextractx{\pgf@circ@res@left}{\northwest} |
| 783 |
\pgfextracty{\pgf@circ@res@up}{\northwest} |
| 784 |
\pgfpoint{\pgf@xa+\pgf@circ@res@left}{% |
| 785 |
\pgf@ya+\pgf@circ@res@up |
| 786 |
}% |
| 787 |
}% |
| 788 |
}{% drawing |
| 789 |
\pgfpathmoveto{\pgfpoint{-\pgf@circ@res@left}{\pgf@circ@res@up}} |
| 790 |
\pgfpatharc{90}{-90}{2\pgf@circ@res@left and \pgf@circ@res@up} |
| 791 |
} |
| 792 |
|
| 793 |
\pgfcirc@declare@iecplug{iecplugL}{% |
| 794 |
% notice: center is on the left side |
| 795 |
\anchor{center}{\northwest\pgf@y=0pt} |
| 796 |
% put the node text above and to the right, ignore depth |
| 797 |
% the text is higher to match the iec socket position |
| 798 |
\savedanchor{\textoffset}{% |
| 799 |
\pgfpoint{-\wd\pgfnodeparttextbox}{.5\ht\pgfnodeparttextbox} |
| 800 |
} |
| 801 |
\anchor{text}{\pgfextractx{\pgf@xa}{\textoffset}\pgfextracty{\pgf@ya}{\textoffset}% |
| 802 |
\pgfextractx{\pgf@circ@res@left}{\northwest} |
| 803 |
\pgfextracty{\pgf@circ@res@up}{\northwest} |
| 804 |
\pgfpoint{\pgf@xa+\pgf@circ@res@left}{ |
| 805 |
\pgf@ya+2\pgf@circ@res@up |
| 806 |
} |
| 807 |
} |
| 808 |
} |
| 809 |
\pgfcirc@declare@iecplug{iecplugR}{% |
| 810 |
% notice: center is on the left side |
| 811 |
\anchor{center}{\northwest\pgf@y=0pt} |
| 812 |
% put the node text above and to the right, ignore depth |
| 813 |
% the text is higher to match the iec socket position |
| 814 |
\savedanchor{\textoffset}{% |
| 815 |
\pgfpoint{-.5\wd\pgfnodeparttextbox}{.5\ht\pgfnodeparttextbox} |
| 816 |
} |
| 817 |
\anchor{text}{\pgfextracty{\pgf@ya}{\textoffset}% |
| 818 |
\pgfextractx{\pgf@circ@res@left}{\northwest} |
| 819 |
\pgfextracty{\pgf@circ@res@up}{\northwest} |
| 820 |
\pgfpoint{-\pgf@circ@res@left}{ |
| 821 |
\pgf@ya+2\pgf@circ@res@up |
| 822 |
} |
| 823 |
} |
| 824 |
} |
| 825 |
% BNC connector |
| 826 |
|
| 827 |
\pgfdeclareshape{bnc}{ |
| 828 |
\savedmacro{\ctikzclass}{\edef\ctikzclass{connectors}} |
| 829 |
\saveddimen{\scaledRlen}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}} |
| 830 |
\anchor{center}{ |
| 831 |
\pgfpointorigin |
| 832 |
} |
| 833 |
% BNC size is 2.5 times the size of the internal "ocirc", when class scale is=1 |
| 834 |
\savedanchor\northwest{% |
| 835 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 836 |
\pgf@y=\ctikzvalof{nodes width}\pgf@circ@scaled@Rlen |
| 837 |
\pgf@y=2.5\pgf@y |
| 838 |
\pgf@x=-\pgf@y |
| 839 |
} |
| 840 |
% center is on the opening |
| 841 |
\anchor{center}{\northwest\pgf@y=0pt\pgf@x=-\pgf@x} |
| 842 |
\anchor{zero}{\pgfpointorigin} |
| 843 |
\anchor{hot}{\northwest\pgf@y=0pt\pgf@x=-\pgf@x} |
| 844 |
\anchor{shield}{\northwest\pgf@x=0pt\pgf@y=-\pgf@y} |
| 845 |
% geo-anchors |
| 846 |
\pgfcirc@northwest@symmetric@geoanchors |
| 847 |
% put the node text above and centered |
| 848 |
\savedanchor{\textoffset}{% |
| 849 |
\pgfpoint{-.5\wd\pgfnodeparttextbox}{.5\dp\pgfnodeparttextbox+.5\ht\pgfnodeparttextbox} |
| 850 |
} |
| 851 |
\anchor{text}{\pgfextractx{\pgf@xa}{\textoffset}\pgfextracty{\pgf@ya}{\textoffset}% |
| 852 |
\pgfextracty{\pgf@circ@res@up}{\northwest} |
| 853 |
\pgfpoint{\pgf@xa}{\pgf@ya+\pgf@circ@res@up} |
| 854 |
} |
| 855 |
\anchorborder{ |
| 856 |
\pgf@circ@res@left=\pgf@x |
| 857 |
\pgf@circ@res@up=\pgf@y |
| 858 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} |
| 859 |
\pgfpointborderellipse{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up} |
| 860 |
}{\pgfpoint{2.5*\ctikzvalof{nodes width}*\pgf@circ@scaled@Rlen}{2.5*\ctikzvalof{nodes width}*\pgf@circ@scaled@Rlen}} |
| 861 |
} |
| 862 |
\pgf@circ@draw@component{ |
| 863 |
\pgfextracty{\pgf@circ@res@other}{\northwest} |
| 864 |
\pgfmathsetlength{\pgf@circ@res@step}{\ctikzvalof{nodes width}*\scaledRlen} |
| 865 |
\pgfstartlinewidth=\pgflinewidth |
| 866 |
\pgf@circ@setlinewidth{bipoles}{\pgflinewidth} |
| 867 |
\pgf@circ@setcolor |
| 868 |
% external circle |
| 869 |
\pgfscope |
| 870 |
% clipping path: first a rectangle bigger then the shape |
| 871 |
% to avoid problems with the line thickness |
| 872 |
\pgfpathrectanglecorners{\pgfpoint{-2\pgf@circ@res@other}{-2\pgf@circ@res@other}} |
| 873 |
{\pgfpoint{2\pgf@circ@res@other}{2\pgf@circ@res@other}} |
| 874 |
% next the opening to the right |
| 875 |
\pgfpathrectanglecorners{\pgfpoint{-\pgf@circ@res@step}{-\pgf@circ@res@step}} |
| 876 |
{\pgfpoint{2\pgf@circ@res@other}{\pgf@circ@res@step}} |
| 877 |
% do the difference and clip before drawing |
| 878 |
\pgfseteorule |
| 879 |
\pgfusepath{clip} |
| 880 |
\pgfpathcircle{\pgfpointorigin}{\pgf@circ@res@other} |
| 881 |
\pgfusepath{draw} |
| 882 |
\endpgfscope |
| 883 |
% internal circle |
| 884 |
\pgfpathcircle{\pgfpointorigin}{\pgf@circ@res@step} |
| 885 |
\pgf@circ@draworfill |
| 886 |
% and the contact line to the right |
| 887 |
\pgfsetlinewidth{\pgfstartlinewidth} |
| 888 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@step}{0pt}} |
| 889 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{0pt}} |
| 890 |
\pgfusepath{draw} |
| 891 |
} |
| 892 |
} |
| 893 |
% %>>> |
| 894 |
|
| 895 |
% misc shapes (ac/dc symbols) %%<<< |
| 896 |
% dc symbol |
| 897 |
\ctikzset{dc symbol/width/.initial=0.3} |
| 898 |
\ctikzset{dc symbol/height/.initial=0.15} |
| 899 |
\ctikzset{dc symbol/segments/.initial=2} |
| 900 |
\ctikzset{dc symbol/text offset/.initial=6pt} |
| 901 |
\tikzset{dc symbol segments/.code={\ctikzset{dc symbol/segments=#1}}} |
| 902 |
\ctikzset{dc symbol/relative thickness/.initial=1} |
| 903 |
\pgfdeclareshape{dc symbol}{ |
| 904 |
\savedmacro{\ctikzclass}{\edef\ctikzclass{misc}} |
| 905 |
\saveddimen{\scaledRlen}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{misc/scale}\pgf@circ@Rlen}} |
| 906 |
\anchor{center}{\pgfpointorigin} |
| 907 |
\savedanchor\northeast{% |
| 908 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{misc/scale}\pgf@circ@Rlen} |
| 909 |
\pgf@x=\ctikzvalof{dc symbol/width}\pgf@circ@scaled@Rlen |
| 910 |
\pgf@y=\ctikzvalof{dc symbol/height}\pgf@circ@scaled@Rlen |
| 911 |
\pgf@x=.5\pgf@x\pgf@y=.5\pgf@y |
| 912 |
} |
| 913 |
\savedanchor{\textanchor}{ |
| 914 |
% above (add a bit of space) |
| 915 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{misc/scale}\pgf@circ@Rlen} |
| 916 |
\pgf@ya=\ctikzvalof{ac symbol/height}\pgf@circ@scaled@Rlen |
| 917 |
\pgfpoint{-.5\wd\pgfnodeparttextbox}{\dimexpr -0.5\dp\pgfnodeparttextbox-.5\ht\pgfnodeparttextbox} |
| 918 |
\advance\pgf@y by \pgf@ya\advance\pgf@y by \ctikzvalof{dc symbol/text offset} |
| 919 |
} |
| 920 |
\anchor{text}{\textanchor} |
| 921 |
\pgfcirc@northeast@symmetric@geoanchors |
| 922 |
\pgf@circ@draw@component{ |
| 923 |
\pgfstartlinewidth=\pgflinewidth |
| 924 |
\pgfscope |
| 925 |
\pgf@circ@setcolor |
| 926 |
\pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth} |
| 927 |
\pgfextractx{\pgf@circ@res@right}{\northeast} |
| 928 |
\pgfextracty{\pgf@circ@res@up}{\northeast} |
| 929 |
\pgf@circ@res@left=-\pgf@circ@res@right |
| 930 |
\pgf@circ@res@down=-\pgf@circ@res@up |
| 931 |
% upper line |
| 932 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}} |
| 933 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}} |
| 934 |
\pgfusepath{draw} |
| 935 |
% lower line |
| 936 |
\edef\@@tmp{\ctikzvalof{dc symbol/relative thickness}} |
| 937 |
\pgfsetlinewidth{\@@tmp\pgflinewidth} |
| 938 |
\edef\@@dashes{\ctikzvalof{dc symbol/segments}} |
| 939 |
\ifnum\@@dashes>1 |
| 940 |
\pgfmathsetlength{\pgf@circ@res@other}{2*\pgf@circ@res@right/(2*(\@@dashes-1)+1)} |
| 941 |
\pgf@circ@do@n@hdashes{\@@dashes}{\pgf@circ@res@other}{\pgf@circ@res@left}{\pgf@circ@res@down} |
| 942 |
\else |
| 943 |
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}} |
| 944 |
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}} |
| 945 |
\fi |
| 946 |
\pgfusepath{draw} |
| 947 |
\endpgfscope |
| 948 |
} |
| 949 |
} |
| 950 |
% ac symbol |
| 951 |
\ctikzset{ac symbol/width/.initial=0.3} |
| 952 |
\ctikzset{ac symbol/height/.initial=0.15} |
| 953 |
\ctikzset{ac symbol/segments/.initial=2} |
| 954 |
\ctikzset{ac symbol/text offset/.initial=6pt} |
| 955 |
\pgfdeclareshape{ac symbol}{ |
| 956 |
\savedmacro{\ctikzclass}{\edef\ctikzclass{misc}} |
| 957 |
\saveddimen{\scaledRlen}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{misc/scale}\pgf@circ@Rlen}} |
| 958 |
\anchor{center}{\pgfpointorigin} |
| 959 |
\savedanchor\northeast{% |
| 960 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{misc/scale}\pgf@circ@Rlen} |
| 961 |
\pgf@x=\ctikzvalof{ac symbol/width}\pgf@circ@scaled@Rlen |
| 962 |
\pgf@y=\ctikzvalof{ac symbol/height}\pgf@circ@scaled@Rlen |
| 963 |
\pgf@x=.5\pgf@x\pgf@y=.5\pgf@y |
| 964 |
} |
| 965 |
\savedanchor{\textanchor}{ |
| 966 |
% above (add a bit of space) |
| 967 |
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{misc/scale}\pgf@circ@Rlen} |
| 968 |
\pgf@ya=\ctikzvalof{ac symbol/height}\pgf@circ@scaled@Rlen |
| 969 |
\pgfpoint{-.5\wd\pgfnodeparttextbox}{\dimexpr-0.5\dp\pgfnodeparttextbox-.5\ht\pgfnodeparttextbox} |
| 970 |
\advance\pgf@y by \pgf@ya\advance\pgf@y by \ctikzvalof{ac symbol/text offset} |
| 971 |
} |
| 972 |
\anchor{text}{\textanchor} |
| 973 |
\pgfcirc@northeast@symmetric@geoanchors |
| 974 |
\pgf@circ@draw@component{ |
| 975 |
\pgfstartlinewidth=\pgflinewidth |
| 976 |
\pgfscope |
| 977 |
\pgf@circ@setcolor |
| 978 |
\pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth} |
| 979 |
\pgfextractx{\pgf@circ@res@right}{\northeast} |
| 980 |
\pgfextracty{\pgf@circ@res@up}{\northeast} |
| 981 |
% draw the sine waveform |
| 982 |
\pgfpathmoveto{\pgfpoint{-\pgf@circ@res@right}{0\pgf@circ@res@up}} |
| 983 |
\pgfpathsine{\pgfpoint{.5\pgf@circ@res@right}{\pgf@circ@res@up}} |
| 984 |
\pgfpathcosine{\pgfpoint{.5\pgf@circ@res@right}{-\pgf@circ@res@up}} |
| 985 |
\pgfpathsine{\pgfpoint{.5\pgf@circ@res@right}{-\pgf@circ@res@up}} |
| 986 |
\pgfpathcosine{\pgfpoint{.5\pgf@circ@res@right}{\pgf@circ@res@up}} |
| 987 |
\pgfusepath{draw} |
| 988 |
\endpgfscope |
| 989 |
} |
| 990 |
} |
| 991 |
%>>> |
| 992 |
|
| 993 |
\endinput |
| 994 |
% vim: set fdm=marker fmr=%<<<,%>>>: |