summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/yquant/yquant-draw.tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-04-14 21:06:44 +0000
committerKarl Berry <karl@freefriends.org>2020-04-14 21:06:44 +0000
commitbbe9e3a2874a81d4559603fc57aa37a0f53ae4bb (patch)
tree3b44a4b917247d46f8b79043e2a2774a9e118d3c /Master/texmf-dist/tex/latex/yquant/yquant-draw.tex
parent70ceb95a32e274762041dec44d43760f70c2dd31 (diff)
yquant (14apr20)
git-svn-id: svn://tug.org/texlive/trunk@54737 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/yquant/yquant-draw.tex')
-rw-r--r--Master/texmf-dist/tex/latex/yquant/yquant-draw.tex410
1 files changed, 357 insertions, 53 deletions
diff --git a/Master/texmf-dist/tex/latex/yquant/yquant-draw.tex b/Master/texmf-dist/tex/latex/yquant/yquant-draw.tex
index baaac6ac0d2..c89eb3ef984 100644
--- a/Master/texmf-dist/tex/latex/yquant/yquant-draw.tex
+++ b/Master/texmf-dist/tex/latex/yquant/yquant-draw.tex
@@ -11,6 +11,8 @@
\fi%
\let\yquant@circuit@extendcontrolline@cmd=\empty%
\let\yquant@circuit@extendcontrolline@prev=\relax%
+ \let\yquant@circuit@extendcontrolline@clip=\empty%
+ \let\yquant@circuit@extendmultiline@total=\empty%
\yquant@langhelper@list@attrs%
% If the quotes library is loaded, activate it. (else, this is by default \relax)
\tikz@enable@node@quotes%
@@ -47,6 +49,7 @@
\yquant@draw@alias@ctrl{#2}p%
\yquant@draw@alias@ctrl{#2}n%
\fi%
+ \yquant@circuit@extendmultiline@total%
\endgroup%
}
@@ -57,86 +60,162 @@
node[/yquant/every operator, \yquant@draw@@style, /yquant/this operator,%
name prefix=, name suffix=, name=yquantbox]%
{\unexpanded\expandafter{\yquant@draw@@content}};%
+ \pgfshapeclippath{yquantbox}%
+ {/yquant/every operator, \yquant@draw@@style,%
+ /yquant/this operator}%
}%
\cmd%
- \ifpgfpointshapexproj{yquantbox}%
- \yquant@circuit@extendwire{#1}%
- \fi%
- \yquant@circuit@extendcontrolline\yquant@draw@@currentcontroltype\yquant@draw@@x%
+ \yquant@circuit@extendwire{#1}%
+ \expandafter\yquant@circuit@extendcontrolline\expandafter%
+ {\the\yquant@draw@@currentcontroltype}\yquant@draw@@x%
% check for empty name parameter
- \if\relax\detokenize{#2}\relax%
- \else%
+ \ifstrempty{#2}\relax{%
\pgfnodealias{\tikz@pp@name{#2}}{yquantbox}%
- \fi%
+ }%
\numdef\yquant@draw@@idx@content{\yquant@draw@@idx@content+1}%
}
-\protected\long\def\yquant@draw@multi#1#2#3#4#5{%
+\protected\def\yquant@draw@multi#1#2#3#4#5{%
\let\idx=\yquant@draw@@idx@content%
+ \edef\yquant@draw@multi@@name{#5}%
+ \def\yquant@draw@@idx@multipart{0}%
+ \let\yquant@circuit@extendmultiline@cmd=\empty%
+ \let\yquant@circuit@extendmultiline@prev=\relax%
+ \let\yquant@circuit@extendmultiline@clip=\empty%
+ \let\yquant@register@multi@contiguous=\yquant@draw@multi@contiguous%
+ #4%
+ \ifnum\yquant@draw@@idx@multipart>1 %
+ % make sure also the first split part is available via the "-s0" suffix
+ \unless\ifx\yquant@draw@multi@@name\empty%
+ \pgfnodealias{\tikz@pp@name{\yquant@draw@multi@@name-s0}}%
+ {\tikz@pp@name{\yquant@draw@multi@@name}}%
+ \fi%
+ \yquant@draw@mline@prep%
+ \fi%
+ \numdef\yquant@draw@@idx@content{\yquant@draw@@idx@content+1}%
+}
+
+\protected\def\yquant@draw@multi@contiguous#1#2#3{%
% We need to somehow extract the y radius
\edef\cmd{%
\noexpand\path (\yquant@draw@@x, \the\dimexpr.5\dimexpr%
\yquant@register@get@y{#1}+\yquant@register@get@y{#2}\relax%
\relax)%
node[/yquant/every operator, \yquant@draw@@style, /yquant/this operator,%
+ /yquant/operator/multi main=\ifnum#3=1 true\else false\fi\unless\ifnum#1=#2 ,%
y radius/.expanded=\the\dimexpr.5\dimexpr\yquant@register@get@ydist{#1}{#2}\relax\relax+%
- .5*\noexpand\pgfkeysvalueof{/tikz/y radius},%
+ .5*\noexpand\pgfkeysvalueof{/tikz/y radius}\fi,%
name prefix=, name suffix=, name=yquantbox]%
{\unexpanded\expandafter{\yquant@draw@@content}};
+ \pgfshapeclippath{yquantbox}%
+ {/yquant/every operator, \yquant@draw@@style,%
+ /yquant/this operator}%
}%
\cmd%
- \ifpgfpointshapexproj{yquantbox}%
- \let\do=\yquant@circuit@extendwire%
- \dolistloop{#4}%
- \fi%
- \yquant@circuit@extendcontrolline\yquant@draw@@currentcontroltype\yquant@draw@@x%
- % check for empty name parameter
- \if\relax\detokenize{#5}\relax%
- \else%
- \pgfnodealias{\tikz@pp@name{#5}}{yquantbox}%
+ \yquant@for \i := #1 to #2 {%
+ \yquant@circuit@extendwire\i%
+ }%
+ \yquant@circuit@extendmultiline\yquant@draw@@x%
+ \expandafter\yquant@circuit@extendcontrolline\expandafter%
+ {\the\yquant@draw@@currentcontroltype}\yquant@draw@@x%
+ \unless\ifx\yquant@draw@multi@@name\empty%
+ \ifnum\yquant@draw@@idx@multipart=0 %
+ \pgfnodealias{\tikz@pp@name{\yquant@draw@multi@@name}}{yquantbox}%
+ \else%
+ \pgfnodealias{\tikz@pp@name{\yquant@draw@multi@@name-s\yquant@draw@@idx@multipart}}{yquantbox}%
+ \fi%
\fi%
- \numdef\yquant@draw@@idx@content{\yquant@draw@@idx@content+1}%
+ \numdef\yquant@draw@@idx@multipart{\yquant@draw@@idx@multipart+1}%
}
-\protected\long\def\yquant@draw@multiinit#1#2#3#4#5{%
+\protected\def\yquant@draw@multiinit#1#2#3#4#5{%
\let\idx=\yquant@draw@@idx@content%
+ \@tempdima=-.5\dimexpr\yquant@config@register@sep\relax%
+ \dimdef\yquant@draw@multiinit@@min{\yquant@register@get@y{#1}-\@tempdima}%
+ \dimdef\yquant@draw@multiinit@@max{\yquant@register@get@y{#2}+\@tempdima}%
+ \dimdef\yquant@draw@multiinit@@total{%
+ \yquant@draw@multiinit@@max-\yquant@draw@multiinit@@min%
+ }%
+ \def\pgfdecorationsegmentaspect{0}%
+ \let\yquant@register@multi@contiguous=\yquant@draw@multiinit@contiguous%
+ \let\pgfdecorationsegmentfromto=\empty%
+ #4%
+ \edef\pgfdecorationsegmentfromto{\expandafter\@gobble\pgfdecorationsegmentfromto}%
% We need to somehow extract the y radius
\edef\cmd{%
\noexpand\path[/yquant/every operator, \yquant@draw@@style,%
/yquant/every multi label, /yquant/this operator]%
- (\yquant@draw@@x, \yquant@register@get@y{#1}) --%
- (\yquant@draw@@x, \yquant@register@get@y{#2})%
+ (\yquant@draw@@x, \yquant@draw@multiinit@@min) --%
+ (\yquant@draw@@x, \yquant@draw@multiinit@@max)%
node[name prefix=, name suffix=, name=yquantbox]%
{\unexpanded\expandafter{\yquant@draw@@content}};
}%
\cmd%
- % no wire extension (we are still at the initial position), no control line (init doesn't allow for those, so just save the no-op)
+ % no wire extension (we are still at the initial position), no control line (init doesn't allow for those, so just save the no-op), no multi line
% check for empty name parameter
- \if\relax\detokenize{#5}\relax%
- \else%
+ \ifstrempty{#5}\relax{%
\pgfnodealias{\tikz@pp@name{#5}}{yquantbox}%
- \fi%
+ }%
\numdef\yquant@draw@@idx@content{\yquant@draw@@idx@content+1}%
}
+\protected\def\yquant@draw@multiinit@contiguous#1#2#3{%
+ \edef\yquant@draw@multiinit@@from{%
+ \pgfmath@tonumber{\dimexpr%
+ \dimexpr\yquant@register@get@y{#1}-\@tempdima-\yquant@draw@multiinit@@min\relax*65536/%
+ \dimexpr\yquant@draw@multiinit@@total\relax%
+ \relax}%
+ }%
+ \edef\yquant@draw@multiinit@@to{%
+ \pgfmath@tonumber{\dimexpr%
+ \dimexpr\yquant@register@get@y{#2}+\@tempdima-\yquant@draw@multiinit@@min\relax*65536/%
+ \dimexpr\yquant@draw@multiinit@@total\relax%
+ \relax}%
+ }%
+ \eappto\pgfdecorationsegmentfromto{,%
+ \yquant@draw@multiinit@@from-\yquant@draw@multiinit@@to%
+ }%
+ % We need to decide where to put the brace arch.
+ \ifdim\yquant@draw@multiinit@@from pt<.5pt %
+ \ifdim\yquant@draw@multiinit@@to pt>.5 pt%
+ % This segment covers the true 1/2 position, take it
+ \def\pgfdecorationsegmentaspect{.5}%
+ \else%
+ % We are not there yet, so the end of this segment is the closest we can get to the mid so far
+ \edef\pgfdecorationsegmentaspect{\yquant@draw@multiinit@@to}%
+ \fi%
+ \else%
+ % We are already beyond the mid...
+ \ifdim\pgfdecorationsegmentaspect pt<.5pt %
+ % ...but we did not find an ideal position yet
+ \ifdim\dimexpr\yquant@draw@multiinit@@from pt-.5pt\relax<%
+ \dimexpr.5pt-\pgfdecorationsegmentaspect pt\relax%
+ % this one is closer to the mid than anything found before
+ \edef\pgfdecorationsegmentaspect{\yquant@draw@multiinit@from}%
+ \fi%
+ \fi%
+ \fi%
+}
+
\protected\def\yquant@draw@control#1#2#3{%
\edef\cmd{%
\noexpand\path (\yquant@draw@@x, \yquant@register@get@y{#2})%
node[/yquant/every control, /yquant/every #1 control, /yquant/this control,%
name prefix=, name suffix=, name=yquantbox]%
{};%
+ \pgfshapeclippath{yquantbox}%
+ {/yquant/every control, /yquant/every #1 control,%
+ /yquant/this control}%
}%
\cmd%
- \ifpgfpointshapexproj{yquantbox}%
- \yquant@circuit@extendwire{#2}%
- \fi%
+ \yquant@circuit@extendwire{#2}%
\yquant@draw@@currentcontroltype=\yquant@register@get@type{#2}\relax%
- \yquant@circuit@extendcontrolline\yquant@draw@@currentcontroltype\yquant@draw@@x%
+ \expandafter\yquant@circuit@extendcontrolline\expandafter%
+ {\yquant@draw@@currentcontroltype}\yquant@draw@@x%
% check for empty name parameter
- \if\relax\detokenize{#3}\relax%
- \else%
+ \ifstrempty{#3}\relax{%
\pgfnodealias{\tikz@pp@name{#3}}{yquantbox}%
- \fi%
+ }%
}
\protected\def\yquant@draw@pcontrol#1#2{%
@@ -152,11 +231,62 @@
}
\protected\def\yquant@draw@cline{%
- \edef\cmd{%
- \noexpand\path[/yquant/every control line]%
- \yquant@circuit@extendcontrolline@cmd;
+ \pgfscope%
+ % install the clipping
+ \pgfsyssoftpath@setcurrentpath\yquant@circuit@extendcontrolline@clip%
+ % and invert it. It is sufficient to cover the current bounding box, as the wire will be drawn between existing operators.
+ \ifyquantdebug%
+ \pgfsetfillcolor{teal}%
+ \pgfsetfillopacity{.3}%
+ \pgfusepathqfill%
+ \else%
+ \begingroup%
+ \pgftransformreset%
+ \pgfpathrectanglecorners%
+ {\pgfqpoint{\pgf@picminx}{\pgf@picminy}}%
+ {\pgfqpoint{\pgf@picmaxx}{\pgf@picmaxy}}%
+ \pgfseteorule% even-odd to properly invert the clipping
+ \pgfusepathqclip%
+ \endgroup%
+ \fi%
+ \edef\cmd{%
+ \noexpand\path[/yquant/every control line]%
+ \yquant@circuit@extendcontrolline@cmd;
+ }%
+ \cmd%
+ \endpgfscope%
+}
+
+\protected\def\yquant@draw@mline@prep{%
+ \eappto\yquant@circuit@extendmultiline@total{%
+ \yquant@draw@mline%
+ {\unexpanded\expandafter{\yquant@circuit@extendmultiline@clip}}%
+ {\yquant@circuit@extendmultiline@cmd}%
}%
- \cmd%
+}
+
+\protected\def\yquant@draw@mline#1#2{%
+ \pgfscope%
+ % install the clipping
+ \def\pgfsyssoftpath@thepath{#1}%
+ \pgfsyssoftpath@setcurrentpath\pgfsyssoftpath@thepath%
+ % and invert it. It is sufficient to cover the current bounding box, as the wire will be drawn between existing operators.
+ \ifyquantdebug%
+ \pgfsetfillcolor{teal}%
+ \pgfsetfillopacity{.3}%
+ \pgfusepathqfill%
+ \else%
+ \begingroup%
+ \pgftransformreset%
+ \pgfpathrectanglecorners%
+ {\pgfqpoint{\pgf@picminx}{\pgf@picminy}}%
+ {\pgfqpoint{\pgf@picmaxx}{\pgf@picmaxy}}%
+ \pgfseteorule% even-odd to properly invert the clipping
+ \pgfusepathqclip%
+ \endgroup%
+ \fi%
+ \path[/yquant/every multi line] #2;
+ \endpgfscope%
}
\protected\def\yquant@draw@alias#1{%
@@ -166,6 +296,106 @@
\protected\def\yquant@draw@alias@ctrl#1#2{%
\pgfnodealias{\tikz@pp@name{#1-#2}}{\tikz@pp@name{#1-#20}}%
}
+
+\protected\def\yquant@draw@wire#1#2{%
+ \begingroup%
+ \yquant@register@get@typeywire{#1}\wiretype\wireypos\wirelast%
+ \edef\wirexprevpos{\expandafter\@firstoffour\wirelast}%
+ \ifx\yquant@env@end@xpos#2\relax%
+ \let\wirexpos=\yquant@env@end@xpos%
+ \else%
+ \edef\wirexpos{\expandafter\@secondoffour\wirelast}%
+ \fi%
+ \unless\ifnum\wiretype=\yquant@register@type@none%
+ \ifdim\wirexpos>\wirexprevpos %
+ \edef\wirestyle{\noexpand\tikzset{%
+ /yquant/this wire/.style={%
+ /yquant/every wire,%
+ /yquant/every \ifcase\wiretype\relax nobit\or qubit \or cbit \or qubits \fi wire,%
+ \yquant@register@get@style{#1}%
+ }, /yquant/this wire%
+ }}%
+ \wirestyle%
+ % load all clippings
+ \edef\wireclipping{%
+ \unexpanded\expandafter\expandafter\expandafter{%
+ \expandafter\@thirdandfourthoffour\wirelast%
+ }%
+ }%
+ \pgfscope%
+ % install the clipping
+ \pgfsyssoftpath@setcurrentpath\wireclipping%
+ % invert the clipping
+ \ifyquantdebug%
+ \pgfsetfillcolor{orange}%
+ \pgfsetfillopacity{.3}%
+ \pgfusepathqfill%
+ \else%
+ % We need to access the current bounding box as well as other positions in the local coordinate frame. For this, transform the bounding box to the current frame (though this is expensive). Does this capture rotations correctly?
+ \begingroup%
+ \pgftransforminvert%
+ \pgfpointtransformednonlinear{\pgfqpoint{\pgf@picminx}{\pgf@picminy}}
+ \global\@tempdima=\pgf@y%
+ \pgfpointtransformednonlinear{\pgfqpoint{\pgf@picmaxx}{\pgf@picmaxy}}%
+ \global\@tempdimb=\pgf@y%
+ \endgroup%
+ % To avoid rendering artifacts at all zoom levels with all renderers, we need to make the clipping region large. Let's try the current bounding box first.
+ % This may be insufficient if there no or a tiny wire label and only registers of a small height. In this case, take at ten times the line width or at least 1cm, but don't let it affect the bounding box.
+ \ifdim\dimexpr\@tempdimb-\@tempdima\relax<10\pgflinewidth %
+ \@tempdima=\dimexpr\wireypos-5\pgflinewidth\relax%
+ \@tempdimb=\dimexpr\wireypos+5\pgflinewidth\relax%
+ \fi%
+ \ifdim\dimexpr\@tempdimb-\@tempdima\relax<1cm %
+ \@tempdima=\dimexpr\wireypos-5mm\relax%
+ \@tempdimb=\dimexpr\wireypos+5mm\relax%
+ \fi%
+ \pgfinterruptboundingbox%
+ \pgfpathrectanglecorners%
+ {\pgfqpoint{\dimexpr\wirexprevpos-2\pgflinewidth\relax}%
+ {\@tempdima}}%
+ {\pgfqpoint{\dimexpr\wirexpos+2\pgflinewidth\relax}%
+ {\@tempdimb}}%
+ \endpgfinterruptboundingbox%
+ \pgfseteorule% even-odd to properly invert the clipping
+ \pgfusepathqclip%
+ \fi%
+ % the clip inversion is left to the drawing commands (clip two \pgflinewidth more to avoid renderer artifacts)
+ \csname yquant@draw@wire@\wiretype\endcsname{#1}%
+ \endpgfscope%
+ \fi%
+ \fi%
+ \endgroup%
+}
+
+% quantum wire
+\protected\csdef{yquant@draw@wire@\yquant@register@type@q}#1{%
+ \edef\cmd{%
+ \noexpand\path [/yquant/this wire]
+ (\wirexprevpos,\wireypos) -- (\wirexpos,\wireypos);%
+ }%
+ \cmd%
+}
+
+% classical wire
+\protected\csdef{yquant@draw@wire@\yquant@register@type@c}#1{%
+ \edef\cmd{%
+ \noexpand\path [/yquant/this wire]
+ (\wirexprevpos,\wireypos+2\pgflinewidth)--(\wirexpos,\wireypos+2\pgflinewidth)%
+ (\wirexprevpos,\wireypos-2\pgflinewidth)--(\wirexpos,\wireypos-2\pgflinewidth);%
+ }%
+ \cmd%
+}
+
+% quantum-bundle
+\protected\csdef{yquant@draw@wire@\yquant@register@type@qs}#1{%
+ \edef\cmd{%
+ \noexpand\path [/yquant/this wire]
+ (\wirexprevpos,\wireypos+2\pgflinewidth)--(\wirexpos,\wireypos+2\pgflinewidth)%
+ (\wirexprevpos,\wireypos)--(\wirexpos,\wireypos)%
+ (\wirexprevpos,\wireypos-2\pgflinewidth)--(\wirexpos,\wireypos-2\pgflinewidth);%
+ }%
+ \cmd%
+}
% END_FOLD
% BEGIN_FOLD Preparation of drawing a generic shape
@@ -274,7 +504,7 @@
\advance \dimen2 by \yquant@circuit@operator@x\relax%
% BEGIN_FOLD shipout
\ifyquant@circuit@operator@hasControls%
- % If we draw a control line, all intermediate registers are affected in their position so that the line is never crossed.
+ % If we draw a control line, all intermediate registers are affected in their position so that the line is never crossed. If the vertical line is instead caused by a multi register, \yquant@draw@finalize@ctrl will be responsible for advancing only the affected positions.
\yquant@for \yquant@i := \yquant@circuit@operator@minctrl to \yquant@circuit@operator@maxctrl {%
\yquant@register@set@x\yquant@i{\the\dimen2}%
}%
@@ -354,14 +584,39 @@
#3%
{\nodename}%
}%
- % Determining the actual height is a problem - where to store its value? We just assume that there is always enough space for such a control, since it anyway already spans multiple registers. (TODO?)
+ % Determining the actual height is a problem - where to store its value? If there are single-register parts, we update the height accordingly; else we just assume that there is always enough space for such a control, since it anyways already spans multiple registers. (TODO?)
\pgfinterruptboundingbox%
\yquant@env@virtualize@path%
- % Here, we just set a dummy height, as we don't know the actual height yet. As the width of most/all shapes should not depend on their height, it does not matter.
- \path%
- (0pt, 0pt)
- node[/yquant/every operator, #2, /yquant/this operator, y radius=1cm,%
- name prefix=, name suffix=0, name=] {#1};
+ \def\yquant@draw@@content{#1}%
+ \def\yquant@draw@@style{#2}%
+ \let\yquant@register@multi@contiguous=\yquant@draw@@multi@contiguous%
+ \@fifthoffive#3%
+ \ifdim\pgf@picmaxy=-16000pt %
+ % if there was no single contiguous part before, determine the width now
+ \path%
+ (0pt, 0pt)
+ node[/yquant/every operator, #2, /yquant/this operator,%
+ name prefix=, name suffix=, name=] {#1};
+ \fi%
+}
+
+\protected\def\yquant@draw@@multi@contiguous#1#2#3{%
+ \ifnum#1=#2 %
+ % we only care about single-register parts
+ \global\pgf@picmaxy=-16000pt %
+ \global\pgf@picminy=16000pt %
+ \edef\cmd{%
+ \noexpand\path (0pt, 0pt)%
+ node[/yquant/every operator, \yquant@draw@@style, /yquant/this operator,%
+ /yquant/operator/multi main=\ifnum#3=1 true\else false\fi,
+ name prefix=, name suffix=, name=]%
+ {\unexpanded\expandafter{\yquant@draw@@content}};
+ }%
+ \cmd%
+ \yquant@register@update@height{#1}{%
+ \the\dimexpr\pgf@picmaxy-\pgf@picminy\relax%
+ }%
+ \fi%
}
\protected\def\yquant@draw@@multiinit#1#2#3{%
@@ -373,11 +628,10 @@
% Determining the actual height is a problem - where to store its value? We just assume that there is always enough space for such a control, since it anyway already spans multiple registers. (TODO?)
\pgfinterruptboundingbox%
\yquant@env@virtualize@path%
- % Here, we just set a dummy height, as we don't know the actual height yet. As the width of most/all shapes should not depend on their height, it does not matter.
\path%
(0pt, 0pt)
- node[/yquant/every operator, #2, /yquant/every multi label, y radius=1cm,%
- name prefix=, name suffix=0, name=] {#1};
+ node[/yquant/every operator, #2, /yquant/every multi label,%
+ name prefix=, name suffix=, name=] {#1};
}
\def\yquant@draw@finalize@ctrl#1{%
@@ -401,6 +655,12 @@
}%
}
+\protected\def\yquant@draw@finalize@ctrl@singleinit#1#2{%
+ \eappto\yquant@draw@append{%
+ \yquant@draw@callback@wire{#1}%
+ }%
+}
+
\protected\def\yquant@draw@finalize@ctrl@multi#1#2#3#4#5{%
\unless\ifyquant@circuit@operator@hasControls{%
% \yquant@for uses \loop...\repeat and hence redefines \body, which would destroy an outer loop.
@@ -410,13 +670,57 @@
}%
}\fi%
% this is called from a do loop itself, so preserve \do (but do not enter grouping)
- \let\yquant@draw@update@x@multi@@olddo=\do%
- \def\do##1{%
- \eappto\yquant@draw@append{%
- \yquant@draw@callback@wire{##1}%
+ \let\yquant@register@multi@contiguous=\yquant@draw@finalize@ctrl@multi@contiguous%
+ \ifyquant@circuit@operator@hasControls%
+ \ifyquant@config@operator@multi@warn%
+ \def\yquant@draw@finalize@ctrl@multi@contiguous@warn{0}%
+ \else%
+ \def\yquant@draw@finalize@ctrl@multi@contiguous@warn{2}%
+ \fi%
+ \else%
+ \def\yquant@draw@finalize@ctrl@multi@contiguous@warn{2}%
+ \fi%
+ \cslet{\yquant@prefix finalize@ctrl@draw@appto}\empty%
+ #4%
+ \eappto\yquant@draw@append{\csname\yquant@prefix finalize@ctrl@draw@appto\endcsname}%
+ \csgundef{\yquant@prefix finalize@ctrl@draw@appto}%
+}
+
+\protected\def\yquant@draw@finalize@ctrl@multiinit#1#2#3#4#5{%
+ % this is called from a do loop itself, so preserve \do (but do not enter grouping)
+ \let\yquant@register@multi@contiguous=\yquant@draw@finalize@ctrl@multi@contiguous%
+ \ifyquant@circuit@operator@hasControls%
+ \ifyquant@config@operator@multi@warn%
+ \def\yquant@draw@finalize@ctrl@multi@contiguous@warn{0}%
+ \else%
+ \def\yquant@draw@finalize@ctrl@multi@contiguous@warn{2}%
+ \fi%
+ \else%
+ \def\yquant@draw@finalize@ctrl@multi@contiguous@warn{2}%
+ \fi%
+ \cslet{\yquant@prefix finalize@ctrl@draw@appto}\empty%
+ #4%
+ \eappto\yquant@draw@append{\csname\yquant@prefix finalize@ctrl@draw@appto\endcsname}%
+ \csgundef{\yquant@prefix finalize@ctrl@draw@appto}%
+}
+
+\protected\def\yquant@draw@finalize@ctrl@multi@contiguous#1#2#3{%
+ \ifnum\yquant@draw@finalize@ctrl@multi@contiguous@warn=1 %
+ \PackageWarning{yquant.sty}{Ambiguous operation: multiple discontiguous multi-register operations in combination with controls make it hard to visually determine on which registers the gates act on.}%
+ % switch the warning off for this group (which is a single operation)
+ \yquant@config@operator@multi@warnfalse%
+ \def\yquant@draw@finalize@ctrl@multi@contiguous@warn{2}%
+ \else%
+ \numdef\yquant@draw@finalize@ctrl@multi@contiguous@warn{%
+ \yquant@draw@finalize@ctrl@multi@contiguous@warn+1%
}%
+ \fi%
+ {% save \body
+ \yquant@for \yquant@i := #1 to #2 {{% let inner loop mess up with macros
+ \csxappto{\yquant@prefix finalize@ctrl@draw@appto}{%
+ \expandafter\yquant@draw@callback@wire\expandafter{\yquant@i}%
+ }%
+ }}%
}%
- \dolistloop{#4}%
- \let\do=\yquant@draw@update@x@multi@@olddo%
}
% END_FOLD \ No newline at end of file