diff options
Diffstat (limited to 'graphics/pgf/contrib/circuitikz/tex/pgfcircshapes.tex')
-rw-r--r-- | graphics/pgf/contrib/circuitikz/tex/pgfcircshapes.tex | 735 |
1 files changed, 401 insertions, 334 deletions
diff --git a/graphics/pgf/contrib/circuitikz/tex/pgfcircshapes.tex b/graphics/pgf/contrib/circuitikz/tex/pgfcircshapes.tex index f489ac58e6..ca5e2b00a8 100644 --- a/graphics/pgf/contrib/circuitikz/tex/pgfcircshapes.tex +++ b/graphics/pgf/contrib/circuitikz/tex/pgfcircshapes.tex @@ -9,30 +9,30 @@ % 2. under the GNU Public License. % % See the files gpl-3.0_license.txt and lppl-1-3c_license.txt for more details. +% +% This file has folding marks for vim (See last line). +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Other shapes -%% Nothing +%% Nothing: empty shape%<<< \pgfdeclareshape{emptyshape}{ \savedanchor{\northeast}{% \pgf@x=.5\wd\pgfnodeparttextbox% \pgf@y=.5\ht\pgfnodeparttextbox% } - \anchor{north}{\northeast\pgf@x=0cm\relax} - \anchor{east}{\northeast\pgf@y=0cm\relax} - \anchor{south}{\northeast\pgf@y=-\pgf@y \pgf@x=0cm\relax} - \anchor{west}{\northeast\pgf@y=0cm\pgf@x=-\pgf@x} - \anchor{north east}{\northeast} - \anchor{north west}{\northeast\pgf@x=-\pgf@x} - \anchor{south east}{\northeast\pgf@y=-\pgf@y} - \anchor{south west}{\northeast\pgf@y=-\pgf@y\pgf@x=-\pgf@x} + % geo anchors based on north-east + \pgfcirc@northeast@symmetric@geoanchors \anchor{text}{\pgfpoint{-.5\wd\pgfnodeparttextbox}{\dimexpr.5\dp\pgfnodeparttextbox-.5\ht\pgfnodeparttextbox}} \anchor{center}{ \pgfpointorigin } -} +}% +%>>> + +%% Poles%<<< % % Provision for changing opacity. Only expert use, see the manual. % @@ -43,6 +43,7 @@ \ctikzset{poles/full fill opacity/.initial=1.0}% better not touch it \tikzset{full poles opacity/.code={% \ctikzset{poles/full fill opacity=#1}% + }} % @@ -62,31 +63,20 @@ \pgf@x=-\pgf@y } \anchor{center}{ \pgf@y=0pt \pgf@x=0pt } - \anchor{east}{ \northwest \pgf@y=0pt \pgf@x=-\pgf@x } - \anchor{e}{ \northwest \pgf@y=0pt \pgf@x=-\pgf@x } - \anchor{west}{ \northwest \pgf@y=0pt } - \anchor{w}{ \northwest \pgf@y=0pt } - \anchor{south}{ \northwest \pgf@x=0pt \pgf@y=-\pgf@y } - \anchor{s}{ \northwest \pgf@x=0pt \pgf@y=-\pgf@y } - \anchor{north}{ \northwest \pgf@x=0pt } - \anchor{n}{ \northwest \pgf@x=0pt } - \anchor{south west}{ \northwest \pgf@y=-\pgf@y } - \anchor{north east}{ \northwest \pgf@x=-\pgf@x } - \anchor{north west}{ \northwest } - \anchor{south east}{ \northwest \pgf@x=-\pgf@x \pgf@y=-\pgf@y } + % geo anchors based on north-west + \pgfcirc@northwest@symmetric@geoanchors \anchorborder{ \pgf@circ@res@left=\pgf@x \pgf@circ@res@up=\pgf@y \pgfpointborderellipse{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up} }{\pgfpoint{\ctikzvalof{nodes width}*\pgf@circ@Rlen}{\ctikzvalof{nodes width}*\pgf@circ@Rlen}} } - \behindforegroundpath{ - \pgfscope + \pgf@circ@draw@component{ \pgfpathcircle{\pgfpointorigin}{\ctikzvalof{nodes width}*\pgf@circ@Rlen} - \pgfsetcolor{\ctikzvalof{color}} + \pgf@circ@setcolor + \pgf@circ@fill@strokecolor \pgfsetfillopacity{\ctikzvalof{poles/full fill opacity}}% normally 1.0 \pgfusepath{draw,fill} - \endpgfscope } } @@ -101,41 +91,29 @@ \pgf@x=-\pgf@y } \anchor{center}{ \pgf@y=0pt \pgf@x=0pt } - \anchor{east}{ \northwest \pgf@y=0pt \pgf@x=-\pgf@x } - \anchor{e}{ \northwest \pgf@y=0pt \pgf@x=-\pgf@x } - \anchor{west}{ \northwest \pgf@y=0pt } - \anchor{w}{ \northwest \pgf@y=0pt } - \anchor{south}{ \northwest \pgf@x=0pt \pgf@y=-\pgf@y } - \anchor{s}{ \northwest \pgf@x=0pt \pgf@y=-\pgf@y } - \anchor{north}{ \northwest \pgf@x=0pt } - \anchor{n}{ \northwest \pgf@x=0pt } - \anchor{south west}{ \northwest \pgf@y=-\pgf@y } - \anchor{north east}{ \northwest \pgf@x=-\pgf@x } - \anchor{north west}{ \northwest } - \anchor{south east}{ \northwest \pgf@x=-\pgf@x \pgf@y=-\pgf@y } + % geo anchors based on north-west + \pgfcirc@northwest@symmetric@geoanchors \anchorborder{ \pgf@circ@res@left=\pgf@x \pgf@circ@res@up=\pgf@y \pgfpointborderellipse{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up} }{\pgfpoint{\ctikzvalof{nodes width}*\pgf@circ@Rlen}{\ctikzvalof{nodes width}*\pgf@circ@Rlen}} } - \behindforegroundpath{ - \pgfscope - \pgfpathcircle{\pgfpointorigin}{\ctikzvalof{nodes width}*\pgf@circ@Rlen} - \pgfsetcolor{\ctikzvalof{color}} - \pgfsetfillopacity{\ctikzvalof{poles/open fill opacity}}% normally 1.0 - \ifx\tikz@fillcolor\pgfutil@empty - % set the default fill color to white - \pgfsetfillcolor{\ctikzvalof{open poles fill}} - % ...but override it if the class is defined! - % note that this element has no class, but will inherit it when used - % into another component - \pgf@circ@setifdefinedfill{draw, fill}{draw, fill} - \else - \pgfsetfillcolor{\tikz@fillcolor} - \fi - \pgfusepath{draw,fill} - \endpgfscope + \pgf@circ@draw@component{ + \pgfpathcircle{\pgfpointorigin}{\ctikzvalof{nodes width}*\pgf@circ@Rlen} + \pgf@circ@setcolor + \pgfsetfillopacity{\ctikzvalof{poles/open fill opacity}}% normally 1.0 + \ifx\tikz@fillcolor\pgfutil@empty + % set the default fill color to white + \pgfsetfillcolor{\ctikzvalof{open poles fill}} + % ...but override it if the class is defined! + % note that this element has no class, but will inherit it when used + % into another component + \pgf@circ@setifdefinedfill{draw, fill}{draw, fill} + \else + \pgfsetfillcolor{\tikz@fillcolor} + \fi + \pgfusepath{draw,fill} } } @@ -150,18 +128,8 @@ \pgf@x=-\pgf@y } \anchor{center}{ \pgf@y=0pt \pgf@x=0pt } - \anchor{east}{ \northwest \pgf@y=0pt \pgf@x=-\pgf@x } - \anchor{e}{ \northwest \pgf@y=0pt \pgf@x=-\pgf@x } - \anchor{west}{ \northwest \pgf@y=0pt } - \anchor{w}{ \northwest \pgf@y=0pt } - \anchor{south}{ \northwest \pgf@x=0pt \pgf@y=-\pgf@y } - \anchor{s}{ \northwest \pgf@x=0pt \pgf@y=-\pgf@y } - \anchor{north}{ \northwest \pgf@x=0pt } - \anchor{n}{ \northwest \pgf@x=0pt } - \anchor{south west}{ \northwest \pgf@y=-\pgf@y } - \anchor{north east}{ \northwest \pgf@x=-\pgf@x } - \anchor{north west}{ \northwest } - \anchor{south east}{ \northwest \pgf@x=-\pgf@x \pgf@y=-\pgf@y } + % geo anchors based on north-west + \pgfcirc@northwest@symmetric@geoanchors \anchorborder{ % \typeout{IN\space X:\the\pgf@x\space Y:\the\pgf@y} \pgfmathsetmacro{\@@switchx}{ifthenelse(\pgf@x>0,1,-1)} @@ -178,17 +146,16 @@ \pgf@x=\@@switchx\pgf@x \pgf@y=\@@switchy\pgf@y } - \behindforegroundpath{ - \pgfscope - \pgfmathsetlength{\pgf@circ@res@temp}{\ctikzvalof{nodes width}*\pgf@circ@Rlen} - \pgftransformrotate{45} - \pgfpathrectanglecorners - {\pgfpoint{-\pgf@circ@res@temp}{-\pgf@circ@res@temp}} - {\pgfpoint{\pgf@circ@res@temp}{\pgf@circ@res@temp}} - \pgfsetcolor{\ctikzvalof{color}} - \pgfsetfillopacity{\ctikzvalof{poles/full fill opacity}}% normally 1.0 - \pgfusepath{draw,fill} - \endpgfscope + \pgf@circ@draw@component{ + \pgfmathsetlength{\pgf@circ@res@temp}{\ctikzvalof{nodes width}*\pgf@circ@Rlen} + \pgftransformrotate{45} + \pgfpathrectanglecorners + {\pgfpoint{-\pgf@circ@res@temp}{-\pgf@circ@res@temp}} + {\pgfpoint{\pgf@circ@res@temp}{\pgf@circ@res@temp}} + \pgf@circ@setcolor + \pgf@circ@fill@strokecolor + \pgfsetfillopacity{\ctikzvalof{poles/full fill opacity}}% normally 1.0 + \pgfusepath{draw,fill} } } @@ -203,18 +170,8 @@ \pgf@x=-\pgf@y } \anchor{center}{ \pgf@y=0pt \pgf@x=0pt } - \anchor{east}{ \northwest \pgf@y=0pt \pgf@x=-\pgf@x } - \anchor{e}{ \northwest \pgf@y=0pt \pgf@x=-\pgf@x } - \anchor{west}{ \northwest \pgf@y=0pt } - \anchor{w}{ \northwest \pgf@y=0pt } - \anchor{south}{ \northwest \pgf@x=0pt \pgf@y=-\pgf@y } - \anchor{s}{ \northwest \pgf@x=0pt \pgf@y=-\pgf@y } - \anchor{north}{ \northwest \pgf@x=0pt } - \anchor{n}{ \northwest \pgf@x=0pt } - \anchor{south west}{ \northwest \pgf@y=-\pgf@y } - \anchor{north east}{ \northwest \pgf@x=-\pgf@x } - \anchor{north west}{ \northwest } - \anchor{south east}{ \northwest \pgf@x=-\pgf@x \pgf@y=-\pgf@y } + % geo anchors based on north-west + \pgfcirc@northwest@symmetric@geoanchors \anchorborder{ % \typeout{IN\space X:\the\pgf@x\space Y:\the\pgf@y} \pgfmathsetmacro{\@@switchx}{ifthenelse(\pgf@x>0,1,-1)} @@ -231,27 +188,25 @@ \pgf@x=\@@switchx\pgf@x \pgf@y=\@@switchy\pgf@y } - \behindforegroundpath{ - \pgfscope - \pgfmathsetlength{\pgf@circ@res@temp}{\ctikzvalof{nodes width}*\pgf@circ@Rlen} - \pgftransformrotate{45} - \pgfpathrectanglecorners - {\pgfpoint{-\pgf@circ@res@temp}{-\pgf@circ@res@temp}} - {\pgfpoint{\pgf@circ@res@temp}{\pgf@circ@res@temp}} - \pgfsetcolor{\ctikzvalof{color}} - \pgfsetfillopacity{\ctikzvalof{poles/open fill opacity}}% normally 1.0 - \ifx\tikz@fillcolor\pgfutil@empty - % set the default fill color to white - \pgfsetfillcolor{\ctikzvalof{open poles fill}} - % ...but override it if the class is defined! - % note that this element has no class, but will inherit it when used - % into another component - \pgf@circ@setifdefinedfill{draw, fill}{draw, fill} - \else - \pgfsetfillcolor{\tikz@fillcolor} - \fi - \pgfusepath{draw,fill} - \endpgfscope + \pgf@circ@draw@component{ + \pgfmathsetlength{\pgf@circ@res@temp}{\ctikzvalof{nodes width}*\pgf@circ@Rlen} + \pgftransformrotate{45} + \pgfpathrectanglecorners + {\pgfpoint{-\pgf@circ@res@temp}{-\pgf@circ@res@temp}} + {\pgfpoint{\pgf@circ@res@temp}{\pgf@circ@res@temp}} + \pgf@circ@setcolor + \pgfsetfillopacity{\ctikzvalof{poles/open fill opacity}}% normally 1.0 + \ifx\tikz@fillcolor\pgfutil@empty + % set the default fill color to white + \pgfsetfillcolor{\ctikzvalof{open poles fill}} + % ...but override it if the class is defined! + % note that this element has no class, but will inherit it when used + % into another component + \pgf@circ@setifdefinedfill{draw, fill}{draw, fill} + \else + \pgfsetfillcolor{\tikz@fillcolor} + \fi + \pgfusepath{draw,fill} } } @@ -266,18 +221,8 @@ \pgf@x=-\pgf@y } \anchor{center}{ \pgf@y=0pt \pgf@x=0pt } - \anchor{east}{ \northwest \pgf@y=0pt \pgf@x=-\pgf@x } - \anchor{e}{ \northwest \pgf@y=0pt \pgf@x=-\pgf@x } - \anchor{west}{ \northwest \pgf@y=0pt } - \anchor{w}{ \northwest \pgf@y=0pt } - \anchor{south}{ \northwest \pgf@x=0pt \pgf@y=-\pgf@y } - \anchor{s}{ \northwest \pgf@x=0pt \pgf@y=-\pgf@y } - \anchor{north}{ \northwest \pgf@x=0pt } - \anchor{n}{ \northwest \pgf@x=0pt } - \anchor{south west}{ \northwest \pgf@y=-\pgf@y } - \anchor{north east}{ \northwest \pgf@x=-\pgf@x } - \anchor{north west}{ \northwest } - \anchor{south east}{ \northwest \pgf@x=-\pgf@x \pgf@y=-\pgf@y } + % geo anchors based on north-west + \pgfcirc@northwest@symmetric@geoanchors \anchorborder{ \pgf@xa=\pgf@x \pgf@ya=\pgf@y @@ -286,16 +231,15 @@ {\pgfqpoint{\pgf@xa}{\pgf@ya}} {\pgfqpoint{\pgf@circ@res@up}{\pgf@circ@res@up}} } - \behindforegroundpath{ - \pgfscope - \pgfmathsetlength{\pgf@circ@res@temp}{\ctikzvalof{nodes width}*\pgf@circ@Rlen} - \pgfpathrectanglecorners - {\pgfpoint{-\pgf@circ@res@temp}{-\pgf@circ@res@temp}} - {\pgfpoint{\pgf@circ@res@temp}{\pgf@circ@res@temp}} - \pgfsetcolor{\ctikzvalof{color}} - \pgfsetfillopacity{\ctikzvalof{poles/full fill opacity}}% normally 1.0 - \pgfusepath{draw,fill} - \endpgfscope + \pgf@circ@draw@component{ + \pgfmathsetlength{\pgf@circ@res@temp}{\ctikzvalof{nodes width}*\pgf@circ@Rlen} + \pgfpathrectanglecorners + {\pgfpoint{-\pgf@circ@res@temp}{-\pgf@circ@res@temp}} + {\pgfpoint{\pgf@circ@res@temp}{\pgf@circ@res@temp}} + \pgf@circ@setcolor + \pgf@circ@fill@strokecolor + \pgfsetfillopacity{\ctikzvalof{poles/full fill opacity}}% normally 1.0 + \pgfusepath{draw,fill} } } %% square terminal, unfilled @@ -309,18 +253,8 @@ \pgf@x=-\pgf@y } \anchor{center}{ \pgf@y=0pt \pgf@x=0pt } - \anchor{east}{ \northwest \pgf@y=0pt \pgf@x=-\pgf@x } - \anchor{e}{ \northwest \pgf@y=0pt \pgf@x=-\pgf@x } - \anchor{west}{ \northwest \pgf@y=0pt } - \anchor{w}{ \northwest \pgf@y=0pt } - \anchor{south}{ \northwest \pgf@x=0pt \pgf@y=-\pgf@y } - \anchor{s}{ \northwest \pgf@x=0pt \pgf@y=-\pgf@y } - \anchor{north}{ \northwest \pgf@x=0pt } - \anchor{n}{ \northwest \pgf@x=0pt } - \anchor{south west}{ \northwest \pgf@y=-\pgf@y } - \anchor{north east}{ \northwest \pgf@x=-\pgf@x } - \anchor{north west}{ \northwest } - \anchor{south east}{ \northwest \pgf@x=-\pgf@x \pgf@y=-\pgf@y } + % geo anchors based on north-west + \pgfcirc@northwest@symmetric@geoanchors \anchorborder{ \pgf@xa=\pgf@x \pgf@ya=\pgf@y @@ -329,99 +263,24 @@ {\pgfqpoint{\pgf@xa}{\pgf@ya}} {\pgfqpoint{\pgf@circ@res@up}{\pgf@circ@res@up}} } - \behindforegroundpath{ - \pgfscope - \pgfmathsetlength{\pgf@circ@res@temp}{\ctikzvalof{nodes width}*\pgf@circ@Rlen} - \pgfpathrectanglecorners - {\pgfpoint{-\pgf@circ@res@temp}{-\pgf@circ@res@temp}} - {\pgfpoint{\pgf@circ@res@temp}{\pgf@circ@res@temp}} - \pgfsetcolor{\ctikzvalof{color}} - \pgfsetfillopacity{\ctikzvalof{poles/open fill opacity}}% normally 1.0 - \ifx\tikz@fillcolor\pgfutil@empty - % set the default fill color to white - \pgfsetfillcolor{\ctikzvalof{open poles fill}} - % ...but override it if the class is defined! - % note that this element has no class, but will inherit it when used - % into another component - \pgf@circ@setifdefinedfill{draw, fill}{draw, fill} - \else - \pgfsetfillcolor{\tikz@fillcolor} - \fi - \pgfusepath{draw,fill} - \endpgfscope - } -} -% BNC connector - -\pgfdeclareshape{bnc}{ - \anchor{center}{ - \pgfpointorigin - } - % BNC size is 2.5 times the size of the internal "ocirc" - \savedanchor\northwest{% - \pgf@y=\ctikzvalof{nodes width}\pgf@circ@Rlen - \pgf@y=2.5\pgf@y - \pgf@x=-\pgf@y - } - % center is on the opening - \anchor{center}{ \northwest \pgf@y=0pt \pgf@x=-\pgf@x } - \anchor{zero}{ \pgfpointorigin } - \anchor{hot}{ \northwest \pgf@y=0pt \pgf@x=-\pgf@x } - \anchor{shield}{ \northwest \pgf@x=0pt \pgf@y=-\pgf@y } - % geo-anchors - \anchor{east}{ \northwest \pgf@y=0pt \pgf@x=-\pgf@x } - \anchor{right}{ \northwest \pgf@y=0pt \pgf@x=-\pgf@x } - \anchor{west}{ \northwest \pgf@y=0pt } - \anchor{left}{ \northwest \pgf@y=0pt } - \anchor{south}{ \northwest \pgf@x=0pt \pgf@y=-\pgf@y } - \anchor{north}{ \northwest \pgf@x=0pt } - \anchor{south west}{ \northwest \pgf@y=-\pgf@y } - \anchor{north east}{ \northwest \pgf@x=-\pgf@x } - \anchor{north west}{ \northwest } - \anchor{south east}{ \northwest \pgf@x=-\pgf@x \pgf@y=-\pgf@y } - % put the node text above and centered - \anchor{text}{\pgfextracty{\pgf@circ@res@up}{\northwest} - \pgfpoint{-.5\wd\pgfnodeparttextbox}{ - \dimexpr.5\dp\pgfnodeparttextbox+.5\ht\pgfnodeparttextbox+\pgf@circ@res@up\relax - } - } - \anchorborder{ - \pgf@circ@res@left=\pgf@x - \pgf@circ@res@up=\pgf@y - \pgfpointborderellipse{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up} - }{\pgfpoint{2.5*\ctikzvalof{nodes width}*\pgf@circ@Rlen}{2.5*\ctikzvalof{nodes width}*\pgf@circ@Rlen}} - } - \behindforegroundpath{ - \pgfextracty{\pgf@circ@res@other}{\northwest} - \pgf@circ@res@step=\ctikzvalof{nodes width}\pgf@circ@Rlen - \pgfscope - \pgfstartlinewidth=\pgflinewidth - \pgf@circ@setlinewidth{bipoles}{\pgflinewidth} - \pgfsetcolor{\ctikzvalof{color}} - % external circle - \pgfscope - % clipping path: first a rectangle bigger then the shape - % to avoid problems with the line thickness - \pgfpathrectanglecorners{\pgfpoint{-2\pgf@circ@res@other}{-2\pgf@circ@res@other}} - {\pgfpoint{2\pgf@circ@res@other}{2\pgf@circ@res@other}} - % next the opening to the right - \pgfpathrectanglecorners{\pgfpoint{-\pgf@circ@res@step}{-\pgf@circ@res@step}} - {\pgfpoint{2\pgf@circ@res@other}{\pgf@circ@res@step}} - % do the difference and clip before drawing - \pgfseteorule - \pgfusepath{clip} - \pgfpathcircle{\pgfpointorigin}{\pgf@circ@res@other} - \pgfusepath{draw} - \endpgfscope - % internal circle - \pgfpathcircle{\pgfpointorigin}{\pgf@circ@res@step} - \pgf@circ@draworfill - % and the contact line to the right - \pgfsetlinewidth{\pgfstartlinewidth} - \pgfpathmoveto{\pgfpoint{\pgf@circ@res@step}{0pt}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{0pt}} - \pgfusepath{draw} - \endpgfscope + \pgf@circ@draw@component{ + \pgfmathsetlength{\pgf@circ@res@temp}{\ctikzvalof{nodes width}*\pgf@circ@Rlen} + \pgfpathrectanglecorners + {\pgfpoint{-\pgf@circ@res@temp}{-\pgf@circ@res@temp}} + {\pgfpoint{\pgf@circ@res@temp}{\pgf@circ@res@temp}} + \pgf@circ@setcolor + \pgfsetfillopacity{\ctikzvalof{poles/open fill opacity}}% normally 1.0 + \ifx\tikz@fillcolor\pgfutil@empty + % set the default fill color to white + \pgfsetfillcolor{\ctikzvalof{open poles fill}} + % ...but override it if the class is defined! + % note that this element has no class, but will inherit it when used + % into another component + \pgf@circ@setifdefinedfill{draw, fill}{draw, fill} + \else + \pgfsetfillcolor{\tikz@fillcolor} + \fi + \pgfusepath{draw,fill} } } @@ -432,14 +291,8 @@ \pgf@x=.5\pgflinewidth% \pgf@y=.5\pgflinewidth% } - \anchor{north}{\northeast\pgf@x=0cm\relax} - \anchor{east}{\northeast\pgf@y=0cm\relax} - \anchor{south}{\northeast\pgf@y=-\pgf@y \pgf@x=0cm\relax} - \anchor{west}{\northeast\pgf@y=0cm\pgf@x=-\pgf@x} - \anchor{north east}{\northeast} - \anchor{north west}{\northeast\pgf@x=-\pgf@x} - \anchor{south east}{\northeast\pgf@y=-\pgf@y} - \anchor{south west}{\northeast\pgf@y=-\pgf@y\pgf@x=-\pgf@x} + % geo anchors based on north-east + \pgfcirc@northeast@symmetric@geoanchors \anchor{center}{ \pgfpointorigin } @@ -447,17 +300,18 @@ \pgf@circ@res@left=\pgf@x \pgf@circ@res@up=\pgf@y } - \behindforegroundpath{ - \pgfscope - \pgfpathrectanglecorners - {\pgfpoint{0}{.5\pgflinewidth}} - {\pgfpoint{0}{-.5\pgflinewidth}} - \pgfsetcolor{\ctikzvalof{color}} - \pgfusepath{draw,fill} - \endpgfscope + \pgf@circ@draw@component{ + \pgfpathrectanglecorners + {\pgfpoint{0}{.5\pgflinewidth}} + {\pgfpoint{0}{-.5\pgflinewidth}} + \pgf@circ@setcolor + \pgf@circ@fill@strokecolor + \pgfusepath{draw,fill} } } +% %>>> +%% Arrows%<<< %% transistor arrow \def\pgf@circ@find@linescale{ @@ -530,22 +384,20 @@ \pgf@circ@res@temp=\@@factor\pgflinewidth \advance\pgf@x by -.5\pgf@circ@res@temp } - \behindforegroundpath{ - \pgfscope - \northwest - \pgf@circ@res@up=\pgf@y - \pgf@circ@res@left=\pgf@x - \tip - \pgf@circ@res@step = \pgf@x - % - \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}} - \pgfpathlineto{\pgfpoint{1\pgf@circ@res@step}{0pt}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{-\pgf@circ@res@up}} - \pgfpathclose - \pgfsetcolor{\ctikzvalof{color}} - \pgfusepath{fill} % just fill - \endpgfscope + \pgf@circ@draw@component{ + \northwest + \pgf@circ@res@up=\pgf@y + \pgf@circ@res@left=\pgf@x + \tip + \pgf@circ@res@step = \pgf@x + % + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}} + \pgfpathlineto{\pgfpoint{1\pgf@circ@res@step}{0pt}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{-\pgf@circ@res@up}} + \pgfpathclose + \pgf@circ@fill@strokecolor + \pgfusepath{fill} % just fill } } @@ -581,22 +433,21 @@ \divide \pgf@circ@res@step by \ctikzvalof{current arrow scale} \pgf@x =\pgf@circ@res@step } - \behindforegroundpath{ - \pgfscope - \ifpgfcirc@really@draw@currarrow - \pgf@circ@reset@arrows@rounded - \pgf@circ@res@step = \pgf@circ@Rlen - \divide \pgf@circ@res@step by \ctikzvalof{current arrow scale} - - \pgfpathmoveto{\pgfpoint{-.7\pgf@circ@res@step}{0pt}} - \pgfpathlineto{\pgfpoint{-.7\pgf@circ@res@step}{-.8\pgf@circ@res@step}} - \pgfpathlineto{\pgfpoint{1\pgf@circ@res@step}{0pt}} - \pgfpathlineto{\pgfpoint{-.7\pgf@circ@res@step}{.8\pgf@circ@res@step}} - \pgfpathclose - \pgfsetcolor{\ctikzvalof{color}} - \pgfusepath{draw,fill} - \fi - \endpgfscope + \pgf@circ@draw@component{ + \ifpgfcirc@really@draw@currarrow + \pgf@circ@reset@arrows@rounded + \pgf@circ@res@step = \pgf@circ@Rlen + \divide \pgf@circ@res@step by \ctikzvalof{current arrow scale} + + \pgfpathmoveto{\pgfpoint{-.7\pgf@circ@res@step}{0pt}} + \pgfpathlineto{\pgfpoint{-.7\pgf@circ@res@step}{-.8\pgf@circ@res@step}} + \pgfpathlineto{\pgfpoint{1\pgf@circ@res@step}{0pt}} + \pgfpathlineto{\pgfpoint{-.7\pgf@circ@res@step}{.8\pgf@circ@res@step}} + \pgfpathclose + \pgf@circ@setcolor + \pgf@circ@fill@strokecolor + \pgfusepath{draw,fill} + \fi } } @@ -637,20 +488,19 @@ \divide \pgf@circ@res@step by \ctikzvalof{current arrow scale} \pgf@x =\pgf@circ@res@step } - \behindforegroundpath{ - \pgfscope - \ifpgfcirc@really@draw@flowarrow - \pgf@circ@reset@arrows@rounded - \pgf@circ@res@step = \pgf@circ@Rlen - \divide \pgf@circ@res@step by 4 - \pgfpathmoveto{\pgfpoint{-\pgf@circ@res@step}{0pt}} - \pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{0pt}} - \pgfsetcolor{\ctikzvalof{color}} - \pgfusepath{draw} - \pgftransformshift{\pgfpoint{\pgf@circ@res@step}{0pt}} - \pgfnode{currarrow}{tip}{}{}{\pgfusepath{fill}} - \fi - \endpgfscope + \pgf@circ@draw@component{ + \ifpgfcirc@really@draw@flowarrow + \pgf@circ@reset@arrows@rounded + \pgf@circ@res@step = \pgf@circ@Rlen + \divide \pgf@circ@res@step by 4 + \pgfpathmoveto{\pgfpoint{-\pgf@circ@res@step}{0pt}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{0pt}} + \pgf@circ@setcolor + \pgfusepath{draw} + \pgf@circ@fill@strokecolor + \pgftransformshift{\pgfpoint{\pgf@circ@res@step}{0pt}} + \pgfnode{currarrow}{tip}{}{}{\pgfusepath{fill}} + \fi } } @@ -680,39 +530,35 @@ \anchor{tip}{ \tip } - \behindforegroundpath{ - - \pgfscope - \pgf@circ@reset@arrows@rounded - \pgf@circ@res@step = \pgf@circ@Rlen - \divide \pgf@circ@res@step by 16 - \pgfpathmoveto{\pgfpoint{-1.7\pgf@circ@res@step}{0pt}} - \pgfpathlineto{\pgfpoint{-1.7\pgf@circ@res@step}{-.8\pgf@circ@res@step}} - \pgfpathlineto{\pgfpoint{0pt}{0pt}} - \pgfpathlineto{\pgfpoint{-1.7\pgf@circ@res@step}{.8\pgf@circ@res@step}} - \pgfpathclose - \pgfsetcolor{\ctikzvalof{color}} - \pgfusepath{fill} - \endpgfscope + \pgf@circ@draw@component{ + \pgf@circ@reset@arrows@rounded + \pgf@circ@res@step = \pgf@circ@Rlen + \divide \pgf@circ@res@step by 16 + \pgfpathmoveto{\pgfpoint{-1.7\pgf@circ@res@step}{0pt}} + \pgfpathlineto{\pgfpoint{-1.7\pgf@circ@res@step}{-.8\pgf@circ@res@step}} + \pgfpathlineto{\pgfpoint{0pt}{0pt}} + \pgfpathlineto{\pgfpoint{-1.7\pgf@circ@res@step}{.8\pgf@circ@res@step}} + \pgfpathclose + \pgf@circ@setcolor + \pgf@circ@fill@strokecolor + \pgfusepath{fill} } } +% %>>> - +%% boxes%<<< %% box \pgfdeclareshape{box}{ \anchor{center}{ \pgfpointorigin } - \behindforegroundpath{ - - \pgfscope - \pgf@circ@res@step = \ctikzvalof{bipoles/twoport/width}\pgf@circ@Rlen - \pgf@circ@res@step = 0.5\pgf@circ@res@step - \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth} - \pgfpathrectanglecorners{\pgfpoint{-\pgf@circ@res@step}{\pgf@circ@res@step}}{\pgfpoint{\pgf@circ@res@step}{-\pgf@circ@res@step}} - \pgf@circ@draworfill - \endpgfscope + \pgf@circ@draw@component{ + \pgf@circ@res@step = \ctikzvalof{bipoles/twoport/width}\pgf@circ@Rlen + \pgf@circ@res@step = 0.5\pgf@circ@res@step + \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth} + \pgfpathrectanglecorners{\pgfpoint{-\pgf@circ@res@step}{\pgf@circ@res@step}}{\pgfpoint{\pgf@circ@res@step}{-\pgf@circ@res@step}} + \pgf@circ@draworfill } } @@ -723,18 +569,18 @@ \anchor{center}{ \pgfpointorigin } - \behindforegroundpath{ + \pgf@circ@draw@component{ \pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{blocks/scale}\pgf@circ@Rlen} - \pgfscope - \pgf@circ@res@step = \ctikzvalof{bipoles/twoport/width}\pgf@circ@scaled@Rlen - \pgf@circ@res@step = 0.5\pgf@circ@res@step - \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth} - \pgfpathrectanglecorners{\pgfpoint{-\pgf@circ@res@step}{\pgf@circ@res@step}}{\pgfpoint{\pgf@circ@res@step}{-\pgf@circ@res@step}} - \pgf@circ@draworfill - \endpgfscope + \pgf@circ@res@step = \ctikzvalof{bipoles/twoport/width}\pgf@circ@scaled@Rlen + \pgf@circ@res@step = 0.5\pgf@circ@res@step + \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth} + \pgfpathrectanglecorners{\pgfpoint{-\pgf@circ@res@step}{\pgf@circ@res@step}}{\pgfpoint{\pgf@circ@res@step}{-\pgf@circ@res@step}} + \pgf@circ@draworfill } } +% %>>> +%% crossings%<<< % full nodes for wire crossing \pgfdeclareshape{jump crossing} @@ -757,7 +603,7 @@ \anchor{north east}{ \northwest \pgf@x=-\pgf@x } \anchor{north west}{ \northwest } \anchor{south east}{ \northwest \pgf@x=-\pgf@x \pgf@y=-\pgf@y } - \behindbackgroundpath{ + \pgf@circ@draw@component{ \northwest \pgf@circ@res@up = \pgf@y \pgf@circ@res@down = -\pgf@y @@ -798,7 +644,7 @@ \anchor{north east}{ \northwest \pgf@x=-\pgf@x } \anchor{north west}{ \northwest } \anchor{south east}{ \northwest \pgf@x=-\pgf@x \pgf@y=-\pgf@y } - \behindbackgroundpath{ + \pgf@circ@draw@component{ \northwest \pgf@circ@res@up = \pgf@y \pgf@circ@res@down = -\pgf@y @@ -816,5 +662,226 @@ } } +% %>>> + +%% Connectors (BNC and IEC connectors; see https://github.com/circuitikz/circuitikz/issues/611)%<<< + +% define new class +\ctikzset{connectors/scale/.initial=1.0} +\ctikzset{connectors/fill/.initial=none} +\ctikzset{connectors/thickness/.initial=none} +% parameters. To have round sockets, 3*height==2*width +\ctikzset{bipoles/iecconn/height/.initial=.2} +\ctikzset{bipoles/iecconn/width/.initial=.3} +% objects +\pgfcircdeclarebipolescaled{connectors} +{ + \anchor{plug center}{\northeast\pgf@y=0pt\divide\pgf@x by 3 } + \anchor{socket center}{\northeast\pgf@y=0pt\pgf@x=-0.333333\pgf@x} + % put the node text above and centered + \anchor{text}{\pgfextracty{\pgf@circ@res@up}{\northeast} + \pgfpoint{-.5\wd\pgfnodeparttextbox}{ + \dimexpr.5\ht\pgfnodeparttextbox+\pgf@circ@res@up\relax + } + } +} +{\ctikzvalof{bipoles/iecconn/height}}%symmetrical +{iecconn} +{\ctikzvalof{bipoles/iecconn/height}} +{\ctikzvalof{bipoles/iecconn/width}} +{ + \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth} + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left/3}{\pgf@circ@res@up}} + \pgfpatharc{90}{-90}{0.66666\pgf@circ@res@left and \pgf@circ@res@up} + \pgfusepath{draw} + \pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left/3}{\pgf@circ@res@up/2}}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down/2}} + \pgf@circ@fill@strokecolor + \pgfusepath{draw, fill} +} +\pgfcirc@activate@bipole@simple{l}{iecconn} +\pgfcirc@style@to@style{iecconn}{iec connector} + +\long\def\pgfcirc@declare@iecsocket#1#2#3{% #1 name, #2 anchors, #3 drawing code + \pgfdeclareshape{#1}{% + \savedmacro{\ctikzclass}{\edef\ctikzclass{connectors}} + \saveddimen{\scaledRlen}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}} + \savedanchor\northwest{% + \pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} + \pgf@y=\ctikzvalof{bipoles/iecconn/height}\pgf@circ@scaled@Rlen + \pgf@y=.5\pgf@y + \pgf@x=-\ctikzvalof{bipoles/iecconn/width}\pgf@circ@scaled@Rlen + \divide\pgf@x by 6 + } + \pgfcirc@northwest@symmetric@geoanchors + #2% + \pgf@circ@draw@component{% + \pgf@circ@scaled@Rlen=\scaledRlen + \pgfstartlinewidth=\pgflinewidth + \northwest + \pgf@circ@res@up=\pgf@y + \pgf@circ@res@left=\pgf@x + \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth} + #3% + \pgfusepath{draw} + } + } +} + +\long\def\pgfcirc@declare@iecplug#1#2{% #1 name, #2 anchors (drawing code is the same) + \pgfdeclareshape{#1}{% + \savedmacro{\ctikzclass}{\edef\ctikzclass{connectors}} + \saveddimen{\scaledRlen}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}} + \savedanchor\northwest{% + \pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} + \pgf@y=\ctikzvalof{bipoles/iecconn/height}\pgf@circ@scaled@Rlen + \pgf@y=.25\pgf@y + \pgf@x=-\ctikzvalof{bipoles/iecconn/width}\pgf@circ@scaled@Rlen + \divide\pgf@x by 3 + } + \pgfcirc@northwest@symmetric@geoanchors + \anchor{plug center}{\pgfpointorigin} + #2% + \pgf@circ@draw@component{% + \pgf@circ@scaled@Rlen=\scaledRlen + \pgfstartlinewidth=\pgflinewidth + \northwest + \pgf@circ@res@up=\pgf@y + \pgf@circ@res@left=\pgf@x + \pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth} + \pgfpathrectanglecorners{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}{\pgfpoint{-\pgf@circ@res@left}{-\pgf@circ@res@up}} + \pgf@circ@setcolor + \pgf@circ@fill@strokecolor + \pgfusepath{draw, fill} + } + } +} + +\pgfcirc@declare@iecsocket{iecsocketR}{% + % notice: center is on the left side + \anchor{center}{\northwest\pgf@y=0pt} + \anchor{socket center}{\northwest\pgf@y=0pt} + % put the node text above and to the left, ignore depth + \anchor{text}{% + \pgfextractx{\pgf@circ@res@left}{\northwest} + \pgfextracty{\pgf@circ@res@up}{\northwest} + \pgfpoint{-\pgf@circ@res@left}{% + .5\ht\pgfnodeparttextbox+\pgf@circ@res@up + }% + }% +}{% drawing + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}} + \pgfpatharc{90}{270}{2\pgf@circ@res@left and \pgf@circ@res@up} +} +\pgfcirc@declare@iecsocket{iecsocketL}{% + % notice: center is on the left side + \anchor{center}{\northwest\pgf@y=0pt} + \anchor{socket center}{\northwest\pgf@y=0pt\pgf@x=-\pgf@x} + % put the node text above and to the left, ignore depth + \anchor{text}{% + \pgfextractx{\pgf@circ@res@left}{\northwest} + \pgfextracty{\pgf@circ@res@up}{\northwest} + \pgfpoint{-\wd\pgfnodeparttextbox+\pgf@circ@res@left}{% + .5\ht\pgfnodeparttextbox+\pgf@circ@res@up + }% + }% +}{% drawing + \pgfpathmoveto{\pgfpoint{-\pgf@circ@res@left}{\pgf@circ@res@up}} + \pgfpatharc{90}{-90}{2\pgf@circ@res@left and \pgf@circ@res@up} +} + +\pgfcirc@declare@iecplug{iecplugL}{% + % notice: center is on the left side + \anchor{center}{\northwest\pgf@y=0pt} + % put the node text above and to the right, ignore depth + % the text is higher to match the iec socket position + \anchor{text}{% + \pgfextractx{\pgf@circ@res@left}{\northwest} + \pgfextracty{\pgf@circ@res@up}{\northwest} + \pgfpoint{-\wd\pgfnodeparttextbox+\pgf@circ@res@left}{ + .5\ht\pgfnodeparttextbox+2\pgf@circ@res@up + } + } +} +\pgfcirc@declare@iecplug{iecplugR}{% + % notice: center is on the left side + \anchor{center}{\northwest\pgf@y=0pt} + % put the node text above and to the right, ignore depth + % the text is higher to match the iec socket position + \anchor{text}{% + \pgfextractx{\pgf@circ@res@left}{\northwest} + \pgfextracty{\pgf@circ@res@up}{\northwest} + \pgfpoint{-\pgf@circ@res@left}{ + .5\ht\pgfnodeparttextbox+2\pgf@circ@res@up + } + } +} +% BNC connector + +\pgfdeclareshape{bnc}{ + \savedmacro{\ctikzclass}{\edef\ctikzclass{connectors}} + \saveddimen{\scaledRlen}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}} + \anchor{center}{ + \pgfpointorigin + } + % BNC size is 2.5 times the size of the internal "ocirc", when class scale is=1 + \savedanchor\northwest{% + \pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} + \pgf@y=\ctikzvalof{nodes width}\pgf@circ@scaled@Rlen + \pgf@y=2.5\pgf@y + \pgf@x=-\pgf@y + } + % center is on the opening + \anchor{center}{\northwest\pgf@y=0pt\pgf@x=-\pgf@x} + \anchor{zero}{\pgfpointorigin} + \anchor{hot}{\northwest\pgf@y=0pt\pgf@x=-\pgf@x} + \anchor{shield}{\northwest\pgf@x=0pt\pgf@y=-\pgf@y} + % geo-anchors + \pgfcirc@northwest@symmetric@geoanchors + % put the node text above and centered + \anchor{text}{\pgfextracty{\pgf@circ@res@up}{\northwest} + \pgfpoint{-.5\wd\pgfnodeparttextbox}{ + \dimexpr.5\dp\pgfnodeparttextbox+.5\ht\pgfnodeparttextbox+\pgf@circ@res@up\relax + } + } + \anchorborder{ + \pgf@circ@res@left=\pgf@x + \pgf@circ@res@up=\pgf@y + \pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen} + \pgfpointborderellipse{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up} + }{\pgfpoint{2.5*\ctikzvalof{nodes width}*\pgf@circ@scaled@Rlen}{2.5*\ctikzvalof{nodes width}*\pgf@circ@scaled@Rlen}} + } + \pgf@circ@draw@component{ + \pgfextracty{\pgf@circ@res@other}{\northwest} + \pgfmathsetlength{\pgf@circ@res@step}{\ctikzvalof{nodes width}*\scaledRlen} + \pgfstartlinewidth=\pgflinewidth + \pgf@circ@setlinewidth{bipoles}{\pgflinewidth} + \pgf@circ@setcolor + % external circle + \pgfscope + % clipping path: first a rectangle bigger then the shape + % to avoid problems with the line thickness + \pgfpathrectanglecorners{\pgfpoint{-2\pgf@circ@res@other}{-2\pgf@circ@res@other}} + {\pgfpoint{2\pgf@circ@res@other}{2\pgf@circ@res@other}} + % next the opening to the right + \pgfpathrectanglecorners{\pgfpoint{-\pgf@circ@res@step}{-\pgf@circ@res@step}} + {\pgfpoint{2\pgf@circ@res@other}{\pgf@circ@res@step}} + % do the difference and clip before drawing + \pgfseteorule + \pgfusepath{clip} + \pgfpathcircle{\pgfpointorigin}{\pgf@circ@res@other} + \pgfusepath{draw} + \endpgfscope + % internal circle + \pgfpathcircle{\pgfpointorigin}{\pgf@circ@res@step} + \pgf@circ@draworfill + % and the contact line to the right + \pgfsetlinewidth{\pgfstartlinewidth} + \pgfpathmoveto{\pgfpoint{\pgf@circ@res@step}{0pt}} + \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{0pt}} + \pgfusepath{draw} + } +} +% %>>> \endinput +% vim: set fdm=marker fmr=%<<<,%>>>: |