| 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 |
\def\pgf@circ@direction{0.0} |
| 15 |
|
| 16 |
% swap two coordinates |
| 17 |
\def\pgfcirc@swap@coordinates#1#2{% |
| 18 |
coordinate (pgfcirc@tmp@swap) at (#1) |
| 19 |
coordinate (#1) at (#2) |
| 20 |
coordinate (#2) at (pgfcirc@tmp@swap) |
| 21 |
} |
| 22 |
|
| 23 |
% Names |
| 24 |
\ctikzset{name/.style = { n={#1} } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@ |
| 25 |
\gdef\ctikz@@null{}% |
| 26 |
% safety net for re-naming a ctikz path-to |
| 27 |
\ctikzset{n/.code = { |
| 28 |
\edef\ctikz@@temp{\ctikzvalof{bipole/name}}% |
| 29 |
\ifx\ctikz@@temp\ctikz@@null\else |
| 30 |
\pgfutil@packagewarning{circuitikz}{path-to component #1 already had a name, ^^J% |
| 31 |
(\ctikz@@temp) expect problems and errors!}% |
| 32 |
\fi |
| 33 |
\pgfkeys{/tikz/circuitikz/bipole/name={#1}}% |
| 34 |
}} |
| 35 |
|
| 36 |
% Reflect the node along |
| 37 |
\ctikzset{mirrored/.is choice} |
| 38 |
\ctikzset{mirror value/.initial=1} |
| 39 |
\ctikzset{mirrored/true/.code = {\ctikzsetvalof{mirror value}{-1}} } |
| 40 |
\ctikzset{mirrored/false/.code = {\ctikzsetvalof{mirror value}{1}} } |
| 41 |
\ctikzset{mirror/.style = {/tikz/circuitikz/mirrored=true}} |
| 42 |
|
| 43 |
% Invert node along path |
| 44 |
\ctikzset{inverted/.is choice} |
| 45 |
\ctikzset{invert value/.initial=1} |
| 46 |
\ctikzset{inverted/true/.code = {\ctikzsetvalof{invert value}{-1}\pgf@circuit@bipole@invertedtrue}} |
| 47 |
\ctikzset{inverted/false/.code = {\ctikzsetvalof{invert value}{1}\pgf@circuit@bipole@invertedfalse}} |
| 48 |
\ctikzset{invert/.style = {/tikz/circuitikz/inverted=true}} |
| 49 |
\newif\ifpgf@circuit@bipole@inverted |
| 50 |
\ctikzset{bipole/inverted/.is if=pgf@circuit@bipole@inverted} |
| 51 |
|
| 52 |
\newif\ifpgf@circuit@bipole@voltage@backward |
| 53 |
\ctikzset{bipole/voltage/direction/.is choice} |
| 54 |
\ctikzset{bipole/voltage/direction/forward/.code={\pgf@circuit@bipole@voltage@backwardfalse}} |
| 55 |
\ctikzset{bipole/voltage/direction/backward/.code={\pgf@circuit@bipole@voltage@backwardtrue}} |
| 56 |
|
| 57 |
% Initialize paths |
| 58 |
\def\pgfcircresetpath{ |
| 59 |
\ctikzset{bipole/name=, bipole/label/name=, bipole/label/position=90, ,bipole/annotation/name=, bipole/annotation/position=-90, |
| 60 |
bipole/inverted=false, bipole/kind=, |
| 61 |
bipole/voltage/direction=backward, bipole/voltage/label/name=, bipole/voltage/position=below, |
| 62 |
bipole/nodes/left=none, bipole/nodes/right=none, bipole/is voltage=false,bipole/is voltageoutsideofsymbol=false,bipole/is strokedsymbol=false, |
| 63 |
bipole/is current=false, bipole/current/label/name=, bipole/current/x position=after, |
| 64 |
bipole/current/y position=above, bipole/current/direction=forward, |
| 65 |
mirrored=false |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
%% |
| 70 |
%% implementation of automatic advanced v-i-f labels |
| 71 |
%% |
| 72 |
\gdef\ctikz@vif@queue{}\newcount\ctikz@vif@count |
| 73 |
\newif\ifctikz@hook@set\global\ctikz@hook@setfalse |
| 74 |
\def\ctikz@vif@add#1#2#3#4{%add to the queue the macro \#1{nodename}{#2}{#3}{#4} |
| 75 |
\edef\ctikz@vif@@name{\ctikzvalof{bipole/name}}% |
| 76 |
\ifx\ctikz@vif@@name\ctikz@@null |
| 77 |
% we *need* to be sure we have no repeated nodenames |
| 78 |
% this should work well for millions of them. |
| 79 |
\global\advance\ctikz@vif@count by 1 \relax |
| 80 |
\pgfmathrandominteger{\ctikz@vif@@rand}{100}{999}% |
| 81 |
\edef\ctikz@vif@@name{ctikz-vif\the\ctikz@vif@count-\ctikz@vif@@rand}% |
| 82 |
\ctikzset{bipole/name=\ctikz@vif@@name} |
| 83 |
\fi |
| 84 |
% \typeout{NODE2: \ctikzvalof{bipole/name}} |
| 85 |
\edef\ctikz@vif@@temp{% |
| 86 |
\noexpand\pgfutil@g@addto@macro\noexpand\ctikz@vif@queue{% |
| 87 |
\expandafter\noexpand\csname #1\endcsname |
| 88 |
{\ctikz@vif@@name}{#2}{#3}{#4}% |
| 89 |
}% |
| 90 |
}% |
| 91 |
\ctikz@vif@@temp |
| 92 |
} |
| 93 |
%% set up the hooks if possible and if they are not already set for this picture |
| 94 |
\def\ctikz@set@hook{% |
| 95 |
\ifctikz@hook@set |
| 96 |
\else |
| 97 |
\global\ctikz@hook@settrue |
| 98 |
\ifpgfutil@format@is@latex |
| 99 |
\ifctikz@latex@has@hooks |
| 100 |
% we must enable both for circuitikz and tikzpicture (grrr) |
| 101 |
% \typeout{EXECUTE AddToHook ctikzprocessvif}% |
| 102 |
\AddToHookNext{env/tikzpicture/end}{\ctikzprocessvif}% |
| 103 |
\AddToHookNext{env/circuitikz/end}{\ctikzprocessvif}% |
| 104 |
\else |
| 105 |
% \typeout{OLD LaTeX, use "use auto vif"}% |
| 106 |
\pgfutil@packagewarning{circuitikz}{You used automatic advanced v-i-f with a ^^J% |
| 107 |
old LaTeX, you must add "use auto vif" (see manual)}% |
| 108 |
\fi |
| 109 |
\else |
| 110 |
% this is not LaTeX, I will not touch internals |
| 111 |
% \typeout{Not on LaTeX, use "use auto vif"}% |
| 112 |
\pgfutil@packagewarning{circuitikz}{You used automatic advanced v-i-f with a ^^J% |
| 113 |
non-LaTeX format, you must add "use auto vif" (see manual)}% |
| 114 |
\fi |
| 115 |
\fi |
| 116 |
} |
| 117 |
% manually add hooks for non-LaTeX or older LaTeX. Safe to use always. |
| 118 |
\tikzset{use auto vif/.style={execute at end picture={\ctikzprocessvif}, |
| 119 |
execute at begin picture={\global\ctikz@hook@settrue}}} |
| 120 |
% main v-i-f processing macro. Safe to call always. |
| 121 |
\def\ctikzprocessvif{% |
| 122 |
% execute and clear queue |
| 123 |
% \typeout{EXECUTE ctikzprocessvif}% |
| 124 |
\ctikz@vif@queue\relax\gdef\ctikz@vif@queue{}% |
| 125 |
\global\ctikz@hook@setfalse |
| 126 |
% clear hooks. Needed because just one of them will be consumed automatically, |
| 127 |
% and we do not know which. |
| 128 |
\ifctikz@latex@has@hooks |
| 129 |
\providecommand\ClearHookNext{}% Added later than \AddToHookNext |
| 130 |
\ClearHookNext{env/tikzpicture/end}% |
| 131 |
\ClearHookNext{env/circuitikz/end}% |
| 132 |
\fi |
| 133 |
} |
| 134 |
% main entry point for automatic v-i-f |
| 135 |
\ctikzset{vif queue add/.code n args={4}{\ctikz@vif@add{#1}{#2}{#3}{#4}\ctikz@set@hook}} |
| 136 |
% |
| 137 |
% expandable IF for the extra nodes (thanks to Henri Menke) |
| 138 |
% see https://chat.stackexchange.com/transcript/message/56560808#56560808 |
| 139 |
% |
| 140 |
\def\pgfcirc@if@has@i{% |
| 141 |
\ifpgfcirc@has@i |
| 142 |
\expandafter\pgfutil@firstoftwo |
| 143 |
\else |
| 144 |
\expandafter\pgfutil@secondoftwo |
| 145 |
\fi} |
| 146 |
\def\pgfcirc@if@has@v{% |
| 147 |
\ifpgfcirc@has@v |
| 148 |
\expandafter\pgfutil@firstoftwo |
| 149 |
\else |
| 150 |
\expandafter\pgfutil@secondoftwo |
| 151 |
\fi} |
| 152 |
\def\pgfcirc@if@has@f{% |
| 153 |
\ifpgfcirc@has@f |
| 154 |
\expandafter\pgfutil@firstoftwo |
| 155 |
\else |
| 156 |
\expandafter\pgfutil@secondoftwo |
| 157 |
\fi} |
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
%% Generic bipole path |
| 162 |
\def\pgf@circ@bipole@path#1#2{ |
| 163 |
% Create a bipole path from the shapes defined with \pgfcircdeclarebipole |
| 164 |
% or \pgfcircdeclarebipolescaled; the node shapes are named with a "shape" |
| 165 |
% appended to the main (path-style) name |
| 166 |
% #1 path-style node name |
| 167 |
% #2 the argument passed from the to-path structure; don't touch |
| 168 |
% |
| 169 |
% Example: |
| 170 |
% \def\pgf@circ@capacitor@path#1{\pgf@circ@bipole@path{capacitor}{#1}} |
| 171 |
% |
| 172 |
\pgf@circ@bipole@path@base{shape}{}{#1}{#2} |
| 173 |
} |
| 174 |
%% |
| 175 |
%% ultra-generic bipole path |
| 176 |
%% I am not sure what the last argument is needed for, but don't touch it or everything explodes |
| 177 |
%% |
| 178 |
\def\pgf@circ@bipole@path@base#1#2#3#4{% |
| 179 |
% |
| 180 |
% Create a path-style component based on a node-style shape |
| 181 |
% #1: postfix to be added to the name path to obtain the main shape name |
| 182 |
% #2: text to be passed as text to the node |
| 183 |
% #3: name of the bipole component |
| 184 |
% #4: this will be filled by the argument of the to-path |
| 185 |
% |
| 186 |
\pgfextra{ |
| 187 |
\ctikzset{bipole/kind = #3} |
| 188 |
\edef\pgf@temp{\ctikzvalof{bipole/name}} |
| 189 |
\def\pgf@circ@temp{} |
| 190 |
\ifx\pgf@temp\pgf@circ@temp % if it has not a name |
| 191 |
\pgfmathrandominteger{\pgf@circ@rand}{1000}{9999} |
| 192 |
\ctikzset{bipole/name = pgfcirc@#3\pgf@circ@rand} % create it (re-usage should not create problem, but...) |
| 193 |
\edef\pgfcirc@a@prefix{pgfcirc}% do not pollute the namespace for nothing |
| 194 |
\edef\pgfcirc@m@prefix{pgfcirc}% do not pollute the namespace for nothing |
| 195 |
\else |
| 196 |
\edef\pgfcirc@a@prefix{\ctikzvalof{bipole/name}}% for exporting v-i-f anchors; use in nodes |
| 197 |
% for exporting supporting macros, need name prefix |
| 198 |
\edef\pgfcirc@m@prefix{\pgfkeysvalueof{/tikz/name prefix}\ctikzvalof{bipole/name}} |
| 199 |
\fi |
| 200 |
} |
| 201 |
% save start and stop values |
| 202 |
% notice that we DO NOT MOVE the path position at all! |
| 203 |
coordinate (\ctikzvalof{bipole/name}start) at (\tikztostart) |
| 204 |
coordinate (\ctikzvalof{bipole/name}end) at (\tikztotarget) |
| 205 |
\pgfextra{ |
| 206 |
% find the direction (angle) of the path |
| 207 |
\pgfmathanglebetweenpoints{\pgfpointanchor{\pgfkeysvalueof{/tikz/name prefix}\ctikzvalof{bipole/name}start}{center}} |
| 208 |
{\pgfpointanchor{\pgfkeysvalueof{/tikz/name prefix}\ctikzvalof{bipole/name}end}{center}} |
| 209 |
\edef\pgf@circ@direction{\pgfmathresult} |
| 210 |
% the global macro pgfcirc@whatever-direction is accessible as \ctikzgetdirection{whatever} |
| 211 |
% this gives access to the element path direction |
| 212 |
\expandafter\xdef\csname pgfcirc@\pgfcirc@m@prefix-direction\endcsname{\pgf@circ@direction} |
| 213 |
} |
| 214 |
% position the component in the middle of the path. We DO NOT MOVE the current position! |
| 215 |
node[#3#1, rotate=\pgf@circ@direction, yscale=\ctikzvalof{mirror value}, |
| 216 |
xscale=\ctikzvalof{invert value}] (\ctikzvalof{bipole/name}) |
| 217 |
at ($(\tikztostart) ! .5 ! (\tikztotarget)$) {#2} |
| 218 |
% set start and end labels |
| 219 |
\ifpgf@circuit@bipole@inverted |
| 220 |
\ifcsname pgf@anchor@#3#1@pathstart\endcsname%if special path-anchors are defined, use them! |
| 221 |
coordinate (pgfcirc@anchorstartnode) at (\ctikzvalof{bipole/name}.pathend) |
| 222 |
coordinate (pgfcirc@anchorendnode) at (\ctikzvalof{bipole/name}.pathstart) |
| 223 |
\else |
| 224 |
coordinate (pgfcirc@anchorstartnode) at (\ctikzvalof{bipole/name}.right) |
| 225 |
coordinate (pgfcirc@anchorendnode) at (\ctikzvalof{bipole/name}.left) |
| 226 |
\fi |
| 227 |
\else |
| 228 |
\ifcsname pgf@anchor@#3#1@pathstart\endcsname%if special path-anchors are defined, use them! |
| 229 |
coordinate (pgfcirc@anchorstartnode) at (\ctikzvalof{bipole/name}.pathstart) |
| 230 |
coordinate (pgfcirc@anchorendnode) at (\ctikzvalof{bipole/name}.pathend) |
| 231 |
\else |
| 232 |
coordinate (pgfcirc@anchorstartnode) at (\ctikzvalof{bipole/name}.left) |
| 233 |
coordinate (pgfcirc@anchorendnode) at (\ctikzvalof{bipole/name}.right) |
| 234 |
\fi |
| 235 |
\fi |
| 236 |
% draw the leads unless it's an open circuit |
| 237 |
% stop at the component |
| 238 |
\pgfextra{\def\pgf@temp{open}\def\pgf@circ@temp{#3}} |
| 239 |
\ifx\pgf@temp\pgf@circ@temp % if it is an open do nothing |
| 240 |
\else |
| 241 |
% it is important to start the path with -- to have correct line joins! |
| 242 |
-- (pgfcirc@anchorstartnode) |
| 243 |
\fi |
| 244 |
% Add all the "ornaments": labels, annotations, voltages, currents and flows |
| 245 |
\drawpoles |
| 246 |
\pgf@circ@ifkeyempty{bipole/label/name}\else\pgf@circ@drawlabels{label}\fi |
| 247 |
\pgf@circ@ifkeyempty{bipole/annotation/name}\else\pgf@circ@drawlabels{annotation}\fi |
| 248 |
% the following must be made in their own path scope to avoid crash in TikZ 3.1.8/3.1.8a |
| 249 |
% it should be logically safe for older version too --- even if TikZ reverted the change |
| 250 |
% use explandable ifs too, thanks to Henri Menke |
| 251 |
{\pgfcirc@if@has@v{\pgf@circ@drawvoltage}{}}% |
| 252 |
{\pgfcirc@if@has@i{\pgf@circ@drawcurrent}{}}% |
| 253 |
{\pgfcirc@if@has@f{\pgf@circ@drawflow}{}}% |
| 254 |
% finish the path from the component to the final target |
| 255 |
% you never know --- re-set \pgf@temp to detect open |
| 256 |
\pgfextra{\def\pgf@temp{open}\def\pgf@circ@temp{#3}} |
| 257 |
\ifx\pgf@temp\pgf@circ@temp % if it is an open do nothing |
| 258 |
(\tikztotarget) |
| 259 |
\else |
| 260 |
(pgfcirc@anchorendnode) -- (\tikztotarget) |
| 261 |
\fi |
| 262 |
% reset internal circuit keys |
| 263 |
\pgfextra{\pgfcircresetpath} |
| 264 |
%draw pending nodes an path |
| 265 |
\tikztonodes |
| 266 |
} |
| 267 |
|
| 268 |
%% Macros for path and style activation for bipoles or path-style |
| 269 |
|
| 270 |
\def\comnpatname{\ifpgf@circuit@compat *\else\fi} |
| 271 |
\def\compattikzset#1{% |
| 272 |
% \typeout{BIPOLEDEF:\space \detokenize{#1}}% |
| 273 |
\tikzset{\comnpatname#1}} |
| 274 |
% |
| 275 |
% this is used for components that are mainly node-style but have a path-style form |
| 276 |
% |
| 277 |
\def\pgfcirc@node@to@path#1#2#3{% |
| 278 |
% add a path-style component based on a node-style one without mangling the name |
| 279 |
% of the shape. |
| 280 |
% #1: node-type shape name (existing) |
| 281 |
% #2: path-type name (to be created) |
| 282 |
% #3: additional options to add to the path style |
| 283 |
% |
| 284 |
\expandafter\def\csname pgf@circ@#1@path\endcsname##1{\pgf@circ@bipole@path@base{}{##1}{#1}{}}% |
| 285 |
\compattikzset{#2/.style = {\circuitikzbasekey, |
| 286 |
/tikz/to path=\csname pgf@circ@#1@path\endcsname{##1}, |
| 287 |
#3}}% |
| 288 |
\ctikzset{bipoles/#1/height/.initial=1}% |
| 289 |
} |
| 290 |
% |
| 291 |
% this one is for normal definition: path to style, directly |
| 292 |
% the first parameter (#1) here is l,v,i (l=..., v=..., i=...) |
| 293 |
% the last parameter are options to be inserted in the "to path" definition |
| 294 |
% |
| 295 |
\def\pgfcirc@path@to@style#1#2#3#4{% using #1 as label, assign \pgf@circ@#2@path to style #3 |
| 296 |
\compattikzset{#3/.style={\circuitikzbasekey, #4, /tikz/to path=\csname pgf@circ@#2@path\endcsname, #1={##1}}}% |
| 297 |
} |
| 298 |
% this one create a alias style from a node definition |
| 299 |
\def\pgfcirc@node@to@style#1#2#3#4{% using #1 as label, assign \pgf@circ@bipole@path{#2} to style #3 |
| 300 |
\compattikzset{#3/.style={\circuitikzbasekey, #4, /tikz/to path=\pgf@circ@bipole@path{#2}, #1={##1}}}% |
| 301 |
} |
| 302 |
% this create an alias style |
| 303 |
\def\pgfcirc@style@to@style#1#2{% alias style #1 to style #2 |
| 304 |
\compattikzset{#2/.style={\comnpatname #1={##1}}}% |
| 305 |
} |
| 306 |
% this create an alias style, changing the labelling |
| 307 |
\def\pgfcirc@style@to@style@label#1#2#3{% alias style #1 to style #2 |
| 308 |
\compattikzset{#2/.style={\comnpatname #1, #3={##1}}}% |
| 309 |
} |
| 310 |
% create a bipole |
| 311 |
\def\pgfcirc@activate@bipole#1#2#3#4{% type of label, path name, base node name, style name |
| 312 |
% \typeout{Activate bipole:\space #4,} |
| 313 |
\expandafter\def\csname pgf@circ@#2@path\endcsname##1{\pgf@circ@bipole@path{#3}{##1}}% |
| 314 |
\pgfcirc@path@to@style{#1}{#2}{#4}{}% no options here, let's see |
| 315 |
} |
| 316 |
\def\pgfcirc@activate@bipole@simple#1#2{\pgfcirc@activate@bipole{#1}{#2}{#2}{#2}} |
| 317 |
% create a bipole with options |
| 318 |
\def\pgfcirc@activate@bipole@opt#1#2#3#4#5{% type of label, path name, base node name, style name, options |
| 319 |
% \typeout{Activate bipole:\space #4,} |
| 320 |
\expandafter\def\csname pgf@circ@#2@path\endcsname##1{\pgf@circ@bipole@path{#3}{##1}}% |
| 321 |
\pgfcirc@path@to@style{#1}{#2}{#4}{#5}% no options here, let's see |
| 322 |
} |
| 323 |
\def\pgfcirc@activate@bipole@simple@opt#1#2#3{\pgfcirc@activate@bipole@opt{#1}{#2}{#2}{#2}{#3}} |
| 324 |
|
| 325 |
|
| 326 |
%% New system, for simple object |
| 327 |
%% \pgfcirc@activate@bipole@simple{l}{mass} |
| 328 |
%% New system, different names |
| 329 |
%% The old system is the following |
| 330 |
%% 1 - define just the pgf@circ@path@whatever#1 |
| 331 |
%% (see for example the variable one) |
| 332 |
%% 2 - set the style |
| 333 |
%% \compattikzset{resistor/.style= {\circuitikzbasekey, /tikz/to path=\pgf@circ@resistor@path, l={#1}}} |
| 334 |
|
| 335 |
%% Path definition with the new mechanism have been moved to where the nodes |
| 336 |
%% are defined. |
| 337 |
|
| 338 |
%% Handling of terminals%<<< |
| 339 |
|
| 340 |
\ctikzset{bipole/nodes/.is family} |
| 341 |
\ctikzset{bipole/nodes/left/.initial=none} |
| 342 |
\ctikzset{bipole/nodes/right/.initial=none} |
| 343 |
\tikzset{bipole nodes/.style n args={2}{% |
| 344 |
\circuitikzbasekey/bipole/nodes/left=#1, |
| 345 |
\circuitikzbasekey/bipole/nodes/right=#2% |
| 346 |
} |
| 347 |
} |
| 348 |
|
| 349 |
%% Easily usable styles |
| 350 |
|
| 351 |
\ctikzset{o-o/.style = {\circuitikzbasekey/bipole/nodes/left=ocirc, \circuitikzbasekey/bipole/nodes/right=ocirc}} |
| 352 |
\ctikzset{-o/.style = {\circuitikzbasekey/bipole/nodes/left=none, \circuitikzbasekey/bipole/nodes/right=ocirc}} |
| 353 |
\ctikzset{o-/.style = {\circuitikzbasekey/bipole/nodes/left=ocirc, \circuitikzbasekey/bipole/nodes/right=none}} |
| 354 |
\ctikzset{*-o/.style = {\circuitikzbasekey/bipole/nodes/left=circ, \circuitikzbasekey/bipole/nodes/right=ocirc}} |
| 355 |
\ctikzset{o-*/.style = {\circuitikzbasekey/bipole/nodes/left=ocirc, \circuitikzbasekey/bipole/nodes/right=circ}} |
| 356 |
\ctikzset{d-o/.style = {\circuitikzbasekey/bipole/nodes/left=diamondpole, \circuitikzbasekey/bipole/nodes/right=ocirc}} |
| 357 |
\ctikzset{o-d/.style = {\circuitikzbasekey/bipole/nodes/left=ocirc, \circuitikzbasekey/bipole/nodes/right=diamondpole}} |
| 358 |
\ctikzset{*-/.style = {\circuitikzbasekey/bipole/nodes/left=circ, \circuitikzbasekey/bipole/nodes/right=none}} |
| 359 |
\ctikzset{-*/.style = {\circuitikzbasekey/bipole/nodes/left=none, \circuitikzbasekey/bipole/nodes/right=circ}} |
| 360 |
\ctikzset{d-/.style = {\circuitikzbasekey/bipole/nodes/left=diamondpole, \circuitikzbasekey/bipole/nodes/right=none}} |
| 361 |
\ctikzset{-d/.style = {\circuitikzbasekey/bipole/nodes/left=none, \circuitikzbasekey/bipole/nodes/right=diamondpole}} |
| 362 |
\ctikzset{*-*/.style = {\circuitikzbasekey/bipole/nodes/left=circ, \circuitikzbasekey/bipole/nodes/right=circ}} |
| 363 |
\ctikzset{d-*/.style = {\circuitikzbasekey/bipole/nodes/left=diamondpole, \circuitikzbasekey/bipole/nodes/right=circ}} |
| 364 |
\ctikzset{*-d/.style = {\circuitikzbasekey/bipole/nodes/left=circ, \circuitikzbasekey/bipole/nodes/right=diamondpole}} |
| 365 |
\ctikzset{d-d/.style = {\circuitikzbasekey/bipole/nodes/left=diamondpole, \circuitikzbasekey/bipole/nodes/right=diamondpole}} |
| 366 |
|
| 367 |
% rectjoinfill workarounds |
| 368 |
|
| 369 |
\ctikzset{.-/.style = {\circuitikzbasekey/bipole/nodes/left=rectjoinfill, \circuitikzbasekey/bipole/nodes/right=none}} |
| 370 |
\ctikzset{.-*/.style = {\circuitikzbasekey/bipole/nodes/left=rectjoinfill, \circuitikzbasekey/bipole/nodes/right=circ}} |
| 371 |
\ctikzset{.-o/.style = {\circuitikzbasekey/bipole/nodes/left=rectjoinfill, \circuitikzbasekey/bipole/nodes/right=ocirc}} |
| 372 |
\ctikzset{.-d/.style = {\circuitikzbasekey/bipole/nodes/left=rectjoinfill, \circuitikzbasekey/bipole/nodes/right=diamondpole}} |
| 373 |
\ctikzset{-./.style = {\circuitikzbasekey/bipole/nodes/left=none, \circuitikzbasekey/bipole/nodes/right=rectjoinfill}} |
| 374 |
\ctikzset{o-./.style = {\circuitikzbasekey/bipole/nodes/left=ocirc, \circuitikzbasekey/bipole/nodes/right=rectjoinfill}} |
| 375 |
\ctikzset{*-./.style = {\circuitikzbasekey/bipole/nodes/left=circ, \circuitikzbasekey/bipole/nodes/right=rectjoinfill}} |
| 376 |
\ctikzset{d-./.style = {\circuitikzbasekey/bipole/nodes/left=diamondpole, \circuitikzbasekey/bipole/nodes/right=rectjoinfill}} |
| 377 |
\ctikzset{.-./.style = {\circuitikzbasekey/bipole/nodes/left=rectjoinfill, \circuitikzbasekey/bipole/nodes/right=rectjoinfill}} |
| 378 |
|
| 379 |
\tikzset{reversed/.style = {\circuitikzbasekey/bipole/inverted=true}} |
| 380 |
|
| 381 |
\def\drawpoles{ |
| 382 |
\pgfextra{ \edef\pgf@circ@temp{\ctikzvalof{bipole/nodes/left}} \def\pgf@temp{none}} |
| 383 |
\ifx\pgf@temp\pgf@circ@temp\else(\tikztostart) node[\pgf@circ@temp] {}\fi |
| 384 |
\pgfextra{ \edef\pgf@circ@temp{\ctikzvalof{bipole/nodes/right}} } |
| 385 |
\ifx\pgf@temp\pgf@circ@temp\else(\tikztotarget) node[\pgf@circ@temp] {}\fi |
| 386 |
} |
| 387 |
% %>>> |
| 388 |
|
| 389 |
%% |
| 390 |
%% Definition of path for transistors |
| 391 |
%% |
| 392 |
% Transistor like bipoles |
| 393 |
|
| 394 |
\def\pgf@circ@trans@path#1#2{ |
| 395 |
\pgfextra{ |
| 396 |
\edef\pgf@temp{\ctikzvalof{bipole/name}} |
| 397 |
\def\pgf@circ@temp{#2} |
| 398 |
\ifx\pgf@temp\pgf@circ@temp % if it has not a name |
| 399 |
\pgfmathrandominteger{\pgf@circ@rand}{1000}{9999} |
| 400 |
\ctikzset{bipole/name = trans\pgf@circ@rand} % create it |
| 401 |
\fi |
| 402 |
} |
| 403 |
\ifpgf@circuit@bipole@inverted |
| 404 |
(\tikztostart) node[coordinate] (\ctikzvalof{bipole/name}end) {} |
| 405 |
(\tikztotarget) node[coordinate] (\ctikzvalof{bipole/name}start) {} |
| 406 |
\else |
| 407 |
(\tikztostart) node[coordinate] (\ctikzvalof{bipole/name}start) {} |
| 408 |
(\tikztotarget) node[coordinate] (\ctikzvalof{bipole/name}end) {} |
| 409 |
\fi |
| 410 |
\pgfextra{ |
| 411 |
\pgfmathanglebetweenpoints{\pgfpointanchor{\ctikzvalof{bipole/name}start}{center}} |
| 412 |
{\pgfpointanchor{\ctikzvalof{bipole/name}end}{center}} |
| 413 |
\pgfmathadd{\pgfmathresult}{-90} |
| 414 |
\pgfmathround{\pgfmathresult} |
| 415 |
\edef\pgf@circ@direction{\pgfmathresult} |
| 416 |
} |
| 417 |
($(\tikztostart) ! .5 ! (\tikztotarget)$) |
| 418 |
node[#1, /tikz/rotate=\pgf@circ@direction, xscale=\ctikzvalof{mirror value}] |
| 419 |
(\ctikzvalof{bipole/name}) {} |
| 420 |
node {\ctikzvalof{bipole/label/name}} |
| 421 |
\ifcsname pgf@anchor@#1@pathstart\endcsname%if special path-anchors are defined, use them! |
| 422 |
(\ctikzvalof{bipole/name}start.center) --(\ctikzvalof{bipole/name}.pathstart) |
| 423 |
(\ctikzvalof{bipole/name}.pathend) -- (\ctikzvalof{bipole/name}end.center) |
| 424 |
\else |
| 425 |
(\ctikzvalof{bipole/name}start.center) --(\ctikzvalof{bipole/name}.left) |
| 426 |
(\ctikzvalof{bipole/name}.right) -- (\ctikzvalof{bipole/name}end.center) |
| 427 |
\fi |
| 428 |
\drawpoles |
| 429 |
\pgfextra{ |
| 430 |
\pgfcircresetpath |
| 431 |
} |
| 432 |
(\tikztotarget) \tikztonodes % and go on! |
| 433 |
} |
| 434 |
|
| 435 |
\def\pgf@circ@definetranspath#1{ |
| 436 |
\compattikzset{T#1/.style = {\circuitikzbasekey, /tikz/to path=\pgf@circ@trans@path{#1}{}, l=##1}} |
| 437 |
} |
| 438 |
|
| 439 |
% |
| 440 |
% vim: set fdm=marker fmr=%<<<,%>>>: |