summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/circuitikz/tex/pgfcircmultipoles.tex
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/pgf/contrib/circuitikz/tex/pgfcircmultipoles.tex')
-rw-r--r--graphics/pgf/contrib/circuitikz/tex/pgfcircmultipoles.tex353
1 files changed, 255 insertions, 98 deletions
diff --git a/graphics/pgf/contrib/circuitikz/tex/pgfcircmultipoles.tex b/graphics/pgf/contrib/circuitikz/tex/pgfcircmultipoles.tex
index 23e0d40b7f..9abaf1e8b6 100644
--- a/graphics/pgf/contrib/circuitikz/tex/pgfcircmultipoles.tex
+++ b/graphics/pgf/contrib/circuitikz/tex/pgfcircmultipoles.tex
@@ -18,6 +18,16 @@
%
\ctikzset{multipoles/thickness/.initial=2}
\ctikzset{multipoles/font/.initial=\pgf@circ@font@tiny}
+\ctikzset{multipoles/draw only pins/.initial={all}}
+\ctikzset{multipoles/draw only left pins/.initial={all}}
+\ctikzset{multipoles/draw only right pins/.initial={all}}
+\ctikzset{multipoles/draw only top pins/.initial={all}}
+\ctikzset{multipoles/draw only bottom pins/.initial={all}}
+\pgfqkeys{/tikz}{draw only pins/.add code={}{\ctikzset{multipoles/draw only pins={#1}}}}
+\pgfqkeys{/tikz}{draw only left pins/.add code={}{\ctikzset{multipoles/draw only left pins={#1}}}}
+\pgfqkeys{/tikz}{draw only right pins/.add code={}{\ctikzset{multipoles/draw only right pins={#1}}}}
+\pgfqkeys{/tikz}{draw only top pins/.add code={}{\ctikzset{multipoles/draw only top pins={#1}}}}
+\pgfqkeys{/tikz}{draw only bottom pins/.add code={}{\ctikzset{multipoles/draw only bottom pins={#1}}}}
% DIP (dual in line package) chips
\ctikzset{multipoles/dipchip/width/.initial=1.2}
\ctikzset{multipoles/dipchip/num pins/.initial=8}
@@ -113,9 +123,23 @@
% Thanks also to John Kormylo https://tex.stackexchange.com/a/372996/38080
% a lot of thanks to @marmot for the un-rotation hint
% https://tex.stackexchange.com/a/473571/38080
+% modifications for 'draw only pins' by Jonathan P. Spratte
% DIP (dual in line package) chips
+% helper macro to set the anchors inside a loop (to expand the current count)
+\pgfutil@protected\def\pgf@circ@make@dippin@anchor#1%
+ {%
+ \expandafter\gdef\csname pgf@anchor@dipchip@pin #1\endcsname
+ {%
+ \pgf@circ@if@num@in@list\pgf@circ@pins@list{#1}
+ {\pgf@circ@dippinanchor{#1}{1}}
+ {\pgf@circ@dippinanchor{#1}{0}}%
+ }%
+ \expandafter\gdef\csname pgf@anchor@dipchip@bpin #1\endcsname
+ {\pgf@circ@dippinanchor{#1}{0}}%
+ }
+
\pgfdeclareshape{dipchip}{
\savedmacro{\ctikzclass}{\edef\ctikzclass{chips}}
\saveddimen{\scaledRlen}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}}
@@ -123,6 +147,14 @@
\pgf@circ@count@a=\ctikzvalof{multipoles/dipchip/num pins}%
\def\numpins{\the\pgf@circ@count@a}
}
+ \savedmacro\pgf@circ@pins@list
+ {%
+ \pgfkeysgetvalue
+ {\circuitikzbasekey/multipoles/draw only pins}\pgf@circ@temp
+ \expandafter\pgf@circ@set@list
+ \expandafter\pgf@circ@pins@list
+ \expandafter{\pgf@circ@temp}%
+ }%
\savedanchor\centerpoint{%
\pgf@x=-.5\wd\pgfnodeparttextbox%
\pgf@y=-.5\ht\pgfnodeparttextbox%
@@ -259,62 +291,85 @@
\repeatpgfmathloop
\fi
\endpgfscope
+ % draw external pins or pads
\ifdim\pgf@circ@res@other>0pt
+ \ifpgfcirc@draw@input@leads
\pgfscope
\pgfsetlinewidth{\ctikzvalof{multipoles/external pins thickness}\pgflinewidth}
\pgf@circ@count@a=\numpins\relax
\divide\pgf@circ@count@a by 2 \pgf@circ@count@b=\pgf@circ@count@a
+ \edef\padfrac{\ctikzvalof{multipoles/external pad fraction}}
+ \ifnum\padfrac>0
+ \pgf@circ@res@temp=\pgf@circ@res@step\divide\pgf@circ@res@temp by \padfrac
+ \fi
\pgfmathloop%
\ifnum\pgf@circ@count@a>0
- \edef\padfrac{\ctikzvalof{multipoles/external pad fraction}}
- \ifnum\padfrac>0
- \pgf@circ@res@temp=\pgf@circ@res@step\divide\pgf@circ@res@temp by \padfrac
- % left side pads
- \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
- \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
- \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
- \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
- % right side pads
- \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
- \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
- \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
- \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
- \else
- % left side pins
- \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
- \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
- % right side pins
- \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
- \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
- \fi
+ % left side
+ \pgf@circ@if@num@in@list\pgf@circ@pins@list\pgf@circ@count@a
+ {%
+ \ifnum\padfrac>0
+ % pads
+ \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
+ \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
+ \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
+ \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
+ \else
+ % pins
+ \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
+ \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
+ \fi
+ }
+ {}%
+ % right side
+ \pgf@circ@if@num@in@list\pgf@circ@pins@list{\numpins+1-\pgf@circ@count@a}
+ {%
+ \ifnum\padfrac>0
+ % pads
+ \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
+ \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
+ \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
+ \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
+ \else
+ % pins
+ \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
+ \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{\pgf@circ@res@up+(\pgf@circ@dip@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
+ \fi
+ }
+ {}%
\advance\pgf@circ@count@a by -1\relax%
\repeatpgfmathloop
\pgfusepath{stroke}
\endpgfscope
\fi
+ \fi
}%
- % \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@dipchip{%
- % Start with the maximum pin number and go backwards.
- \pgf@circ@count@a=\numpins\relax
- \pgfmathloop%
+ \pgf@circ@count@a=\numpins
+ \pgfmathloop
\ifnum\pgf@circ@count@a>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@dipchip@pin\space\the\pgf@circ@count@a\endcsname{%
- \noexpand\pgf@circ@dippinanchor{\the\pgf@circ@count@a}{1}%
- }
- \expandafter\xdef\csname pgf@anchor@dipchip@bpin\space\the\pgf@circ@count@a\endcsname{%
- \noexpand\pgf@circ@dippinanchor{\the\pgf@circ@count@a}{0}%
- }
- \advance\pgf@circ@count@a by -1\relax%
- \repeatpgfmathloop%
- }%
+ % 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.
+ % see the helper function above the start of the shape definition (by Jonathan P. Spratte)
+ \expandafter\pgf@circ@make@dippin@anchor\expandafter{\the\pgf@circ@count@a}%
+ \advance\pgf@circ@count@a by -1\relax
+ \repeatpgfmathloop
+ }%
}
% QFP (quad flat package) chips
+% helper macro to set the anchors inside a loop (to expand the current count)
+\pgfutil@protected\def\pgf@circ@make@qfppin@anchor#1%
+ {%
+ \expandafter\gdef\csname pgf@anchor@qfpchip@pin #1\endcsname
+ {%
+ \pgf@circ@if@num@in@list\pgf@circ@pins@list{#1}
+ {\pgf@circ@qfppinanchor{#1}{1}}
+ {\pgf@circ@qfppinanchor{#1}{0}}%
+ }%
+ \expandafter\gdef\csname pgf@anchor@qfpchip@bpin #1\endcsname
+ {\pgf@circ@qfppinanchor{#1}{0}}%
+ }
\pgfdeclareshape{qfpchip}{
\savedmacro{\ctikzclass}{\edef\ctikzclass{chips}}
@@ -323,6 +378,14 @@
\pgf@circ@count@a=\ctikzvalof{multipoles/qfpchip/num pins}%
\def\numpins{\the\pgf@circ@count@a}
}
+ \savedmacro\pgf@circ@pins@list
+ {% some magic here, thanks to Jonathan P. Spratte
+ \pgfkeysgetvalue
+ {\circuitikzbasekey/multipoles/draw only pins}\pgf@circ@temp
+ \expandafter\pgf@circ@set@list
+ \expandafter\pgf@circ@pins@list
+ \expandafter{\pgf@circ@temp}%
+ }%
\savedanchor\centerpoint{%
\pgf@x=-.5\wd\pgfnodeparttextbox%
\pgf@y=-.5\ht\pgfnodeparttextbox%
@@ -507,6 +570,7 @@
\fi
\endpgfscope
\ifdim\pgf@circ@res@other>0pt
+ \ifpgfcirc@draw@input@leads
\pgfscope
\pgfsetlinewidth{\ctikzvalof{multipoles/external pins thickness}\pgflinewidth}
\pgf@circ@count@a=\numpins%
@@ -517,44 +581,69 @@
\ifnum\padfrac>0
\pgf@circ@res@temp=\pgf@circ@res@step\divide\pgf@circ@res@temp by \padfrac
% left side pads
- \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
- \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
- \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
- \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
+ \pgf@circ@if@num@in@list\pgf@circ@pins@list\pgf@circ@count@a
+ {%
+ \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
+ \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
+ \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
+ \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
+ }{}%
% bottom side pads
- \pgfpathmoveto{\pgfpoint{-\pgf@circ@res@temp+\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down}}
- \pgfpathlineto{\pgfpoint{-\pgf@circ@res@temp+\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down-\pgf@circ@res@other}}
- \pgfpathlineto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down-\pgf@circ@res@other}}
- \pgfpathlineto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down}}
+ \pgf@circ@if@num@in@list\pgf@circ@pins@list{\numpins/4+\pgf@circ@count@a}
+ {%
+ \pgfpathmoveto{\pgfpoint{-\pgf@circ@res@temp+\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down}}
+ \pgfpathlineto{\pgfpoint{-\pgf@circ@res@temp+\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down-\pgf@circ@res@other}}
+ \pgfpathlineto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down-\pgf@circ@res@other}}
+ \pgfpathlineto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down}}
+ }{}%
% right side pads
- \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
- \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
- \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
- \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
+ \pgf@circ@if@num@in@list\pgf@circ@pins@list{3*\numpins/4+1-\pgf@circ@count@a}
+ {%
+ \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
+ \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
+ \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
+ \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{-\pgf@circ@res@temp+\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
+ }{}%
% top side pads
- \pgfpathmoveto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up}}
- \pgfpathlineto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up+\pgf@circ@res@other}}
- \pgfpathlineto{\pgfpoint{-\pgf@circ@res@temp+\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up+\pgf@circ@res@other}}
- \pgfpathlineto{\pgfpoint{-\pgf@circ@res@temp+\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up}}
+ \pgf@circ@if@num@in@list\pgf@circ@pins@list{3*\numpins/4+\pgf@circ@count@a}
+ {%
+ \pgfpathmoveto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up}}
+ \pgfpathlineto{\pgfpoint{\pgf@circ@res@temp+\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up+\pgf@circ@res@other}}
+ \pgfpathlineto{\pgfpoint{-\pgf@circ@res@temp+\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up+\pgf@circ@res@other}}
+ \pgfpathlineto{\pgfpoint{-\pgf@circ@res@temp+\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up}}
+ }{}%
\else
% left side pins
- \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
- \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
+ \pgf@circ@if@num@in@list\pgf@circ@pins@list\pgf@circ@count@a
+ {%
+ \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
+ \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@other}{\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
+ }{}%
% bottom side pins
- \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down}}
- \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down-\pgf@circ@res@other}}
+ \pgf@circ@if@num@in@list\pgf@circ@pins@list{\numpins/4+\pgf@circ@count@a}
+ {%
+ \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down}}
+ \pgfpathlineto{\pgfpoint{\pgf@circ@res@left-(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@down-\pgf@circ@res@other}}
+ }{}%
% right side pins
- \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
- \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
+ \pgf@circ@if@num@in@list\pgf@circ@pins@list{3*\numpins/4+1-\pgf@circ@count@a}
+ {%
+ \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
+ \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\pgf@circ@res@other}{\pgf@circ@res@up+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}}
+ }{}%
% top side pins
- \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up}}
- \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up+\pgf@circ@res@other}}
+ \pgf@circ@if@num@in@list\pgf@circ@pins@list{3*\numpins/4+\pgf@circ@count@a}
+ {%
+ \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up}}
+ \pgfpathlineto{\pgfpoint{\pgf@circ@res@right+(\pgf@circ@qfp@pin@shift-\the\pgf@circ@count@a)*\pgf@circ@res@step}{\pgf@circ@res@up+\pgf@circ@res@other}}
+ }{}%
\fi
\advance\pgf@circ@count@a-1\relax%
\repeatpgfmathloop
\pgfusepath{stroke}
\endpgfscope
\fi
+ \fi
}%
% \pgf@sh@s@<name of the shape here> contains all the code for the shape
% and is executed just before a node is drawn.
@@ -563,14 +652,9 @@
\pgf@circ@count@a=\numpins%
\pgfmathloop%
\ifnum\pgf@circ@count@a>0
- \expandafter\xdef\csname pgf@anchor@qfpchip@pin\space\the\pgf@circ@count@a\endcsname{%
- \noexpand\pgf@circ@qfppinanchor{\the\pgf@circ@count@a}{1}%
- }
- \expandafter\xdef\csname pgf@anchor@qfpchip@bpin\space\the\pgf@circ@count@a\endcsname{%
- \noexpand\pgf@circ@qfppinanchor{\the\pgf@circ@count@a}{0}%
- }
+ \expandafter\pgf@circ@make@qfppin@anchor\expandafter{\the\pgf@circ@count@a}%
\advance\pgf@circ@count@a-1\relax%
- \repeatpgfmathloop%
+ \repeatpgfmathloop%
}%
}
@@ -1520,21 +1604,103 @@
\tikzset{ALU/.style={muxdemux,
muxdemux def={Lh=5, NL=2, Rh=2, NR=1, NB=2, NT=1, w=2,
inset w=1, inset Lh=2, inset Rh=0, square pins=1}}}
+
%generic mux-demux shape
+
+% helper macros to set the anchors inside a loop (to expand the current count)
+% left
+\pgfutil@protected\def\pgf@circ@make@muxdemux@L@anchor#1%
+ {%
+ \expandafter\gdef\csname pgf@anchor@muxdemux@lpin #1\endcsname
+ {%
+ \pgf@circ@if@num@in@list\pgf@circ@Lpins@list{#1}
+ {\pgf@circ@muxdemux@L@anchor{#1}{1}}
+ {\pgf@circ@muxdemux@L@anchor{#1}{0}}%
+ }%
+ \expandafter\gdef\csname pgf@anchor@muxdemux@blpin #1\endcsname
+ {\pgf@circ@muxdemux@L@anchor{#1}{0}}%
+ }
+% right
+\pgfutil@protected\def\pgf@circ@make@muxdemux@R@anchor#1%
+ {%
+ \expandafter\gdef\csname pgf@anchor@muxdemux@rpin #1\endcsname
+ {%
+ \pgf@circ@if@num@in@list\pgf@circ@Rpins@list{#1}
+ {\pgf@circ@muxdemux@R@anchor{#1}{1}}
+ {\pgf@circ@muxdemux@R@anchor{#1}{0}}%
+ }%
+ \expandafter\gdef\csname pgf@anchor@muxdemux@brpin #1\endcsname
+ {\pgf@circ@muxdemux@R@anchor{#1}{0}}%
+ }
+% bottom
+\pgfutil@protected\def\pgf@circ@make@muxdemux@B@anchor#1%
+ {%
+ \expandafter\gdef\csname pgf@anchor@muxdemux@bpin #1\endcsname
+ {%
+ \pgf@circ@if@num@in@list\pgf@circ@Bpins@list{#1}
+ {\pgf@circ@muxdemux@B@anchor{#1}{1}}
+ {\pgf@circ@muxdemux@B@anchor{#1}{0}}%
+ }%
+ \expandafter\gdef\csname pgf@anchor@muxdemux@bbpin #1\endcsname
+ {\pgf@circ@muxdemux@B@anchor{#1}{0}}%
+ }
+% top
+\pgfutil@protected\def\pgf@circ@make@muxdemux@T@anchor#1%
+ {%
+ \expandafter\gdef\csname pgf@anchor@muxdemux@tpin #1\endcsname
+ {%
+ \pgf@circ@if@num@in@list\pgf@circ@Tpins@list{#1}
+ {\pgf@circ@muxdemux@T@anchor{#1}{1}}
+ {\pgf@circ@muxdemux@T@anchor{#1}{0}}%
+ }%
+ \expandafter\gdef\csname pgf@anchor@muxdemux@btpin #1\endcsname
+ {\pgf@circ@muxdemux@T@anchor{#1}{0}}%
+ }
+
+
\pgfdeclareshape{muxdemux}{
\savedmacro{\ctikzclass}{\edef\ctikzclass{muxdemuxes}}
\saveddimen{\scaledRlen}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}}
\savedmacro{\thisshape}{\def\thisshape{\tikz@fig@name}}
% pins on the four sides
- % \savedmacro\NL{%
- % \pgf@circ@count@a=\ctikzvalof{multipoles/muxdemux/NL}%
- % \def\NL{\the\pgf@circ@count@a}
- % }
\savedmacro\NL{\edef\NL{\ctikzvalof{multipoles/muxdemux/NL}}}
\savedmacro\NR{\edef\NR{\ctikzvalof{multipoles/muxdemux/NR}}}
\savedmacro\NT{\edef\NT{\ctikzvalof{multipoles/muxdemux/NT}}}
\savedmacro\NB{\edef\NB{\ctikzvalof{multipoles/muxdemux/NB}}}
\savedmacro\squarepins{\edef\squarepins{\ctikzvalof{multipoles/muxdemux/square pins}}}
+ % pin lists
+ \savedmacro\pgf@circ@Lpins@list
+ {%
+ \pgfkeysgetvalue
+ {\circuitikzbasekey/multipoles/draw only left pins}\pgf@circ@temp
+ \expandafter\pgf@circ@set@list
+ \expandafter\pgf@circ@Lpins@list
+ \expandafter{\pgf@circ@temp}%
+ }%
+ \savedmacro\pgf@circ@Rpins@list
+ {%
+ \pgfkeysgetvalue
+ {\circuitikzbasekey/multipoles/draw only right pins}\pgf@circ@temp
+ \expandafter\pgf@circ@set@list
+ \expandafter\pgf@circ@Rpins@list
+ \expandafter{\pgf@circ@temp}%
+ }%
+ \savedmacro\pgf@circ@Tpins@list
+ {%
+ \pgfkeysgetvalue
+ {\circuitikzbasekey/multipoles/draw only top pins}\pgf@circ@temp
+ \expandafter\pgf@circ@set@list
+ \expandafter\pgf@circ@Tpins@list
+ \expandafter{\pgf@circ@temp}%
+ }%
+ \savedmacro\pgf@circ@Bpins@list
+ {%
+ \pgfkeysgetvalue
+ {\circuitikzbasekey/multipoles/draw only bottom pins}\pgf@circ@temp
+ \expandafter\pgf@circ@set@list
+ \expandafter\pgf@circ@Bpins@list
+ \expandafter{\pgf@circ@temp}%
+ }%
% topleft and topright sizes
\savedanchor{\topleft}{%
\pgfmathsetlength{\pgf@circ@scaled@Rlen}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}
@@ -1681,7 +1847,8 @@
\fi
\pgfmathloop%
\ifnum\pgf@circ@count@a>0
- %%%%%
+ %%%%% check if we want to draw this pin
+ \pgf@circ@if@num@in@list\pgf@circ@Lpins@list\pgf@circ@count@a{%
\ifdim\pgf@circ@res@down>0pt % check if we have an inset
\ifnum\pgf@circ@count@a>\pgf@circ@count@b\relax
% for lower pins we have to shift them down
@@ -1716,6 +1883,7 @@
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\extshift}{\pgf@circ@res@up+(0.5-\pgf@circ@count@a)*\pgf@circ@res@step}}
\fi
%%%%%
+ }{}% close the pin list check
\advance\pgf@circ@count@a by -1\relax%
\repeatpgfmathloop\fi%
% right pins
@@ -1724,8 +1892,11 @@
\topright\pgf@circ@res@right=\pgf@x \pgf@circ@res@up=\pgf@y
\pgfmathsetlength{\pgf@circ@res@step}{2*\pgf@circ@res@up/\NR}
\ifnum\pgf@circ@count@a>0
+ %%%%% check if we want to draw this pin
+ \pgf@circ@if@num@in@list\pgf@circ@Rpins@list\pgf@circ@count@a{%
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up+(0.5-\pgf@circ@count@a)*\pgf@circ@res@step}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right+\extshift}{\pgf@circ@res@up+(0.5-\pgf@circ@count@a)*\pgf@circ@res@step}}
+ }{}%
\advance\pgf@circ@count@a by -1\relax%
\repeatpgfmathloop\fi%
% bottom pins
@@ -1736,6 +1907,8 @@
\pgfmathsetlength{\pgf@circ@res@step}{2*\pgf@circ@res@right/\NB}
\pgfmathsetlength{\pgf@circ@res@other}{(\pgf@circ@res@down-\pgf@circ@res@up)/(\pgf@circ@res@right-\pgf@circ@res@left)*\pgf@circ@res@step}
\ifnum\pgf@circ@count@a>0
+ %%%%% check if we want to draw this pin
+ \pgf@circ@if@num@in@list\pgf@circ@Bpins@list\pgf@circ@count@a{%
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left+(\pgf@circ@count@a-0.5)*\pgf@circ@res@step}
{-\pgf@circ@res@down+(\NB-\pgf@circ@count@a+0.5)*\pgf@circ@res@other}}
\ifnum\squarepins>0
@@ -1745,6 +1918,7 @@
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left+(\pgf@circ@count@a-0.5)*\pgf@circ@res@step}
{-\pgf@circ@res@down+(\NB-\pgf@circ@count@a+0.5)*\pgf@circ@res@other-\extshift}}
\fi
+ }{}%
\advance\pgf@circ@count@a by -1\relax%
\repeatpgfmathloop\fi%
% top pins
@@ -1755,6 +1929,8 @@
\pgfmathsetlength{\pgf@circ@res@step}{2*\pgf@circ@res@right/\NT}
\pgfmathsetlength{\pgf@circ@res@other}{(\pgf@circ@res@down-\pgf@circ@res@up)/(\pgf@circ@res@right-\pgf@circ@res@left)*\pgf@circ@res@step}
\ifnum\pgf@circ@count@a>0
+ %%%%% check if we want to draw this pin
+ \pgf@circ@if@num@in@list\pgf@circ@Tpins@list\pgf@circ@count@a{%
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left+(\pgf@circ@count@a-0.5)*\pgf@circ@res@step}
{\pgf@circ@res@down-(\NT-\pgf@circ@count@a+0.5)*\pgf@circ@res@other}}
\ifnum\squarepins>0
@@ -1764,6 +1940,7 @@
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left+(\pgf@circ@count@a-0.5)*\pgf@circ@res@step}
{\pgf@circ@res@down-(\NT-\pgf@circ@count@a+0.5)*\pgf@circ@res@other+\extshift}}
\fi
+ }{}%
\advance\pgf@circ@count@a by -1\relax%
\repeatpgfmathloop\fi%
% end drawing pins; stroke them
@@ -1781,12 +1958,7 @@
% we will create two anchors per pin: the "normal one" like `lpin 1` for the
% external leads, and the "border one" like `blpin 1` for internal ones.
% they will coincide if `external pins width` is set to 0.
- \expandafter\xdef\csname pgf@anchor@muxdemux@lpin\space\the\pgf@circ@count@a\endcsname{%
- \noexpand\pgf@circ@muxdemux@L@anchor{\the\pgf@circ@count@a}{1}%
- }
- \expandafter\xdef\csname pgf@anchor@muxdemux@blpin\space\the\pgf@circ@count@a\endcsname{%
- \noexpand\pgf@circ@muxdemux@L@anchor{\the\pgf@circ@count@a}{0}%
- }
+ \expandafter\pgf@circ@make@muxdemux@L@anchor\expandafter{\the\pgf@circ@count@a}%
\advance\pgf@circ@count@a by -1\relax%
\repeatpgfmathloop%
% right anchors
@@ -1796,12 +1968,7 @@
% we will create two anchors per pin: the "normal one" like `rpin 1` for the
% external leads, and the "border one" like `brpin 1` for internal ones.
% they will coincide if `external pins width` is set to 0.
- \expandafter\xdef\csname pgf@anchor@muxdemux@rpin\space\the\pgf@circ@count@a\endcsname{%
- \noexpand\pgf@circ@muxdemux@R@anchor{\the\pgf@circ@count@a}{1}%
- }
- \expandafter\xdef\csname pgf@anchor@muxdemux@brpin\space\the\pgf@circ@count@a\endcsname{%
- \noexpand\pgf@circ@muxdemux@R@anchor{\the\pgf@circ@count@a}{0}%
- }
+ \expandafter\pgf@circ@make@muxdemux@R@anchor\expandafter{\the\pgf@circ@count@a}%
\advance\pgf@circ@count@a by -1\relax%
\repeatpgfmathloop%
% bottom anchors
@@ -1811,12 +1978,7 @@
% we will create two anchors per pin: the "normal one" like `bpin 1` for the
% external leads, and the "border one" like `bbpin 1` for internal ones.
% they will coincide if `external pins width` is set to 0.
- \expandafter\xdef\csname pgf@anchor@muxdemux@bpin\space\the\pgf@circ@count@a\endcsname{%
- \noexpand\pgf@circ@muxdemux@B@anchor{\the\pgf@circ@count@a}{1}%
- }
- \expandafter\xdef\csname pgf@anchor@muxdemux@bbpin\space\the\pgf@circ@count@a\endcsname{%
- \noexpand\pgf@circ@muxdemux@B@anchor{\the\pgf@circ@count@a}{0}%
- }
+ \expandafter\pgf@circ@make@muxdemux@B@anchor\expandafter{\the\pgf@circ@count@a}%
\advance\pgf@circ@count@a by -1\relax%
\repeatpgfmathloop%
% top anchors
@@ -1826,12 +1988,7 @@
% we will create two anchors per pin: the "normal one" like `tpin 1` for the
% external leads, and the "border one" like `btpin 1` for internal ones.
% they will coincide if `external pins width` is set to 0.
- \expandafter\xdef\csname pgf@anchor@muxdemux@tpin\space\the\pgf@circ@count@a\endcsname{%
- \noexpand\pgf@circ@muxdemux@T@anchor{\the\pgf@circ@count@a}{1}%
- }
- \expandafter\xdef\csname pgf@anchor@muxdemux@btpin\space\the\pgf@circ@count@a\endcsname{%
- \noexpand\pgf@circ@muxdemux@T@anchor{\the\pgf@circ@count@a}{0}%
- }
+ \expandafter\pgf@circ@make@muxdemux@T@anchor\expandafter{\the\pgf@circ@count@a}%
\advance\pgf@circ@count@a by -1\relax%
\repeatpgfmathloop%
}%