summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/yquant/yquant-config.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/yquant/yquant-config.tex')
-rw-r--r--Master/texmf-dist/tex/latex/yquant/yquant-config.tex275
1 files changed, 250 insertions, 25 deletions
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%