summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/yquant/tex/yquant-config.tex
blob: d5844480ee0c7c49e9452913dd2480ad11d70091 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
\pgfdeclaremetadecoration{tikz@internal}{pre}{%
   \state{pre}[width=\pgfkeysvalueof{/pgf/decoration/pre length}+\pgfkeysvalueof{/pgf/decoration/post length}, next state=main]{%
      \appto\tikz@dec@shift{\pgftransformxshift{-\pgfkeysvalueof{/pgf/decoration/post length}}}%
      \tikz@dec@trans%
      \decoration{\pgfkeysvalueof{/pgf/decoration/pre}}%
   }%
   \state{main}[width=\pgfmetadecoratedremainingdistance, next state=final]{%
      \tikz@dec@trans%
      \decoration{\tikz@decoration@name}%
   }%
   \state{final}{%
      \tikz@dec@trans%
      \decoration{\pgfkeysvalueof{/pgf/decoration/post}}%
   }%
}

% BEGIN_FOLD Circuit layout
\ifnum\yquant@compat<2 %
   \pgfqkeys{/yquant}{%
      register/minimum height/.code=%
         {\dimdef\yquant@config@register@minimum@height{.5\dimexpr#1\relax}%
          \let\yquant@config@register@minimum@depth=\yquant@config@register@minimum@height}%
   }
\else%
   \pgfqkeys{/yquant}{%
      register/minimum height/.code=%
         {\dimdef\yquant@config@register@minimum@height{#1}},%
      register/minimum depth/.code=%
         {\dimdef\yquant@config@register@minimum@depth{#1}}%
   }
\fi
\pgfqkeys{/yquant}{%
   register/separation/.code=%
      {\dimdef\yquant@config@register@sep{#1}},%
   operator/minimum width/.code=%
      {\dimdef\yquant@config@operator@minimum@width{#1}},%
   operator/separation/.code=%
      {\dimdef\yquant@config@operator@sep{#1}},%
   operator/multi warning/.is if=%
      yquant@config@operator@multi@warn%
}%
% END_FOLD
% BEGIN_FOLD Register creation
\pgfqkeys{/yquant}{%
   register/default name/.store in=%
      \yquant@config@register@default@name%
}
\ifnum\yquant@compat<2 %
   \pgfqkeys{/yquant}{%
      every label/.style=%
         {shape=yquant-init, anchor=center, align=right, outer xsep=2pt},%
      every multi label/.style=%
         {draw, decoration={gapped brace, mirror, raise=2pt}, 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}}%
    }
\fi
\pgfqkeys{/yquant}{
   every initial label/.style=%
      {anchor=east},%
   every qubit label/.style=%
      {},%
   every cbit label/.style=%
      {},%
   every qubits label/.style=%
      {}%
}
\ifnum\yquant@compat<2 %
   \pgfqkeys{/yquant}{%
      every input label/.style=%
         {}%
   }%
\fi%
% END_FOLD
% BEGIN_FOLD Register outputs
\ifnum\yquant@compat<2 %
   \pgfqkeys{/yquant}{%
      every output/.style=%
         {shape=yquant-output, anchor=west, align=left, outer xsep=2pt},%
      every multi output/.style=%
         {draw, decoration={gapped brace, raise=2pt}, 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}}%
   }
\fi
\pgfqkeys{/yquant}{%
   every qubit output/.style=%
      {},%
   every cbit output/.style=%
      {},%
   every qubits output/.style=%
      {}%
}
% END_FOLD
% BEGIN_FOLD General styling
\pgfqkeys{/yquant}{%
   every circuit/.style={%
      every node/.prefix style={transform shape}
   }%
}
\@ifpackagelater{pgf}{2020/09/31}\relax{
   \pgfkeys{/yquant/every circuit/.append style={%
      every label/.prefix style={transform shape=false}%
   }}
}
\pgfqkeys{/yquant}{%
   every wire/.style=%
      {draw},%
   every qubit wire/.style=%
      {},%
   every cbit wire/.style=%
      {},%
   every qubits wire/.style=%
      {},%
   every control line/.style=%
      {draw},%
   every control/.style=%
      {shape=yquant-circle, anchor=center, radius=.5mm},%
   every positive control/.style=%
      {fill=black},%
   every negative control/.style=%
      {draw},%
   every operator/.style=%
      {anchor=center},%
   every multi line/.style=%
      {draw, decoration={snake, amplitude=.25mm, segment length=5pt}, decorate},%
   this operator/.style=%
      {},%
   this control/.style=%
      {},%
   operator style/.style=%
      {/yquant/this operator/.append style={#1}},%
   control style/.style=%
      {/yquant/every control line/.append style={#1},%
       /yquant/this control/.append style={#1}},%
   style/.style=%
      {/yquant/this operator/.append style={#1},%
       /yquant/every control line/.append style={#1},%
       /yquant/this control/.append style={#1}},%
   operator/multi as single/.style=%
      {/yquant/every multi line/.style=/yquant/every control line},%
   operator/if multi/.code=%
      {\ifyquant@config@operator@multi\pgfkeysalso{#1}\fi},%
   circuit/seamless/.is if=yquant@config@circuit@seamless,%
   every post measurement control/.is choice,
   every post measurement control/indirect/.code={%
      \undef\yquant@lang@attr@directcontrol%
   },%
   every post measurement control/direct/.code={%
      \let\yquant@lang@attr@directcontrol=\relax%
   }%
}
% END_FOLD
% BEGIN_FOLD Styles for operators
\ifnum\yquant@compat<2 %
   \pgfqkeys{/yquant}{%
      operators/every barrier/.style=%
         {shape=yquant-line, dashed, draw}%
   }
\else
   \pgfqkeys{/yquant}{%
      operators/every barrier/.style=%
         {shape=yquant-line, dashed, draw, shorten <= -1mm, shorten >= -1mm}
   }
\fi
\pgfqkeys{/yquant}{%
   operators/every box/.style=%
      {shape=yquant-rectangle, draw, align=center, inner xsep=1mm, x radius=2mm, y radius=2.47mm},%
}
\ifnum\yquant@compat<2 %
   \pgfqkeys{/yquant}{%
      operators/every custom gate/.style=%
         {/yquant/operators/subcircuit/frameless, /yquant/register/default name=}%
   }
\else
   \pgfqkeys{/yquant}{%
      operators/every custom gate/.style=%
         {/yquant/operators/subcircuit/seamless}%
   }
\fi
\pgfqkeys{/yquant}{%
   operators/every dmeter/.style=%
      {shape=yquant-dmeter, x radius=2mm, y radius=2mm, draw},
   % 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}},%
   operators/every measure/.style=%
      {shape=yquant-measure, x radius=4mm, y radius=2.5mm, draw},%
   operators/every measure meter/.style=%
      {draw, -{Latex[length=2.5pt]}},%
   operators/every not/.style=%
      {shape=yquant-oplus, radius=1.3mm, draw},%
   operators/every pauli/.style=%
      {/yquant/operators/every box},%
   operators/every phase/.style=%
      {shape=yquant-circle, radius=.5mm, fill},%
   operators/every slash/.style=%
      {shape=yquant-slash, x radius=.5mm, y radius=.7mm, draw},%
   operators/every subcircuit/.style=%
      {},%
   operators/every subcircuit box/.style=%
      {/yquant/operators/every box},%
   subcircuit box style/.style=%
      {/yquant/operators/every subcircuit box/.append style={#1}},%
   operators/this subcircuit box/.style=%
      {},%
   this subcircuit box style/.style=%
      {/yquant/operators/this subcircuit box/.append style={#1}},%
   operators/subcircuit/frameless/.style=
      {/yquant/operators/this subcircuit box/.append style={draw=none, inner sep=0pt}},%
   operators/subcircuit/seamless/.code=%
      {\pgfkeysalso{/yquant/operators/subcircuit/frameless, /yquant/register/default name=}%
       \letcs\yquant@prevseamless{\yquant@prefix seamless}%
       \yquant@config@circuit@seamlesstrue},
   operators/every swap/.style=%
      {shape=yquant-swap, radius=.75mm, draw},%
   operators/every wave/.style=%
      {shape=yquant-circle, radius=.5mm, fill}%
   % every x is implicitly defined during gate declaration
   operators/every xx/.style=%
      {shape=yquant-rectangle, radius=.75mm, draw},%
   % every y is implicitly defined during gate declaration
   % every z is implicitly defined during gate declaration
   operators/every zz/.style=%
      {shape=yquant-circle, radius=.5mm, fill},%
}
% END_FOLD
% BEGIN_FOLD Internal styles (undocument, do not use!)
\pgfqkeys{/yquant}{%
   internal/move label/.code=%
      {\yquant@config@operator@position@rightaligntrue},
   internal/no advance/.code=%
      {\unless\ifyquantmeasuring% We don't draw subcircuits during measuring time, but we need their advancement
          \yquant@config@operator@position@advancefalse%
       \fi},
   internal/multi main/.is if=%
      yquant@config@internal@multi@main,%
}
\ifnum\yquant@compat<2 %
   \pgfqkeys{/yquant}{%
      internal/squeeze slash/.code=%
         {\dimdef\yquant@config@operator@sep{.5\dimexpr\yquant@config@operator@sep-\pgflinewidth\relax}%
          \yquant@config@operator@position@advancefalse},%
   }
\else%
   \pgfqkeys{/yquant}{%
      internal/squeeze slash/.code={}%
   }
\fi
% END_FOLD

\def\yquant@config@register@default@name{\regidx}
\def\yquant@config@register@minimum@height{1.5mm}
\def\yquant@config@register@minimum@depth{1.5mm}
\def\yquant@config@register@sep{1mm}
\def\yquant@config@operator@sep{1mm}
\def\yquant@config@operator@minimum@width{5mm}
\newif\ifyquant@config@internal@multi@main%
\yquant@config@internal@multi@maintrue
\newif\ifyquant@config@operator@multi@warn
\yquant@config@operator@multi@warntrue
\newif\ifyquant@config@operator@position@rightalign
\newif\ifyquant@config@operator@position@advance
\yquant@config@operator@position@advancetrue
\newif\ifyquant@config@circuit@seamless
\newif\ifyquant@config@operator@multi