hooke/ui.tex: Fill in user interface section
[thesis.git] / src / local_cmmds.tex
1 % String comparison for \fref
2 \makeatletter
3 \long\def\isequal#1#2{\pdf@strcmp{#1}{#2}}
4 \makeatother
5
6 % An reference index from an unspecified source
7 % usage: \iref{environment}{value}
8 % for example: \iref{equation}{75}
9 \newcommand{\iref}[2]{%
10   \switch%
11   \case{\isequal{#1}{equation}}%
12     ({#2})%
13   \otherwise%
14     {#2}%
15   \endswitch%
16 }
17
18 % A formatted reference from an unspecified source
19 % usage: \fref{environment}{value}
20 % for example: \fref{figure}{75}
21 \newcommand{\fref}[2]{%
22   \switch%
23   \case{\isequal{#1}{equation}}%
24     Eq.~\iref{#1}{#2}%
25   \case{\isequal{#1}{figure}}%
26     Fig.~\iref{#1}{#2}%
27   \case{\isequal{#1}{section}}%
28     Section~\iref{#1}{#2}%
29   \otherwise%
30     \PackageError{fref}{
31       \MessageBreak
32       environment value >#2< unknown \MessageBreak
33     }{possible values are: equation. \MessageBreak}%
34   \endswitch%
35 }
36
37 % References to external figures, equations, etc.
38 % usage: \xref{key}{environment}{value}
39 % for example: \xref{roman12}{figure}{75}
40 \newcommand{\xref}[3]{\citet{#1} \fref{#2}{#3}}
41
42 % Fourier Transform to angular momentum space
43 \newcommand{\Four}[1]{\ensuremath{{\mathcal F}\left\{ {#1} \right\}}}
44 % Fourier Transform to frequency space
45 \newcommand{\Fourf}[1]{\ensuremath{{\mathcal F}_f\left\{ {#1} \right\}}}
46
47 % use e^{...} instead of exp ...
48 \renewcommand{\exp}[1]{\ensuremath{e^{#1}}}
49
50 % Symbol denoting the Langevin function
51 \newcommand{\Langevin}{\ensuremath{\mathcal{L}}}
52 % Symbol denoting big-O order of #1
53 \newcommand{\order}[1]{\ensuremath{\mathcal{O}\p({#1})}}
54
55 % Integral from #1 to #2 of #4 with respect to #3
56 \newcommand{\integral}[4]{\ensuremath{\int_{#1}^{#2} {#4} \dd{#3}}}
57 % Integral from -infty to +infty of #2 with respect to #1
58 \newcommand{\iInfInf}[2]{\integral{-\infty}{\infty}{#1}{#2}}
59 % Integral from 0 to +infty of #2 with respect to #1
60 % note that the second char in the name is a capital o, not a 0
61 % because ?Latex doesn't allow digits in command names
62 \newcommand{\iOInf}[2]{\integral{0}{\infty}{#1}{#2}}
63 % #3 evaluated at #2 and #1
64 \newcommand{\evaluated}[3]{\ensuremath{\left.{#3}\right|_{#1}^{#2}}}
65 % #2 evaluated at #1
66 \newcommand{\eval}[2]{\ensuremath{\left.{#2}\right|_{#1}}}
67 % evaluated at infty and -infty
68 \newcommand{\eInfInf}[1]{\evaluated{-\infty}{\infty}{#1}}
69 % evaluated at infty and 0
70 \newcommand{\eOInf}[1]{\evaluated{0}{\infty}{#1}}
71
72 % we do a lot of lim t_T -> infty, so macro that out
73 % lim as #1 -> infty
74 \newcommand{\limInf}[1]{\ensuremath{\lim_{{#1}\rightarrow \infty}}}
75 \newcommand{\limT}{\limInf{t_T}}
76 \newcommand{\normLimT}{\limT \frac{1}{t_T}\ } % '\ ' for a normal space
77 % lim as t_T -> infty of integral from -t_T/2 to t_T/2 of #1 with respect to t
78 \newcommand{\iLimT}[1]{\normLimT \integral{-t_T/2}{t_T/2}{t}{#1}}
79
80 \newcommand{\magSq}[1]{\ensuremath{\left|{#1}\right|^2}}
81 \newcommand{\PSD}{\ensuremath{\operatorname{PSD}}}
82
83 % complex conjugate
84 \newcommand{\conj}[1]{\ensuremath{\overline{#1}}}
85
86 % Symbol denoting the contour C
87 \newcommand{\C}{\ensuremath{\mathcal{C}}}
88 % Integral about contour C of #1 with respect to z
89 \newcommand{\iC}[1]{\integral{\C}{}{z}{#1}}
90 \newcommand{\Reals}{\ensuremath{\mathds{R}}}
91 \newcommand{\Imags}{\ensuremath{\mathds{I}}}
92 \newcommand{\Real}{\ensuremath{\operatorname{Re}}}
93 \newcommand{\Imag}{\ensuremath{\operatorname{Im}}}
94 \newcommand{\ResX}[3]{\operatorname{Res}\left({{#1}={#2}},{#3}\right)}
95 \newcommand{\Res}[2]{\ResX{z}{#1}{#2}}
96 \newcommand{\limX}[2]{\lim_{{#1} \rightarrow {#2}}}
97 \newcommand{\limZ}[1]{\limX{z}{#1}}
98 \newcommand{\limZp}{\limZ{z_p}}
99 \newcommand{\CPV}{\ensuremath{\mathds{P}}}
100
101 \newcommand{\supScript}[1]{\ensuremath{^{\text{#1}}}}
102 \newcommand{\st}{\supScript{st}}
103 \newcommand{\nd}{\supScript{nd}}
104 \newcommand{\rd}{\supScript{rd}}
105 \newcommand{\sth}{\supScript{th}} % th, TH already taken
106
107 \newcommand{\colA}[1]{\textcolor{red}{#1}}
108 \newcommand{\colB}[1]{\textcolor{blue}{#1}}
109 \definecolor{purple}{rgb}{0.8, 0, 0.8}
110 \newcommand{\colAB}[1]{\textcolor{purple}{#1}}
111 \newcommand{\colC}[1]{\textcolor{green}{#1}}
112
113 \newcommand{\cf}{\emph{cf.}} % "confer" or "bring together" / "compare"
114 \newcommand{\ie}{\emph{i.e.}} % "id est" or "in other words"
115 \newcommand{\insilico}{\emph{in silico}} % quasi latin for "on a computer"
116 \newcommand{\invitro}{\emph{in vitro}}   % latin for "in glass"
117 \newcommand{\invivo}{\emph{in vivo}}     % latin for "in living organisms"
118
119 \newcommand{\gui}[1]{\emph{#1}}  % highlighting for quotes from a GUI
120
121 \newcommand{\ensuretext}[1]{\ensuremath{\text{#1}}}
122 % Hyeon and Thirumalai equation number #1
123 \newcommand{\HTeq}[1]{\ensuretext{\emph{H\&T eq.\ {#1}}}}
124 \newcommand{\kT}{\ensuremath{k_B T}}
125 \newcommand{\bt}{\ensuremath{\beta}}
126 \newcommand{\fs}{\ensuremath{f^*}}
127 \newcommand{\dx}{\ensuremath{\Delta x(\fs)}}
128 \newcommand{\dxs}[1]{\ensuremath{\Delta x_{#1}(\fs)}} % for subscripting
129 \newcommand{\FO}{\ensuremath{\Delta F_0^\ddagger(\fs)}}
130 \newcommand{\vD}{\ensuremath{\nu_D(\fs)}}
131 \newcommand{\vDs}[1]{\ensuremath{\nu_{D{#1}}(\fs)}}
132 \newcommand{\kexp}{\ensuremath{\vD e^{-\bt \FO}}}
133 \newcommand{\kexps}[1]{\ensuremath{\vDs{#1} e^{-\bt_{#1} \FO_{#1}}}}
134 \newcommand{\kf}{\ensuremath{k(\fs)}}
135 \newcommand{\kfs}[1]{\ensuremath{k_{#1}(\fs)}}
136 %\newcommand{\avg}[1]{\ensuremath{\left\langle {#1} \right\rangle}}
137 \newcommand{\abs}[1]{\ensuremath{\lvert {#1} \rvert}}
138 \newcommand{\logp}[1]{\ensuremath{\log\!\!\left( {#1} \right)}}
139 % \! is a negative thin space to get the paren closer to the log
140 %\renewcommand{\r}{\ensuremath{r_f}}
141 %\newcommand{\rs}[1]{\ensuremath{r_{f{#1}}}}% to avoid double-subscripting
142 \newcommand{\ep}{\varepsilon}
143
144 \newcommand{\species}[1]{\emph{#1}} % \species{Homo sapiens}
145
146 % Chemicals
147 \newcommand{\Ca}{Ca\textsuperscript{2+}}
148 \newcommand{\CaCl}{CaCl\textsubscript{2}}
149 \newcommand{\Cu}{Cu\textsuperscript{2+}}
150 \newcommand{\Cl}{Cl\textsuperscript{-}}
151 \newcommand{\HCl}{HCl}
152 \newcommand{\Na}{Na\textsuperscript{+}}
153 \newcommand{\NaCl}{NaCl}
154 \newcommand{\diNaHPO}{Na\textsubscript{2}HPO\textsubscript{4}}
155 \newcommand{\NadiHPO}{NaH\textsubscript{2}PO\textsubscript{4}}
156 \newcommand{\NaOH}{NaOH}
157
158 % Workaround for inline minted markup
159 %   http://code.google.com/p/minted/issues/detail?id=15
160 % usage: \imint{language}|value|
161 \NewDocumentCommand\imint{mv}{\texttt{#2}}
162
163 % Aliases for citations
164 \defcitealias{calibcant}{calibcant}
165 \defcitealias{comedi}{Comedi}
166 \defcitealias{cygwin}{Cygwin}
167 \defcitealias{cython}{Cython}
168 \defcitealias{epics}{EPICS}
169 \defcitealias{force-robot}{ForceRobot}
170 \defcitealias{gentoo}{Gentoo}
171 \defcitealias{git}{Git}
172 \defcitealias{h5config}{h5config}
173 \defcitealias{hdf5}{HDF5}
174 \defcitealias{interix}{Interix}
175 \defcitealias{kernighan88}{C}
176 \defcitealias{king10}{sawsim}
177 \defcitealias{labview}{LabVIEW}
178 \defcitealias{picoforce}{PicoForce}
179 \defcitealias{prefix}{Gentoo Prefix}
180 \defcitealias{punias}{PUNIAS}
181 \defcitealias{pyafm}{pyafm}
182 \defcitealias{pycomedi}{pycomedi}
183 \defcitealias{pymodbus}{pymodbus}
184 \defcitealias{pymol}{PyMol}
185 \defcitealias{pypid}{pypid}
186 \defcitealias{pypiezo}{pypiezo}
187 \defcitealias{python}{Python}
188 \defcitealias{sandal09}{Hooke}
189 \defcitealias{stepper}{stepper}
190 \defcitealias{beazley96}{SWIG}
191 \defcitealias{unfold-protein}{unfold-protein}
192 \defcitealias{wavemetrics-igor}{IGOR Pro}
193 \defcitealias{xcode}{Xcode}
194 \defcitealias{yaml}{YAML}
195
196 \newcommand{\Comedi}{\citetalias{comedi}}
197 \newcommand{\Hooke}{\citetalias{sandal09}}
198 \newcommand{\calibcant}{\citetalias{calibcant}}
199 \newcommand{\hFconfig}{\citetalias{h5config}}
200 \newcommand{\pyafm}{\citetalias{pyafm}}
201 \newcommand{\pypid}{\citetalias{pypid}}
202 \newcommand{\pypiezo}{\citetalias{pypiezo}}
203 \newcommand{\pycomedi}{\citetalias{pycomedi}}
204 \newcommand{\pysawsim}{\texttt{pysawsim}}
205 \newcommand{\sawsim}{\citetalias{king10}}
206 \newcommand{\stepper}{\citetalias{stepper}}
207 \newcommand{\unfoldprotein}{\citetalias{unfold-protein}}
208
209 % draw a line TikZ (useful for captions explaining figures)
210 % usage: \tikzline{style}
211 \DeclareRobustCommand{\tikzline}[1]{%
212   \protect\tikz \draw[#1] (0,0) -- (14pt,6pt);}
213
214 \DeclareRobustCommand{\thermocouple}{%
215   \begin{tikzpicture}
216     \draw[red] (0,1pt) -- (10pt,1pt);
217     \draw[purple] (0,3pt) -- (10pt,3pt);
218     \fill[black!20] (10pt,2pt) circle (2pt);
219   \end{tikzpicture}
220 }
221
222 % draw a thermometer in TikZ
223 % usage: \thermometerx{bulb-location}
224 \newcommand{\thermometerx}[1]{
225   \draw[blue!20, line width=4pt, cap=round] #1 -- +(0, 12pt);
226   \fill[blue!20] #1 circle (5pt);
227   \draw[red, line width=2pt, cap=butt] #1 -- +(0, 8pt);
228   \fill[red] #1 circle (4pt);
229 }
230
231 \DeclareRobustCommand{\thermometer}{%
232   \raisebox{-2pt}{%
233     \resizebox{!}{10pt}{%
234       \begin{tikzpicture}%
235         \thermometerx{(0,2.5pt)};%
236       \end{tikzpicture}%
237     }%
238   }%
239 }
240
241 % shared figure between pyafm and calibcant
242 % usage: \tikzstack{unfold-protein-color}{calibcant-color}
243 \newcommand{\tikzstack}[2]{%
244   \begin{tikzpicture}[decoration={
245       markings,%  switch on markings
246       mark=%  add a mark for screw threading
247         between positions 0 and 1 step 1pt
248         with
249         {
250           \draw (0, 2pt) -- (1pt, -2pt);
251         }
252       },
253       bend angle=5
254       ]
255     \tikzstyle{every node}=[text depth=0pt, rounded rectangle,
256       draw=blue!50, very thick, minimum height=1.7em]
257     % hardware nodes and coordinates
258     \node[shape=rectangle,draw=none,inner sep=0]
259       (image) at (0,0) {
260       \asyinclude{figures/schematic/afm}};
261     \node[shape=rectangle,draw=black, semithick]
262       (daq) at ($(image.south west) + (-0.25, -1)$) {DAQ card};
263     \node[shape=rectangle,draw=black, semithick]
264       (motor) at ($(image.south) + (0, -1)$) {motor};
265     \coordinate (thermocouple) at ($(image.west) + (1.4, -4pt)$);
266     \thermometerx{(thermocouple)}
267     \coordinate (photodiode) at ($(image.west) + (1, 26pt)$);
268     \coordinate (piezo) at ($(image.south) + (-6pt, 0)$);
269     \draw[black!20,dashed] ($(daq.south west) + (-10pt, 0)$) -- +(0, 4);
270     % software nodes
271     \node (pycomedi) at ($(daq) + (-6,0)$) {pycomedi};
272     \node (pypiezo) at ($(pycomedi) + (0,1)$) {pypiezo};
273     \node (pyafm) at ($(pypiezo) + (0,1)$) {pyafm};
274     \node[#1] (unfold-protein) at ($(pyafm) + (0,1)$) {unfold-protein};
275     \node (stepper) at ($(pycomedi) + (2,1)$) {stepper};
276     \node (pypid) at ($(stepper) + (2,0)$) {pypid};
277     \node (h5config) at ($(pycomedi) + (-3,0)$) {h5config};
278     \node[#2] (calibcant) at ($(unfold-protein) + (-3,0)$) {calibcant};
279     % software connections
280     \draw (pypiezo) -- (pyafm);
281     \draw (stepper) -- (pyafm);
282     \draw (pypid) -- (pyafm);
283     \draw[#1] (pyafm) -- (unfold-protein);
284     \draw (h5config) -- (pypiezo);
285     \draw (h5config) -- (pyafm);
286     \ifthenelse{\equal{#1}{}}{%  draw unfold-protein in black (the default)
287       \draw[#2] (pyafm) -- (calibcant);
288       \draw[#1] (h5config) -- (unfold-protein);%  default path on top
289       }{%
290       \draw[#1] (h5config) -- (unfold-protein);
291       \draw[#2] (pyafm) -- (calibcant);%  default path on top
292       }
293     \draw[#2] (h5config) -- (calibcant);
294     % hardware connections
295     \begin{pgfonlayer}{background}
296       \draw[purple, ->] (thermocouple) -- (pypid);
297     \end{pgfonlayer}
298     % begin motor screw
299     \draw[black!20, line width=4pt]
300       (motor) -- (image.south);   % shaft with decoration threads
301     \draw[black, decorate, ultra thin]
302       (motor) -- (image.south);   % shaft with decoration threads
303     % end motor screw
304     \draw[red, <->] (pypiezo) -- (pycomedi);
305     \draw[red, <->] (pycomedi) to [bend left] (daq);
306     \draw[red, ->] (daq) -- (piezo);
307     \begin{pgfonlayer}{background}
308       \draw[red, ->, out=180, in=90] (photodiode) to (daq.north);
309     \end{pgfonlayer}
310     \draw[blue, ->] (stepper) -- (pycomedi);
311     \draw[blue, ->] (pycomedi) to [bend right] (daq);
312     \draw[blue, ->] (daq) -- (motor);
313   \end{tikzpicture}
314 }