summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/circuitikz/pgfcircmultipoles.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/generic/circuitikz/pgfcircmultipoles.tex')
-rw-r--r--Master/texmf-dist/tex/generic/circuitikz/pgfcircmultipoles.tex470
1 files changed, 363 insertions, 107 deletions
diff --git a/Master/texmf-dist/tex/generic/circuitikz/pgfcircmultipoles.tex b/Master/texmf-dist/tex/generic/circuitikz/pgfcircmultipoles.tex
index 48c9c91a9d7..b2a626b63d9 100644
--- a/Master/texmf-dist/tex/generic/circuitikz/pgfcircmultipoles.tex
+++ b/Master/texmf-dist/tex/generic/circuitikz/pgfcircmultipoles.tex
@@ -27,6 +27,10 @@
% DIP (dual in line package) chips
\pgfdeclareshape{dipchip}{
+ \savedmacro\numpins{%
+ \c@pgf@counta=\pgfkeysvalueof{/tikz/circuitikz/multipoles/dipchip/num pins}%
+ \def\numpins{\the\c@pgf@counta}
+ }
\savedanchor\centerpoint{%
\pgf@x=-.5\wd\pgfnodeparttextbox%
\pgf@y=-.5\ht\pgfnodeparttextbox%
@@ -36,7 +40,7 @@
\anchor{center}{\origin}
\anchor{text}{\centerpoint}% to adjust text
\saveddimen\height{%
- \pgfmathsetlength\pgf@x{((\pgfkeysvalueof{/tikz/circuitikz/multipoles/dipchip/num pins})
+ \pgfmathsetlength\pgf@x{((\numpins)
*\pgfkeysvalueof{/tikz/circuitikz/multipoles/dipchip/pin spacing})*\pgf@circ@Rlen/2}%
}%
\saveddimen{\chipspacing}{\pgfmathsetlength\pgf@x{\pgf@circ@Rlen*\pgfkeysvalueof{/tikz/circuitikz/multipoles/dipchip/pin spacing}}}
@@ -44,7 +48,7 @@
\saveddimen{\extshift}{\pgfmathsetlength\pgf@x{\pgf@circ@Rlen*\pgfkeysvalueof{/tikz/circuitikz/multipoles/external pins width}}}
% standard anchors
\savedanchor\northwest{%
- \pgfmathsetlength\pgf@y{0.5*((\pgfkeysvalueof{/tikz/circuitikz/multipoles/dipchip/num pins})
+ \pgfmathsetlength\pgf@y{0.5*((\numpins)
*\pgfkeysvalueof{/tikz/circuitikz/multipoles/dipchip/pin spacing})*\pgf@circ@Rlen/2}%
\pgfmathsetlength\pgf@x{-0.5*\pgf@circ@Rlen*\pgfkeysvalueof{/tikz/circuitikz/multipoles/dipchip/width}}
}
@@ -90,7 +94,7 @@
\pgfsetcolor{\pgfkeysvalueof{/tikz/circuitikz/color}}
% Adding the pin number
\ifpgf@circuit@chip@shownumbers
- \c@pgf@counta=\pgfkeysvalueof{/tikz/circuitikz/multipoles/dipchip/num pins}%
+ \c@pgf@counta=\numpins\relax
\divide\c@pgf@counta by 2 \pgf@circ@count@b=\c@pgf@counta
% thanks to @marmot: https://tex.stackexchange.com/a/473571/38080
\ifpgf@circuit@chip@straightnumbers
@@ -157,7 +161,7 @@
\ifdim\pgf@circ@res@other>0pt
\pgfscope
\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/multipoles/external pins thickness}\pgflinewidth}
- \c@pgf@counta=\pgfkeysvalueof{/tikz/circuitikz/multipoles/dipchip/num pins}%
+ \c@pgf@counta=\numpins\relax
\divide\c@pgf@counta by 2 \pgf@circ@count@b=\c@pgf@counta
\pgfmathloop%
\ifnum\c@pgf@counta>0
@@ -192,29 +196,18 @@
% and is executed just before a node is drawn.
\pgfutil@g@addto@macro\pgf@sh@s@dipchip{%
% Start with the maximum pin number and go backwards.
- % If the anchor is undefined, create it. Otherwise stop.
- \c@pgf@counta=\pgfkeysvalueof{/tikz/circuitikz/multipoles/dipchip/num pins}%
- \divide\c@pgf@counta by 2 \pgf@circ@count@b=\c@pgf@counta
+ \c@pgf@counta=\numpins\relax
\pgfmathloop%
\ifnum\c@pgf@counta>0
- % left side, pins 1..npins/2
% we will create two anchors per pin: the "normal one" like `pin 1` for the
% electrical contact, and the "border one" like `bpin 1` for labels.
% they will coincide if `external pins width` is set to 0.
- \expandafter\xdef\csname pgf@anchor@dipchip@bpin\space\the\c@pgf@counta\endcsname{%
- \noexpand\pgf@circ@chippinanchorLB{\the\c@pgf@counta}%
- }
\expandafter\xdef\csname pgf@anchor@dipchip@pin\space\the\c@pgf@counta\endcsname{%
- \noexpand\pgf@circ@chippinanchorL{\the\c@pgf@counta}%
+ \noexpand\pgf@circ@dippinanchor{\the\c@pgf@counta}{1}%
+ }
+ \expandafter\xdef\csname pgf@anchor@dipchip@bpin\space\the\c@pgf@counta\endcsname{%
+ \noexpand\pgf@circ@dippinanchor{\the\c@pgf@counta}{0}%
}
- % right side
- \pgf@circ@count@c=\numexpr2*\pgf@circ@count@b-\c@pgf@counta+1\relax
- \expandafter\xdef\csname pgf@anchor@dipchip@bpin\space\the\pgf@circ@count@c\endcsname{%
- \noexpand\pgf@circ@chippinanchorRB{\the\c@pgf@counta}%
- }%
- \expandafter\xdef\csname pgf@anchor@dipchip@pin\space\the\pgf@circ@count@c\endcsname{%
- \noexpand\pgf@circ@chippinanchorR{\the\c@pgf@counta}%
- }%
\advance\c@pgf@counta by -1\relax%
\repeatpgfmathloop%
}%
@@ -223,6 +216,10 @@
% QFP (quad flat package) chips
\pgfdeclareshape{qfpchip}{
+ \savedmacro\numpins{%
+ \c@pgf@counta=\pgfkeysvalueof{/tikz/circuitikz/multipoles/qfpchip/num pins}%
+ \def\numpins{\the\c@pgf@counta}
+ }
\savedanchor\centerpoint{%
\pgf@x=-.5\wd\pgfnodeparttextbox%
\pgf@y=-.5\ht\pgfnodeparttextbox%
@@ -232,18 +229,18 @@
\anchor{center}{\origin}
\anchor{text}{\centerpoint}% to adjust text
\saveddimen\height{%
- \pgfmathsetlength\pgf@x{((\pgfkeysvalueof{/tikz/circuitikz/multipoles/qfpchip/num pins}+2)
+ \pgfmathsetlength\pgf@x{((\numpins+2)
*\pgfkeysvalueof{/tikz/circuitikz/multipoles/qfpchip/pin spacing})*\pgf@circ@Rlen/4}%
}%
\saveddimen\width{%
- \pgfmathsetlength\pgf@x{((\pgfkeysvalueof{/tikz/circuitikz/multipoles/qfpchip/num pins}+2)
+ \pgfmathsetlength\pgf@x{((\numpins+2)
*\pgfkeysvalueof{/tikz/circuitikz/multipoles/qfpchip/pin spacing})*\pgf@circ@Rlen/4}%
}%
\saveddimen{\chipspacing}{\pgfmathsetlength\pgf@x{\pgf@circ@Rlen*\pgfkeysvalueof{/tikz/circuitikz/multipoles/qfpchip/pin spacing}}}
\saveddimen{\extshift}{\pgfmathsetlength\pgf@x{\pgf@circ@Rlen*\pgfkeysvalueof{/tikz/circuitikz/multipoles/external pins width}}}
% standard anchors
\savedanchor\northwest{%
- \pgfmathsetlength\pgf@y{0.5*((\pgfkeysvalueof{/tikz/circuitikz/multipoles/qfpchip/num pins}+2)
+ \pgfmathsetlength\pgf@y{0.5*((\numpins+2)
*\pgfkeysvalueof{/tikz/circuitikz/multipoles/qfpchip/pin spacing})*\pgf@circ@Rlen/4}%
\pgf@x=-\pgf@y
}
@@ -294,7 +291,7 @@
% Adding the pin number
\pgfsetcolor{\pgfkeysvalueof{/tikz/circuitikz/color}}
\ifpgf@circuit@chip@shownumbers
- \c@pgf@counta=\pgfkeysvalueof{/tikz/circuitikz/multipoles/qfpchip/num pins}%
+ \c@pgf@counta=\numpins%
\divide\c@pgf@counta by 4 \pgf@circ@count@b=\c@pgf@counta
% thanks to @marmot: https://tex.stackexchange.com/a/473571/38080
\ifpgf@circuit@chip@straightnumbers
@@ -401,7 +398,7 @@
\ifdim\pgf@circ@res@other>0pt
\pgfscope
\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/multipoles/external pins thickness}\pgflinewidth}
- \c@pgf@counta=\pgfkeysvalueof{/tikz/circuitikz/multipoles/qfpchip/num pins}%
+ \c@pgf@counta=\numpins%
\divide\c@pgf@counta by 4 \pgf@circ@count@b=\c@pgf@counta
\pgfmathloop%
\ifnum\c@pgf@counta>0
@@ -452,41 +449,14 @@
% and is executed just before a node is drawn.
\pgfutil@g@addto@macro\pgf@sh@s@qfpchip{%
% Start with the maximum pin number and go backwards.
- % If the anchor is undefined, create it. Otherwise stop.
- \c@pgf@counta=\pgfkeysvalueof{/tikz/circuitikz/multipoles/qfpchip/num pins}%
- \divide\c@pgf@counta by 4 \pgf@circ@count@b=\c@pgf@counta
+ \c@pgf@counta=\numpins%
\pgfmathloop%
\ifnum\c@pgf@counta>0
- % left side; 1..npins/4
\expandafter\xdef\csname pgf@anchor@qfpchip@pin\space\the\c@pgf@counta\endcsname{%
- \noexpand\pgf@circ@chippinanchorQL{\the\c@pgf@counta}%
+ \noexpand\pgf@circ@qfppinanchor{\the\c@pgf@counta}{1}%
}
\expandafter\xdef\csname pgf@anchor@qfpchip@bpin\space\the\c@pgf@counta\endcsname{%
- \noexpand\pgf@circ@chippinanchorQLB{\the\c@pgf@counta}%
- }
- % bottom side;
- \pgf@circ@count@c=\numexpr2*\pgf@circ@count@b-\c@pgf@counta+1\relax
- \expandafter\xdef\csname pgf@anchor@qfpchip@pin\space\the\pgf@circ@count@c\endcsname{%
- \noexpand\pgf@circ@chippinanchorQB{\the\c@pgf@counta}%
- }
- \expandafter\xdef\csname pgf@anchor@qfpchip@bpin\space\the\pgf@circ@count@c\endcsname{%
- \noexpand\pgf@circ@chippinanchorQBB{\the\c@pgf@counta}%
- }
- % right side; 2*npins/4+1, 3*npins/4
- \pgf@circ@count@c=\numexpr3*\pgf@circ@count@b-\c@pgf@counta+1\relax
- \expandafter\xdef\csname pgf@anchor@qfpchip@pin\space\the\pgf@circ@count@c\endcsname{%
- \noexpand\pgf@circ@chippinanchorQR{\the\c@pgf@counta}%
- }
- \expandafter\xdef\csname pgf@anchor@qfpchip@bpin\space\the\pgf@circ@count@c\endcsname{%
- \noexpand\pgf@circ@chippinanchorQRB{\the\c@pgf@counta}%
- }
- % top side
- \pgf@circ@count@c=\numexpr3*\pgf@circ@count@b+\c@pgf@counta\relax
- \expandafter\xdef\csname pgf@anchor@qfpchip@pin\space\the\pgf@circ@count@c\endcsname{%
- \noexpand\pgf@circ@chippinanchorQT{\the\c@pgf@counta}%
- }
- \expandafter\xdef\csname pgf@anchor@qfpchip@bpin\space\the\pgf@circ@count@c\endcsname{%
- \noexpand\pgf@circ@chippinanchorQTB{\the\c@pgf@counta}%
+ \noexpand\pgf@circ@qfppinanchor{\the\c@pgf@counta}{0}%
}
\advance\c@pgf@counta-1\relax%
\repeatpgfmathloop%
@@ -494,66 +464,352 @@
}
%% anchors for DIP
-\def\pgf@circ@chippinanchorR#1{%
- % When this macro is called,
- % \extshift, \height and \chipspacing will be defined.
- \pgfpoint{\width/2+\extshift}{\height/2+(\pgf@circ@dip@pin@shift-#1)*\chipspacing}%
-}
-\def\pgf@circ@chippinanchorL#1{%
- % When this macro is called,
- % \extshift, \height and \chipspacing will be defined.
- \pgfpoint{-\width/2-\extshift}{\height/2+(\pgf@circ@dip@pin@shift-#1)*\chipspacing}%
-}
-\def\pgf@circ@chippinanchorRB#1{%
- % When this macro is called,
- % \extshift, \height and \chipspacing will be defined.
- \pgfpoint{\width/2}{\height/2+(\pgf@circ@dip@pin@shift-#1)*\chipspacing}%
-}
-\def\pgf@circ@chippinanchorLB#1{%
- % When this macro is called,
- % \extshift, \height and \chipspacing will be defined.
- \pgfpoint{-\width/2}{\height/2+(\pgf@circ@dip@pin@shift-#1)*\chipspacing}%
+\def\pgf@circ@dippinanchor#1#2{% #1: pin number #2: 0 for border pin, 1 for external pin
+ \c@pgf@countc=\numpins\relax
+ \divide\c@pgf@countc by 2
+ \ifnum #1 > \the\c@pgf@countc
+ % right side
+ \pgfpoint{\width/2+#2*\extshift}{-\height/2+(\pgf@circ@dip@pin@shift-\c@pgf@countc+#1-1)*\chipspacing}
+ \else
+ \pgfpoint{-\width/2-#2*\extshift}{\height/2+(\pgf@circ@dip@pin@shift-#1)*\chipspacing}
+\fi
}
%% anchors for QFP
-\def\pgf@circ@chippinanchorQR#1{%
- % When this macro is called,
- % \extshift, \height and \chipspacing will be defined.
- \pgfpoint{\width/2+\extshift}{\height/2+(\pgf@circ@qfp@pin@shift-#1)*\chipspacing}%
+\def\pgf@circ@qfppinanchor#1#2{% #1: pin number #2: 0 for border pin, 1 for external pin
+ \c@pgf@countc=\numpins\relax
+ \divide\c@pgf@countc by 4
+ \ifnum #1 > \the\c@pgf@countc
+ \c@pgf@countb=\c@pgf@countc \multiply \c@pgf@countb by 2
+ \ifnum #1 > \the\c@pgf@countb
+ \c@pgf@countb=\c@pgf@countc \multiply \c@pgf@countb by 3
+ \ifnum #1 > \the\c@pgf@countb
+ % 3*npins/4 < pin, top side
+ \pgfpoint{\width/2+(\pgf@circ@qfp@pin@shift+\c@pgf@countb-#1)*\chipspacing}{\height/2+#2*\extshift}%
+ \else
+ % 2*npins/4 < pin <= 3*npins/4, right side
+ \pgfpoint{\width/2+#2*\extshift}{\height/2+(\pgf@circ@qfp@pin@shift-\c@pgf@countb+#1-1)*\chipspacing}%
+ \fi
+ \else
+ % npins/4 < pin <= 2*npins/4, bottom side
+ \pgfpoint{\width/2+(\pgf@circ@qfp@pin@shift-\c@pgf@countb+#1-1)*\chipspacing}{-\height/2-#2*\extshift}%
+ \fi
+ \else
+ % <= npins/4, left side
+ \pgfpoint{-\width/2-#2*\extshift}{\height/2+(\pgf@circ@qfp@pin@shift-#1)*\chipspacing}%
+ \fi
+}
+
+
+%% Rotary Switch
+
+\pgfdeclareshape{rotaryswitch}
+{
+ \savedanchor\northeast{%
+ % this strange value makes the 2-pole rotary switch equal to the 2 poles cute spdt
+ % the magic number is 0.25/cos(35)
+ % try to recalculate it for the actual switch
+ \pgf@circ@res@temp=\ctikzvalof{tripoles/spdt/width}\pgf@circ@Rlen
+ \pgf@circ@res@temp=.3052\pgf@circ@res@temp
+ \edef\a{\ctikzvalof{multipoles/rotary/angle}}
+ \edef\r{\ctikzvalof{nodes width}}
+ \pgfmathsetlength{\pgf@y}{\r*\pgf@circ@Rlen +(\a>90 ? 2 : 2*sin(\a))*\pgf@circ@res@temp}
+ \pgfmathsetlength{\pgf@x}{\r*\pgf@circ@Rlen + \pgf@circ@res@temp}
+ }
+ \savedanchor\northwest{%
+ % this strange value makes the 2-pole rotary switch equal to the 2 poles cute spdt
+ % the magic number is 0.25/cos(35)
+ % try to recalculate it for the actual switch
+ \pgf@circ@res@temp=\ctikzvalof{tripoles/spdt/width}\pgf@circ@Rlen
+ \pgf@circ@res@temp=.3052\pgf@circ@res@temp
+ \edef\a{\ctikzvalof{multipoles/rotary/angle}}
+ \edef\r{\ctikzvalof{nodes width}}
+ \pgfmathsetlength{\pgf@y}{\r*\pgf@circ@Rlen +(\a>90 ? 2 : 2*sin(\a))*\pgf@circ@res@temp}
+ \pgfmathsetlength{\pgf@x}{-\r*\pgf@circ@Rlen - (\a<90 ? 1 : 1-2*cos(\a))*\pgf@circ@res@temp}
+ }
+ \savedanchor\central{%
+ % this strange value makes the 2-pole rotary switch equal to the 2 poles cute spdt
+ % the magic number is 0.25/cos(35)
+ % try to recalculate it for the actual switch
+ \pgf@circ@res@temp=\ctikzvalof{tripoles/spdt/width}\pgf@circ@Rlen
+ \pgf@circ@res@temp=.3052\pgf@circ@res@temp
+ \edef\a{\ctikzvalof{multipoles/rotary/angle}}
+ \edef\r{\ctikzvalof{nodes width}}
+ \pgfmathsetlength{\pgf@y}{\r*\pgf@circ@Rlen +(\a>90 ? 2 : 2*sin(\a))*\pgf@circ@res@temp}
+ \pgfmathsetlength{\pgf@x}{(\a<90 ? 0 : cos(\a))*\pgf@circ@res@temp}
+ }
+ % external square limits
+ \savedanchor\extnorthwest{%
+ \pgf@x=-\ctikzvalof{tripoles/spdt/width}\pgf@circ@Rlen
+ % this strange value makes the 2-pole rotary switch equal to the 2 poles cute spdt
+ \pgf@x=.3052\pgf@x % the magic number is 0.25/cos(35)
+ \pgf@x=2.5\pgf@x % external square size
+ \pgf@y=-\pgf@x %square thing when angle=180?
+ }
+ \saveddimen{\width}{\pgfmathsetlength\pgf@x{0.3052*\pgf@circ@Rlen*\ctikzvalof{tripoles/spdt/width}}}
+ % radius of the connector
+ % This is the radius of the "ocirc" shape (see pgfcircshapes.tex)
+ \saveddimen{\radius}{\pgfmathsetlength\pgf@x{\pgf@circ@Rlen*\ctikzvalof{nodes width}}}
+ % shapename
+ \savedmacro{\thisshape}{\def\thisshape{\tikz@fig@name}}
+ % shape type
+ \savedmacro{\cshape}{\def\cshape{\ctikzvalof{multipoles/rotary/shape}}}
+ \savedmacro{\channels}{\def\channels{\ctikzvalof{multipoles/rotary/channels}}}
+ \savedmacro{\angle}{\def\angle{\ctikzvalof{multipoles/rotary/angle}}}
+ \savedmacro{\wiper}{\def\wiper{\ctikzvalof{multipoles/rotary/wiper}}}
+ \savedmacro{\stepa}{\pgfmathsetmacro{\stepa}{2*\ctikzvalof{multipoles/rotary/angle}/(\ctikzvalof{multipoles/rotary/channels}-1)}}
+ % mid of the lever, to stack switches
+ %\anchor{mid}{\midlever}
+ \anchor{mid}{\northwest
+ \pgf@circ@res@temp=-\pgf@x
+ \pgfmathsetlength{\pgf@x}{\pgf@circ@res@temp*(-1+cos(\wiper))}
+ \pgfmathsetlength{\pgf@y}{\pgf@circ@res@temp*sin(\wiper)}
+ }
+ % center anchors
+ \anchor{cin}{ \northwest \pgf@y=0pt\advance\pgf@x by \radius}
+ % horizontal angles
+ \anchor{in}{ \northwest \pgf@y=0pt}
+ \anchor{ain}{ \northwest \pgf@y=0pt}
+
+ \anchor{center}{ \central \pgf@y=0pt }
+ \anchor{east}{ \northeast \pgf@y=0pt }
+ \anchor{west}{ \northwest \pgf@y=0pt }
+ \anchor{south}{ \central \pgf@y=-\pgf@y }
+ \anchor{north}{ \central }
+ \anchor{south west}{ \northwest \pgf@y=-\pgf@y }
+ \anchor{north east}{ \northeast }
+ \anchor{north west}{ \northwest }
+ \anchor{south east}{ \northeast \pgf@y=-\pgf@y }
+
+ \anchor{ext center}{ \pgf@y=0pt \pgf@x=0pt \advance\pgf@x by -\width}
+ \anchor{ext east}{ \extnorthwest \pgf@y=0pt \pgf@x=-\pgf@x \advance\pgf@x by -\width}
+ \anchor{ext west}{ \extnorthwest \pgf@y=0pt \advance\pgf@x by -\width}
+ \anchor{ext south}{ \extnorthwest \pgf@x=0pt \pgf@y=-\pgf@y \advance\pgf@x by -\width}
+ \anchor{ext north}{ \extnorthwest \pgf@x=0pt \advance\pgf@x by -\width}
+ \anchor{ext south west}{ \extnorthwest \pgf@y=-\pgf@y \advance\pgf@x by -\width}
+ \anchor{ext north east}{ \extnorthwest \pgf@x=-\pgf@x \advance\pgf@x by -\width}
+ \anchor{ext north west}{ \extnorthwest \advance\pgf@x by -\width}
+ \anchor{ext south east}{ \extnorthwest \pgf@x=-\pgf@x \pgf@y=-\pgf@y \advance\pgf@x by -\width}
+
+ \backgroundpath{
+ \pgfsetcolor{\pgfkeysvalueof{/tikz/circuitikz/color}}
+ \pgf@circ@res@right = \width
+ \pgf@circ@res@left = -\width
+
+ \pgfscope %wiper
+ % This is the radius of the "ocirc" shape (see pgfcircshapes.tex)
+ \pgf@circ@res@temp=\radius\relax
+ \pgf@circ@res@temp=\ctikzvalof{multipoles/rotary/thickness}\pgf@circ@res@temp
+ \pgfsetlinewidth{2\pgf@circ@res@temp}
+ \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
+ \pgfpathlineto{\pgfpointadd{\pgfpoint{\pgf@circ@res@left}{0pt}}{\pgfpointpolar{\wiper}{2\pgf@circ@res@right}}}
+ \pgfsetroundcap\pgfusepath{draw}
+ \endpgfscope
+
+ \ifpgf@circ@rotaryarrow
+ \pgfscope % arrow
+ \ifpgf@circ@rotaryarrow@ccw\pgfsetarrowsstart{latexslim}\fi
+ \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgflinewidth}
+ \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}} % center of cin node
+ \pgftransformrotate{\wiper}
+ \pgfpathmoveto{\pgfpointpolar{50}{1.0\pgf@circ@res@right}}
+ \pgfpatharc{50}{-50}{1.0\pgf@circ@res@right}
+ \ifpgf@circ@rotaryarrow@cw\pgfsetarrowsend{latexslim}\fi
+ \pgfusepath{draw}
+ \endpgfscope
+ \fi
+
+ % \typeout{CHANNELS\space\channels\space ANGLE\space\angle}
+ \c@pgf@counta=\channels\relax
+ \pgfmathsetmacro{\currenta}{-\angle}
+ \pgfmathloop%
+ \ifnum\c@pgf@counta>0
+ % \typeout{LOOP\space\the\c@pgf@counta\space CURRENTA\space\currenta\space RIGHT\space\the\pgf@circ@res@right}
+ \pgfscope
+ \pgftransformshift{\pgfpointadd{\pgfpoint{\pgf@circ@res@left}{0pt}}{\pgfpointpolar{\currenta}{2\pgf@circ@res@right}}}
+ \pgfnode{\cshape}{center}{}{\thisshape-out \the\c@pgf@counta}{\pgfusepath{stroke}}
+ \endpgfscope
+ \pgfmathsetmacro{\currenta}{\currenta+\stepa}
+ \advance\c@pgf@counta by -1\relax%
+ \repeatpgfmathloop
+
+ \pgfscope % input
+ \pgftransformshift{\pgfpoint{\pgf@circ@res@left}{0pt}}
+ \pgfnode{\cshape}{center}{}{\thisshape-in}{\pgfusepath{stroke}}
+ \endpgfscope
+ }
+ % \pgf@sh@s@<name of the shape here> contains all the code for the shape
+ % and is executed just before a node is drawn.
+ \pgfutil@g@addto@macro\pgf@sh@s@rotaryswitch{%
+ % Start with the maximum pin number and go backwards.
+ \c@pgf@counta=\channels\relax
+ \pgfmathloop%
+ \ifnum\c@pgf@counta>0
+ % we will create two anchors per pin: the "normal one" like `pin 1` for the
+ % electrical contact, and the "border one" like `bpin 1` for labels.
+ % they will coincide if `external pins width` is set to 0.
+ \expandafter\xdef\csname pgf@anchor@rotaryswitch@out\space\the\c@pgf@counta\endcsname{%
+ \noexpand\pgf@circ@rotaryanchor{\the\c@pgf@counta}{1}{0}%
+ }
+ \expandafter\xdef\csname pgf@anchor@rotaryswitch@cout\space\the\c@pgf@counta\endcsname{%
+ \noexpand\pgf@circ@rotaryanchor{\the\c@pgf@counta}{0}{0}%
+ }
+ \expandafter\xdef\csname pgf@anchor@rotaryswitch@aout\space\the\c@pgf@counta\endcsname{%
+ \noexpand\pgf@circ@rotaryanchor{\the\c@pgf@counta}{0}{1}%
+ }
+ \expandafter\xdef\csname pgf@anchor@rotaryswitch@sqout\space\the\c@pgf@counta\endcsname{%
+ \noexpand\pgf@circ@rotarysqanchor{\the\c@pgf@counta}{0}%
+ }
+ \advance\c@pgf@counta by -1\relax%
+ \repeatpgfmathloop%
+ }%
}
-\def\pgf@circ@chippinanchorQL#1{%
- % When this macro is called,
- % \extshift, \height and \chipspacing will be defined.
- \pgfpoint{-\width/2-\extshift}{\height/2+(\pgf@circ@qfp@pin@shift-#1)*\chipspacing}%
+
+\def\pgf@circ@rotaryanchor#1#2#3{% #1: numero del pin; #2: 1 - x pos, 0 - center; #3 0: inner, 1 outer
+ \pgf@circ@res@temp=\width
+ \pgfmathsetmacro{\myangle}{\angle-(#1-1)*\stepa}
+ \pgfmathsetlength{\pgf@x}{2*(\pgf@circ@res@temp+#3*\radius/2)*cos(\myangle))+#2*\radius}
+ \pgfmathsetlength{\pgf@y}{2*(\pgf@circ@res@temp+#3*\radius/2)*sin(\myangle)}
+ \advance\pgf@x by -\pgf@circ@res@temp
}
-\def\pgf@circ@chippinanchorQT#1{%
- % When this macro is called,
- % \extshift, \height and \chipspacing will be defined.
- \pgfpoint{\width/2+(\pgf@circ@qfp@pin@shift-#1)*\chipspacing}{\height/2+\extshift}%
+
+\def\pgf@circ@rotarysqanchor#1{% external square anchors
+ \pgf@circ@res@temp=\width
+ \pgfmathsetmacro{\myangle}{\angle-(#1-1)*\stepa}
+ \pgfpointborderrectangle{\pgfpointpolar{\myangle}{1pt}}{\pgfpoint{2.5\pgf@circ@res@temp}{2.5\pgf@circ@res@temp}}
+ \advance\pgf@x by -\pgf@circ@res@temp
}
-\def\pgf@circ@chippinanchorQB#1{%
- % When this macro is called,
- % \extshift, \height and \chipspacing will be defined.
- \pgfpoint{\width/2+(\pgf@circ@qfp@pin@shift-#1)*\chipspacing}{-\height/2-\extshift}%
+
+% Seven segments displays
+
+\pgfdeclareshape{bare7seg}{
+ \savedmacro{\dotstatus}{\edef\dotstatus{\pgf@circ@sevenseg@dotstate}}
+ \saveddimen{\dotspace}{% the dot is on the right, and occupy the same as the thickness
+ \ifpgf@circ@sevenseg@dot
+ \pgfmathsetlength{\pgf@x}{\ctikzvalof{seven seg/thickness}}
+ \else
+ \pgf@x=0pt
+ \fi
+ }
+ % The object extension is more or less (-width/2,-width) to (width/2,width)
+ % and adjusted for line thickness (both sides) and eventually the dot
+ \saveddimen{\width}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{seven seg/width}*\pgf@circ@Rlen}}
+ \saveddimen{\gap}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{seven seg/segment sep}}}
+ \saveddimen{\boxgap}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{seven seg/box sep}}}
+ \savedanchor{\southwest}{% both negative
+ \pgfmathsetlength{\pgf@x}{-0.5*\ctikzvalof{seven seg/width}*\pgf@circ@Rlen
+ -0.5*\ctikzvalof{seven seg/thickness}-\ctikzvalof{seven seg/box sep}}
+ \pgfmathsetlength{\pgf@y}{-\ctikzvalof{seven seg/width}*\pgf@circ@Rlen
+ -0.5*\ctikzvalof{seven seg/thickness}-\ctikzvalof{seven seg/box sep}}
+ }
+ \savedanchor{\northeast}{% both positive
+ \ifpgf@circ@sevenseg@dot
+ \pgfmathsetlength{\pgf@circ@res@other}{\ctikzvalof{seven seg/thickness}}
+ \else
+ \pgf@circ@res@other=0pt
+ \fi
+ \pgfmathsetlength{\pgf@x}{0.5*\ctikzvalof{seven seg/width}*\pgf@circ@Rlen
+ +0.5*\ctikzvalof{seven seg/thickness}+\pgf@circ@res@other+\ctikzvalof{seven seg/box sep}}
+ \pgfmathsetlength{\pgf@y}{\ctikzvalof{seven seg/width}*\pgf@circ@Rlen
+ +0.5*\ctikzvalof{seven seg/thickness}+\ctikzvalof{seven seg/box sep}}
+ }
+ \savedanchor{\topright}{% anchor without the box sep and the thickness
+ \pgfmathsetlength{\pgf@x}{0.5*\ctikzvalof{seven seg/width}*\pgf@circ@Rlen}
+ \pgfmathsetlength{\pgf@y}{\ctikzvalof{seven seg/width}*\pgf@circ@Rlen}
+ }
+ \anchor{center}{\pgfpointorigin}
+ \anchor{north west}{\southwest\pgf@y=-\pgf@y}
+ \anchor{north east}{\northeast}
+ \anchor{south east}{\northeast\pgf@y=-\pgf@y}
+ \anchor{south west}{\southwest}
+ \anchor{north}{\northeast\pgf@x=0pt}
+ \anchor{east}{\northeast\pgf@y=0pt}
+ \anchor{south}{\southwest\pgf@x=0pt}
+ \anchor{west}{\southwest\pgf@y=0pt}
+ \anchor{a}{\topright\pgf@x=0pt}
+ \anchor{b}{\topright\pgf@y=0.5\pgf@y}
+ \anchor{c}{\topright\pgf@y=-0.5\pgf@y}
+ \anchor{d}{\topright\pgf@y=-\pgf@y\pgf@x=0pt}
+ \anchor{e}{\topright\pgf@x=-\pgf@x\pgf@y=-0.5\pgf@y}
+ \anchor{f}{\topright\pgf@x=-\pgf@x\pgf@y=0.5\pgf@y}
+ \anchor{g}{\pgfpointorigin}
+ \anchor{dot}{\topright\pgf@y=-\pgf@y\advance\pgf@x by \dotspace}
+ \behindbackgroundpath{%
+ \southwest % I do not want the dot here, it will stick out
+ \pgf@circ@res@up = -\pgf@y
+ \pgf@circ@res@down = \pgf@y
+ \pgf@circ@res@right = \pgf@x
+ \pgf@circ@res@left = -\pgf@x
+ \pgfscope
+ \pgfsetlinewidth{\ctikzvalof{multipoles/thickness}\pgflinewidth}
+ \pgfsetcolor{\pgfkeysvalueof{/tikz/circuitikz/color}}
+ \pgfpathrectanglecorners%
+ {\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
+ {\pgfpoint{\pgf@circ@res@left+\dotspace}{\pgf@circ@res@up}}
+ \ifpgf@circ@sevenseg@box
+ \pgf@circ@draworfill
+ \else
+ \pgf@circ@maybefill
+ \fi
+ \endpgfscope
+ \edef\bits{\ctikzvalof{seven seg/bits}}
+ \pgfscope
+ \pfg@circ@sseg@drawbits{\bits}
+ \endpgfscope
+ \pgfscope
+ \ifpgf@circ@sevenseg@dot
+ \pgf@circ@sseg@drawdots
+ \fi
+ \endpgfscope
+ }
}
-\def\pgf@circ@chippinanchorQRB#1{%
- % When this macro is called,
- % \extshift, \height and \chipspacing will be defined.
- \pgfpoint{\width/2}{\height/2+(\pgf@circ@qfp@pin@shift-#1)*\chipspacing}%
+
+\def\pgf@circ@sseg@splitbits#1#2#3#4#5#6#7\relax{%split the seven bits
+ \edef\@@a{#1}\edef\@@b{#2}\edef\@@c{#3}\edef\@@d{#4}\edef\@@e{#5}\edef\@@f{#6}\edef\@@g{#7}%
}
-\def\pgf@circ@chippinanchorQLB#1{%
- % When this macro is called,
- % \extshift, \height and \chipspacing will be defined.
- \pgfpoint{-\width/2}{\height/2+(\pgf@circ@qfp@pin@shift-#1)*\chipspacing}%
+\def\pgf@circ@sseg@drawone#1#2#3#4#5{% #1 on off the x1, y1, x2 , y2
+ \ifnum #1 > 0\relax
+ \pgfsetcolor{\ctikzvalof{seven seg/color on}}
+ \else
+ \pgfsetcolor{\ctikzvalof{seven seg/color off}}
+ \fi
+ \pgfpathmoveto{\pgfpoint{#2}{#3}}
+ \pgfpathlineto{\pgfpoint{#4}{#5}}
+ \pgfusepath{draw}
}
-\def\pgf@circ@chippinanchorQTB#1{%
- % When this macro is called,
- % \extshift, \height and \chipspacing will be defined.
- \pgfpoint{\width/2+(\pgf@circ@qfp@pin@shift-#1)*\chipspacing}{\height/2}%
+\def\pfg@circ@sseg@drawbits#1{% #1 must be 7 bits
+ \expandafter\pgf@circ@sseg@splitbits#1\relax% a bit of magic...
+ \pgfmathsetlength{\pgf@circ@res@other}{0.5*\ctikzvalof{seven seg/thickness}}
+ \pgfsetlinewidth{\ctikzvalof{seven seg/thickness}}
+ % \pgfsetroundcap
+ \pgfsetarrowsstart{Triangle Cap[]}
+ \pgfsetarrowsend{Triangle Cap[]}
+ % segments
+ \pgf@circ@sseg@drawone{\@@a}{-\width/2+\gap}{\width}{\width/2-\gap}{\width}
+ \pgf@circ@sseg@drawone{\@@b}{\width/2}{\width-\gap}{\width/2}{0pt+\gap}
+ \pgf@circ@sseg@drawone{\@@c}{\width/2}{0pt-\gap}{\width/2}{-\width+\gap}
+ \pgf@circ@sseg@drawone{\@@d}{\width/2-\gap}{-\width}{-\width/2+\gap}{-\width}
+ \pgf@circ@sseg@drawone{\@@e}{-\width/2}{-\width+\gap}{-\width/2}{0pt-\gap}
+ \pgf@circ@sseg@drawone{\@@f}{-\width/2}{0pt+\gap}{-\width/2}{\width-\gap}
+ \pgf@circ@sseg@drawone{\@@g}{-\width/2+\gap}{0pt}{\width/2-\gap}{0pt}
}
-\def\pgf@circ@chippinanchorQBB#1{%
- % When this macro is called,
- % \extshift, \height and \chipspacing will be defined.
- \pgfpoint{\width/2+(\pgf@circ@qfp@pin@shift-#1)*\chipspacing}{-\height/2}%
+\def\pgf@circ@sseg@drawdots{% dots
+ \edef\what{empty}
+ \ifx\what\pgf@circ@sevenseg@dotstate
+ % do nothing
+ \else
+ \pgfmathsetlength{\pgf@circ@res@other}{0.5*\ctikzvalof{seven seg/thickness}}
+ \edef\what{off}
+ \ifx\what\pgf@circ@sevenseg@dotstate
+ % dot off
+ \pgfsetfillcolor{\ctikzvalof{seven seg/color off}}
+ \pgfsetcolor{\ctikzvalof{seven seg/color off}}
+ \else
+ % dot on
+ \pgfsetfillcolor{\ctikzvalof{seven seg/color on}}
+ \pgfsetcolor{\ctikzvalof{seven seg/color on}}
+ \fi
+ \pgfpathcircle{\pgfpoint{\width/2+2*\pgf@circ@res@other}{-\width}}{\pgf@circ@res@other}
+ \pgfusepath{draw,fill}
+ \fi
}
-