summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/yquant
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
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')
-rw-r--r--Master/texmf-dist/tex/latex/yquant/yquant-circuit.tex70
-rw-r--r--Master/texmf-dist/tex/latex/yquant/yquant-config.tex275
-rw-r--r--Master/texmf-dist/tex/latex/yquant/yquant-draw.tex561
-rw-r--r--Master/texmf-dist/tex/latex/yquant/yquant-env.tex13
-rw-r--r--Master/texmf-dist/tex/latex/yquant/yquant-lang.tex10
-rw-r--r--Master/texmf-dist/tex/latex/yquant/yquant-prepare.tex134
-rw-r--r--Master/texmf-dist/tex/latex/yquant/yquant-registers.tex12
-rw-r--r--Master/texmf-dist/tex/latex/yquant/yquant-shapes.tex524
-rw-r--r--Master/texmf-dist/tex/latex/yquant/yquant-tools.tex140
-rw-r--r--Master/texmf-dist/tex/latex/yquant/yquant.sty8
-rw-r--r--Master/texmf-dist/tex/latex/yquant/yquantlanguage-groups.sty93
11 files changed, 1266 insertions, 574 deletions
diff --git a/Master/texmf-dist/tex/latex/yquant/yquant-circuit.tex b/Master/texmf-dist/tex/latex/yquant/yquant-circuit.tex
index 14f6a1f77bc..c4c99eceb2c 100644
--- a/Master/texmf-dist/tex/latex/yquant/yquant-circuit.tex
+++ b/Master/texmf-dist/tex/latex/yquant/yquant-circuit.tex
@@ -6,16 +6,18 @@
\edef\wirexpos{\the\dimen0}%
\else%
\pgfpointanchor{yquantbox}{#2}%
- \edef\wirexpos{\the\pgf@x}%
+ \edef\wirexpos{\the\yquant@pgf@x}%
\fi%
- \ifdim\wirexpos>0pt % may be negative for init gates
+ \ifdim\yquant@orientation@plus\wirexpos>0pt % may be negative for init gates
\yquant@register@get@typeywire{#1}\wiretype\wireypos\wirelast%
\edef\wirexprevpos{\expandafter\@firstoffour\wirelast}%
\ifnum\wiretype=\yquant@register@type@none%
% the clippings of the previous operator will for sure not be needed, but the type might be turned into an active one, so we need the last clipping.
\yquant@register@set@lastwire{#1}{%
{\wirexprevpos}{\wirexpos}{}%
- {\unexpanded\expandafter{\pgfshapeclippathhorzresult}}%
+ {\ifyquant@config@draw@quality%
+ \unexpanded\expandafter{\pgfshapeclippathhorzresult}%
+ \fi}%
}%
\else%
% append the previous `last' clipping to the old list and insert the new one
@@ -25,7 +27,9 @@
\expandafter\@thirdandfourthoffour\wirelast%
}%
}%
- {\unexpanded\expandafter{\pgfshapeclippathhorzresult}}%
+ {\ifyquant@config@draw@quality%
+ \unexpanded\expandafter{\pgfshapeclippathhorzresult}%
+ \fi}%
}%
\fi%
\fi%
@@ -41,10 +45,14 @@
% to have a symmetric situation, we extend again one separation at the end, unless this is supposed to be seamless and we don't have outputs (for seamless circuits with outputs, extend - since this extension will be between last register and output)
\ifyquant@env@seamless{%
\expandafter\unless\expandafter\ifx\csname\yquant@prefix outputs\endcsname\relax%
- \dimdef\yquant@circuit@endwires@x{\yquant@circuit@endwires@x+\yquant@config@operator@sep}%
+ \dimdef\yquant@circuit@endwires@x{%
+ \yquant@circuit@endwires@x\yquant@orientation@plus\yquant@config@operator@sep%
+ }%
\fi%
}{%
- \dimdef\yquant@circuit@endwires@x{\yquant@circuit@endwires@x+\yquant@config@operator@sep}%
+ \dimdef\yquant@circuit@endwires@x{%
+ \yquant@circuit@endwires@x\yquant@orientation@plus\yquant@config@operator@sep%
+ }%
}%
\let\yquant@circuit@endwires@finalize=\relax%
\yquant@for \yquant@circuit@endwires@i := 1 to \csname\yquant@prefix registers\endcsname {%
@@ -52,9 +60,15 @@
\ifcsname\yquant@prefix registermap@\yquant@circuit@endwires@i\endcsname%
\xifinlistcs\yquant@circuit@endwires@i{\yquant@prefix inonly}{%
% however, the wire is to be discarded after this circuit
- \edef\storedleft{\the\pgf@picminx}%
- \yquant@draw@wire\yquant@circuit@endwires@i1%
- \global\pgf@picminx=\storedleft%
+ \ifyquanthorz{%
+ \edef\storedleft{\the\pgf@picminx}%
+ \yquant@draw@wire\yquant@circuit@endwires@i1%
+ \global\pgf@picminx=\storedleft%
+ }{%
+ \edef\storedtop{\the\pgf@picmaxy}%
+ \yquant@draw@wire\yquant@circuit@endwires@i1%
+ \global\pgf@picmaxy=\storedtop%
+ }%
\eappto\yquant@circuit@endwires@finalize{%
\yquant@register@set@type%
\yquant@circuit@endwires@i\noexpand\yquant@register@type@none%
@@ -84,9 +98,11 @@
% BEGIN_FOLD Drawing control lines
% populates a drawing macro with the current control line with style #1 at position #2. Assumes a node called yquantbox is set up, and the \pgfshapeclippathvertresult was set up appropriately for this node. At the first call, \yquant@circuit@extendcontrolline@cmd must be \let to \empty and \yquant@circuit@extendcontrolline@prev to \relax.
\protected\def\yquant@circuit@extendcontrolline#1#2{%
- \eappto\yquant@circuit@extendcontrolline@clip{%
- \unexpanded\expandafter{\pgfshapeclippathvertresult}%
- }%
+ \ifyquant@config@draw@quality%
+ \eappto\yquant@circuit@extendcontrolline@clip{%
+ \unexpanded\expandafter{\pgfshapeclippathvertresult}%
+ }%
+ \fi%
\begingroup%
\tikzset{/yquant/every control line}%
\expandafter%
@@ -100,7 +116,7 @@
\unless\ifx\yquant@circuit@extendcontrolline@prev\relax%
\eappto\yquant@circuit@extendcontrolline@cmd{%
\expandafter\@secondofthree\yquant@circuit@extendcontrolline@prev%
- -- (#2,\the\pgf@y)%
+ -- \yquant@coords(#2,\the\yquant@pgf@y)%
}%
\fi%
\yquant@circuit@extendcontrolline@store{#2}%
@@ -110,9 +126,9 @@
\unless\ifx\yquant@circuit@extendcontrolline@prev\relax%
\eappto\yquant@circuit@extendcontrolline@cmd{%
\expandafter\@firstofthree\yquant@circuit@extendcontrolline@prev%
- -- (\the\dimexpr#2-2\@tempdima\relax,\the\pgf@y)%
+ -- \yquant@coords(\the\dimexpr#2-2\@tempdima\relax,\the\yquant@pgf@y)%
\expandafter\@thirdofthree\yquant@circuit@extendcontrolline@prev%
- -- (\the\dimexpr#2+2\@tempdima\relax,\the\pgf@y)%
+ -- \yquant@coords(\the\dimexpr#2+2\@tempdima\relax,\the\yquant@pgf@y)%
}%
\fi%
\yquant@circuit@extendcontrolline@store{#2}%
@@ -122,11 +138,11 @@
\unless\ifx\yquant@circuit@extendcontrolline@prev\relax%
\eappto\yquant@circuit@extendcontrolline@cmd{%
\expandafter\@firstofthree\yquant@circuit@extendcontrolline@prev%
- -- (\the\dimexpr#2-2\@tempdima\relax,\the\pgf@y)%
+ -- \yquant@coords(\the\dimexpr#2-2\@tempdima\relax,\the\yquant@pgf@y)%
\expandafter\@secondofthree\yquant@circuit@extendcontrolline@prev%
- -- (\the\dimexpr#2\relax,\the\pgf@y)%
+ -- \yquant@coords(\the\dimexpr#2\relax,\the\yquant@pgf@y)%
\expandafter\@thirdofthree\yquant@circuit@extendcontrolline@prev%
- -- (\the\dimexpr#2+2\@tempdima\relax,\the\pgf@y)%
+ -- \yquant@coords(\the\dimexpr#2+2\@tempdima\relax,\the\yquant@pgf@y)%
}%
\fi%
\yquant@circuit@extendcontrolline@store{#2}%
@@ -138,9 +154,9 @@
\protected\def\yquant@circuit@extendcontrolline@store#1{%
\edef\yquant@circuit@extendcontrolline@prev{%
- {(\the\dimexpr#1-2\@tempdima\relax,\the\pgf@y)}%
- {(\the\dimexpr#1\relax,\the\pgf@y)}%
- {(\the\dimexpr#1+2\@tempdima\relax,\the\pgf@y)}%
+ {\yquant@coords(\the\dimexpr#1-2\@tempdima\relax,\the\yquant@pgf@y)}%
+ {\yquant@coords(\the\dimexpr#1\relax,\the\yquant@pgf@y)}%
+ {\yquant@coords(\the\dimexpr#1+2\@tempdima\relax,\the\yquant@pgf@y)}%
}%
}
@@ -150,18 +166,20 @@
\tikzset{/yquant/every multi line}%
\expandafter%
\endgroup%
- \eappto\yquant@circuit@extendmultiline@clip{%
- \unexpanded\expandafter{\pgfshapeclippathvertresult}%
- }%
+ \ifyquant@config@draw@quality%
+ \eappto\yquant@circuit@extendmultiline@clip{%
+ \unexpanded\expandafter{\pgfshapeclippathvertresult}%
+ }%
+ \fi%
\expandafter\@tempdima\the\pgflinewidth%
\pgfpointanchor{yquantbox}{center}%
\unless\ifx\yquant@circuit@extendmultiline@prev\relax%
\eappto\yquant@circuit@extendmultiline@cmd{%
- \yquant@circuit@extendmultiline@prev -- (#1,\the\pgf@y)%
+ \yquant@circuit@extendmultiline@prev -- \yquant@coords(#1,\the\yquant@pgf@y)%
}%
\fi%
\edef\yquant@circuit@extendmultiline@prev{%
- (\the\dimexpr#1\relax,\the\pgf@y)%
+ \yquant@coords(\the\dimexpr#1\relax,\the\yquant@pgf@y)%
}%
}
% END_FOLD
diff --git a/Master/texmf-dist/tex/latex/yquant/yquant-config.tex b/Master/texmf-dist/tex/latex/yquant/yquant-config.tex
index a50b2a4792c..ab07830929f 100644
--- a/Master/texmf-dist/tex/latex/yquant/yquant-config.tex
+++ b/Master/texmf-dist/tex/latex/yquant/yquant-config.tex
@@ -26,18 +26,99 @@
register/minimum height/.code=%
{\dimdef\yquant@config@register@minimum@height{#1}},%
register/minimum depth/.code=%
- {\dimdef\yquant@config@register@minimum@depth{#1}}%
+ {\dimdef\yquant@config@register@minimum@depth{#1}},%
+ register/minimum left/.forward to=/yquant/register/minimum height,%
+ register/minimum right/.forward to=/yquant/register/minimum depth,%
+ register/minimum before/.forward to=/yquant/register/minimum height,%
+ register/minimum after/.forward to=/yquant/register/minimum after%
}
\fi
+\def\yquant@config@draw@ensurelayers@addwires#1,main,#2\yquant@stop{%
+ \ifstrempty{#2}{%
+ % main was the last item in the list, so we needed to add the comma
+ \edef\pgf@layerlist{\@gobble#1,wires,main}%
+ }{%
+ % there were more items in the list, so we have a spurious comma in #2
+ \expandafter\yquant@config@draw@ensurelayers@addwires@%
+ \expandafter,\pgf@layerlist\yquant@stop%
+ }%
+}
+\def\yquant@config@draw@ensurelayers@addwires@#1,main,#2\yquant@stop{%
+ \edef\pgf@layerlist{\@gobble#1,wires,main,#2}%
+}
+\def\yquant@config@draw@ensurelayers@haswires#1,wires,#2\yquant@stop{%
+ \ifstrempty{#2}{%
+ % wires not present yet, take action
+ \expandafter\yquant@config@draw@ensurelayers@addwires%
+ \expandafter,\pgf@layerlist,\yquant@stop%
+ }\relax%
+}
+\def\yquant@config@draw@ensurelayers@addbehindwires#1,wires,#2\yquant@stop{%
+ \ifstrempty{#2}{%
+ % wires was the last item in the list, so we needed to add the comma (should never happen)
+ \edef\pgf@layerlist{\@gobble#1,behindwires,wires}%
+ \PackageWarning{yquant.sty}{The wires layer was set on top of the main layer - expect undesirable outcomes.}%
+ }{%
+ % there were more items in the list, so we have a spurious comma in #2
+ \expandafter\yquant@config@draw@ensurelayers@addbehindwires@%
+ \expandafter,\pgf@layerlist\yquant@stop%
+ }%
+}
+\def\yquant@config@draw@ensurelayers@addbehindwires@#1,wires,#2\yquant@stop{%
+ \edef\pgf@layerlist{\@gobble#1,behindwires,wires,#2}%
+}
+\def\yquant@config@draw@ensurelayers@hasbehindwires#1,behindwires,#2\yquant@stop{%
+ \ifstrempty{#2}{%
+ % wires not present yet, take action
+ \expandafter\yquant@config@draw@ensurelayers@addbehindwires%
+ \expandafter,\pgf@layerlist,\yquant@stop%
+ }\relax%
+}
+\def\yquant@config@draw@ensurelayers{%
+ \expandafter\yquant@config@draw@ensurelayers@haswires%
+ \expandafter,\pgf@layerlist,wires,\yquant@stop%
+ \expandafter\yquant@config@draw@ensurelayers@hasbehindwires%
+ \expandafter,\pgf@layerlist,behindwires,\yquant@stop%
+ \ifyquant@config@draw@quality%
+ % maybe the option was set outside of a tikzpicture, then we need to keep this
+ \global\let\endpgfpicture=\yquant@old@endpgfpicture%
+ \global\yquant@config@requirelayersfalse%
+ \fi%
+}
+
\pgfqkeys{/yquant}{%
register/separation/.code=%
{\dimdef\yquant@config@register@sep{#1}},%
operator/minimum width/.code=%
{\dimdef\yquant@config@operator@minimum@width{#1}},%
+ operator/minimum extent/.forward to=/yquant/operator/minimum width,%
operator/separation/.code=%
{\dimdef\yquant@config@operator@sep{#1}},%
operator/multi warning/.is if=%
- yquant@config@operator@multi@warn%
+ yquant@config@operator@multi@warn,%
+ drawing mode/.is choice,%
+ drawing mode/quality/.code=%
+ {\yquant@config@draw@qualitytrue%
+ \pgfkeysalso{/yquant/default background=none}%
+ \unless\ifpgfpicture%
+ % we do not reset the special layer injection (there may be multiple yquant environments, and only one of them had the "size" drawing mode; then, we still need the layers), unless this is actually set outside of a tikzpicture
+ \ifdefined\yquant@old@endpgfpicture% only if we changed before
+ \global\let\endpgfpicture=\yquant@old@endpgfpicture%
+ \global\yquant@config@requirelayersfalse%
+ \fi%
+ \fi},%
+ drawing mode/size/.code=%
+ {\yquant@config@draw@qualityfalse%
+ \pgfkeysalso{/yquant/default background=white}%
+ \unless\ifyquant@config@requirelayers%
+ \global\let\yquant@old@endpgfpicture=\endpgfpicture%
+ \gpreto\endpgfpicture\yquant@config@draw@ensurelayers%
+ \fi%
+ \global\yquant@config@requirelayerstrue},%
+ default background/.initial=%
+ {none},%
+ default fill/.style={%
+ fill/.expanded=\pgfkeysvalueof{/yquant/default background}}
}%
% END_FOLD
% BEGIN_FOLD Register creation
@@ -50,20 +131,22 @@
\ifnum\yquant@compat<2 %
\pgfqkeys{/yquant}{%
every label/.style=%
- {shape=yquant-init, anchor=center, align=right, outer xsep=2pt},%
+ {shape=yquant-init, anchor=center,%
+ align/.expanded=\ifyquanthorz{right}{center}, outer timesep=2pt},%
every multi label/.style=%
- {draw, decoration={gapped brace, mirror, raise=2pt}, decorate}%
+ {draw, decoration/.expanded={gapped brace, raise=2pt, \ifyquanthorz{mirror}{}}, decorate}%
}
\else
\pgfqkeys{/yquant}{%
every label/.style=%
- {shape=yquant-init, anchor=center, align=right, outer xsep=2pt,%
- /yquant/operator/if multi={draw, decoration={gapped brace, mirror, raise=2pt}, decorate}}%
+ {shape=yquant-init, anchor=center,%
+ align/.expanded=\ifyquanthorz{right}{center}, outer timesep=2pt,%
+ /yquant/operator/if multi={draw, decoration/.expanded={gapped brace, raise=2pt, \ifyquanthorz{mirror}{}}, decorate}}%
}
\fi
\pgfqkeys{/yquant}{
every initial label/.style=%
- {anchor=east},%
+ {anchor/.expanded=\ifyquanthorz{east}{south}, /yquant/internal/autorotate init},%
every qubit label/.style=%
{},%
every cbit label/.style=%
@@ -82,15 +165,19 @@
\ifnum\yquant@compat<2 %
\pgfqkeys{/yquant}{%
every output/.style=%
- {shape=yquant-output, anchor=west, align=left, outer xsep=2pt},%
+ {shape=yquant-output, anchor/.expanded=\ifyquanthorz{west}{north},%
+ align/.expanded=\ifyquanthorz{left}{center}, outer timesep=2pt,%
+ /yquant/internal/autorotate output},%
every multi output/.style=%
- {draw, decoration={gapped brace, raise=2pt}, decorate}%
+ {draw, decoration/.expanded={gapped brace, raise=2pt, \ifyquanthorz{}{mirror}}, decorate}%
}
\else
\pgfqkeys{/yquant}{%
every output/.style=%
- {shape=yquant-output, anchor=west, align=left, outer xsep=2pt,%
- /yquant/operator/if multi={draw, decoration={gapped brace, raise=2pt}, decorate}}%
+ {shape=yquant-output, anchor/.expanded=\ifyquanthorz{west}{north},%
+ align/.expanded=\ifyquanthorz{left}{center}, outer timesep=2pt,%
+ /yquant/operator/if multi={draw, decoration/.expanded={gapped brace, raise=2pt, \ifyquanthorz{}{mirror}}, decorate},%
+ /yquant/internal/autorotate output}%
}
\fi
\pgfqkeys{/yquant}{%
@@ -129,7 +216,7 @@
every positive control/.style=%
{fill=black},%
every negative control/.style=%
- {draw},%
+ {draw, /yquant/default fill},%
every operator/.style=%
{anchor=center},%
every multi line/.style=%
@@ -152,6 +239,41 @@
operator/if multi/.code=%
{\ifyquant@config@operator@multi\pgfkeysalso{#1}\fi},%
circuit/seamless/.is if=yquant@config@circuit@seamless,%
+ circuit/orientation/.is choice,%
+ circuit/orientation/horizontal/.code={%
+ \ifyquant@config@circuitsetup%
+ \pgfkeysalso{/yquant/internal/autorotate init/.style={},%
+ /yquant/internal/autorotate output/.style={}}%
+ \yquant@config@circuit@orientation@horizontal%
+ \else%
+ \PackageError{yquant.sty}{`circuit/orientation' can only be modified in the environment options or globally.}{Don't modify this within a circuit.}%
+ \fi%
+ },%
+ circuit/orientation/vertical/.code={%
+ \ifyquant@config@circuitsetup%
+ \yquant@config@circuit@orientation@vertical%
+ \else%
+ \PackageError{yquant.sty}{`circuit/orientation' can only be modified in the environment options or globally.}{Don't modify this within a circuit.}%
+ \fi%
+ },%
+ horizontal/.forward to=/yquant/circuit/orientation/horizontal,%
+ vertical/.code={%
+ \pgfkeysalso{/yquant/circuit/orientation/vertical}%
+ \unless\ifdim#1 pt=0pt %
+ \ifdefined\adjustbox%
+ \pgfkeysalso{%
+ /yquant/internal/autorotate init/.style={%
+ /tikz/execute at begin node={\adjustbox{rotate=#1}}%
+ }, /yquant/internal/autorotate output/.style={%
+ /tikz/execute at begin node={\adjustbox{rotate=-#1}}%
+ }%
+ }%
+ \else%
+ \PackageWarning{yquant.sty}{In order to use the automatic rotation of initial labels for vertical circuits, you need to load the `adjustbox' package.}%
+ \fi%
+ \fi%
+ },%
+ vertical/.default=0,%
every post measurement control/.is choice,
every post measurement control/indirect/.code={%
\undef\yquant@lang@attr@directcontrol%
@@ -175,7 +297,7 @@
\fi
\pgfqkeys{/yquant}{%
operators/every text/.style=%
- {shape=yquant-rectangle, align=center, inner xsep=1mm, x radius=2mm, y radius=2.47mm}%
+ {shape=yquant-rectangle, align=center, inner timesep=1mm, time radius=2mm, space radius=2.47mm, /yquant/default fill}%
}
\ifnum\yquant@compat<3 %
\pgfqkeys{/yquant}{%
@@ -183,12 +305,12 @@
operators/every rectangular box/.style=%
{/yquant/operators/every box},%
operators/every box/.style=%
- {shape=yquant-rectangle, draw, align=center, inner xsep=1mm, x radius=2mm, y radius=2.47mm}%
+ {shape=yquant-rectangle, draw, align=center, inner timesep=1mm, time radius=2mm, space radius=2.47mm, /yquant/default fill}%
}
\else
\pgfqkeys{/yquant}{%
operators/every rectangular box/.style=%
- {shape=yquant-rectangle, draw, align=center, inner xsep=1mm, x radius=2mm, y radius=2.47mm},%
+ {shape=yquant-rectangle, draw, align=center, inner timesep=1mm, time radius=2mm, space radius=2.47mm, /yquant/default fill},%
operators/every box/.style=%
{/yquant/operators/every rectangular box}%
}
@@ -206,17 +328,18 @@
\fi
\pgfqkeys{/yquant}{%
operators/every dmeter/.style=%
- {shape=yquant-dmeter, x radius=2mm, y radius=2mm, draw},
+ {shape=yquant-dmeter, time radius=2mm, space radius=2mm, draw, /yquant/default fill},
% every h is implicitly defined during gate declaration
operators/every inspect/.style=%
- {shape=yquant-output, align=left, outer xsep=.3333em, y radius=2.47mm,%
- /yquant/operator/if multi={draw, decoration={gapped brace, raise=2pt}, decorate}},%
+ {shape=yquant-output, align/.expanded=\ifyquanthorz{left}{center},
+ outer timesep=.3333em, space radius=2.47mm, /yquant/default fill,%
+ /yquant/operator/if multi={draw, decoration/.expanded={gapped brace, raise=2pt, \ifyquanthorz{}{mirror}}, decorate}},%
operators/every measure/.style=%
- {shape=yquant-measure, x radius=4mm, y radius=2.5mm, draw},%
+ {shape=yquant-measure, x radius=4mm, y radius=2.5mm, draw, /yquant/default fill},%
operators/every measure meter/.style=%
{draw, -{Latex[length=2.5pt]}},%
operators/every not/.style=%
- {shape=yquant-oplus, radius=1.3mm, draw},%
+ {shape=yquant-oplus, radius=1.3mm, draw, /yquant/default fill},%
operators/every pauli/.style=%
{/yquant/operators/every rectangular box},%
operators/every phase/.style=%
@@ -226,7 +349,7 @@
operators/every subcircuit/.style=%
{},%
operators/every subcircuit box/.style=%
- {/yquant/operators/every rectangular box},%
+ {/yquant/operators/every rectangular box, fill=none},%
subcircuit box style/.style=%
{/yquant/operators/every subcircuit box/.append style={#1}},%
operators/this subcircuit box/.style=%
@@ -260,7 +383,7 @@
{shape=yquant-circle, radius=.5mm, fill},%
% every x is implicitly defined during gate declaration
operators/every xx/.style=%
- {shape=yquant-rectangle, radius=.75mm, draw},%
+ {shape=yquant-rectangle, radius=.75mm, draw, /yquant/default fill},%
% every y is implicitly defined during gate declaration
% every z is implicitly defined during gate declaration
operators/every zz/.style=%
@@ -277,6 +400,10 @@
\fi},
internal/multi main/.is if=%
yquant@config@internal@multi@main,%
+ internal/setup done/.code=%
+ {\yquant@config@circuitsetupfalse},%
+ internal/autorotate init/.style={},%
+ internal/autorotate output/.style={},%
}
\ifnum\yquant@compat<2 %
\pgfqkeys{/yquant}{%
@@ -291,13 +418,105 @@
\fi
% END_FOLD
+\protected\def\yquant@config@circuit@orientation@horizontal{%
+ \let\ifyquanthorz=\@firstoftwo%
+ \tikzset{%
+ % in principle, these are all /.forward to handlers, but we want them non-accumulative
+ time radius/.code={\pgfkeys{/tikz/x radius={##1}}},%
+ space radius/.code={\pgfkeys{/tikz/y radius={##1}}},%
+ inner timesep/.code={\pgfkeys{/tikz/inner xsep={##1}}},%
+ inner spacesep/.code={\pgfkeys{/tikz/inner ysep={##1}}},%
+ outer timesep/.code={\pgfkeys{/tikz/outer xsep={##1}}},%
+ outer spacesep/.code={\pgfkeys{/tikz/outer ysep={##1}}}%
+ }%
+ \def\yquant@config@register@minimum@height@default{1.5mm}%
+ \def\yquant@config@register@minimum@depth@default{1.5mm}%
+ \def\yquant@config@operator@minimum@width@default{5mm}%
+ \let\yquant@pgf@picminx=\pgf@picminx%
+ \let\yquant@pgf@picmaxx=\pgf@picmaxx%
+ \let\yquant@pgf@picminy=\pgf@picminy%
+ \let\yquant@pgf@picmaxy=\pgf@picmaxy%
+ \let\yquant@pgf@x=\pgf@x%
+ \let\yquant@pgf@y=\pgf@y%
+ \let\yquant@pgf@pt@x=\pgf@pt@x%
+ \let\yquant@pgf@pt@y=\pgf@pt@y%
+ \let\yquant@pgfqpoint=\pgfqpoint%
+ \let\yquant@coords=\empty%
+ \let\pgfshapeclippath=\yquant@pgfshapeclippath@horz%
+ \def\yquant@orientation@x{x}%
+ \def\yquant@orientation@y{y}%
+ \def\yquant@orientation@plus{+}%
+ \def\yquant@orientation@minus{-}%
+}
+
+\protected\def\yquant@config@circuit@orientation@vertical{%
+ \let\ifyquanthorz=\@secondoftwo%
+ \tikzset{%
+ % in principle, these are all /.forward to handlers, but we want them non-accumulative
+ time radius/.code={\pgfkeys{/tikz/y radius={##1}}},%
+ space radius/.code={\pgfkeys{/tikz/x radius={##1}}},%
+ inner timesep/.code={\pgfkeys{/tikz/inner ysep={##1}}},%
+ inner spacesep/.code={\pgfkeys{/tikz/inner xsep={##1}}},%
+ outer timesep/.code={\pgfkeys{/tikz/outer ysep={##1}}},%
+ outer spacesep/.code={\pgfkeys{/tikz/outer xsep={##1}}}%
+ }%
+ \def\yquant@config@register@minimum@height@default{2.5mm}%
+ \def\yquant@config@register@minimum@depth@default{2.5mm}%
+ \def\yquant@config@operator@minimum@width@default{3mm}%
+ \let\yquant@pgf@picminx=\pgf@picminy%
+ \let\yquant@pgf@picmaxx=\pgf@picmaxy%
+ \let\yquant@pgf@picminy=\pgf@picminx%
+ \let\yquant@pgf@picmaxy=\pgf@picmaxx%
+ \let\yquant@pgf@x=\pgf@y%
+ \let\yquant@pgf@y=\pgf@x%
+ \let\yquant@pgf@pt@x=\pgf@pt@y%
+ \let\yquant@pgf@pt@y=\pgf@pt@x%
+ \def\yquant@pgfqpoint##1##2{\pgfqpoint{##2}{##1}}%
+ \def\yquant@coords(##1,##2){({##2},{##1})}%
+ \let\pgfshapeclippath=\yquant@pgfshapeclippath@vert%
+ \def\yquant@orientation@x{y}%
+ \def\yquant@orientation@y{x}%
+ \def\yquant@orientation@plus{-}%
+ \def\yquant@orientation@minus{+}%
+}
+
+\let\yquant@pgfshapeclippath@horz=\pgfshapeclippath
+\let\yquant@pgfshapeclippath@vert=\pgfshapeclippath
+\patchcmd\yquant@pgfshapeclippath@vert{%
+ \global\let\pgfshapeclippathhorzresult=\pgfshapeclippathresult%
+ \ifcsname pgf@sh@clipvert@\csname pgf@sh@ns@#1\endcsname\endcsname%
+ % different clipping in vertical direction
+ \pgfsyssoftpath@setcurrentpath\pgfutil@empty%
+ \csname pgf@sh@clipvert@\csname pgf@sh@ns@#1\endcsname\endcsname%
+ \pgfsyssoftpath@getcurrentpath\pgfshapeclippathresult%
+ \pgfprocessround{\pgfshapeclippathresult}{\pgfshapeclippathresult}%
+ \fi%
+ \global\let\pgfshapeclippathvertresult=\pgfshapeclippathresult%
+}{%
+ \global\let\pgfshapeclippathvertresult=\pgfshapeclippathresult%
+ \ifcsname pgf@sh@clipvert@\csname pgf@sh@ns@#1\endcsname\endcsname%
+ % different clipping in vertical direction
+ \pgfsyssoftpath@setcurrentpath\pgfutil@empty%
+ \csname pgf@sh@clipvert@\csname pgf@sh@ns@#1\endcsname\endcsname%
+ \pgfsyssoftpath@getcurrentpath\pgfshapeclippathresult%
+ \pgfprocessround{\pgfshapeclippathresult}{\pgfshapeclippathresult}%
+ \fi%
+ \global\let\pgfshapeclippathhorzresult=\pgfshapeclippathresult%
+}{}{%
+ \PackageError{yquant.sty}{Unable to path \string\pgfshapeclippath}%
+ {Vertical layout will not work.}%
+}
+
\def\yquant@config@register@default@name{\regidx}
\let\yquant@config@register@default@lazyname=\empty
-\def\yquant@config@register@minimum@height{1.5mm}
-\def\yquant@config@register@minimum@depth{1.5mm}
+\def\yquant@config@register@minimum@height{\yquant@config@register@minimum@height@default}
+\def\yquant@config@register@minimum@height@default{1.5mm}
+\def\yquant@config@register@minimum@depth{\yquant@config@register@minimum@depth@default}
+\def\yquant@config@register@minimum@depth@default{1.5mm}
\def\yquant@config@register@sep{1mm}
\def\yquant@config@operator@sep{1mm}
-\def\yquant@config@operator@minimum@width{5mm}
+\def\yquant@config@operator@minimum@width{\yquant@config@operator@minimum@width@default}
+\def\yquant@config@operator@minimum@width@default{5mm}
\newif\ifyquant@config@internal@multi@main%
\yquant@config@internal@multi@maintrue
\newif\ifyquant@config@operator@multi@warn
@@ -310,6 +529,12 @@
\newif\ifyquant@config@operator@subcircuit@manglingreset
\yquant@config@operator@subcircuit@manglingresettrue
\newif\ifyquant@config@operator@multi
+\newif\ifyquant@config@circuitsetup
+\yquant@config@circuitsetuptrue
+\yquant@config@circuit@orientation@horizontal
+\newif\ifyquant@config@draw@quality
+\yquant@config@draw@qualitytrue
+\newif\ifyquant@config@requirelayers
\protected\def\yquant@config@operator@subcircuit@mangling@set#1{%
\ifyquant@config@operator@subcircuit@manglingreset%
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}%
diff --git a/Master/texmf-dist/tex/latex/yquant/yquant-env.tex b/Master/texmf-dist/tex/latex/yquant/yquant-env.tex
index f26919c8d16..bbbf740e713 100644
--- a/Master/texmf-dist/tex/latex/yquant/yquant-env.tex
+++ b/Master/texmf-dist/tex/latex/yquant/yquant-env.tex
@@ -85,7 +85,7 @@
\expandafter\noexpand\csname\yquant@prefix seamless\endcsname%
\expandafter\noexpand\csname\yquant@prefix cleanup\endcsname%
}%
- \scope[{/yquant/.cd, #2, /tikz/.cd, /yquant/every circuit}]%
+ \scope[{/yquant/.cd, #2, /tikz/.cd, /yquant/every circuit, /yquant/internal/setup done}]%
}
\protected\def\yquant@env@end{%
@@ -175,7 +175,7 @@
\yquant@env@end@calcypositions@run1%
\yquant@env@end@calcypositions@godeepfalse%
\yquant@env@end@calcypositions@redo%
-% % The macros now set up performed all the proper and unambiguous justification. After that, we will also need to take care of the multi gates. We expect that for most of all multi gates, we already have enough space. But sometimes, this may not be the case, so we need to increase overall spacing and re-evaluate all spacing. In order to get a proper balanced layout, we start with the largest enlargement that is required. Every enlargement step will equally distribute the registers in between. Starting with the largest one, this is likely to also solve issues with smaller ones.
+ % The macros now set up performed all the proper and unambiguous justification. After that, we will also need to take care of the multi gates. We expect that for most of all multi gates, we already have enough space. But sometimes, this may not be the case, so we need to increase overall spacing and re-evaluate all spacing. In order to get a proper balanced layout, we start with the largest enlargement that is required. Every enlargement step will equally distribute the registers in between. Starting with the largest one, this is likely to also solve issues with smaller ones.
\yquant@env@end@calcypositions@multi%
% Turn the preliminary positions into true ones at every level.
\yquant@env@end@setypositions1%
@@ -477,16 +477,17 @@
\ifyquantdebug%
\yquant@for \i := 1 to \csname\yquant@prefix registers\endcsname {%
\ifcsname\yquant@prefix registermap@\i\endcsname%
- \message{^^J y(#1, \i): external}%
+ \message{^^J \yquant@orientation@y(#1, \i): external}%
\else%
- \message{^^J y(#1, \i): \csname\yquant@prefix env@endy@\i\endcsname}%
- \yquant@register@set@y\i{-\csname\yquant@prefix env@endy@\i\endcsname}%
+ \message{^^J \yquant@orientation@y(#1, \i): \csname\yquant@prefix env@endy@\i\endcsname}%
+ % do not use \yquant@orientation@minus: this will lead to an explicit + in vertical mode, and the value of the register y position is directly used for TikZ coordinates. However, those are parsed using \pgfmathsetlength, which will skip pgf's parser if the value starts with an explicit +. We don't want this.
+ \yquant@register@set@y\i{\ifyquanthorz{-}{}\csname\yquant@prefix env@endy@\i\endcsname}%
\fi%
}%
\else%
\yquant@for \i := 1 to \csname\yquant@prefix registers\endcsname {%
\unless\ifcsname\yquant@prefix registermap@\i\endcsname%
- \yquant@register@set@y\i{-\csname\yquant@prefix env@endy@\i\endcsname}%
+ \yquant@register@set@y\i{\ifyquanthorz{-}{}\csname\yquant@prefix env@endy@\i\endcsname}%
\fi%
}%
\fi%
diff --git a/Master/texmf-dist/tex/latex/yquant/yquant-lang.tex b/Master/texmf-dist/tex/latex/yquant/yquant-lang.tex
index cc882a7ffb0..1b462d2d85f 100644
--- a/Master/texmf-dist/tex/latex/yquant/yquant-lang.tex
+++ b/Master/texmf-dist/tex/latex/yquant/yquant-lang.tex
@@ -65,9 +65,19 @@
overlay/height/.is if=yquant@lang@attr@overlay@height,%
overlay/ht/.forward to=/yquant/global attrs/overlay/height,%
overlay/h/.forward to=/yquant/global attrs/overlay/height,%
+ overlay/left/.forward to=/yquant/global attrs/overlay/height,%
+ overlay/l/.forward to=/yquant/global attrs/overlay/height,%
+ overlay/before/.forward to=/yquant/global attrs/overlay/height,%
+ overlay/bef/.forward to=/yquant/global attrs/overlay/height,%
+ overlay/b/.forward to=/yquant/global attrs/overlay/height,%
overlay/depth/.is if=yquant@lang@attr@overlay@depth,%
overlay/dp/.forward to=/yquant/global attrs/overlay/depth,%
overlay/d/.forward to=/yquant/global attrs/overlay/depth,%
+ overlay/right/.forward to=/yquant/global attrs/overlay/depth,%
+ overlay/r/.forward to=/yquant/global attrs/overlay/depth,%
+ overlay/after/.forward to=/yquant/global attrs/overlay/depth,%
+ overlay/aft/.forward to=/yquant/global attrs/overlay/depth,%
+ overlay/a/.forward to=/yquant/global attrs/overlay/depth,%
overlay/single/.code={\pgfkeysalso{%
/yquant/global attrs/overlay/height={#1},%
/yquant/global attrs/overlay/depth={#1}%
diff --git a/Master/texmf-dist/tex/latex/yquant/yquant-prepare.tex b/Master/texmf-dist/tex/latex/yquant/yquant-prepare.tex
index 9869a61a763..af5960111d3 100644
--- a/Master/texmf-dist/tex/latex/yquant/yquant-prepare.tex
+++ b/Master/texmf-dist/tex/latex/yquant/yquant-prepare.tex
@@ -84,7 +84,7 @@
\expandafter%
\endpgfinterruptboundingbox%
\expandafter\dimen\expandafter0\expandafter=%
- \the\dimexpr\pgf@picmaxx-\pgf@picminx\relax\relax%
+ \the\dimexpr\yquant@pgf@picmaxx-\yquant@pgf@picminx\relax\relax%
\ifdim\dimen0>\dimen2 %
\dimen2=\dimen0 %
\fi%
@@ -375,8 +375,8 @@
(0pt, 0pt)%
node[/yquant/every operator, #2, /yquant/this operator,%
name prefix=, name suffix=, name=] {#1};%
- \yquant@register@update@height{#3}{\the\pgf@picmaxy}%
- \yquant@register@update@depth{#3}{\the\dimexpr-\pgf@picminy\relax}%
+ \yquant@register@update@height{#3}{\the\yquant@pgf@picmaxy}%
+ \yquant@register@update@depth{#3}{\the\dimexpr-\yquant@pgf@picminy\relax}%
}
\protected\def\yquant@prepare@multi#1#2#3{%
@@ -397,7 +397,7 @@
\def\yquant@prepare@style{#2}%
\let\yquant@register@multi@contiguous=\yquant@prepare@multi@contiguous%
\@fifthoffive#3%
- \ifdim\pgf@picmaxy=-16000pt %
+ \ifdim\yquant@pgf@picmaxy=-16000pt %
% if there was no single contiguous part before, determine the width now
\path%
(0pt, 0pt)%
@@ -407,8 +407,8 @@
}
\protected\def\yquant@prepare@multi@contiguous#1#2#3{%
- \global\pgf@picmaxy=-16000pt %
- \global\pgf@picminy=16000pt %
+ \global\yquant@pgf@picmaxy=-16000pt %
+ \global\yquant@pgf@picminy=16000pt %
\edef\cmd{%
\noexpand\path (0pt, 0pt)%
node[/yquant/every operator, \yquant@prepare@style, /yquant/this operator,%
@@ -419,10 +419,10 @@
\cmd%
\ifnum#1=#2 %
% this is a single register in disguise
- \yquant@register@update@height{#1}{\the\pgf@picmaxy}%
- \yquant@register@update@depth{#1}{\the\dimexpr-\pgf@picminy\relax}%
+ \yquant@register@update@height{#1}{\the\yquant@pgf@picmaxy}%
+ \yquant@register@update@depth{#1}{\the\dimexpr-\yquant@pgf@picminy\relax}%
\else%
- \yquant@register@update@multispace{#1}{#2}{\the\dimexpr\pgf@picmaxy-\pgf@picminy\relax}%
+ \yquant@register@update@multispace{#1}{#2}{\the\dimexpr\yquant@pgf@picmaxy-\yquant@pgf@picminy\relax}%
\fi%
}
@@ -454,14 +454,14 @@
\fi%
\ifnum\@secondoffive#3=\@thirdoffive#3 %
% this is a single register in disguise
- \yquant@register@update@height{\first}{\the\pgf@picmaxy}%
- \yquant@register@update@depth{\first}{\the\dimexpr-\pgf@picminy\relax}%
+ \yquant@register@update@height{\first}{\the\yquant@pgf@picmaxy}%
+ \yquant@register@update@depth{\first}{\the\dimexpr-\yquant@pgf@picminy\relax}%
\else%
% this may not be sufficient. Since the text position need not necessarily be at the center (if the register corresponding to the visual center is excluded), we may require some space here which we will later only use in parts, but then extend where we should not. However, resolving this would require a special handling when calculating the y positions at the end, meaning we could not use the multispace facility. Let's assume discontiguous init registers are so scarce that this does not matter (disable the acquiration by using the operator/overlay key).
\edef\upd{%
\yquant@register@update@multispace%
{\first}{\@thirdoffive#3}%
- {\the\dimexpr\pgf@picmaxy-\pgf@picminy\relax}%
+ {\the\dimexpr\yquant@pgf@picmaxy-\yquant@pgf@picminy\relax}%
}%
\upd%
\fi%
@@ -502,8 +502,8 @@
name prefix=, name suffix=, name=] {\unexpanded{#1}};%
}%
\cmd%
- \yquant@register@update@height{#3}{\the\pgf@picmaxy}%
- \yquant@register@update@depth{#3}{\the\dimexpr-\pgf@picminy\relax}%
+ \yquant@register@update@height{#3}{\the\yquant@pgf@picmaxy}%
+ \yquant@register@update@depth{#3}{\the\dimexpr-\yquant@pgf@picminy\relax}%
}
\protected\long\def\yquant@prepare@output@multi#1#2#3{%
@@ -545,14 +545,14 @@
\cmd%
\ifnum\@secondoffive#3=\@thirdoffive#3 %
% this is a single register in disguise
- \yquant@register@update@height{\first}{\the\pgf@picmaxy}%
- \yquant@register@update@depth{\first}{\the\dimexpr-\pgf@picminy\relax}%
+ \yquant@register@update@height{\first}{\the\yquant@pgf@picmaxy}%
+ \yquant@register@update@depth{\first}{\the\dimexpr-\yquant@pgf@picminy\relax}%
\else%
% this may not be sufficient. Since the text position need not necessarily be at the center (if the register corresponding to the visual center is excluded), we may require some space here which we will later only use in parts, but then extend where we should not. However, resolving this would require a special handling when calculating the y positions at the end, meaning we could not use the multispace facility. Let's assume discontiguous output registers are so scarce that this does not matter (disable the acquiration by using the operator/overlay key).
\edef\upd{%
\yquant@register@update@multispace%
{\first}{\@thirdoffive#3}%
- {\the\dimexpr\pgf@picmaxy-\pgf@picminy\relax}%
+ {\the\dimexpr\yquant@pgf@picmaxy-\yquant@pgf@picminy\relax}%
}%
\upd%
\fi%
@@ -566,11 +566,11 @@
\protected\def\yquant@prepare@subcircuit@getmaxx#1{%
\begingroup%
- \dimen0=-16383.99999pt %
+ \dimen0=\yquant@orientation@minus16383.99999pt %
\def\do##1{%
\ifcsname\yquant@prefix xpos@##1\endcsname%
\dimen2=\csname\yquant@prefix xpos@##1\endcsname\relax%
- \ifdim\dimen0<\dimen2 %
+ \ifdim\yquant@orientation@plus\dimen0<\yquant@orientation@plus\dimen2 %
\dimen0=\dimen2 %
\fi%
\else%
@@ -598,28 +598,40 @@
\yquant@set{#3}%
\let\next=\endgroup%
\ifyquant@config@operator@position@rightalign%
- \ifdim#1>-\pgf@picminx%
- \global\pgf@picminx=-\dimexpr#1\relax%
- \fi%
+ \ifyquanthorz{%
+ \ifdim#1>-\pgf@picminx%
+ \global\pgf@picminx=-\dimexpr#1\relax%
+ \fi%
+ }{%
+ \ifdim#1>\pgf@picmaxy%
+ \global\pgf@picmaxy=#1 %
+ \fi%
+ }%
\else%
\ifyquant@env@seamless{%
\ifdim\newx=0pt %
\dimdef\newx{%
- \newx+#1%
+ \newx\yquant@orientation@plus#1%
}%
\else%
\dimdef\newx{%
- \newx+\yquant@config@operator@sep+#1%
+ \newx\yquant@orientation@plus\yquant@config@operator@sep\yquant@orientation@plus#1%
}%
\fi%
}{%
\dimdef\newx{%
- \newx+\yquant@config@operator@sep+#1%
+ \newx\yquant@orientation@plus\yquant@config@operator@sep\yquant@orientation@plus#1%
}%
}%
- \ifdim\newx>\pgf@picmaxx%
- \global\pgf@picmaxx=\newx%
- \fi%
+ \ifyquanthorz{%
+ \ifdim\newx>\pgf@picmaxx%
+ \global\pgf@picmaxx=\newx%
+ \fi%
+ }{%
+ \ifdim\newx<\pgf@picminy%
+ \global\pgf@picminy=\newx%
+ \fi%
+ }%
\ifyquant@config@operator@position@advance%
\edef\next{%
\endgroup%
@@ -647,27 +659,37 @@
\protected\def\yquant@prepare@subcircuit@hspace#1#2{%
\yquant@prepare@subcircuit@getmaxx{#1}%
- \dimdef\newx{\newx+#2}%
+ \dimdef\newx{\newx\yquant@orientation@plus#2}%
\forlistloop\yquant@prepare@subcircuit@move@loop{#1}%
- \ifdim\newx>\pgf@picmaxx %
- \global\pgf@picmaxx=\newx %
- \fi%
+ \ifyquanthorz{%
+ \ifdim\newx>\pgf@picmaxx %
+ \global\pgf@picmaxx=\newx %
+ \fi%
+ }{%
+ \ifdim\newx<\pgf@picminy%
+ \global\pgf@picminy=\newx %
+ \fi%
+ }%
}
\protected\def\yquant@prepare@subcircuit@endwires{%
\expandafter\ifx\csname\yquant@prefix outputs\endcsname\relax%
% to have a symmetric situation, we extend again one separation at the end, unless this is supposed to be seamless and we don't have outputs (for seamless circuits with outputs, extend - since this extension will be between last register and output)
\ifyquant@env@seamless\relax{%
- \global\advance\pgf@picmaxx by \yquant@config@operator@sep\relax%
+ \ifyquanthorz{%
+ \global\advance\pgf@picmaxx by \yquant@config@operator@sep\relax%
+ }{%
+ \global\advance\pgf@picminy by -\yquant@config@operator@sep\relax%
+ }%
}%
\else%
% if we have outputs, those will be realized as additional drawing groups following this macro, so increasing the picture at this point is rather pointless. Instead, we adjust the wire positions appropriately. The additional separation will be inserted by the outputs.
\begingroup%
- \dimen0=-16383.99999pt %
+ \dimen0=\yquant@orientation@minus16383.99999pt %
\yquant@fordown \i := \csname\yquant@prefix registers\endcsname downto 1 {%
\ifcsname\yquant@prefix xpos@\i\endcsname%
\dimen2=\csname\yquant@prefix xpos@\i\endcsname\relax%
- \ifdim\dimen0<\dimen2 %
+ \ifdim\yquant@orientation@plus\dimen0<\yquant@orientation@plus\dimen2 %
\dimen0=\dimen2 %
\fi%
\else%
@@ -746,27 +768,39 @@
\let\endtikz@scope@env=\yquant@env@substikz@endscope%
\let\endscope=\endtikz@scope@env%
\let\stopscope=\endscope%
- \global\pgf@picmaxx=0pt %
- \global\pgf@picminx=0pt %
+ \global\yquant@pgf@picmaxx=0pt %
+ \global\yquant@pgf@picminx=0pt %
\global\setbox\yquant@prepare@subcircuit@box=\vbox to 1sp{%
\csname\yquant@prefix draw\endcsname%
}%
- \ifdim\pgf@picmaxy=-16000pt %
- \global\pgf@picmaxy=0pt %
- \global\pgf@picminy=0pt %
+ \ifdim\yquant@pgf@picmaxy=-16000pt %
+ \global\yquant@pgf@picmaxy=0pt %
+ \global\yquant@pgf@picminy=0pt %
\fi%
\ifyquant@env@seamless{%
% for seamless circuits, we do not have an initial separation. However, if there is a label to registers (which you should not do for seamless subcircuits), the "initial" separation is in fact an inner one, so we need it.
- \ifdim\pgf@picminx<0pt %
- \global\advance\pgf@picmaxx by \yquant@config@operator@sep\relax%
- \fi%
+ \ifyquanthorz{%
+ \ifdim\pgf@picminx<0pt %
+ \global\advance\pgf@picmaxx by \yquant@config@operator@sep\relax%
+ \fi%
+ }{%
+ \ifdim\pgf@picmaxy>0pt %
+ \global\advance\pgf@picminy by -\yquant@config@operator@sep\relax%
+ \fi%
+ }%
}\relax%
- \global\wd\yquant@prepare@subcircuit@box=\dimexpr\pgf@picmaxx-\pgf@picminx\relax%
+ \ifyquanthorz{%
+ \global\wd\yquant@prepare@subcircuit@box=\dimexpr\pgf@picmaxx-\pgf@picminx\relax%
+ }{%
+ \global\ht\yquant@prepare@subcircuit@box=\pgf@picmaxy%
+ \global\dp\yquant@prepare@subcircuit@box=-\pgf@picminy%
+ }%
\endgroup%
\edef\yquant@prepare@subcircuit@width{%
- {\the\wd\yquant@prepare@subcircuit@box}% inner width
- {\noexpand\the\dimexpr\pgf@picmaxx-\pgf@picminx\relax}% outer width
- {\the\pgf@picminx}% left margin
+ {\ifyquanthorz{\the\wd\yquant@prepare@subcircuit@box}% inner width
+ {\the\dimexpr\ht\yquant@prepare@subcircuit@box+\dp\yquant@prepare@subcircuit@box\relax}}%
+ {\noexpand\the\dimexpr\yquant@pgf@picmaxx-\yquant@pgf@picminx\relax}% outer width
+ {\ifyquanthorz{\the\pgf@picminx}{-\the\pgf@picmaxy}}% left margin
}%
\pgfresetboundingbox%
\path%
@@ -774,12 +808,12 @@
node[/yquant/every operator, #1,%
/yquant/operators/every subcircuit box, /yquant/this operator,%
/yquant/operators/this subcircuit box,%
- name prefix=, name suffix=, name=, y radius=0pt]%
+ name prefix=, name suffix=, name=, space radius=0pt]%
{\box\yquant@prepare@subcircuit@box};%
% the extra height is taken care for by manually inserting it to the height of the first and last register in the subcircuit
- \yquant@register@inject@extents{\pgf@picmaxy}{-\pgf@picminy}%
+ \yquant@register@inject@extents{\yquant@pgf@picmaxy}{-\yquant@pgf@picminy}%
\edef\cmd{%
- \dimen0=\the\dimexpr\pgf@picmaxx-\pgf@picminx\relax\relax%
+ \dimen0=\the\dimexpr\yquant@pgf@picmaxx-\yquant@pgf@picminx\relax\relax%
\yquant@prepare@subcircuit@add%
}%
\expandafter%
diff --git a/Master/texmf-dist/tex/latex/yquant/yquant-registers.tex b/Master/texmf-dist/tex/latex/yquant/yquant-registers.tex
index 41a472821f1..07d443c8642 100644
--- a/Master/texmf-dist/tex/latex/yquant/yquant-registers.tex
+++ b/Master/texmf-dist/tex/latex/yquant/yquant-registers.tex
@@ -882,13 +882,13 @@
\def#9{#4}%
}%
-% Set #1 to the maximum x value found between #2 and #3
+% Set #1 to the maximum x (vertical: minimum y) value found between #2 and #3
\protected\def\yquant@register@get@maxxrange#1#2#3{%
\begingroup%
- \dimen0=-16383.99999pt %
+ \dimen0=\yquant@orientation@minus16383.99999pt %
\yquant@for \yquant@register@get@maxx@i := #2 to #3 {%
\dimen2=\yquant@register@get@x{\yquant@register@get@maxx@i}\relax%
- \ifdim\dimen0<\dimen2 %
+ \ifdim\yquant@orientation@plus\dimen0<\yquant@orientation@plus\dimen2 %
\dimen0=\dimen2 %
\fi%
}%
@@ -897,13 +897,13 @@
\expandafter\def\expandafter#1\expandafter{\the\dimen0}%
}
-% Set #1 to the maximum x value found in the list #2
+% Set #1 to the maximum x (vertical: minimum y) value found in the list #2
\protected\def\yquant@register@get@maxxlist#1#2{%
\begingroup%
- \dimen0=-16383.99999pt %
+ \dimen0=\yquant@orientation@minus16383.99999pt %
\def\do##1{%
\dimen2=\yquant@register@get@x{##1}\relax%
- \ifdim\dimen0<\dimen2 %
+ \ifdim\yquant@orientation@plus\dimen0<\yquant@orientation@plus\dimen2 %
\dimen0=\dimen2 %
\fi%
}%
diff --git a/Master/texmf-dist/tex/latex/yquant/yquant-shapes.tex b/Master/texmf-dist/tex/latex/yquant/yquant-shapes.tex
index ea62802b2b5..0ebfca317ba 100644
--- a/Master/texmf-dist/tex/latex/yquant/yquant-shapes.tex
+++ b/Master/texmf-dist/tex/latex/yquant/yquant-shapes.tex
@@ -22,6 +22,7 @@
{Failed to patch \string\pgfdeclareshape}%
{yquant could not provide a necessary extension to pgf.}}%
% Every shape additionally provides information about how it should clip the wires. The clipping softpath instructions of shape #1 are stored into \pgfshapeclippath[horz|vert]result. The path is drawn with the tikz options #2 in place.
+% sync with yquant@config
\protected\def\pgfshapeclippath#1#2{%
% Ok, check whether #1 is known!
\ifcsname pgf@sh@ns@#1\endcsname%
@@ -459,13 +460,14 @@
}%
}
+% The dmeter shape is aware of the circuit orientation
\pgfdeclareshape{yquant-dmeter}{%
\saveddimen\xradius{%
\pgfmathsetlength\pgf@x{\pgfkeysvalueof{/tikz/x radius}}%
\ifdim\wd\pgfnodeparttextbox=0pt %
\pgf@xa=0pt %
\else%
- \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/inner xsep}+.5mm}%
+ \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/inner xsep}\ifyquanthorz{+.5mm}{}}%
\fi%
\ifdim\dimexpr.5\wd\pgfnodeparttextbox+\pgf@xa\relax>\pgf@x%
\pgf@x=\dimexpr.5\wd\pgfnodeparttextbox+\pgf@xa\relax%
@@ -476,7 +478,7 @@
\ifdim\dimexpr\ht\pgfnodeparttextbox+\dp\pgfnodeparttextbox\relax=0pt %
\pgf@xa=0pt %
\else%
- \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/inner ysep}}%
+ \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/inner ysep}\ifyquanthorz{}{+.325mm}}%
\fi%
\@tempdima=\dimexpr.5\ht\pgfnodeparttextbox+.5\dp\pgfnodeparttextbox+\pgf@xa\relax%
\ifdim\@tempdima>\pgf@x%
@@ -484,9 +486,24 @@
\fi%
}%
\savedanchor\stext{%
- \pgfqpoint%
- {-\dimexpr.5\wd\pgfnodeparttextbox+1mm\relax}%
- {-\dimexpr.5\ht\pgfnodeparttextbox-.5\dp\pgfnodeparttextbox\relax}%
+ \ifyquanthorz{%
+ \pgfqpoint%
+ {-\dimexpr.5\wd\pgfnodeparttextbox+1mm\relax}%
+ {-\dimexpr.5\ht\pgfnodeparttextbox-.5\dp\pgfnodeparttextbox\relax}%
+ }{%
+ % \pgf@x is still \yradius
+ \@tempdima=\pgf@x%
+ \pgfqpoint%
+ {-\dimexpr.5\wd\pgfnodeparttextbox\relax}%
+ {-\dimexpr.5\ht\pgfnodeparttextbox-.5\dp\pgfnodeparttextbox-.75mm\relax}%
+ }%
+ }%
+ \savedmacro\ifhorz{%
+ \ifyquanthorz{%
+ \def\ifhorz{\noexpand\@firstoftwo}%
+ }{%
+ \def\ifhorz{\noexpand\@secondoftwo}%
+ }%
}%
\foreach \anc in {center, north, south, south west, west, north west, text} {%
\inheritanchor[from=yquant-rectangle]{\anc}%
@@ -497,43 +514,112 @@
\anchorborder{%
\@tempdima=\pgf@x%
\@tempdimb=\pgf@y%
- \ifdim\pgf@x>\dimexpr\xradius-3mm\relax%
- \pgfpointborderellipse{\pgfqpoint{\dimexpr\@tempdima-\xradius+3mm\relax}%
- {\@tempdimb}}%
- {\pgfqpoint{3mm}%
- {.707107\dimexpr\yradius\relax}}%
- \advance\pgf@x by \dimexpr\xradius-3mm\relax%
- \else%
- \pgfpointborderrectangle{\pgfqpoint{\@tempdima}{\@tempdimb}}%
- {\pgfqpoint{\xradius}{\yradius}}%
- \fi%
+ \pgfpointborderrectangle{\pgfqpoint{\@tempdima}{\@tempdimb}}%
+ {\pgfqpoint{\xradius}{\yradius}}%
+ % for very distorted shapes, we lose a lot of accuracy in these calculations
+ \ifhorz{%
+ \ifdim\pgf@x>\dimexpr\xradius-3mm\relax%
+ \pgf@xa=\dimexpr\xradius-3mm\relax% shift of the ellipse
+ \pgf@xb=\dimexpr\@tempdimb*65536/\@tempdima\relax%
+ \pgf@xb=\dimexpr\pgf@xb*\pgf@xb/65536\relax% slope^2
+ \pgf@ya=72.86009pt % xradius^2 of ellipse (72.86009pt = 3mm^2/65536)
+ \pgf@yb=\yradius\relax%
+ \pgf@yb=\dimexpr\pgf@yb*\pgf@yb/65536\relax% yradius^2
+ % sqrt(slope^2 * (xradius^2 - shift^2) + yradius^2)
+ \pgfmathsqrt@{\the\dimexpr\pgf@xb*\dimexpr\pgf@ya-\pgf@xa*\pgf@xa/65536\relax/65536+%
+ \pgf@yb\relax\@gobbletwo}%
+ % yradius (shift yradius + xradius sqrt(...)) / (slope^2 xradius^2 + yradius^2)
+ \pgf@x=\dimexpr\dimexpr\yradius\relax*%
+ \dimexpr\pgf@xa*\dimexpr\yradius\relax/65536+%
+ 9\dimexpr\pgfmathresult pt\relax% 9 = 3mm/65536
+ \relax/%
+ \dimexpr\pgf@xb*\pgf@ya/65536+\pgf@yb\relax%
+ \relax%
+ % y = slope x
+ \pgf@y=\dimexpr\@tempdimb*\pgf@x/\@tempdima\relax%
+ \fi%
+ }{%
+ \ifdim\pgf@y<\dimexpr-\yradius+3mm\relax%
+ \pgf@xa=\dimexpr-\yradius+3mm\relax% shift of the ellipse
+ \pgf@xb=\dimexpr\@tempdima*65536/\@tempdimb\relax%
+ \pgf@xb=\dimexpr\pgf@xb*\pgf@xb/65536\relax% 1/slope^2
+ \pgf@ya=\xradius\relax% xradius
+ \pgf@ya=\dimexpr\pgf@ya*\pgf@ya/65535\relax% xradius^2
+ \pgf@yb=72.86009pt % yradius^2 of ellipse (72.86009pt = 3mm^2/65536)
+ % sqrt(1/slope^2 * (yradius^2 - shift^2) + xradius^2)
+ \pgfmathsqrt@{\the\dimexpr\pgf@xb*\dimexpr\pgf@yb-\pgf@xa*\pgf@xa/65536\relax/65536+%
+ \pgf@ya\relax\@gobbletwo}%
+ % xradius (shift xradius - yradius sqrt(...)) / (1/slope^2 yradius^2 + xradius^2)
+ \pgf@y=\dimexpr\dimexpr\xradius\relax*%
+ \dimexpr\pgf@xa*\dimexpr\xradius\relax/65536-%
+ 9\dimexpr\pgfmathresult pt\relax% 9 = 3mm/65536
+ \relax/%
+ \dimexpr\pgf@xb*\pgf@yb/65536+\pgf@ya\relax%
+ \relax%
+ % x = 1/slope y
+ \pgf@x=\dimexpr\@tempdima*\pgf@y/\@tempdimb\relax%
+ \fi%
+ }%
}%
\backgroundpath{%
- \pgfpathmoveto{\pgfqpoint{-\xradius}{\yradius}}%
- \pgfpathlineto{\pgfqpoint{\dimexpr\xradius-3mm\relax}{\yradius}}%
- \pgfpatharc{90}{-90}{3mm and \yradius}%
- \pgfpathlineto{\pgfqpoint{-\xradius}{-\yradius}}%
+ \ifhorz{%
+ \pgfpathmoveto{\pgfqpoint{-\xradius}{\yradius}}%
+ \pgfpathlineto{\pgfqpoint{\dimexpr\xradius-3mm\relax}{\yradius}}%
+ \pgfpatharc{90}{-90}{3mm and \yradius}%
+ \pgfpathlineto{\pgfqpoint{-\xradius}{-\yradius}}%
+ }{%
+ \pgfpathmoveto{\pgfqpoint{\xradius}{\yradius}}%
+ \pgfpathlineto{\pgfqpoint{\xradius}{\dimexpr-\yradius+3mm\relax}}%
+ \pgfpatharc{0}{-180}{\xradius and 3mm}%
+ \pgfpathlineto{\pgfqpoint{-\xradius}{\yradius}}%
+ }%
\pgfpathclose%
}%
\clippath{%
- \pgfpathmoveto{\pgfqpoint{-\dimexpr\xradius+.5\pgflinewidth\relax}%
- {\dimexpr\yradius+.5\pgflinewidth\relax}}%
- \pgfpathlineto{\pgfqpoint{\dimexpr\xradius-3mm\relax}%
- {\dimexpr\yradius+.5\pgflinewidth\relax}}%
- \pgfpatharc{90}{-90}{3mm+.5\pgflinewidth and \yradius+.5\pgflinewidth}%
- \pgfpathlineto{\pgfqpoint{-\dimexpr\xradius+.5\pgflinewidth\relax}%
- {-\dimexpr\yradius+.5\pgflinewidth\relax}}%
+ \ifhorz{%
+ \pgfpathmoveto{\pgfqpoint{-\dimexpr\xradius+.5\pgflinewidth\relax}%
+ {\dimexpr\yradius+.5\pgflinewidth\relax}}%
+ \pgfpathlineto{\pgfqpoint{\dimexpr\xradius-3mm\relax}%
+ {\dimexpr\yradius+.5\pgflinewidth\relax}}%
+ \pgfpatharc{90}{-90}{3mm+.5\pgflinewidth and \yradius+.5\pgflinewidth}%
+ \pgfpathlineto{\pgfqpoint{-\dimexpr\xradius+.5\pgflinewidth\relax}%
+ {-\dimexpr\yradius+.5\pgflinewidth\relax}}%
+ }{%
+ \pgfpathmoveto{\pgfqpoint{\dimexpr\xradius+.5\pgflinewidth\relax}%
+ {\dimexpr\yradius+.5\pgflinewidth\relax}}%
+ \pgfpathlineto{\pgfqpoint{\dimexpr\xradius+.5\pgflinewidth\relax}%
+ {\dimexpr-\yradius+3mm\relax}}%
+ \pgfpatharc{0}{-180}{\xradius+.5\pgflinewidth and 3mm+.5\pgflinewidth}%
+ \pgfpathlineto{\pgfqpoint{-\dimexpr\xradius+.5\pgflinewidth\relax}%
+ {\dimexpr\yradius+.5\pgflinewidth}}%
+ }%
\pgfpathclose%
}%
}
+% The line shape is aware of the circuit orientation (it always extends in space dimension with constant time)
\pgfdeclareshape{yquant-line}{%
\saveddimen\xradius{%
% we only need this for the border anchor; the value is automatically correct in the paths.
- \pgf@x=.5\pgflinewidth%
+ \ifyquanthorz{%
+ \pgf@x=.5\pgflinewidth%
+ }{%
+ \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/tikz/x radius}+.5*\yquant@config@register@sep}%
+ }%
}%
\saveddimen\yradius{%
- \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/tikz/y radius}+.5*\yquant@config@register@sep}%
+ \ifyquanthorz{%
+ \pgfmathsetlength\pgf@x{\pgfkeysvalueof{/tikz/y radius}+.5*\yquant@config@register@sep}%
+ }{%
+ \pgf@x=.5\pgflinewidth%
+ }%
+ }%
+ \savedmacro\ifhorz{%
+ \ifyquanthorz{%
+ \def\ifhorz{\noexpand\@firstoftwo}%
+ }{%
+ \def\ifhorz{\noexpand\@secondoftwo}%
+ }%
}%
\foreach \anc in {center, north, north east, east, south east, south, south west, west, north west} {%
\inheritanchor[from=yquant-rectangle]{\anc}%
@@ -541,19 +627,36 @@
\inheritanchorborder[from=yquant-rectangle]%
\backgroundpath{%
% manually shorten for the bounding box
- \pgf@xa=\dimexpr\yradius-\pgf@shorten@end@additional\relax%
- \pgf@ya=\dimexpr\yradius-\pgf@shorten@start@additional\relax%
- \pgf@shorten@end@additional=0pt %
- \pgf@shorten@start@additional=0pt %
- \pgfpathmoveto{\pgfqpoint{0pt}{\pgf@xa}}%
- \pgfpathlineto{\pgfqpoint{0pt}{-\pgf@ya}}%
+ \ifhorz{%
+ \pgf@xa=\dimexpr\yradius-\pgf@shorten@end@additional\relax%
+ \pgf@ya=\dimexpr\yradius-\pgf@shorten@start@additional\relax%
+ \pgf@shorten@end@additional=0pt %
+ \pgf@shorten@start@additional=0pt %
+ \pgfpathmoveto{\pgfqpoint{0pt}{\pgf@xa}}%
+ \pgfpathlineto{\pgfqpoint{0pt}{-\pgf@ya}}%
+ }{%
+ \pgf@xa=\dimexpr\xradius-\pgf@shorten@end@additional\relax%
+ \pgf@ya=\dimexpr\xradius-\pgf@shorten@start@additional\relax%
+ \pgf@shorten@end@additional=0pt %
+ \pgf@shorten@start@additional=0pt %
+ \pgfpathmoveto{\pgfqpoint{\pgf@xa}{0pt}}%
+ \pgfpathlineto{\pgfqpoint{-\pgf@ya}{0pt}}%
+ }%
}%
\clippath{%
- \@tempdima=\dimexpr\yradius-\pgf@shorten@end@additional\relax%
- \@tempdimb=\dimexpr\yradius-\pgf@shorten@start@additional\relax%
- \pgfpathrectanglecorners%
- {\pgfqpoint{-.5\pgflinewidth}{\@tempdima}}%
- {\pgfqpoint{.5\pgflinewidth}{-\@tempdimb}}%
+ \ifhorz{%
+ \@tempdima=\dimexpr\yradius-\pgf@shorten@end@additional\relax%
+ \@tempdimb=\dimexpr\yradius-\pgf@shorten@start@additional\relax%
+ \pgfpathrectanglecorners%
+ {\pgfqpoint{-.5\pgflinewidth}{\@tempdima}}%
+ {\pgfqpoint{.5\pgflinewidth}{-\@tempdimb}}%
+ }{%
+ \@tempdima=\dimexpr\xradius-\pgf@shorten@end@additional\relax%
+ \@tempdimb=\dimexpr\xradius-\pgf@shorten@start@additional\relax%
+ \pgfpathrectanglecorners%
+ {\pgfqpoint{\@tempdima}{-.5\pgflinewidth}}%
+ {\pgfqpoint{-\@tempdimb}{.5\pgflinewidth}}%
+ }%
}%
}
@@ -708,77 +811,145 @@
}
% END_FOLD
+% The init and output shapes are tightly connected to quantum circuits, so they will depend on the current circuit orientation!
\pgfdeclareshape{yquant-init}{%
\saveddimen\xradius{%
\pgfmathsetlength\pgf@x{\pgfkeysvalueof{/tikz/x radius}}%
- % inner xsep is between the brace tip and the right end of the text. Check if the decoration is raised (will define \def\tikz@dec@shift{\pgftransformyshift{#1}})
- \iftikz@decoratepath%
- \ifx\tikz@dec@shift\relax%
- \pgf@xa=\pgfdecorationsegmentamplitude %
+ \ifyquanthorz{%
+ % inner xsep is between the brace tip and the right end of the text. Check if the decoration is raised (will define \def\tikz@dec@shift{\pgftransformyshift{#1}})
+ \iftikz@decoratepath%
+ \ifx\tikz@dec@shift\relax%
+ \pgf@xa=\pgfdecorationsegmentamplitude %
+ \else%
+ \pgfmathsetlength\pgf@xa{\expandafter\@secondoftwo\tikz@dec@shift+\pgfdecorationsegmentamplitude}%
+ \fi%
+ \pgfmathaddtolength\pgf@xa{\pgfkeysvalueof{/pgf/inner xsep}}%
\else%
- \pgfmathsetlength\pgf@xa{\expandafter\@secondoftwo\tikz@dec@shift+\pgfdecorationsegmentamplitude}%
+ \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/inner xsep}}%
\fi%
- \pgfmathaddtolength\pgf@xa{\pgfkeysvalueof{/pgf/inner xsep}}%
- \else%
- \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/inner xsep}}%
- \fi%
- % outer xsep is (a lower bound) from the left end of the border to the left end of the text
- \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/outer xsep}}%
- \@tempdima=.5\dimexpr\wd\pgfnodeparttextbox+\pgf@xa+\pgf@xb\relax%
- \ifdim\@tempdima>\pgf@x%
- \pgf@x=\@tempdima%
- \fi%
+ % outer xsep is (a lower bound) from the left end of the border to the left end of the text
+ \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/outer xsep}}%
+ \@tempdima=.5\dimexpr\wd\pgfnodeparttextbox+\pgf@xa+\pgf@xb\relax%
+ \ifdim\@tempdima>\pgf@x%
+ \pgf@x=\@tempdima%
+ \fi%
+ }{%
+ \ifdim.5\wd\pgfnodeparttextbox>\pgf@x%
+ \pgf@x=.5\wd\pgfnodeparttextbox%
+ \fi%
+ \iftikz@decoratepath%
+ \ifdim2\pgfdecorationsegmentamplitude>\pgf@x%
+ \pgf@x=2\pgfdecorationsegmentamplitude%
+ \fi%
+ \fi%
+ }%
+ \global\pgf@y=\pgf@x%
}%
\saveddimen\yradius{%
\pgfmathsetlength\pgf@x{\pgfkeysvalueof{/tikz/y radius}}%
- \@tempdima=.5\dimexpr\ht\pgfnodeparttextbox+\dp\pgfnodeparttextbox\relax%
- \ifdim\@tempdima>\pgf@x%
- \pgf@x=\@tempdima%
- \fi%
- \iftikz@decoratepath%
- \ifdim2\pgfdecorationsegmentamplitude>\pgf@x%
- \pgf@x=2\pgfdecorationsegmentamplitude%
+ \ifyquanthorz{%
+ \@tempdima=.5\dimexpr\ht\pgfnodeparttextbox+\dp\pgfnodeparttextbox\relax%
+ \ifdim\@tempdima>\pgf@x%
+ \pgf@x=\@tempdima%
\fi%
- \fi%
+ \iftikz@decoratepath%
+ \ifdim2\pgfdecorationsegmentamplitude>\pgf@x%
+ \pgf@x=2\pgfdecorationsegmentamplitude%
+ \fi%
+ \fi%
+ }{%
+ % inner ysep is between the brace tip and the bottom end of the text. Check if the decoration is raised (will define \def\tikz@dec@shift{\pgftransformyshift{#1}})
+ \iftikz@decoratepath%
+ \ifx\tikz@dec@shift\relax%
+ \pgf@xa=\pgfdecorationsegmentamplitude %
+ \else%
+ \pgfmathsetlength\pgf@xa{\expandafter\@secondoftwo\tikz@dec@shift+\pgfdecorationsegmentamplitude}%
+ \fi%
+ \pgfmathaddtolength\pgf@xa{\pgfkeysvalueof{/pgf/inner ysep}}%
+ \else%
+ \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/inner ysep}}%
+ \fi%
+ % outer ysep is (a lower bound) from the top end of the border to the top end of the text
+ \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/outer ysep}}%
+ \@tempdima=.5\dimexpr\ht\pgfnodeparttextbox+\dp\pgfnodeparttextbox+\pgf@xa+\pgf@xb\relax%
+ \ifdim\@tempdima>\pgf@x%
+ \pgf@x=\@tempdima%
+ \fi%
+ }%
}%
\savedanchor\stext{%
- \iftikz@decoratepath%
- % \pgf@x is still \yradius...
- % first set \pgfdecoratedremainingdistance appropriately
- \pgfdecoratedremainingdistance=2\pgf@x%
- % now perform the transformation
- \yquant@gappedbrace@calcshift%
- \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/inner xsep}+\pgfdecorationsegmentamplitude}%
- \unless\ifx\tikz@dec@shift\relax%
- \pgfmathaddtolength\pgf@xa{\expandafter\@secondoftwo\tikz@dec@shift}%
+ % \pgf@x is still \yradius, \pgf@y is still \xradius
+ \@tempdima=\pgf@y%
+ \@tempdimb=\pgf@x%
+ \ifyquanthorz{%
+ \iftikz@decoratepath%
+ % first set \pgfdecoratedremainingdistance appropriately
+ \pgfdecoratedremainingdistance=2\@tempdimb%
+ % now perform the transformation
+ \yquant@gappedbrace@calcshift%
+ \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/inner xsep}+\pgfdecorationsegmentamplitude}%
+ \unless\ifx\tikz@dec@shift\relax%
+ \pgfmathaddtolength\pgf@xa{\expandafter\@secondoftwo\tikz@dec@shift}%
+ \fi%
+ \pgfqpoint%
+ {\dimexpr\@tempdima-\wd\pgfnodeparttextbox-\pgf@xa\relax}%
+ {\dimexpr\@tempdimb% = \yradius
+ -\pgfdecorationsegmentaspect\pgfdecoratedremainingdistance% - aspect
+ -.5\ht\pgfnodeparttextbox+.5\dp\pgfnodeparttextbox% center there
+ \relax}%
+ \else%
+ \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/inner xsep}}%
+ \pgfqpoint%
+ {\dimexpr\@tempdima-\wd\pgfnodeparttextbox-\pgf@xa\relax}%
+ {-.5\dimexpr\ht\pgfnodeparttextbox-\dp\pgfnodeparttextbox\relax}%
\fi%
- \pgfqpoint%
- {-\dimexpr\wd\pgfnodeparttextbox+\pgf@xa\relax}%
- {\dimexpr.5\pgfdecoratedremainingdistance% = \yradius
- -\pgfdecorationsegmentaspect\pgfdecoratedremainingdistance% - aspect
- -.5\ht\pgfnodeparttextbox+.5\dp\pgfnodeparttextbox% center there
- \relax}%
- \else%
- \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/inner xsep}}%
- \pgfqpoint%
- {-\dimexpr\wd\pgfnodeparttextbox+\pgf@xa\relax}%
- {-.5\dimexpr\ht\pgfnodeparttextbox-\dp\pgfnodeparttextbox\relax}%
- \fi%
+ }{%
+ \iftikz@decoratepath%
+ % first set \pgfdecoratedremainingdistance appropriately
+ \pgfdecoratedremainingdistance=2\@tempdima%
+ % now perform the transformation
+ \yquant@gappedbrace@calcshift%
+ \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/inner ysep}+\pgfdecorationsegmentamplitude}%
+ \unless\ifx\tikz@dec@shift\relax%
+ \pgfmathaddtolength\pgf@xa{\expandafter\@secondoftwo\tikz@dec@shift}%
+ \fi%
+ \pgfqpoint%
+ {\dimexpr-\@tempdima+%
+ \pgfdecorationsegmentaspect\pgfdecoratedremainingdistance% - aspect
+ -.5\wd\pgfnodeparttextbox% center there
+ \relax}%
+ {\dimexpr-\@tempdimb+\dp\pgfnodeparttextbox+\pgf@xa\relax}%
+ \else%
+ \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/inner ysep}}%
+ \pgfqpoint%
+ {-.5\wd\pgfnodeparttextbox}%
+ {\dimexpr-\@tempdimb+\dp\pgfnodeparttextbox+\pgf@xa\relax}%
+ \fi%
+ }%
+ }%
+ \savedmacro\ifhorz{%
+ \ifyquanthorz{%
+ \def\ifhorz{\noexpand\@firstoftwo}%
+ }{%
+ \def\ifhorz{\noexpand\@secondoftwo}%
+ }%
}%
% BEGIN_FOLD Operator anchors
\foreach \anc in {center, north, north east, east, south east, south, south west, west, north west} {%
\inheritanchor[from=yquant-rectangle]{\anc}%
}%
- \anchor{text}{%
- \stext%
- \advance \pgf@x by \xradius\relax%
- }%
+ \anchor{text}{\stext}%
\inheritanchorborder[from=yquant-rectangle]%
% END_FOLD
% BEGIN_FOLD Path
\backgroundpath{%
- \pgfpathmoveto{\pgfqpoint{\xradius}{\yradius}}%
- \pgfpathlineto{\pgfqpoint{\xradius}{-\yradius}}%
+ \ifhorz{%
+ \pgfpathmoveto{\pgfqpoint{\xradius}{\yradius}}%
+ \pgfpathlineto{\pgfqpoint{\xradius}{-\yradius}}%
+ }{%
+ \pgfpathmoveto{\pgfqpoint{-\xradius}{-\yradius}}%
+ \pgfpathlineto{\pgfqpoint{\xradius}{-\yradius}}%
+ }%
\pgfpointtransformed{\pgfqpoint{-\xradius}{\yradius}}%
\pgf@protocolsizes{\pgf@x}{\pgf@y}%
\pgfpointtransformed{\pgfqpoint{-\xradius}{-\yradius}}% for rotations
@@ -788,8 +959,8 @@
\pgfpathrectanglecorners%
{\pgfqpoint{-\dimexpr\xradius\relax}%
{\dimexpr\yradius\relax}}%
- {\pgfqpoint{\dimexpr\xradius+.5\pgflinewidth\relax}%
- {-\dimexpr\yradius\relax}}%
+ {\pgfqpoint{\dimexpr\xradius\ifhorz{+.5\pgflinewidth}{}\relax}%
+ {-\dimexpr\yradius\ifhorz{}{+.5\pgflinewidth}\relax}}%
}%
% END_FOLD
}
@@ -798,74 +969,141 @@
% Almost the same as in yquant-input, only a minimal change in \stext's x position
\saveddimen\xradius{%
\pgfmathsetlength\pgf@x{\pgfkeysvalueof{/tikz/x radius}}%
- % inner xsep is from the brace tip and the left end of the text. Check if the decoration is raised (will define \def\tikz@dec@shift{\pgftransformyshift{#1}})
- \iftikz@decoratepath%
- \ifx\tikz@dec@shift\relax%
- \pgf@xa=\pgfdecorationsegmentamplitude %
+ \ifyquanthorz{%
+ % inner xsep is between the brace tip and the left end of the text. Check if the decoration is raised (will define \def\tikz@dec@shift{\pgftransformyshift{#1}})
+ \iftikz@decoratepath%
+ \ifx\tikz@dec@shift\relax%
+ \pgf@xa=\pgfdecorationsegmentamplitude %
+ \else%
+ \pgfmathsetlength\pgf@xa{\expandafter\@secondoftwo\tikz@dec@shift+\pgfdecorationsegmentamplitude}%
+ \fi%
+ \pgfmathaddtolength\pgf@xa{\pgfkeysvalueof{/pgf/inner xsep}}%
\else%
- \pgfmathsetlength\pgf@xa{\expandafter\@secondoftwo\tikz@dec@shift+\pgfdecorationsegmentamplitude}%
+ \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/inner xsep}}%
\fi%
- \pgfmathaddtolength\pgf@xa{\pgfkeysvalueof{/pgf/inner xsep}}%
- \else%
- \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/inner xsep}}%
- \fi%
- % outer xsep is (a lower bound) from the left end of the border to the left end of the text
- \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/outer xsep}}%
- \@tempdima=.5\dimexpr\wd\pgfnodeparttextbox+\pgf@xa+\pgf@xb\relax%
- \ifdim\@tempdima>\pgf@x%
- \pgf@x=\@tempdima%
- \fi%
+ % outer xsep is (a lower bound) from the right end of the border to the right end of the text
+ \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/outer xsep}}%
+ \@tempdima=.5\dimexpr\wd\pgfnodeparttextbox+\pgf@xa+\pgf@xb\relax%
+ \ifdim\@tempdima>\pgf@x%
+ \pgf@x=\@tempdima%
+ \fi%
+ }{%
+ \ifdim.5\wd\pgfnodeparttextbox>\pgf@x%
+ \pgf@x=.5\wd\pgfnodeparttextbox%
+ \fi%
+ \iftikz@decoratepath%
+ \ifdim2\pgfdecorationsegmentamplitude>\pgf@x%
+ \pgf@x=2\pgfdecorationsegmentamplitude%
+ \fi%
+ \fi%
+ }%
+ \global\pgf@y=\pgf@x%
}%
\saveddimen\yradius{%
\pgfmathsetlength\pgf@x{\pgfkeysvalueof{/tikz/y radius}}%
- \@tempdima=.5\dimexpr\ht\pgfnodeparttextbox+\dp\pgfnodeparttextbox\relax%
- \ifdim\@tempdima>\pgf@x%
- \pgf@x=\@tempdima%
- \fi%
- \iftikz@decoratepath%
- \ifdim2\pgfdecorationsegmentamplitude>\pgf@x%
- \pgf@x=2\pgfdecorationsegmentamplitude%
+ \ifyquanthorz{%
+ \@tempdima=.5\dimexpr\ht\pgfnodeparttextbox+\dp\pgfnodeparttextbox\relax%
+ \ifdim\@tempdima>\pgf@x%
+ \pgf@x=\@tempdima%
\fi%
- \fi%
+ \iftikz@decoratepath%
+ \ifdim2\pgfdecorationsegmentamplitude>\pgf@x%
+ \pgf@x=2\pgfdecorationsegmentamplitude%
+ \fi%
+ \fi%
+ }{%
+ % inner ysep is between the brace tip and the top end of the text. Check if the decoration is raised (will define \def\tikz@dec@shift{\pgftransformyshift{#1}})
+ \iftikz@decoratepath%
+ \ifx\tikz@dec@shift\relax%
+ \pgf@xa=\pgfdecorationsegmentamplitude %
+ \else%
+ \pgfmathsetlength\pgf@xa{\expandafter\@secondoftwo\tikz@dec@shift+\pgfdecorationsegmentamplitude}%
+ \fi%
+ \pgfmathaddtolength\pgf@xa{\pgfkeysvalueof{/pgf/inner ysep}}%
+ \else%
+ \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/inner ysep}}%
+ \fi%
+ % outer ysep is (a lower bound) from the bottom end of the border to the bottom end of the text
+ \pgfmathsetlength\pgf@xb{\pgfkeysvalueof{/pgf/outer ysep}}%
+ \@tempdima=.5\dimexpr\ht\pgfnodeparttextbox+\dp\pgfnodeparttextbox+\pgf@xa+\pgf@xb\relax%
+ \ifdim\@tempdima>\pgf@x%
+ \pgf@x=\@tempdima%
+ \fi%
+ }%
}%
\savedanchor\stext{%
- \iftikz@decoratepath%
- % \pgf@x is still \yradius...
- % first set \pgfdecoratedremainingdistance appropriately
- \pgfdecoratedremainingdistance=2\pgf@x%
- % now perform the transformation
- \yquant@gappedbrace@calcshift%
- \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/inner xsep}+\pgfdecorationsegmentamplitude}%
- \unless\ifx\tikz@dec@shift\relax%
- \pgfmathaddtolength\pgf@xa{\expandafter\@secondoftwo\tikz@dec@shift}%
+ % \pgf@x is still \yradius, \pgf@y is still \xradius
+ \@tempdima=\pgf@y%
+ \@tempdimb=\pgf@x%
+ \ifyquanthorz{%
+ \iftikz@decoratepath%
+ % first set \pgfdecoratedremainingdistance appropriately
+ \pgfdecoratedremainingdistance=2\@tempdimb%
+ % now perform the transformation
+ \yquant@gappedbrace@calcshift%
+ \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/inner xsep}+\pgfdecorationsegmentamplitude}%
+ \unless\ifx\tikz@dec@shift\relax%
+ \pgfmathaddtolength\pgf@xa{\expandafter\@secondoftwo\tikz@dec@shift}%
+ \fi%
+ \pgfqpoint%
+ {\dimexpr-\@tempdima+\pgf@xa\relax}%
+ {\dimexpr\@tempdimb% = \yradius
+ -\pgfdecorationsegmentaspect\pgfdecoratedremainingdistance% - aspect
+ -.5\ht\pgfnodeparttextbox+.5\dp\pgfnodeparttextbox% center there
+ \relax}%
+ \else%
+ \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/inner xsep}}%
+ \pgfqpoint%
+ {\dimexpr-\@tempdima+\pgf@xa\relax}%
+ {-.5\dimexpr\ht\pgfnodeparttextbox-\dp\pgfnodeparttextbox\relax}%
\fi%
- \pgfqpoint%
- {\dimexpr\pgf@xa\relax}%
- {\dimexpr.5\pgfdecoratedremainingdistance% = \yradius
- -\pgfdecorationsegmentaspect\pgfdecoratedremainingdistance% - aspect
- -.5\ht\pgfnodeparttextbox+.5\dp\pgfnodeparttextbox% center there
- \relax}%
- \else%
- \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/inner xsep}}%
- \pgfqpoint%
- {\dimexpr\pgf@xa\relax}%
- {-.5\dimexpr\ht\pgfnodeparttextbox-\dp\pgfnodeparttextbox\relax}%
- \fi%
+ }{%
+ \iftikz@decoratepath%
+ % first set \pgfdecoratedremainingdistance appropriately
+ \pgfdecoratedremainingdistance=2\@tempdima%
+ % now perform the transformation
+ \yquant@gappedbrace@calcshift%
+ \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/inner ysep}+\pgfdecorationsegmentamplitude}%
+ \unless\ifx\tikz@dec@shift\relax%
+ \pgfmathaddtolength\pgf@xa{\expandafter\@secondoftwo\tikz@dec@shift}%
+ \fi%
+ \pgfqpoint%
+ {\dimexpr-\@tempdima% = \xradius
+ +\pgfdecorationsegmentaspect\pgfdecoratedremainingdistance% - aspect
+ -.5\wd\pgfnodeparttextbox% center there
+ \relax}%
+ {\dimexpr\@tempdimb-\ht\pgfnodeparttextbox-\pgf@xa\relax}%
+ \else%
+ \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/inner ysep}}%
+ \pgfqpoint%
+ {-.5\wd\pgfnodeparttextbox}%
+ {\dimexpr\@tempdimb-\ht\pgfnodeparttextbox-\pgf@xa\relax}%
+ \fi%
+ }%
+ }%
+ \savedmacro\ifhorz{%
+ \ifyquanthorz{%
+ \def\ifhorz{\noexpand\@firstoftwo}%
+ }{%
+ \def\ifhorz{\noexpand\@secondoftwo}%
+ }%
}%
% BEGIN_FOLD Operator anchors
\foreach \anc in {center, north, north east, east, south east, south, south west, west, north west} {%
\inheritanchor[from=yquant-init]{\anc}%
}%
- \anchor{text}{%
- \stext%
- \advance \pgf@x by -\xradius\relax%
- }%
+ \anchor{text}{\stext}%
\inheritanchorborder[from=yquant-init]%
% END_FOLD
% BEGIN_FOLD Path
\backgroundpath{%
- \pgfpathmoveto{\pgfqpoint{-\xradius}{\yradius}}%
- \pgfpathlineto{\pgfqpoint{-\xradius}{-\yradius}}%
+ \ifhorz{%
+ \pgfpathmoveto{\pgfqpoint{-\xradius}{\yradius}}%
+ \pgfpathlineto{\pgfqpoint{-\xradius}{-\yradius}}%
+ }{%
+ \pgfpathmoveto{\pgfqpoint{-\xradius}{\yradius}}%
+ \pgfpathlineto{\pgfqpoint{\xradius}{\yradius}}%
+ }%
\pgfpointtransformed{\pgfqpoint{\xradius}{\yradius}}%
\pgf@protocolsizes{\pgf@x}{\pgf@y}%
\pgfpointtransformed{\pgfqpoint{\xradius}{-\yradius}}% for rotations
@@ -873,8 +1111,8 @@
}%
\clippath{%
\pgfpathrectanglecorners%
- {\pgfqpoint{-\dimexpr\xradius+.5\pgflinewidth\relax}%
- {\dimexpr\yradius\relax}}%
+ {\pgfqpoint{-\dimexpr\xradius\ifhorz{+.5\pgflinewidth}{}\relax}%
+ {\dimexpr\yradius\ifhorz{}{+.5\pgflinewidth}\relax}}%
{\pgfqpoint{\dimexpr\xradius\relax}%
{-\dimexpr\yradius\relax}}%
}%
diff --git a/Master/texmf-dist/tex/latex/yquant/yquant-tools.tex b/Master/texmf-dist/tex/latex/yquant/yquant-tools.tex
index f30dc308bc0..fbfd3c1814e 100644
--- a/Master/texmf-dist/tex/latex/yquant/yquant-tools.tex
+++ b/Master/texmf-dist/tex/latex/yquant/yquant-tools.tex
@@ -455,9 +455,10 @@
}
% #1 is a pgf soft path. We extract the maximum x position at the y position specified in #2 and assign it to \dimen0, which is translated to the user coordinate system.
+% If the circuit is currently vertical, we extract the minimum y position at the x position specified in #2.
\protected\def\yquant@softpath@extractmaxxat#1#2{%
\begingroup%
- \dimen0=-16000pt %
+ \dimen0=\yquant@orientation@minus16000pt %
\dimen2=#2 %
\pgftransforminvert%
\let\pgfsyssoftpath@movetotoken=\yquant@softpath@extractmaxxat@moveto%
@@ -473,44 +474,45 @@
}
\protected\def\yquant@softpath@extractmaxxat@update#1{%
- \ifdim\dimen0<#1 %
+ \ifdim\yquant@orientation@plus\dimen0<\yquant@orientation@plus#1 %
\dimen0=#1 %
\fi%
}
\protected\def\yquant@softpath@extractmaxxat@moveto#1#2{%
\pgfpointtransformed{\pgfqpoint{#1}{#2}}%
- \dimen4=\pgf@x %
- \dimen6=\pgf@y %
+ \dimen4=\yquant@pgf@x %
+ \dimen6=\yquant@pgf@y %
}
\protected\def\yquant@softpath@extractmaxxat@lineto#1#2{%
\pgfpointtransformed{\pgfqpoint{#1}{#2}}%
- \ifyquant@OR{\ifdim\dimen4>\dimen0 }{\ifdim\pgf@x>\dimen0 }{%
+ \ifyquant@OR{\ifdim\yquant@orientation@plus\dimen4>\yquant@orientation@plus\dimen0 }%
+ {\ifdim\yquant@orientation@plus\yquant@pgf@x>\yquant@orientation@plus\dimen0 }{%
\ifdim\dimen6=\dimen2 %
\yquant@softpath@extractmaxxat@update{\dimen4}%
\else%
\ifdim\dimen6<\dimen2 %
- \unless\ifdim\pgf@y<\dimen2 %
+ \unless\ifdim\yquant@pgf@y<\dimen2 %
\expandafter\yquant@softpath@extractmaxxat@update\expandafter{\the\dimexpr%
\dimen4+% x0
- \dimexpr\pgf@x-\dimen4\relax*% (x1-x0)
- \dimexpr\dimen2-\dimen6\relax/\dimexpr\pgf@y-\dimen6\relax% (y-y0)/(y1-y0)
+ \dimexpr\yquant@pgf@x-\dimen4\relax*% (x1-x0)
+ \dimexpr\dimen2-\dimen6\relax/\dimexpr\yquant@pgf@y-\dimen6\relax% (y-y0)/(y1-y0)
\relax}%
\fi%
\else%
- \unless\ifdim\pgf@y>\dimen2 %
+ \unless\ifdim\yquant@pgf@y>\dimen2 %
\expandafter\yquant@softpath@extractmaxxat@update\expandafter{\the\dimexpr%
\dimen4+% x0
- \dimexpr\pgf@x-\dimen4\relax*% (x1-x0)
- \dimexpr\dimen2-\dimen6\relax/\dimexpr\pgf@y-\dimen6\relax% (y-y0)/(y1-y0)
+ \dimexpr\yquant@pgf@x-\dimen4\relax*% (x1-x0)
+ \dimexpr\dimen2-\dimen6\relax/\dimexpr\yquant@pgf@y-\dimen6\relax% (y-y0)/(y1-y0)
\relax}%
\fi%
\fi%
\fi%
}\relax%
- \dimen4=\pgf@x%
- \dimen6=\pgf@y%
+ \dimen4=\yquant@pgf@x%
+ \dimen6=\yquant@pgf@y%
}
\protected\def\yquant@softpath@extractmaxxat@curveto@checkx{%
@@ -520,12 +522,12 @@
% it is. \dimen4: x0, \pgf@xa: xa, \pgf@xb: xb, \pgf@xc: x1
\begingroup%
\dimen12=\dimexpr1pt-\dimen11\relax% 1 - t
- \dimen13=\dimexpr\dimen11*\dimen11/65535\relax% t^2
- \dimen14=\dimexpr\dimen12*\dimen12/65535\relax% (1 - t)^2
- \dimen255=\dimexpr\dimen13*\dimen11/65535*\pgf@xc/65535+% t^3 x1
- 3\dimen13*\dimen12/65535*\pgf@xb/65535+% t^2(1 - t) xb
- \dimen14*\dimen12/65535*\dimen4/65535+% (1 - t)^3 x0
- 3\dimen11*\dimen14/65535*\pgf@xa/65535% 3t(1 - t)^2 xa
+ \dimen13=\dimexpr\dimen11*\dimen11/65536\relax% t^2
+ \dimen14=\dimexpr\dimen12*\dimen12/65536\relax% (1 - t)^2
+ \dimen255=\dimexpr\dimen13*\dimen11/65536*\pgf@xc/65536+% t^3 x1
+ 3\dimen13*\dimen12/65536*\pgf@xb/65536+% t^2(1 - t) xb
+ \dimen14*\dimen12/65536*\dimen4/65536+% (1 - t)^3 x0
+ 3\dimen11*\dimen14/65536*\pgf@xa/65536% 3t(1 - t)^2 xa
\relax%
\expandafter%
\endgroup%
@@ -542,60 +544,80 @@
% Likewise for y:
% y0 = \dimen6 (the moveto point), ya = #2, yb = #4, y1 = #6.
\pgfpointtransformed{\pgfqpoint{#1}{#2}}%
- \pgf@xa=\pgf@x%
- \pgf@ya=\pgf@y%
+ \pgf@xa=\yquant@pgf@x%
+ \pgf@ya=\yquant@pgf@y%
\pgfpointtransformed{\pgfqpoint{#3}{#4}}%
- \pgf@xb=\pgf@x%
- \pgf@yb=\pgf@y%
+ \pgf@xb=\yquant@pgf@x%
+ \pgf@yb=\yquant@pgf@y%
\pgfpointtransformed{\pgfqpoint{#5}{#6}}%
- \pgf@xc=\pgf@x%
- \pgf@yc=\pgf@y%
+ \pgf@xc=\yquant@pgf@x%
+ \pgf@yc=\yquant@pgf@y%
% We first solve the third-order polynomial for t using the y value, then plug it back into the x value.
% TODO: this is accurate to approx. 3 digits. Can this be improved by reformulating Cardanos formula to involve less divisions?
\begingroup%
- % We need so may dimensions that we break with TeX's convention for their use.
- % for the multiplications with and divisions by dimensions, we exploit that eTeX fuses muldiv to 64 bits. Further note that each dimension has a scaling factor of 65535 for sp<->pt conversion. This is why don't factor out divisions (which would be more efficient, but not give the benefit of 64bit accuracy).
+ % We need so many dimensions that we break with TeX's convention for their use.
+ % for the multiplications with and divisions by dimensions, we exploit that eTeX fuses muldiv to 64 bits. Further note that each dimension has a scaling factor of 65536 for sp<->pt conversion. This is why don't factor out divisions (which would be more efficient, but not give the benefit of 64bit accuracy).
% a = 3(ya - yb) + (y1 - y0)
\dimen1=\dimexpr3\pgf@ya-3\pgf@yb+\pgf@yc-\dimen6\relax%
+ \ifdim\dimen1<1pt %
+ \ifdim\dimen1>-1pt %
+ \dimen1=0pt % this is almost a quadratic curve
+ \fi%
+ \fi%
\ifdim\dimen1=0pt %
% this is only a quadratic curve!
% b = 3(y0 - 2ya + yb)
- \dimen3=\dimexpr3\dimexpr\dimen6-2\pgf@ya+\pgf@yb\relax*65535\relax%
+ \dimen3=3\dimexpr\dimen6-2\pgf@ya+\pgf@yb\relax%
% c: 3(ya - y0)
- \dimen5=\dimexpr3\dimexpr\pgf@ya-\dimen6\relax*65535\relax%
+ \dimen5=3\dimexpr\pgf@ya-\dimen6\relax%
% d: y0 - <desired y>
- \dimen7=\dimexpr\dimexpr\dimen6-\dimen2\relax*65535\relax%
- % check the discriminant of the equation
- \dimen8=\dimexpr\dimen3*\dimen3/65535-4\dimen3*\dimen7/65535\relax%
- \unless\ifdim\dimen8<0pt%
- % there are two potential candidates, (-c +- sqrt(c^2 - 4b d))/2b
- \pgfmathsqrt@{\the\dimen8\@gobbletwo}%
- \dimen11=\dimexpr\dimexpr-\dimen5+\pgfmathresult pt\relax*65535/%
- \dimexpr2\dimen3\relax\relax%
- \yquant@softpath@extractmaxxat@curveto@checkx%
- \dimen11=\dimexpr\dimexpr-\dimen5-\pgfmathresult pt\relax*65535/%
- \dimexpr2\dimen3\relax\relax%
- \yquant@softpath@extractmaxxat@curveto@checkx%
- \fi%
+ \dimen7=\dimexpr\dimen6-\dimen2\relax%
+ \ifdim\dimen3<1pt %
+ \expandafter\@firstofone%
+ \else%
+ \expandafter\@secondoftwo%
+ \fi{%
+ \ifdim\dimen3>-1pt %
+ % this is almost a linear curve!
+ \dimen11=\dimexpr-\dimen7*65536/\dimen5\relax%
+ \yquant@softpath@extractmaxxat@curveto@checkx%
+ \expandafter\@gobble%
+ \else%
+ \expandafter\@firstofone%
+ \fi%
+ }{%
+ % check the discriminant of the equation
+ \dimen8=\dimexpr\dimen3*\dimen3/65536-4\dimen3*\dimen7/65536\relax%
+ \unless\ifdim\dimen8<0pt%
+ % there are two potential candidates, (-c +- sqrt(c^2 - 4b d))/2b
+ \pgfmathsqrt@{\the\dimen8\@gobbletwo}%
+ \dimen11=\dimexpr\dimexpr-\dimen5+\pgfmathresult pt\relax*65536/%
+ \dimexpr2\dimen3\relax\relax%
+ \yquant@softpath@extractmaxxat@curveto@checkx%
+ \dimen11=\dimexpr\dimexpr-\dimen5-\pgfmathresult pt\relax*65536/%
+ \dimexpr2\dimen3\relax\relax%
+ \yquant@softpath@extractmaxxat@curveto@checkx%
+ \fi%
+ }%
\else%
% We will simplify by directly dividing all coefficients by a
% b = 3(y0 - 2ya + yb)
- \dimen3=\dimexpr3\dimexpr\dimen6-2\pgf@ya+\pgf@yb\relax*65535/\dimen1\relax%
+ \dimen3=\dimexpr3\dimexpr\dimen6-2\pgf@ya+\pgf@yb\relax*65536/\dimen1\relax%
% c: 3(ya - y0)
- \dimen5=\dimexpr3\dimexpr\pgf@ya-\dimen6\relax*65535/\dimen1\relax%
+ \dimen5=\dimexpr3\dimexpr\pgf@ya-\dimen6\relax*65536/\dimen1\relax%
% d: y0 - <desired y>
- \dimen7=\dimexpr\dimexpr\dimen6-\dimen2\relax*65535/\dimen1\relax%
+ \dimen7=\dimexpr\dimexpr\dimen6-\dimen2\relax*65536/\dimen1\relax%
% Note that now our a value (\dimen1) is no longer needed, it is one.
% check the discriminant of the equation
% Q = (3c - b^2)/9
- \dimen8=\dimexpr\dimexpr3\dimen5-\dimen3*\dimen3/65535\relax/9\relax%
+ \dimen8=\dimexpr\dimexpr3\dimen5-\dimen3*\dimen3/65536\relax/9\relax%
% R = (9bc - 27d - 2b^3)/54 = bc/6 - d/2 - b^3/27
- \dimen9=\dimexpr\dimen3*\dimen5/393210-% 6*65535
+ \dimen9=\dimexpr\dimen3*\dimen5/393216-% 6*65536
.5\dimen7-%
- \dimen3*\dimen3/65535*\dimen3/1769445% 27*65535
+ \dimen3*\dimen3/65536*\dimen3/1769472% 27*65536
\relax%
% D = Q^3 + R^2
- \dimen10=\dimexpr\dimen8*\dimen8/65535*\dimen8/65535+\dimen9*\dimen9/65535\relax%
+ \dimen10=\dimexpr\dimen8*\dimen8/65536*\dimen8/65536+\dimen9*\dimen9/65536\relax%
\ifdim\dimen10>0pt %
% only one real root: y_1 = S + T - b/3a
% S = cbrt(R + sqrt(Q^3 + R^2))
@@ -641,7 +663,7 @@
\pgfmathsqrt@{\the\dimexpr-\dimen10\relax\@gobbletwo}%
\dimen10=\pgfmathresult pt %
% Let us first find the absolute value
- \dimen12=\dimexpr\dimen9*\dimen9/65535+\dimen10*\dimen10/65535\relax%
+ \dimen12=\dimexpr\dimen9*\dimen9/65536+\dimen10*\dimen10/65536\relax%
\pgfmathpow@{\the\dimen12\@gobbletwo}{.1666666667}%
\dimen12=\pgfmathresult pt%
% then we need 1/3 the argument of R + i sqrt(|D|).
@@ -676,15 +698,15 @@
\protected\def\yquant@softpath@extractmaxxat@rectto#1#2\pgfsyssoftpath@rectsizetoken#3#4{%
% #1: lower left x, #2: lower left y, #3: width, #4: height
\pgfpointtransformed{\pgfqpoint{#1}{#2}}%
- \pgf@xa=\pgf@x%
- \pgf@ya=\pgf@y%
+ \pgf@xa=\yquant@pgf@x%
+ \pgf@ya=\yquant@pgf@y%
\pgfpointtransformed{\pgfqpoint{\dimexpr#1+#3\relax}{\dimexpr#2+#4\relax}}%
% (\pgf@xa, \pgf@ya) one corner, (\pgf@x, \pgf@y) other corner
- \ifdim\pgf@y>\pgf@ya %
+ \ifdim\yquant@pgf@y>\pgf@ya %
\unless\ifdim\pgf@ya>\dimen2 %
- \unless\ifdim\pgf@y<\dimen2 %
- \ifdim\pgf@x>\pgf@xa %
- \yquant@softpath@extractmaxxat@update\pgf@x%
+ \unless\ifdim\yquant@pgf@y<\dimen2 %
+ \ifdim\yquant@orientation@plus\yquant@pgf@x>\yquant@orientation@plus\pgf@xa %
+ \yquant@softpath@extractmaxxat@update\yquant@pgf@x%
\else%
\yquant@softpath@extractmaxxat@update\pgf@xa%
\fi%
@@ -692,9 +714,9 @@
\fi%
\else%
\unless\ifdim\pgf@ya<\dimen2 %
- \unless\ifdim\pgf@y>\dimen2 %
- \ifdim\pgf@x>\pgf@xa %
- \yquant@softpath@extractmaxxat@update\pgf@x%
+ \unless\ifdim\yquant@pgf@y>\dimen2 %
+ \ifdim\yquant@orientation@plus\yquant@pgf@x>\yquant@orientation@plus\pgf@xa %
+ \yquant@softpath@extractmaxxat@update\yquant@pgf@x%
\else%
\yquant@softpath@extractmaxxat@update\pgf@xa%
\fi%
diff --git a/Master/texmf-dist/tex/latex/yquant/yquant.sty b/Master/texmf-dist/tex/latex/yquant/yquant.sty
index 75b1cfd2149..1b44a60c795 100644
--- a/Master/texmf-dist/tex/latex/yquant/yquant.sty
+++ b/Master/texmf-dist/tex/latex/yquant/yquant.sty
@@ -15,7 +15,7 @@
%
% The Current Maintainer of this work is Benjamin Desef.
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{yquant}[2021/12/28 v0.6 Yet another quantum circuit library for LaTeX]
+\ProvidesPackage{yquant}[2022/02/05 v0.7 Yet another quantum circuit library for LaTeX]
\RequirePackage{etoolbox}[2018/02/11]
\RequirePackage{tikz}[2015/08/29]
@@ -37,15 +37,17 @@
\fi
\newif\ifyquantdebug
-\input yquant-config.tex
+\pgfdeclarelayer{wires}
+\pgfdeclarelayer{behindwires}
\input yquant-tools.tex
+\input yquant-shapes.tex
+\input yquant-config.tex
\input yquant-registers.tex
\input yquant-env.tex
\input yquant-langhelper.tex
\input yquant-circuit.tex
\input yquant-prepare.tex
\input yquant-draw.tex
-\input yquant-shapes.tex
\input yquant-lang.tex
% usually, \\ is robust; but when using \centering, it is \let to \@centercr, which is not robust (probably because this happens only when not protecting). Fix this, so that \\ does not require \protect if a centered circuit is drawn.
diff --git a/Master/texmf-dist/tex/latex/yquant/yquantlanguage-groups.sty b/Master/texmf-dist/tex/latex/yquant/yquantlanguage-groups.sty
index 1ea78cace69..fc1986ff048 100644
--- a/Master/texmf-dist/tex/latex/yquant/yquantlanguage-groups.sty
+++ b/Master/texmf-dist/tex/latex/yquant/yquantlanguage-groups.sty
@@ -15,9 +15,9 @@
%
% The Current Maintainer of this work is Benjamin Desef.
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{yquantlanguage-groups}[2021/08/14 v0.6 yquant-groups]
+\ProvidesPackage{yquantlanguage-groups}[2022/01/07 v0.7 yquant-groups]
-\RequirePackage{yquant}[2021/12/24]
+\RequirePackage{yquant}[2022/01/07]
% BEGIN_FOLD Config
\newif\ifyquantgroup@config@aligned
@@ -39,7 +39,11 @@
}%
\fi%
},%
- operators/every group equals/.style={shape=yquant-rectangle, align=center, inner xsep=1mm, x radius=2mm, y radius=2.47mm}
+ operators/every group equals/.style={%
+ shape=yquant-rectangle, align=center,
+ anchor/.expanded=\ifyquanthorz{center}{north west},%
+ inner xsep=1mm, x radius=2mm, y radius=2.47mm%
+ }
}
\def\yquantgroup@config@lineseparation{5mm}%
% END_FOLD
@@ -66,7 +70,7 @@
\let\equals=\yquantgroup@equals%
\let\shiftright=\yquantgroup@shiftright%
\let\\=\yquantgroup@linebreak%
- % This is a bit inconsistent, we should check \iftikz@inside@picture, but this is no longer appropriately set since at pgf 3.1.2.
+ % This is a bit inconsistent, we should check \iftikz@inside@picture, but this is no longer appropriately set since at least pgf 3.1.2.
\let\ifyquantgroup@inpicture=\ifpgfpicture%
\pgfkeysgetvalue{/yquant/preamble}\yquantgroup@save@preamble%
\ifpgfpicture%
@@ -127,6 +131,10 @@
% BEGIN_FOLD Register declaration
\protected\long\def\yquantgroup@registers#1{%
+ \def\registers{%
+ \PackageError{yquant.sty}{Double invocation of \string\registers}%
+ {All registers must be specified once at the beginning of the group. Multiple declarations or later additions are not allowed.}%
+ }%
\begingroup%
\gdef\yquantgroup@registers@text{#1}%
\let\yquantgroup@save@lang@create@parse=\yquant@lang@create@parse@name%
@@ -152,10 +160,6 @@
\yquant@env@end%
\endpgfinterruptboundingbox%
}%
- \def\registers{%
- \PackageError{yquant.sty}{Double invocation of \string\registers}%
- {All registers must be specified once at the beginning of the group. Multiple declarations or later additions are not allowed.}%
- }%
\unless\ifx\yquantgroup@registers@text\empty%
\csxappto{\yquantgroup@prefix import@\csname\yquantgroup@prefix registers\endcsname}{%
\unexpanded\expandafter{\yquantgroup@registers@text}%
@@ -248,14 +252,25 @@
\fi%
% since \registers is in subcircuit mode, that the existence of the macro implies that it is greater than zero
\ifdef\yquant@prefix{%
- % We already started the yquant environment - but this means that potentially, we could have changed our wire styles. The underlying subcircuit architecture will preserve these changes, but since in our context, we treat the circuits as independent, this is not the desired behavior: remove all styles.
- \yquant@for \i := 1 to \csname\yquant@prefix registers\endcsname {%
- % we don't really need to flush a wire, since it is discarded anyway
- \csxappto{\yquant@prefix draw}{%
- \yquant@register@set@style{\i}{}%
+ \ifyquanthorz{%
+ % We already started the yquant environment - but this means that potentially, we could have changed our wire styles. The underlying subcircuit architecture will preserve these changes, but since in our context, we treat the circuits as independent, this is not the desired behavior: remove all styles.
+ \yquant@for \i := 1 to \csname\yquant@prefix registers\endcsname {%
+ % we don't really need to flush a wire, since it is discarded anyway
+ \csxappto{\yquant@prefix draw}{%
+ \yquant@register@set@style{\i}{}%
+ }%
+ }%
+ \@gobble%
+ }{%
+ % We already started the yquant environment, but it was a vertical one. We are unable to perform wire alignment with vertical circuits. We want to place the next circuit to its right, which means that we acutually need to end the environment.
+ \expandafter%
+ \yquant@env@end%
+ \expandafter\def\expandafter\yquantgroup@currentxpos\expandafter{\the\dimexpr%
+ \pgf@picmaxx+\yquant@config@operator@sep%
}%
}%
- }{%
+ }\@firstofone%
+ {%
\yquant@env@begin[/tikz/shift={(\yquantgroup@currentxpos, \yquantgroup@currentypos)}]%
% we re-create all the outer registers, but without the names.
% sync with yquant-registers/\yquant@register@define
@@ -377,18 +392,48 @@
}
\protected\long\def\yquantgroup@equals@ii#1[#2]{%
- \yquantgroup@startenvironments%
- \ifx0#1%
- \yquant group\space equals {#2} (-);%
- \else%
+ \unless\ifx0#1%
\numgdef\yquantgroup@alignments{\yquantgroup@alignments+1}%
- % hopefully no prefixes/suffixes are installed - if we reset them here, it will also reset them for the content, which we don't want to do; but this will then give an error when we try to access the node. Probably never a problem.
- \yquant [name=yquantgroup@internal@alignment@\yquantgroup@alignments]%
- group\space equals {#2} (-);%
+ \fi%
+ \ifyquanthorz{%
+ \yquantgroup@startenvironments%
+ \ifx0#1%
+ \yquant group\space equals {#2} (-);%
+ \else%
+ % hopefully no prefixes/suffixes are installed - if we reset them here, it will also reset them for the content, which we don't want to do; but this will then give an error when we try to access the node. Probably never a problem.
+ \yquant [name=yquantgroup@internal@alignment@\yquantgroup@alignments]%
+ group\space equals {#2} (-);%
+ \fi%
+ }{%
+ % in vertical mode, we must be very careful: we cannot place the box in a circuit, as it would go under the others. In principle, it would be nice to place the equals vertically centered to the right of the last circuit, but the circuits may well have different vertical extents, so a centering does not make sense. Therefore, we place it to the top.
+ \ifdefined\yquant@prefix%
+ \edef\yquantgroup@handlesize{%
+ \global\pgf@picmaxx=-16000pt %
+ \yquant@env@end%
+ \edef\noexpand\yquantgroup@currentxpos{%
+ \noexpand\the\dimexpr\pgf@picmaxx+%
+ \noexpand\yquant@config@operator@sep\relax%
+ }%
+ \noexpand\ifdim\pgf@picmaxx<\the\pgf@picmaxx\space%
+ \global\pgf@picmaxx=\the\pgf@picmaxx\space%
+ \noexpand\fi%
+ }%
+ \yquantgroup@handlesize%
+ \fi%
+ \node[/yquant/operators/every group equals] (yquantnode) at (\yquantgroup@currentxpos, \yquantgroup@currentypos) {#2};
+ \unless\ifx0#1%
+ \pgfcoordinate{yquantgroup@internal@alignment@\yquantgroup@alignments}%
+ {\pgfqpoint{\dimexpr\yquantgroup@currentxpos+\yquant@config@operator@sep}%
+ {\yquantgroup@currentypos}}%
+ \fi%
+ \pgfpointanchor{yquantnode}{north east}
+ \dimdef\yquantgroup@currentxpos{\pgf@x+\yquant@config@operator@sep}%
+ }%
+ \unless\ifx0#1%
\ifnum\yquantgroup@alignments>1 %
- \pgfcoordinate{yquantgroup@internal@alignment@\the\numexpr\yquantgroup@alignments-1\relax}{west}%
+ \pgfpointanchor{yquantgroup@internal@alignment@\the\numexpr\yquantgroup@alignments-1\relax}{west}%
\pgf@xa=\pgf@x%
- \pgfcoordinate{yquantgroup@internal@alignment@\yquantgroup@alignments}{west}%
+ \pgfpointanchor{yquantgroup@internal@alignment@\yquantgroup@alignments}{west}%
\unless\ifdim\pgf@x>\pgf@xa%
\PackageError{yquant.sty}{Invalid alignment mark position}%
{The desired alignment mark position would be to the left of an already existing mark.}%
@@ -431,7 +476,7 @@
}%
\ifx1#1%
\ifnum\yquantgroup@alignments>0 %
- \pgfcoordinate{yquantgroup@internal@alignment@\yquantgroup@alignments}{west}%
+ \pgfpointanchor{yquantgroup@internal@alignment@\yquantgroup@alignments}{west}%
\unless\ifdim\dimexpr\yquantgroup@currentxpos+\yquant@config@operator@sep\relax>\pgf@x%
\PackageError{yquant.sty}{Invalid alignment mark position}%
{The desired alignment mark position would be to the left of an already existing mark.}%