diff options
author | Karl Berry <karl@freefriends.org> | 2023-02-19 20:57:28 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-02-19 20:57:28 +0000 |
commit | 3955c6f567cb3dcb8061a5f6b5989673371c143e (patch) | |
tree | 1bdb3932178dee950d835998adcd72b2228dcd4f /Master/texmf-dist/tex/latex | |
parent | 9c8377ee047747b61cf8242b3a072efee1c772a6 (diff) |
yquant (19feb23)
git-svn-id: svn://tug.org/texlive/trunk@65933 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/yquant/yquant-config.tex | 76 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/yquant/yquant-draw.tex | 55 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/yquant/yquant-env.tex | 28 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/yquant/yquant-prepare.tex | 26 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/yquant/yquant.sty | 4 |
5 files changed, 134 insertions, 55 deletions
diff --git a/Master/texmf-dist/tex/latex/yquant/yquant-config.tex b/Master/texmf-dist/tex/latex/yquant/yquant-config.tex index 4d7f9630bdb..bcd590edd8b 100644 --- a/Master/texmf-dist/tex/latex/yquant/yquant-config.tex +++ b/Master/texmf-dist/tex/latex/yquant/yquant-config.tex @@ -286,6 +286,78 @@ },% every post measurement control/direct/.code={% \let\yquant@lang@attr@directcontrol=\relax% + },% +} +\def\yquant@config@only@multi#1#2#3#4\yquant@sep{% + \yquant@config@only{#1}{#2}{#3}% + \ifstrempty{#4}\relax{% + \yquant@config@only@multi{#1}#4\yquant@sep% + }% +} +\protected\def\yquant@config@only#1#2#3{% + \begingroup% + \let\yquant@config@onlyloop@idxs=\empty% + \forcsvlist\yquant@config@onlyloop{#2}% + \let\ifdoit=\iffalse% + \ifdefined\yquant@config@onlyloop@allupto% + \unless\ifnum\idx>\yquant@config@onlyloop@allupto\space% + \csletcs{ifdoit}{iftrue}% + \fi% + \fi% + \ifdefined\yquant@config@onlyloop@allfrom% + \unless\ifnum\idx<\yquant@config@onlyloop@allfrom\space% + \csletcs{ifdoit}{iftrue}% + \fi% + \fi% + \unless\ifdoit% + \xifinlist\idx\yquant@config@onlyloop@idxs{% + \csletcs{ifdoit}{iftrue}% + }\relax% + \fi% + \expandafter% + \endgroup% + #1\ifdoit + \pgfkeysalso{#3}% + \fi% +} +\protected\def\yquant@config@onlyloop#1{% + \yquant@config@onlyloop@checkrange#1-\yquant@sep% +} +\protected\def\yquant@config@onlyloop@checkrange#1-#2\yquant@sep{% + \ifstrempty{#2}{% + \listeadd\yquant@config@onlyloop@idxs{#1}% + }{% + \yquant@config@onlyloop@range#1-#2\yquant@sep% + }% +} +\protected\def\yquant@config@onlyloop@range#1-#2-\yquant@sep{% + \ifblank{#1}{% + \ifblank{#2}{% + % pretty meaningless, but let's allow for it + \def\yquant@config@onlyloop@allfrom{0}% + }{% + \ifdefined\yquant@config@onlyloop@allupto% + \ifnum#2>\yquant@config@onlyloop@allupto\space% + \numdef\yquant@config@onlyloop@allupto{#2}% + \fi% + \else% + \numdef\yquant@config@onlyloop@allupto{#2}% + \fi% + } + }{% + \ifblank{#2}{% + \ifdefined\yquant@config@onlyloop@allfrom% + \ifnum#1<\yquant@config@onlyloop@allfrom\space% + \numdef\yquant@config@onlyloop@allfrom{#1}% + \fi% + \else% + \numdef\yquant@config@onlyloop@allfrom{#1}% + \fi% + }{% + \yquant@for \i := #1 to #2 {% + \listeadd\yquant@config@onlyloop@idxs\i% + }% + }% }% } % END_FOLD @@ -412,6 +484,10 @@ {\yquant@config@circuitsetupfalse},% internal/autorotate init/.style={},% internal/autorotate output/.style={},% + internal/before styles/.style={% + /tikz/only at/.code=\yquant@config@only@multi{}##1\yquant@sep, + /tikz/not at/.code=\yquant@config@only@multi\unless##1\yquant@sep + }, } \ifnum\yquant@compat<2 % \pgfqkeys{/yquant}{% diff --git a/Master/texmf-dist/tex/latex/yquant/yquant-draw.tex b/Master/texmf-dist/tex/latex/yquant/yquant-draw.tex index 6f509418099..ed99e036d70 100644 --- a/Master/texmf-dist/tex/latex/yquant/yquant-draw.tex +++ b/Master/texmf-dist/tex/latex/yquant/yquant-draw.tex @@ -53,6 +53,7 @@ \tikz@enable@node@quotes% \yquant@config@operator@position@rightalignfalse% \yquant@config@operator@position@advancetrue% + \pgfkeys{/yquant/internal/before styles}% \yquant@set{#3}% % if the operator is right-aligned, we will not advance, as we must assume that the x position is already chosen appropriately \ifyquant@config@operator@position@rightalign% @@ -849,10 +850,11 @@ \pgfusepathqfill% \else% \begingroup% + \pgf@relevantforpicturesizefalse% \pgftransformreset% - \pgfpathrectanglecorners% - {\pgfqpoint{\pgf@picminx}{\pgf@picminy}}% - {\pgfqpoint{\pgf@picmaxx}{\pgf@picmaxy}}% + \pgfpathrectangle% + {\yquant@pgfqpoint{-.5\maxdimen}{-.5\maxdimen}}% + {\yquant@pgfqpoint{\maxdimen}{\maxdimen}}% \pgfseteorule% even-odd to properly invert the clipping \pgfusepathqclip% \endgroup% @@ -895,10 +897,11 @@ \pgfusepathqfill% \else% \begingroup% + \pgf@relevantforpicturesizefalse% \pgftransformreset% - \pgfpathrectanglecorners% - {\pgfqpoint{\pgf@picminx}{\pgf@picminy}}% - {\pgfqpoint{\pgf@picmaxx}{\pgf@picmaxy}}% + \pgfpathrectangle% + {\yquant@pgfqpoint{-.5\maxdimen}{-.5\maxdimen}}% + {\yquant@pgfqpoint{\maxdimen}{\maxdimen}}% \pgfseteorule% even-odd to properly invert the clipping \pgfusepathqclip% \endgroup% @@ -956,42 +959,14 @@ \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% + \pgf@relevantforpicturesizefalse% + \pgftransformreset% + % everything serves as clipping inversion, which smells like a rectangle from (-\maxdimen, -\maxdimen) to (\maxdimen, \maxdimen). However, this is translated into a base point plus a direction vector, and since neither is allowed to exceed \maxdimen, we must just hope that the circuit is never drawn outside of .5\maxdimen - which is a fair assumption. + \pgfpathrectangle% + {\yquant@pgfqpoint{-.5\maxdimen}{-.5\maxdimen}}% + {\yquant@pgfqpoint{\maxdimen}{\maxdimen}}% \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\dimexpr\@tempdimb-\@tempdima\relax<1cm % - \@tempdima=\dimexpr\wireypos-5mm\relax% - \@tempdimb=\dimexpr\wireypos+5mm\relax% - \fi% - \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% diff --git a/Master/texmf-dist/tex/latex/yquant/yquant-env.tex b/Master/texmf-dist/tex/latex/yquant/yquant-env.tex index bbbf740e713..f87745b05c0 100644 --- a/Master/texmf-dist/tex/latex/yquant/yquant-env.tex +++ b/Master/texmf-dist/tex/latex/yquant/yquant-env.tex @@ -259,17 +259,9 @@ \listremove\noexpand\redolist{#1}% \expandafter\noexpand\csname yquant@env@end@calcypositions@#1@\i\endcsname% \expandafter\unless\expandafter\ifx\csname\yquant@prefix subcircuits\endcsname\empty% - \ifinlist{#1}\noexpand\redolist{% - \noexpand\forlistloop% - \yquant@env@end@calcypositions@run% - \expandafter\noexpand\csname\yquant@prefix subcircuits\endcsname% - }{% - \noexpand\ifyquant@env@end@calcypositions@godeep% - \noexpand\forlistloop% - \yquant@env@end@calcypositions@run% - \expandafter\noexpand\csname\yquant@prefix subcircuits\endcsname% - \noexpand\fi% - }% + \noexpand\forlistloop% + \yquant@env@end@calcypositions@run% + \expandafter\noexpand\csname\yquant@prefix subcircuits\endcsname% \fi% }% % END_FOLD @@ -416,8 +408,20 @@ \csname yquant@env@end@calcypositions@#1\endcsname% } +\protected\def\yquant@env@end@calcypositions@redo@min#1{% + \ifnum#1<\redoitem\space % + \def\redoitem{#1}% + \fi% +} + \protected\def\yquant@env@end@calcypositions@redo{% - \forlistloop\yquant@env@end@calcypositions@run\redolist% + % instead of looping through the list, we only check the lowest item - since running it may actually remove some other items from the list. Note that the lowest item is not necessarily the outermost, but for sure the topmost wire that should be redone is contained in it. + \unless\ifx\redolist\empty% + \def\redoitem{2147483647}% + \forlistloop\yquant@env@end@calcypositions@redo@min\redolist% + % this will automatically remove the item from the list + \expandafter\yquant@env@end@calcypositions@run\expandafter{\redoitem}% + \fi% \unless\ifx\redolist\empty% \expandafter\yquant@env@end@calcypositions@redo% \fi% diff --git a/Master/texmf-dist/tex/latex/yquant/yquant-prepare.tex b/Master/texmf-dist/tex/latex/yquant/yquant-prepare.tex index af5960111d3..bbd826a8c8c 100644 --- a/Master/texmf-dist/tex/latex/yquant/yquant-prepare.tex +++ b/Master/texmf-dist/tex/latex/yquant/yquant-prepare.tex @@ -69,6 +69,7 @@ \else% \let\yquant@prepare@list=\empty% \fi% + \pgfkeys{/yquant/internal/before styles}% % BEGIN_FOLD register \def\do##1{% \ifx\yquant@lang@attr@name\empty% @@ -237,10 +238,33 @@ {#2}% register index {\nodename}% }% - \numdef\idx{\idx+1}% \unless\ifdefined\yquant@prepare@controltype% \edef\yquant@prepare@controltype{#2}% \fi% + \pgfinterruptboundingbox% + \yquant@config@operator@multifalse% + \yquant@env@virtualize@path% + \ifx#1p + \path% + (0pt, 0pt)% + node[/yquant/every control, /yquant/every positive control, /yquant/this control,% + name prefix=, name suffix=, name=] {};% + \else% + \path% + (0pt, 0pt)% + node[/yquant/every control, /yquant/every negative control, /yquant/this control,% + name prefix=, name suffix=, name=] {};% + \fi + \yquant@register@update@height{#2}{\the\yquant@pgf@picmaxy}% + \yquant@register@update@depth{#2}{\the\dimexpr-\yquant@pgf@picminy\relax}% + \expandafter% + \endpgfinterruptboundingbox% + \expandafter\dimen\expandafter0\expandafter=% + \the\dimexpr\yquant@pgf@picmaxx-\yquant@pgf@picminx\relax\relax% + \ifdim\dimen0>\dimen2 % + \dimen2=\dimen0 % + \fi% + \numdef\idx{\idx+1}% \fi% } diff --git a/Master/texmf-dist/tex/latex/yquant/yquant.sty b/Master/texmf-dist/tex/latex/yquant/yquant.sty index f62faf64be0..63cdebbd1db 100644 --- a/Master/texmf-dist/tex/latex/yquant/yquant.sty +++ b/Master/texmf-dist/tex/latex/yquant/yquant.sty @@ -1,7 +1,7 @@ % yquant.sty % Typesetting quantum circuits using a flow-oriented language % -% Copyright 2019-2022 Benjamin Desef +% Copyright 2019-2023 Benjamin Desef % % This work may be distributed and/or modified under the conditions of the LaTeX Project % Public License, either version 1.3c of this license or (at your option) any later @@ -15,7 +15,7 @@ % % The Current Maintainer of this work is Benjamin Desef. \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{yquant}[2022/12/24 v0.7.2 Yet another quantum circuit library for LaTeX] +\ProvidesPackage{yquant}[2023/02/19 v0.7.3 Yet another quantum circuit library for LaTeX] \RequirePackage{etoolbox}[2018/02/11] \RequirePackage{tikz}[2015/08/29] |