summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/yquant/yquant-draw.tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2022-02-05 21:23:01 +0000
committerKarl Berry <karl@freefriends.org>2022-02-05 21:23:01 +0000
commit57df68d21de1b2bd14611df0f545834e2fbe26ce (patch)
tree5eb6720900623108d5733183dd5016e4a895853c /Master/texmf-dist/tex/latex/yquant/yquant-draw.tex
parent26bd0456c7b295515be257d4fbf595d2393b9bab (diff)
yquant (5feb22)
git-svn-id: svn://tug.org/texlive/trunk@61897 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.tex561
1 files changed, 329 insertions, 232 deletions
diff --git a/Master/texmf-dist/tex/latex/yquant/yquant-draw.tex b/Master/texmf-dist/tex/latex/yquant/yquant-draw.tex
index 574a45eec19..6f509418099 100644
--- a/Master/texmf-dist/tex/latex/yquant/yquant-draw.tex
+++ b/Master/texmf-dist/tex/latex/yquant/yquant-draw.tex
@@ -62,19 +62,19 @@
\ifyquant@env@seamless{%
\unless\ifdim\yquant@draw@@x=\yquant@draw@subcircuit@leftpos%
\dimdef\yquant@draw@@x{%
- \yquant@draw@@x+\yquant@config@operator@sep%
+ \yquant@draw@@x\yquant@orientation@plus\yquant@config@operator@sep%
}%
\fi%
}{%
\dimdef\yquant@draw@@x{%
- \yquant@draw@@x+\yquant@config@operator@sep%
+ \yquant@draw@@x\yquant@orientation@plus\yquant@config@operator@sep%
}%
}%
\ifyquant@config@operator@position@advance%
- \dimdef\newx{\yquant@draw@@x+#1}%
+ \dimdef\newx{\yquant@draw@@x\yquant@orientation@plus#1}%
\forlistloop\yquant@draw@group@advance{#6}%
\fi%
- \dimdef\yquant@draw@@x{\yquant@draw@@x+.5\dimexpr#1\relax}%
+ \dimdef\yquant@draw@@x{\yquant@draw@@x\yquant@orientation@plus.5\dimexpr#1\relax}%
\fi%
}
@@ -157,9 +157,11 @@
\fi%
\edef\process{%
\endgroup%
- \def\noexpand\yquant@circuit@extendcontrolline@clip{%
- \unexpanded\expandafter{\yquant@circuit@extendcontrolline@clip}%
- }%
+ \ifyquant@config@draw@quality%
+ \def\noexpand\yquant@circuit@extendcontrolline@clip{%
+ \unexpanded\expandafter{\yquant@circuit@extendcontrolline@clip}%
+ }%
+ \fi%
\def\noexpand\yquant@circuit@extendcontrolline@prev{%
\unexpanded\expandafter{\yquant@circuit@extendcontrolline@prev}%
}%
@@ -196,13 +198,15 @@
\let\idx=\yquant@draw@@idx@content%
\yquant@config@operator@multifalse%
\edef\cmd{%
- \noexpand\path (\yquant@draw@@x, \yquant@register@get@y{#1})%
+ \noexpand\path \yquant@coords(\yquant@draw@@x, \yquant@register@get@y{#1})%
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}%
+ \ifyquant@config@draw@quality%
+ \pgfshapeclippath{yquantbox}%
+ {/yquant/every operator, \yquant@draw@@style,%
+ /yquant/this operator}%
+ \fi%
}%
\cmd%
\yquant@circuit@extendwire{#1}{center}%
@@ -239,18 +243,20 @@
\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%
+ \noexpand\path \yquant@coords(\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/internal/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}\fi,%
+ space radius/.expanded=\the\dimexpr.5\dimexpr\yquant@register@get@ydist{#1}{#2}\relax\relax+%
+ .5*\noexpand\pgfkeysvalueof{/tikz/\yquant@orientation@y\space radius}\fi,%
name prefix=, name suffix=, name=yquantbox]%
{\unexpanded\expandafter{\yquant@draw@@content}};%
- \pgfshapeclippath{yquantbox}%
- {/yquant/every operator, \yquant@draw@@style,%
- /yquant/this operator}%
+ \ifyquant@config@draw@quality%
+ \pgfshapeclippath{yquantbox}%
+ {/yquant/every operator, \yquant@draw@@style,%
+ /yquant/this operator}%
+ \fi%
}%
\cmd%
\yquant@for \i := #1 to #2 {%
@@ -271,7 +277,7 @@
\protected\def\yquant@draw@multiinit#1#2#3#4#5{%
\let\idx=\yquant@draw@@idx@content%
- \@tempdima=-.5\dimexpr\yquant@config@register@sep\relax%
+ \@tempdima=\yquant@orientation@minus.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{%
@@ -285,19 +291,21 @@
\yquant@config@operator@multitrue%
% We need to somehow extract the y radius
\edef\cmd{%
- \noexpand\path (\yquant@draw@@x, \the\dimexpr.5\dimexpr%
+ \noexpand\path \yquant@coords(\yquant@draw@@x, \the\dimexpr.5\dimexpr%
\yquant@draw@multiinit@@min+\yquant@draw@multiinit@@max\relax%
\relax)%
node[/yquant/every operator, \yquant@draw@@style,
\ifnum\yquant@compat<2 /yquant/every multi label,\fi%
/yquant/this operator,%
- y radius=\yquant@abs{\the\dimexpr.5\dimexpr\yquant@draw@multiinit@@total\relax\relax},%
+ space radius=\yquant@abs{\the\dimexpr.5\dimexpr\yquant@draw@multiinit@@total\relax\relax},%
name prefix=, name suffix=, name=yquantbox]%
{\unexpanded\expandafter{\yquant@draw@@content}};%
- \pgfshapeclippath{yquantbox}%
- {/yquant/every operator, \yquant@draw@@style,%
- \ifnum\yquant@compat<2 /yquant/every multi label,\fi%
- /yquant/this operator}%
+ \ifyquant@config@draw@quality%
+ \pgfshapeclippath{yquantbox}%
+ {/yquant/every operator, \yquant@draw@@style,%
+ \ifnum\yquant@compat<2 /yquant/every multi label,\fi%
+ /yquant/this operator}%
+ \fi%
}%
\cmd%
\yquant@for \i := #1 to #2 {%
@@ -353,20 +361,22 @@
\let\idx=\yquant@draw@@idx@content%
\yquant@config@operator@multifalse%
\edef\cmd{%
- \noexpand\path (\yquant@circuit@endwires@x, \yquant@register@get@y{#1})%
+ \noexpand\path \yquant@coords(\yquant@circuit@endwires@x, \yquant@register@get@y{#1})%
node[\ifnum\yquant@compat>1 /yquant/every operator,\fi%
/yquant/every output,%
/yquant/every \yquant@register@type@tostring{\yquant@register@get@type{#1}} output,%
\yquant@draw@@style, /yquant/this operator,%
name prefix=, name suffix=, name=yquantbox]%
{\unexpanded\expandafter{\yquant@draw@@content}};%
- \ifdefined\yquant@parent%
- \pgfshapeclippath{yquantbox}%
- {\ifnum\yquant@compat>1 /yquant/every operator,\fi%
- /yquant/every output,%
- /yquant/every \yquant@register@type@tostring{\yquant@register@get@type{#1}} output,%
- \yquant@draw@@style,%
- /yquant/this operator}%
+ \ifyquant@config@draw@quality%
+ \ifdefined\yquant@parent%
+ \pgfshapeclippath{yquantbox}%
+ {\ifnum\yquant@compat>1 /yquant/every operator,\fi%
+ /yquant/every output,%
+ /yquant/every \yquant@register@type@tostring{\yquant@register@get@type{#1}} output,%
+ \yquant@draw@@style,%
+ /yquant/this operator}%
+ \fi%
\fi%
}%
\cmd%
@@ -383,7 +393,7 @@
\protected\long\def\yquant@draw@output@multi#1#2#3#4#5{%
\let\idx=\yquant@draw@@idx@content%
- \@tempdima=-.5\dimexpr\yquant@config@register@sep\relax%
+ \@tempdima=\yquant@orientation@minus.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{%
@@ -397,22 +407,24 @@
\yquant@config@operator@multitrue%
% We need to somehow extract the y radius
\edef\cmd{%
- \noexpand\path (\yquant@circuit@endwires@x, \the\dimexpr.5\dimexpr%
+ \noexpand\path \yquant@coords(\yquant@circuit@endwires@x, \the\dimexpr.5\dimexpr%
\yquant@draw@multiinit@@min+\yquant@draw@multiinit@@max\relax%
\relax)%
node[\ifnum\yquant@compat>1 /yquant/every operator,\fi /yquant/every output,%
\yquant@draw@@style,%
\ifnum\yquant@compat<2 /yquant/every multi output,\fi%
/yquant/this operator,%
- y radius=\yquant@abs{\the\dimexpr.5\dimexpr\yquant@draw@multiinit@@total\relax\relax},%
+ space radius=\yquant@abs{\the\dimexpr.5\dimexpr\yquant@draw@multiinit@@total\relax\relax},%
name prefix=, name suffix=, name=yquantbox]%
{\unexpanded\expandafter{\yquant@draw@@content}};%
- \ifdefined\yquant@parent%
- \pgfshapeclippath{yquantbox}%
- {\ifnum\yquant@compat>1 /yquant/every operator,\fi /yquant/every output,%
- \yquant@draw@@style,
- \ifnum\yquant@compat<2 /yquant/every multi output,\fi%
- /yquant/this operator}%
+ \ifyquant@config@draw@quality%
+ \ifdefined\yquant@parent%
+ \pgfshapeclippath{yquantbox}%
+ {\ifnum\yquant@compat>1 /yquant/every operator,\fi /yquant/every output,%
+ \yquant@draw@@style,
+ \ifnum\yquant@compat<2 /yquant/every multi output,\fi%
+ /yquant/this operator}%
+ \fi%
\fi%
}%
\cmd%
@@ -449,15 +461,16 @@
\global\cslet\yquant@draw@subcircuit@nodelist\empty%
% \pgfinterruptboundingbox, but just for y
\begingroup%
- \edef\pgf@interrupt@savemaxy{\the\pgf@picmaxy}%
- \edef\pgf@interrupt@saveminy{\the\pgf@picminy}%
- \pgf@picmaxy=-16000pt %
- \pgf@picminy=16000pt %
+ \edef\pgf@interrupt@savemaxy{\the\yquant@pgf@picmaxy}%
+ \edef\pgf@interrupt@saveminy{\the\yquant@pgf@picminy}%
+ \yquant@pgf@picmaxy=-16000pt %
+ \yquant@pgf@picminy=16000pt %
\pgf@size@hookedfalse%
\let\pgf@path@size@hook=\pgfutil@empty%
% now we must take care of extending all the wires appropriately until the beginning of the box. #4 contains width of this box, #5 contains registers affected by this box. Note that for subcircuits, x extension by the group is disabled.
\dimdef\newx{%
- \yquant@draw@@x-.5\dimexpr\@secondofthree#4\relax%
+ \yquant@draw@@x\yquant@orientation@minus%
+ .5\dimexpr\@secondofthree#4\relax%
}%
\dimen0=\newx%
\let\yquant@draw@subcircuit@leftpos=\newx% seamless subcircuits: do not add another separation if we are there
@@ -465,7 +478,9 @@
\forlistloop\yquant@draw@move@loop{#5}%
% but the new positions are not at the beginning of the box, but inside (with possible margin)
\dimdef\newx{%
- \yquant@draw@@x-.5\dimexpr\@firstofthree#4\relax-\@thirdofthree#4%
+ \yquant@draw@@x\yquant@orientation@minus%
+ .5\dimexpr\@firstofthree#4\relax\yquant@orientation@minus%
+ \@thirdofthree#4%
}%
\forlistloop\yquant@draw@group@advance{#5}%
\setbox\yquant@prepare@subcircuit@box=\hbox{{%
@@ -509,53 +524,55 @@
/yquant/this operator, /yquant/internal/multi main=true,%
}%
\expandafter\tikzset\expandafter{\yquant@draw@subcircuit@style}%
+ % #18: The styles may have set this subcircuit box again, but we disallow this. The "this" style is only supposed to effect the actual box and nothing else, so it should not permeat in the inner of the circuit. This is what every subcircuit box is for!
+ \pgfkeys{/yquant/operators/this subcircuit box/.style={}}%
\begingroup%
\csname\yquant@prefix draw\endcsname%
\endgroup%
% BEGIN_FOLD bounding box
% Completely empty wires did not yet affect the bounding box
- % Problem: we compare an user-mode TikZ position (register y position) with a system-level pgf position (picture boundary box). If shifts or scalings are in effect, we must first transform the point appropriately. Note that negative scalings may upset our assumption of which is the minimum and which is the maximum! If additionally rotations are in effect, we must even consider those transformations for the leftmost and the rightmost point, which makes all of this far more complicated than it should be. For this reason, we have a shortcut in action in case no nontranslation transformations are present.
+ % Problem: we compare a user-mode TikZ position (register y position) with a system-level pgf position (picture boundary box). If shifts or scalings are in effect, we must first transform the point appropriately. Note that negative scalings may upset our assumption of which is the minimum and which is the maximum! If additionally rotations are in effect, we must even consider those transformations for the leftmost and the rightmost point, which makes all of this far more complicated than it should be. For this reason, we have a shortcut in action in case no nontranslation transformations are present.
\ifpgf@pt@identity%
- \dimen0=\dimexpr\yquant@register@get@y1+\pgf@pt@y\relax%
- \ifdim\dimen0>\pgf@picmaxy %
- \global\pgf@picmaxy=\dimen0 %
+ \dimen0=\dimexpr\yquant@register@get@y1+\yquant@pgf@pt@y\relax%
+ \ifdim\dimen0>\yquant@pgf@picmaxy %
+ \global\yquant@pgf@picmaxy=\dimen0 %
\fi%
- \dimen0=\dimexpr\yquant@register@get@y{\csname\yquant@prefix registers\endcsname}+\pgf@pt@y\relax%
- \ifdim\dimen0<\pgf@picminy %
- \global\pgf@picminy=\dimen0 %
+ \dimen0=\dimexpr\yquant@register@get@y{\csname\yquant@prefix registers\endcsname}+\yquant@pgf@pt@y\relax%
+ \ifdim\dimen0<\yquant@pgf@picminy %
+ \global\yquant@pgf@picminy=\dimen0 %
\fi%
\else%
% first wire, left end
- \pgfpointtransformed{\pgfqpoint{\yquant@draw@@x-.5\dimexpr\@firstofthree#4\relax}{\yquant@register@get@y1\relax}}%
- \ifdim\pgf@y>\pgf@picmaxy %
- \global\pgf@picmaxy=\pgf@y %
+ \pgfpointtransformed{\yquant@pgfqpoint{\yquant@draw@@x-.5\dimexpr\@firstofthree#4\relax}{\yquant@register@get@y1\relax}}%
+ \ifdim\yquant@pgf@y>\yquant@pgf@picmaxy %
+ \global\yquant@pgf@picmaxy=\yquant@pgf@y %
\fi%
- \ifdim\pgf@y<\pgf@picminy % negative scaling
- \global\pgf@picminy=\pgf@y %
+ \ifdim\yquant@pgf@y<\yquant@pgf@picminy % negative scaling
+ \global\yquant@pgf@picminy=\yquant@pgf@y %
\fi%
% first wire, right end
- \pgfpointtransformed{\pgfqpoint{\yquant@draw@@x+.5\dimenxpr\@firstofthree#4\relax}{\yquant@register@get@y1\relax}}%
- \ifdim\pgf@y>\pgf@picmaxy %
- \global\pgf@picmaxy=\pgf@y %
+ \pgfpointtransformed{\yquant@pgfqpoint{\yquant@draw@@x+.5\dimenxpr\@firstofthree#4\relax}{\yquant@register@get@y1\relax}}%
+ \ifdim\yquant@pgf@y>\yquant@pgf@picmaxy %
+ \global\yquant@pgf@picmaxy=\yquant@pgf@y %
\fi%
- \ifdim\pgf@y<\pgf@picminy % negative scaling
- \global\pgf@picminy=\pgf@y %
+ \ifdim\yquant@pgf@y<\yquant@pgf@picminy % negative scaling
+ \global\yquant@pgf@picminy=\yquant@pgf@y %
\fi%
% last wire, left end
- \pgfpointtransformed{\pgfqpoint{\yquant@draw@@x-.5\dimexpr\@firstofthree#4\relax}{\yquant@register@get@y{\csname\yquant@prefix registers\endcsname}\relax}}%
- \ifdim\pgf@y>\pgf@picmaxy %
- \global\pgf@picmaxy=\pgf@y %
+ \pgfpointtransformed{\yquant@pgfqpoint{\yquant@draw@@x-.5\dimexpr\@firstofthree#4\relax}{\yquant@register@get@y{\csname\yquant@prefix registers\endcsname}\relax}}%
+ \ifdim\yquant@pgf@y>\yquant@pgf@picmaxy %
+ \global\yquant@pgf@picmaxy=\yquant@pgf@y %
\fi%
- \ifdim\pgf@y<\pgf@picminy % negative scaling
- \global\pgf@picminy=\pgf@y %
+ \ifdim\yquant@pgf@y<\yquant@pgf@picminy % negative scaling
+ \global\yquant@pgf@picminy=\yquant@pgf@y %
\fi%
% last wire, right end
- \pgfpointtransformed{\pgfqpoint{\yquant@draw@@x+.5\dimenxpr\@firstofthree#4\relax}{\yquant@register@get@y{\csname\yquant@prefix registers\endcsname}\relax}}%
- \ifdim\pgf@y>\pgf@picmaxy %
- \global\pgf@picmaxy=\pgf@y %
+ \pgfpointtransformed{\yquant@pgfqpoint{\yquant@draw@@x+.5\dimenxpr\@firstofthree#4\relax}{\yquant@register@get@y{\csname\yquant@prefix registers\endcsname}\relax}}%
+ \ifdim\yquant@pgf@y>\yquant@pgf@picmaxy %
+ \global\yquant@pgf@picmaxy=\yquant@pgf@y %
\fi%
- \ifdim\pgf@y<\pgf@picminy % negative scaling
- \global\pgf@picminy=\pgf@y %
+ \ifdim\yquant@pgf@y<\yquant@pgf@picminy % negative scaling
+ \global\yquant@pgf@picminy=\yquant@pgf@y %
\fi%
\fi%
% END_FOLD
@@ -581,46 +598,57 @@
\fi%
}}%
\ifpgf@pt@identity%
- \dimen0=\dimexpr.5\pgf@picminy+.5\pgf@picmaxy-\pgf@pt@y\relax%
- \dimen2=\dimexpr\pgf@picmaxy-\pgf@picminy\relax%
+ \dimen0=\dimexpr.5\yquant@pgf@picminy+.5\yquant@pgf@picmaxy-\yquant@pgf@pt@y\relax%
+ \dimen2=\dimexpr\yquant@pgf@picmaxy-\yquant@pgf@picminy\relax%
\else%
\begingroup%
\pgftransforminvert%
\pgfpointtransformed{\pgfqpoint{\pgf@picminx}{\pgf@picminy}}%
- \@tempdima=\pgf@y%
+ \@tempdima=\yquant@pgf@y%
\pgfpointtransform{\pgfqpoint{\pgf@picmaxx}{\pgf@picmaxy}}%
- \edef\cmd{\@tempdima=\the\@tempdima\space\@tempdimb=\the\@tempdimb\space}%
+ \edef\cmd{\@tempdima=\the\@tempdima\space\@tempdimb=\the\yquant@pgf@y\space}%
\expandafter%
\endgroup%
\cmd%
- \pgfpointtransformed{\pgfqpoint{\yquant@draw@@x}%
- {.5\dimexpr\@tempdima+\@tempdimb\relax}}%
- \dimen0=\pgf@y%
- \pgfpointtransformed{\pgfqpoint{\yquant@draw@@x}%
- {\dimexpr\@tempdimb-\@tempdima\relax}}%
- \dimen2=\pgf@y%
+ \pgfpointtransformed{\yquant@pgfqpoint{\yquant@draw@@x}%
+ {.5\dimexpr\@tempdima+\@tempdimb\relax}}%
+ \dimen0=\yquant@pgf@y%
+ \pgfpointtransformed{\yquant@pgfqpoint{\yquant@draw@@x}%
+ {\dimexpr\@tempdimb-\@tempdima\relax}}%
+ \dimen2=\yquant@pgf@y%
\fi%
\edef\cmd{%
- \noexpand\path (\yquant@draw@@x, \the\dimen0)%
+ \noexpand\path \yquant@coords(\yquant@draw@@x, \the\dimen0)%
node[/yquant/every operator, \yquant@draw@@style,%
/yquant/operators/every subcircuit box, /yquant/this operator,%
/yquant/operators/this subcircuit box,%
/yquant/internal/multi main=true,%
name prefix=, name suffix=, name=yquantbox]%
- {\vbox to \the\dimen2 {\hbox to \@firstofthree#4 {}}};%
+ {\ifyquanthorz{\vbox to \the\dimen2 {\hbox to \@firstofthree#4 {}}}%
+ {\hbox to \the\dimen2 {\vbox to \@firstofthree#4 {}}}};%
}%
- \cmd%
+ \ifyquant@config@draw@quality%
+ \cmd%
+ \else%
+ % we draw the box on the behindwires layer. In this way, the box can even be filled without overshadowing the wires. However, this implies that the frame of the box will also be drawn behind the wires. If the color of the frame is different from the color of the wires, this may not be desired. In this case, there's no alternative to the quality layout.
+ \begingroup%
+ \let\pgfonlayer@assert@is@active=\relax%
+ \pgfonlayer{behindwires}%
+ \cmd%
+ \endpgfonlayer%
+ \endgroup%
+ \fi%
\unhbox\yquant@prepare@subcircuit@box%
% \endpgfinterruptboundingbox + increase
- \ifdim\pgf@interrupt@savemaxy>\pgf@picmaxy%
- \global\pgf@picmaxy=\pgf@interrupt@savemaxy%
+ \ifdim\pgf@interrupt@savemaxy>\yquant@pgf@picmaxy%
+ \global\yquant@pgf@picmaxy=\pgf@interrupt@savemaxy%
\fi%
- \ifdim\pgf@interrupt@saveminy<\pgf@picminy%
- \global\pgf@picminy=\pgf@interrupt@saveminy%
+ \ifdim\pgf@interrupt@saveminy<\yquant@pgf@picminy%
+ \global\yquant@pgf@picminy=\pgf@interrupt@saveminy%
\fi%
\endgroup%
% Now that the subcircuit is finished, we need advance all the wires
- \dimdef\newx{\yquant@draw@@x+.5\dimexpr\yquant@draw@@width\relax}%
+ \dimdef\newx{\yquant@draw@@x\yquant@orientation@plus.5\dimexpr\yquant@draw@@width\relax}%
\forlistloop\yquant@draw@group@advance{#5}%
% name mangling
\ifcase\yquant@config@operator@subcircuit@mangling\relax%
@@ -679,18 +707,29 @@
\protected\long\def\yquant@draw@subcircuit@single#1#2#3#4#5{%
\yquant@config@operator@multifalse%
\yquant@draw@subcircuit@prepare{#2}{#3}{#4}{#5}{#1}%
- \edef\cmd{%
- \pgfshapeclippath{yquantbox}{%
- /yquant/every operator, \yquant@draw@@style,%
- /yquant/operators/every subcircuit box, /yquant/this operator,%
- /yquant/operators/this subcircuit box,%
+ \ifyquant@config@draw@quality%
+ \edef\cmd{%
+ \pgfshapeclippath{yquantbox}{%
+ /yquant/every operator, \yquant@draw@@style,%
+ /yquant/operators/every subcircuit box, /yquant/this operator,%
+ /yquant/operators/this subcircuit box,%
+ }%
}%
- }%
- \cmd%
- % see comment in draw@subcircuit@multi
- \yquant@softpath@extractmaxxat\pgfshapeclippathhorzresult{\yquant@register@get@y{#1}}%
- \let\pgfshapeclippathhorzresult=\empty%
- \yquant@circuit@extendwire{#1}*%
+ \cmd%
+ % see comment in draw@subcircuit@multi
+ \yquant@softpath@extractmaxxat\pgfshapeclippathhorzresult{\yquant@register@get@y{#1}}%
+ \let\pgfshapeclippathhorzresult=\empty%
+ \yquant@circuit@extendwire{#1}*%
+ \else%
+ \ifyquanthorz{%
+ \pgfpointanchor{yquantbox}{east}%
+ \dimen0=\pgf@x%
+ }{%
+ \pgfpointanchor{yquantbox}{south}%
+ \dimen0=\pgf@y%
+ }%
+ \yquant@circuit@extendwire{#1}*%
+ \fi%
\expandafter\yquant@circuit@extendcontrolline\expandafter%
{\the\yquant@draw@@currentcontroltype}\yquant@draw@@x%
% check for empty name parameter
@@ -704,30 +743,48 @@
\yquant@config@operator@multitrue%
% there is no contiguous slicing for subcircuits, as they may have all kinds of wire operations that can extend beyond the individual slices, let alone ancillas
\yquant@draw@subcircuit@prepare{#5}{#6}{#7}{#8}{#4}%
- \edef\cmd{%
- \pgfshapeclippath{yquantbox}{%
- /yquant/every operator, \yquant@draw@@style,%
- /yquant/operators/every subcircuit box, /yquant/this operator,%
- /yquant/operators/this subcircuit box,%
- /yquant/internal/multi main=true,%
+ \ifyquant@config@draw@quality%
+ \edef\cmd{%
+ \pgfshapeclippath{yquantbox}{%
+ /yquant/every operator, \yquant@draw@@style,%
+ /yquant/operators/every subcircuit box, /yquant/this operator,%
+ /yquant/operators/this subcircuit box,%
+ /yquant/internal/multi main=true,%
+ }%
}%
- }%
- \cmd%
- % install the clippings - but only on wires that are visually between the first and list while not being part of the circuit.
- \let\nonaffectedpgfshapeclippathhorzresult=\pgfshapeclippathhorzresult%
- \yquant@for \i := #1 to #2 {%
- \xifinlist{\i}{#4}{%
- % Usually, we always begin with a wire from the center of the operator shape and clip the inner parts away. This can't be done here, as the wire needs to be drawn _inside_ of the outer box operator here. Instead of clipping against the clip path, we extract its maximum x position at the position of the wire (which is an overkill for simple shapes, but allows to specify even more complicated ones) and place the wire at this position without clipping.
- % Note: this works very well for lines joining at perpendicular angles; but if the shape of the box is more fancy, while the position will be calculated correctly, the wire has a rectangular (or rounded, depending on the line cap) shape that is drawn on top of the operator. While \yquant@softpath@extractmaxxat could without much effort determine exactly the segment of the path that corresponds to the rightmost line, we would then have to convert this single line into a closed path that fills the linewidth and clip against it to get proper joiners. Since most likely, no-one will ever need this, we don't do it. But file a feature request if desired.
- \yquant@softpath@extractmaxxat\nonaffectedpgfshapeclippathhorzresult%
- {\yquant@register@get@y\i}%
- \let\pgfshapeclippathhorzresult=\empty%
- \yquant@circuit@extendwire\i*%
+ \cmd%
+ % install the clippings - but only on wires that are visually between the first and list while not being part of the circuit.
+ \let\nonaffectedpgfshapeclippathhorzresult=\pgfshapeclippathhorzresult%
+ \yquant@for \i := #1 to #2 {%
+ \xifinlist{\i}{#4}{%
+ % Usually, we always begin with a wire from the center of the operator shape and clip the inner parts away. This can't be done here, as the wire needs to be drawn _inside_ of the outer box operator here. Instead of clipping against the clip path, we extract its maximum x position at the position of the wire (which is an overkill for simple shapes, but allows to specify even more complicated ones) and place the wire at this position without clipping.
+ % Note: this works very well for lines joining at perpendicular angles; but if the shape of the box is more fancy, while the position will be calculated correctly, the wire has a rectangular (or rounded, depending on the line cap) shape that is drawn on top of the operator. While \yquant@softpath@extractmaxxat could without much effort determine exactly the segment of the path that corresponds to the rightmost line, we would then have to convert this single line into a closed path that fills the linewidth and clip against it to get proper joiners. Since most likely, no-one will ever need this, we don't do it. But file a feature request if desired.
+ \yquant@softpath@extractmaxxat\nonaffectedpgfshapeclippathhorzresult%
+ {\yquant@register@get@y\i}%
+ \let\pgfshapeclippathhorzresult=\empty%
+ \yquant@circuit@extendwire\i*%
+ }{%
+ \let\pgfshapeclippathhorzresult=\nonaffectedpgfshapeclippathhorzresult%
+ \yquant@circuit@extendwire\i{center}%
+ }%
+ }%
+ \else%
+ % we don't fill subcircuits, so the nonaffected wires will be drawn through (we deliberatly fill the subcircuit on the behindwires layer, so that the wires within a subcircuit will be visible despite the filling; but we cannot differentiate between "good" internal and "bad" nonaffected wires). If such a constellation arises, better use the quality layout
+ \ifyquanthorz{%
+ \pgfpointanchor{yquantbox}{east}%
+ \dimen0=\pgf@x%
}{%
- \let\pgfshapeclippathhorzresult=\nonaffectedpgfshapeclippathhorzresult%
- \yquant@circuit@extendwire\i{center}%
+ \pgfpointanchor{yquantbox}{south}%
+ \dimen0=\pgf@y%
}%
- }%
+ \yquant@for \i := #1 to #2 {%
+ \xifinlist{\i}{#4}{%
+ \yquant@circuit@extendwire\i*%
+ }{%
+ \yquant@circuit@extendwire\i{center}%
+ }%
+ }%
+ \fi%
\expandafter\yquant@circuit@extendcontrolline\expandafter%
{\the\yquant@draw@@currentcontroltype}\yquant@draw@@x%
\ifstrempty{#6}\relax{%
@@ -738,13 +795,15 @@
\protected\def\yquant@draw@control#1#2#3{%
\edef\cmd{%
- \noexpand\path (\yquant@draw@@x, \yquant@register@get@y{#2})%
+ \noexpand\path \yquant@coords(\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}%
+ \ifyquant@config@draw@quality%
+ \pgfshapeclippath{yquantbox}%
+ {/yquant/every control, /yquant/every #1 control,%
+ /yquant/this control}%
+ \fi%
}%
\cmd%
\yquant@circuit@extendwire{#2}{center}%
@@ -769,31 +828,50 @@
\numdef\yquant@draw@@idx@ncontrol{\yquant@draw@@idx@ncontrol+1}%
}
+\protected\long\def\yquant@draw@onwires#1{%
+ \begingroup%
+ \let\pgfonlayer@assert@is@active=\relax%
+ \pgfonlayer{wires}%
+ #1%
+ \endpgfonlayer%
+ \endgroup%
+}
+
\protected\def\yquant@draw@cline{%
- \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;%
+ \ifyquant@config@draw@quality%
+ \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%
+ \else%
+ \yquant@draw@onwires{%
+ \edef\cmd{%
+ \noexpand\path[/yquant/every control line]%
+ \yquant@circuit@extendcontrolline@cmd;%
+ }%
+ \cmd%
}%
- \cmd%
- \endpgfscope%
+ \fi%
}
\protected\def\yquant@draw@mline@prep{%
@@ -805,27 +883,33 @@
}
\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%
+ \ifyquant@config@draw@quality%
+ \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%
+ \else%
+ \yquant@draw@onwires{%
+ \path[/yquant/every multi line] #2;%
+ }%
+ \fi%
}
\protected\def\yquant@draw@alias#1{%
@@ -846,7 +930,7 @@
\else%
\let\wirexpos=\yquant@circuit@endwires@x%
\fi%
- \ifdim\wirexpos>\wirexprevpos %
+ \ifdim\yquant@orientation@plus\wirexpos>\yquant@orientation@plus\wirexprevpos %
\edef\wirestyle{\noexpand\tikzset{%
/yquant/this wire/.style={%
/yquant/every wire,%
@@ -855,63 +939,71 @@
}, /yquant/this wire%
}}%
\wirestyle%
- % load all clippings
- \edef\wireclipping{%
- \unexpanded\expandafter\expandafter\expandafter{%
- \expandafter\@thirdandfourthoffour\wirelast%
+ \ifyquant@config@draw@quality%
+ % load all clippings
+ \edef\wireclipping{%
+ \unexpanded\expandafter\expandafter\expandafter{%
+ \expandafter\@thirdandfourthoffour\wirelast%
+ }%
}%
- }%
- \pgfscope%
- \unless\ifx\wireclipping\empty% may happen if the style is altered to be invisible, though the type is not none
- % 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%
- \ifdim\pgf@picminx>\pgf@picmaxx%
- % nothing drawn yet (or bounding box reset)
- \pgf@picminx=0pt %
- \pgf@picmaxx=0pt %
+ \pgfscope%
+ \unless\ifx\wireclipping\empty% may happen if the style is altered to be invisible, though the type is not none
+ % 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%
+ \ifdim\pgf@picminx>\pgf@picmaxx%
+ % nothing drawn yet (or bounding box reset)
+ \pgf@picminx=0pt %
+ \pgf@picmaxx=0pt %
+ \fi%
+ \ifdim\pgf@picminy>\pgf@picmaxy%
+ \pgf@picminy=0pt %
+ \pgf@picmaxy=0pt %
+ \fi%
+ \pgftransforminvert%
+ \pgfpointtransformed{\pgfqpoint{\pgf@picminx}{\pgf@picminy}}%
+ \global\@tempdima=\yquant@pgf@y%
+ \pgfpointtransformed{\pgfqpoint{\pgf@picmaxx}{\pgf@picmaxy}}%
+ \global\@tempdimb=\yquant@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 is no or a tiny wire label and only registers of a small height. In this case, take 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\pgf@picminy>\pgf@picmaxy%
- \pgf@picminy=0pt %
- \pgf@picmaxy=0pt %
+ \ifdim\dimexpr\@tempdimb-\@tempdima\relax<1cm %
+ \@tempdima=\dimexpr\wireypos-5mm\relax%
+ \@tempdimb=\dimexpr\wireypos+5mm\relax%
\fi%
- \pgftransforminvert%
- \pgfpointtransformed{\pgfqpoint{\pgf@picminx}{\pgf@picminy}}%
- \global\@tempdima=\pgf@y%
- \pgfpointtransformed{\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 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%
+ \pgf@relevantforpicturesizefalse%
+ \pgfpathrectanglecorners%
+ {\yquant@pgfqpoint{\dimexpr\wirexprevpos\yquant@orientation@minus%
+ 2\pgflinewidth\relax}%
+ {\@tempdima}}%
+ {\yquant@pgfqpoint{\dimexpr\wirexpos\yquant@orientation@plus%
+ 2\pgflinewidth\relax}%
+ {\@tempdimb}}%
+ \pgf@relevantforpicturesizetrue%
+ \pgfseteorule% even-odd to properly invert the clipping
+ \pgfusepathqclip%
\fi%
- \pgf@relevantforpicturesizefalse%
- \pgfpathrectanglecorners%
- {\pgfqpoint{\dimexpr\wirexprevpos-2\pgflinewidth\relax}%
- {\@tempdima}}%
- {\pgfqpoint{\dimexpr\wirexpos+2\pgflinewidth\relax}%
- {\@tempdimb}}%
- \pgf@relevantforpicturesizetrue%
- \pgfseteorule% even-odd to properly invert the clipping
- \pgfusepathqclip%
\fi%
- \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%
+ % 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%
+ \else%
+ \yquant@draw@onwires{%
+ \csname yquant@draw@wire@\wiretype\endcsname{#1}%
+ }%
+ \fi%
\fi%
\fi%
\endgroup%
@@ -921,7 +1013,7 @@
\protected\csdef{yquant@draw@wire@\yquant@register@type@q}#1{%
\edef\cmd{%
\noexpand\path [/yquant/this wire]%
- (\wirexprevpos,\wireypos) -- (\wirexpos,\wireypos);%
+ \yquant@coords(\wirexprevpos,\wireypos) -- \yquant@coords(\wirexpos,\wireypos);%
}%
\cmd%
}
@@ -930,8 +1022,10 @@
\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);%
+ \yquant@coords(\wirexprevpos,\wireypos+2\pgflinewidth) --
+ \yquant@coords(\wirexpos,\wireypos+2\pgflinewidth)%
+ \yquant@coords(\wirexprevpos,\wireypos-2\pgflinewidth) --
+ \yquant@coords(\wirexpos,\wireypos-2\pgflinewidth);%
}%
\cmd%
}
@@ -940,9 +1034,12 @@
\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);%
+ \yquant@coords(\wirexprevpos,\wireypos+2\pgflinewidth) --
+ \yquant@coords(\wirexpos,\wireypos+2\pgflinewidth)%
+ \yquant@coords(\wirexprevpos,\wireypos) --
+ \yquant@coords(\wirexpos,\wireypos)%
+ \yquant@coords(\wirexprevpos,\wireypos-2\pgflinewidth) --
+ \yquant@coords(\wirexpos,\wireypos-2\pgflinewidth);%
}%
\cmd%
}
@@ -950,7 +1047,7 @@
\protected\def\yquant@draw@hspace#1#2{%
\begingroup%
\yquant@register@get@maxxlist\newx{#1}%
- \dimdef\newx{\newx+#2}%
+ \dimdef\newx{\newx\yquant@orientation@plus#2}%
\dimen0=\newx%
\let\pgfshapeclippathhorzresult=\empty%
\forlistloop\yquant@draw@move@loop{#1}%