| 1 |
% \iffalse meta-comment |
| 2 |
%<*internal> |
| 3 |
\iffalse |
| 4 |
%</internal> |
| 5 |
%<*readme> |
| 6 |
--------------------------------------------------------------- |
| 7 |
rulercompass --- a TikZ/PGF library for drawing straight-edge |
| 8 |
and compass diagrams |
| 9 |
E-mail: [email protected] |
| 10 |
Released under the LaTeX Project Public Licence v1.3c or later |
| 11 |
See http://www.latex-project.org/lppl.txt |
| 12 |
--------------------------------------------------------------- |
| 13 |
|
| 14 |
This package defines some commands and styles intended for |
| 15 |
drawing straight-edge and compass diagrams. |
| 16 |
%</readme> |
| 17 |
%<*internal> |
| 18 |
\fi |
| 19 |
\def\nameofplainTeX{plain} |
| 20 |
\ifx\fmtname\nameofplainTeX\else |
| 21 |
\expandafter\begingroup |
| 22 |
\fi |
| 23 |
%</internal> |
| 24 |
%<*install> |
| 25 |
\input docstrip.tex |
| 26 |
\keepsilent |
| 27 |
\askforoverwritefalse |
| 28 |
\preamble |
| 29 |
--------------------------------------------------------------- |
| 30 |
rulercompass --- a TikZ/PGF library for drawing straight-edge |
| 31 |
and compass diagrams |
| 32 |
E-mail: [email protected] |
| 33 |
Released under the LaTeX Project Public Licence v1.3c or later |
| 34 |
See http://www.latex-project.org/lppl.txt |
| 35 |
--------------------------------------------------------------- |
| 36 |
|
| 37 |
\endpreamble |
| 38 |
\postamble |
| 39 |
|
| 40 |
Copyright (C) 2013 by Andrew Stacey <[email protected]> |
| 41 |
|
| 42 |
This file may be distributed and/or modified under the conditions |
| 43 |
of the LaTeX Project Public License, either version 1.3 of this |
| 44 |
license or (at your option) any later version. |
| 45 |
The latest version of this license is in: |
| 46 |
|
| 47 |
http://www.latex-project.org/lppl.txt |
| 48 |
|
| 49 |
and version 1.3 or later is part of all distributions of LaTeX |
| 50 |
version 2005/12/01 or later. |
| 51 |
|
| 52 |
This work is "maintained" (as per LPPL maintenance status) by |
| 53 |
Andrew Stacey. |
| 54 |
|
| 55 |
This work consists of the files rulercompass.dtx |
| 56 |
rulercompass_doc.tex |
| 57 |
and the derived files tikzlibraryrulercompass.code.tex |
| 58 |
rulercompass.ins |
| 59 |
rulercompass.pdf |
| 60 |
rulercompass_doc.pdf |
| 61 |
README.txt |
| 62 |
|
| 63 |
|
| 64 |
\endpostamble |
| 65 |
\usedir{tex/latex/rulercompass} |
| 66 |
\generate{\file{tikzlibraryrulercompass.code.tex}{\from{rulercompass.dtx}{tikzlibrary}}} |
| 67 |
%</install> |
| 68 |
%<install>\endbatchfile |
| 69 |
%<*internal> |
| 70 |
\usedir{source/latex/rulercompass} |
| 71 |
\generate{ |
| 72 |
\file{\jobname.ins}{\from{\jobname.dtx}{install}} |
| 73 |
} |
| 74 |
\nopreamble\nopostamble |
| 75 |
\generate{ |
| 76 |
\file{README.txt}{\from{\jobname.dtx}{readme}} |
| 77 |
} |
| 78 |
\ifx\fmtname\nameofplainTeX |
| 79 |
\expandafter\endbatchfile |
| 80 |
\else |
| 81 |
\expandafter\endgroup |
| 82 |
\fi |
| 83 |
%</internal> |
| 84 |
%<*driver> |
| 85 |
\documentclass[full]{l3doc} |
| 86 |
\usepackage[T1]{fontenc} |
| 87 |
\usepackage{csquotes} |
| 88 |
\usepackage{lmodern} |
| 89 |
\usepackage{alphalph} |
| 90 |
\usepackage{tikz} |
| 91 |
\usetikzlibrary{rulercompass} |
| 92 |
\EnableCrossrefs |
| 93 |
\CodelineIndex |
| 94 |
\RecordChanges |
| 95 |
\begin{document} |
| 96 |
\DocInput{\jobname.dtx} |
| 97 |
\end{document} |
| 98 |
%</driver> |
| 99 |
% \fi |
| 100 |
% |
| 101 |
% \CheckSum{785} |
| 102 |
% |
| 103 |
% \CharacterTable |
| 104 |
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z |
| 105 |
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z |
| 106 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 107 |
% Exclamation \! Double quote \" Hash (number) \# |
| 108 |
% Dollar \$ Percent \% Ampersand \& |
| 109 |
% Acute accent \' Left paren \( Right paren \) |
| 110 |
% Asterisk \* Plus \+ Comma \, |
| 111 |
% Minus \- Point \. Solidus \/ |
| 112 |
% Colon \: Semicolon \; Less than \< |
| 113 |
% Equals \= Greater than \> Question mark \? |
| 114 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 115 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 116 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 117 |
% Right brace \} Tilde \~} |
| 118 |
% |
| 119 |
% |
| 120 |
% |
| 121 |
% |
| 122 |
% \DoNotIndex{\newcommand,\newenvironment} |
| 123 |
% |
| 124 |
% \providecommand*{\url}{\texttt} |
| 125 |
% \title{The \textsf{rulercompass} package: code} |
| 126 |
% \author{Andrew Stacey \\ \url{[email protected]}} |
| 127 |
% \maketitle |
| 128 |
% |
| 129 |
% |
| 130 |
% \StopEventually{\PrintChanges} |
| 131 |
% \section{Implementation} |
| 132 |
% |
| 133 |
% \iffalse |
| 134 |
%<*tikzlibrary> |
| 135 |
% \fi |
| 136 |
% |
| 137 |
% Load in useful tikzlibraries. |
| 138 |
% \begin{macrocode} |
| 139 |
\usetikzlibrary{intersections,calc} |
| 140 |
% \end{macrocode} |
| 141 |
%^^A |
| 142 |
% Are we in draft mode (so display point labels)? |
| 143 |
% \begin{macrocode} |
| 144 |
\newif\ifrc@draft |
| 145 |
% \end{macrocode} |
| 146 |
%^^A |
| 147 |
% Is beamer loaded? |
| 148 |
% \begin{macrocode} |
| 149 |
\newif\ifrc@beamer |
| 150 |
% \end{macrocode} |
| 151 |
%^^A |
| 152 |
% When drawing arc segments, do we flip the segment? |
| 153 |
% \begin{macrocode} |
| 154 |
\newif\ifrc@fliparc |
| 155 |
% \end{macrocode} |
| 156 |
%^^A |
| 157 |
% A picture id that stays the same on beamer frames to make it easier to compare bounding boxes and other information of the ``same'' tikzpicture. |
| 158 |
% \begin{macrocode} |
| 159 |
\newcount\rc@picture@id |
| 160 |
% \end{macrocode} |
| 161 |
%^^A |
| 162 |
% Counter for our point labels. |
| 163 |
% \begin{macrocode} |
| 164 |
\newcounter{pointlabels} |
| 165 |
% \end{macrocode} |
| 166 |
%^^A |
| 167 |
% Set the beamer boolean. |
| 168 |
% \begin{macrocode} |
| 169 |
\@ifclassloaded{beamer}{% |
| 170 |
\rc@beamertrue |
| 171 |
}{} |
| 172 |
% \end{macrocode} |
| 173 |
%^^A |
| 174 |
% Internal separator for the path-naming scheme |
| 175 |
% \begin{macrocode} |
| 176 |
\def\rc@pathsep{@} |
| 177 |
% \end{macrocode} |
| 178 |
%^^A |
| 179 |
% Are we running under beamer? |
| 180 |
% \begin{macrocode} |
| 181 |
\ifrc@beamer |
| 182 |
% \end{macrocode} |
| 183 |
% Make our counters reset on frames |
| 184 |
% \begin{macrocode} |
| 185 |
\resetcounteronoverlays{pointlabels} |
| 186 |
\resetcountonoverlays{rc@picture@id} |
| 187 |
% \end{macrocode} |
| 188 |
%^^A |
| 189 |
% Define an overlay-aware style |
| 190 |
% \begin{macrocode} |
| 191 |
\tikzset{ |
| 192 |
alt if exist/.code args={#1#2#3}{% |
| 193 |
\@ifundefined{path@\the\rc@picture@id @#1}{% |
| 194 |
\pgfkeysalso{#2}% |
| 195 |
}{ |
| 196 |
\alt<.-\csname path@\the\rc@picture@id @#1\endcsname>{% |
| 197 |
\pgfkeysalso{#2}% |
| 198 |
}{ |
| 199 |
\pgfkeysalso{#3}% |
| 200 |
}% |
| 201 |
}% |
| 202 |
}, |
| 203 |
% \end{macrocode} |
| 204 |
% Save a path when it is used to compute a point |
| 205 |
% \begin{macrocode} |
| 206 |
intersection/save/.code={% |
| 207 |
\only<.>{% |
| 208 |
\begingroup |
| 209 |
\tikz@intersect@path@names@parse#1\tikz@stop |
| 210 |
\protected@write\pgfutil@auxout{}{% |
| 211 |
\string\global\string\@namedef{path@\the\rc@picture@id @\tikz@intersect@path@a}{\the\beamer@slideinframe}% |
| 212 |
\string\global\string\@namedef{path@\the\rc@picture@id @\tikz@intersect@path@b}{\the\beamer@slideinframe}% |
| 213 |
}% |
| 214 |
\endgroup |
| 215 |
}% |
| 216 |
} |
| 217 |
} |
| 218 |
% \end{macrocode} |
| 219 |
%^^A |
| 220 |
% Define overlay-aware versions of the main macros. |
| 221 |
% \begin{macrocode} |
| 222 |
\newcommand<>\compass[3][]{% |
| 223 |
\draw#4[#1,ruler compass/compass={#2}{#3}]; |
| 224 |
} |
| 225 |
|
| 226 |
\newcommand<>\ruler[3][]{% |
| 227 |
\draw#4[#1,ruler compass/ruler={#2}{#3}]; |
| 228 |
} |
| 229 |
% \end{macrocode} |
| 230 |
%^^A |
| 231 |
% The \verb+\point+ macro is doubly overlay aware. |
| 232 |
% If the intersection has already been computed (say, on another slide of the same picture), reuse it. |
| 233 |
% \begin{macrocode} |
| 234 |
\newcommand<>\point[4][]{% |
| 235 |
{% |
| 236 |
\advance\c@pointlabels by 1\relax |
| 237 |
\xdef\rc@temp{\thepointlabels}% |
| 238 |
}% |
| 239 |
\edef\rc@tempa{\the\rc@picture@id}% |
| 240 |
\expandafter\ifx\csname rc@id@\rc@temp\endcsname\rc@tempa |
| 241 |
\path#5 (\rc@temp) node[ruler compass/point,#1] {}; |
| 242 |
\else |
| 243 |
\path#5 [name intersections={use=#2 and #3}] (intersection-#4) node[ruler compass/point,#1] {}; |
| 244 |
\fi |
| 245 |
} |
| 246 |
% \end{macrocode} |
| 247 |
%^^A |
| 248 |
% Now for the non-beamer versions |
| 249 |
% \begin{macrocode} |
| 250 |
\else |
| 251 |
% \end{macrocode} |
| 252 |
%^^A |
| 253 |
% The overlay-aware style defaults to the first option. |
| 254 |
% \begin{macrocode} |
| 255 |
\tikzset{ |
| 256 |
alt if exist/.code args={#1#2#3}{% |
| 257 |
\pgfkeysalso{#2}% |
| 258 |
}, |
| 259 |
% \end{macrocode} |
| 260 |
% Saving this means we don't have to have two versions of a more complicated bit of code. |
| 261 |
% \begin{macrocode} |
| 262 |
intersection/save/.code={% |
| 263 |
\begingroup |
| 264 |
\tikz@intersect@path@names@parse#1\tikz@stop |
| 265 |
\protected@write\pgfutil@auxout{}{% |
| 266 |
\string\global\string\@namedef{path@\the\rc@picture@id @\tikz@intersect@path@a}{\thepage}% |
| 267 |
\string\global\string\@namedef{path@\the\rc@picture@id @\tikz@intersect@path@b}{\thepage}% |
| 268 |
}% |
| 269 |
\endgroup |
| 270 |
} |
| 271 |
} |
| 272 |
% \end{macrocode} |
| 273 |
%^^A |
| 274 |
% Non-overlay aware versions of the primary commands. |
| 275 |
% \begin{macrocode} |
| 276 |
\newcommand\compass[3][]{% |
| 277 |
\draw [#1,ruler compass/compass={#2}{#3}]; |
| 278 |
} |
| 279 |
|
| 280 |
\newcommand\ruler[3][]{% |
| 281 |
\draw [#1,ruler compass/ruler={#2}{#3}]; |
| 282 |
} |
| 283 |
|
| 284 |
\newcommand\point[4][]{% |
| 285 |
\path [name intersections={use=#2 and #3}] (intersection-#4) node[ruler compass/point,#1] {}; |
| 286 |
} |
| 287 |
% \end{macrocode} |
| 288 |
%^^A |
| 289 |
% End of non-beamer specific section |
| 290 |
% \begin{macrocode} |
| 291 |
\fi |
| 292 |
% \end{macrocode} |
| 293 |
%^^A |
| 294 |
% The following macros process the path/point specifications. |
| 295 |
% The first looks to see if the first character is a period. |
| 296 |
% \begin{macrocode} |
| 297 |
\def\rc@processpt#1{% |
| 298 |
\pgfutil@ifnextchar.{\rc@processpt@@#1}{\rc@processpt@#1}} |
| 299 |
% \end{macrocode} |
| 300 |
% Nope, so now look for a plus or a minus. |
| 301 |
% \begin{macrocode} |
| 302 |
\def\rc@processpt@#1#2\pgf@stop{% |
| 303 |
\pgfutil@in@+{#2}% |
| 304 |
\ifpgfutil@in@ |
| 305 |
\let\@next=\rc@processpt@plus |
| 306 |
\else |
| 307 |
\pgfutil@in@-{#2}% |
| 308 |
\ifpgfutil@in@ |
| 309 |
\let\@next=\rc@processpt@minus |
| 310 |
\else |
| 311 |
\let\@next=\rc@processpt@bare |
| 312 |
\fi |
| 313 |
\fi |
| 314 |
\@next#1#2\pgf@stop |
| 315 |
} |
| 316 |
% \end{macrocode} |
| 317 |
%^^A |
| 318 |
% Okay, we got a period. |
| 319 |
% That means the current point, possibly with an offset. |
| 320 |
% \begin{macrocode} |
| 321 |
\def\rc@processpt@@#1.#2\pgf@stop{% |
| 322 |
\def\rc@temp{#2}% |
| 323 |
\ifx\rc@temp\pgfutil@empty |
| 324 |
\edef\rc@temp{\thepointlabels}% |
| 325 |
\else |
| 326 |
\pgfmathparse{int(\the\c@pointlabels + #2)}% |
| 327 |
\begingroup |
| 328 |
\c@pointlabels=\pgfmathresult\relax |
| 329 |
\xdef\rc@temp{\thepointlabels}% |
| 330 |
\endgroup |
| 331 |
\fi |
| 332 |
\let#1\rc@temp |
| 333 |
} |
| 334 |
% \end{macrocode} |
| 335 |
%^^A |
| 336 |
% We need to add an offset to the given label, so need to compute the index of the label. |
| 337 |
% \begin{macrocode} |
| 338 |
\def\rc@processpt@plus#1#2+#3\pgf@stop{% |
| 339 |
\pgfmathsetmacro\rc@temp{0}% |
| 340 |
\rc@reverse#2\pgf@stop% |
| 341 |
\pgfmathparse{int(\rc@temp + #3)}% |
| 342 |
\begingroup |
| 343 |
\c@pointlabels=\pgfmathresult\relax |
| 344 |
\xdef\rc@temp{\thepointlabels}% |
| 345 |
\endgroup |
| 346 |
\let#1\rc@temp |
| 347 |
} |
| 348 |
% \end{macrocode} |
| 349 |
%^^A |
| 350 |
% Same, but with a minus. |
| 351 |
% \begin{macrocode} |
| 352 |
\def\rc@processpt@minus#1#2-#3\pgf@stop{% |
| 353 |
\pgfmathsetmacro\rc@temp{0}% |
| 354 |
\rc@reverse#2\pgf@stop% |
| 355 |
\pgfmathparse{int(\rc@temp - #3)}% |
| 356 |
\begingroup |
| 357 |
\c@pointlabels=\pgfmathresult\relax |
| 358 |
\xdef\rc@temp{\thepointlabels}% |
| 359 |
\endgroup |
| 360 |
\let#1\rc@temp |
| 361 |
} |
| 362 |
% \end{macrocode} |
| 363 |
%^^A |
| 364 |
% Simplest case. |
| 365 |
% \begin{macrocode} |
| 366 |
\def\rc@processpt@bare#1#2\pgf@stop{% |
| 367 |
\def#1{#2}} |
| 368 |
% \end{macrocode} |
| 369 |
%^^A |
| 370 |
% Reverse lookup the counter value from its displayed format. |
| 371 |
% \begin{macrocode} |
| 372 |
\def\rc@reverse#1{% |
| 373 |
\ifx#1\pgf@stop |
| 374 |
\let\@next=\pgfutil@empty |
| 375 |
\else |
| 376 |
\let\@next=\rc@reverse |
| 377 |
\pgfutil@tempcnta=`#1\relax |
| 378 |
\pgfmathsetmacro\rc@temp{\rc@temp * \rc@factor + \the\pgfutil@tempcnta - \rc@initial}% |
| 379 |
\fi |
| 380 |
\@next} |
| 381 |
% \end{macrocode} |
| 382 |
%^^A |
| 383 |
% Compute the actual path name from the three token (lists). |
| 384 |
% \begin{macrocode} |
| 385 |
\def\rc@parsepath#1#2#3#4\pgf@stop{% |
| 386 |
\rc@processpt\rc@tempa#3\pgf@stop |
| 387 |
\rc@processpt\rc@tempb#4\pgf@stop |
| 388 |
\xdef#1{#2\rc@pathsep\rc@tempa\rc@pathsep\rc@tempb}% |
| 389 |
} |
| 390 |
% \end{macrocode} |
| 391 |
%^^A |
| 392 |
% Now we install all our styles |
| 393 |
% \begin{macrocode} |
| 394 |
\tikzset{ |
| 395 |
% \end{macrocode} |
| 396 |
%^^A |
| 397 |
% Code which initialises our counters at the start of a picture. |
| 398 |
% \begin{macrocode} |
| 399 |
every picture/.append style={ |
| 400 |
ruler compass/at begin picture |
| 401 |
}, |
| 402 |
% \end{macrocode} |
| 403 |
%^^A |
| 404 |
% Passes the paths to the intersection but also takes note of their use. |
| 405 |
% \begin{macrocode} |
| 406 |
intersection/use/.code args={#1 and #2}{% |
| 407 |
\rc@parsepath\rc@pta#1\pgf@stop |
| 408 |
\rc@parsepath\rc@ptb#2\pgf@stop |
| 409 |
\pgfkeysalso{ |
| 410 |
of={\rc@pta} and \rc@ptb, |
| 411 |
save={\rc@pta} and \rc@ptb, |
| 412 |
} |
| 413 |
}, |
| 414 |
% \end{macrocode} |
| 415 |
%^^A |
| 416 |
% \verb+to path+ for a circle through a given point. |
| 417 |
% \begin{macrocode} |
| 418 |
circle through/.style={ |
| 419 |
to path={ |
| 420 |
\pgfextra{ |
| 421 |
\tikz@scan@one@point\pgfutil@firstofone(\tikztostart)\relax |
| 422 |
\pgf@xa=\pgf@x |
| 423 |
\pgf@ya=\pgf@y |
| 424 |
\tikz@scan@one@point\pgfutil@firstofone(\tikztotarget)\relax |
| 425 |
\pgfmathsetmacro\rc@radius{veclen(\pgf@x - \pgf@xa,\pgf@y - \pgf@ya)}% |
| 426 |
} |
| 427 |
circle[radius=\rc@radius pt] (\tikztotarget) |
| 428 |
} |
| 429 |
}, |
| 430 |
% \end{macrocode} |
| 431 |
%^^A |
| 432 |
% Flip an arc when drawing a segment. |
| 433 |
% \begin{macrocode} |
| 434 |
arc flip/.is if=rc@fliparc, |
| 435 |
% \end{macrocode} |
| 436 |
%^^A |
| 437 |
% Arc from one point to another centred on specified point. |
| 438 |
% \begin{macrocode} |
| 439 |
centred arc to/.code 2 args={% |
| 440 |
\tikz@scan@one@point\pgfutil@firstofone(#1)\relax |
| 441 |
\pgfmathsetmacro\rc@radius{veclen(\tikz@lastx-\pgf@x,\tikz@lasty-\pgf@y)}% |
| 442 |
\pgfmathsetmacro\rc@sangle{atan2(\tikz@lasty - \pgf@y,\tikz@lastx - \pgf@x)}% |
| 443 |
\pgf@xa=\pgf@x |
| 444 |
\pgf@ya=\pgf@y |
| 445 |
\tikz@scan@one@point\pgfutil@firstofone(#2)\relax |
| 446 |
\pgfmathsetmacro\rc@eangle{atan2(\pgf@y - \pgf@ya,\pgf@x - \pgf@xa)}% |
| 447 |
\pgfmathsetmacro\rc@eangle{\rc@eangle < \rc@sangle ? \rc@eangle + 360 : \rc@eangle}% |
| 448 |
\ifrc@fliparc |
| 449 |
\pgfmathsetmacro\rc@eangle{\rc@eangle - 360}% |
| 450 |
\fi |
| 451 |
\pgfkeysalso{start angle=\rc@sangle, end angle=\rc@eangle, radius=\rc@radius pt} |
| 452 |
}, |
| 453 |
% \end{macrocode} |
| 454 |
%^^A |
| 455 |
% Most of our keys are in this family. |
| 456 |
% \begin{macrocode} |
| 457 |
ruler compass/.is family, |
| 458 |
ruler compass/.cd, |
| 459 |
% \end{macrocode} |
| 460 |
%^^A |
| 461 |
% Draft mode displays the labels. |
| 462 |
% \begin{macrocode} |
| 463 |
draft mode/.is if=rc@draft, |
| 464 |
% beamer mode/.is if=rc@beamer, |
| 465 |
% \end{macrocode} |
| 466 |
%^^A |
| 467 |
% This is the actual code for resetting the counters. |
| 468 |
% \begin{macrocode} |
| 469 |
at begin picture/.style={ |
| 470 |
execute at begin picture={ |
| 471 |
\global\advance\rc@picture@id by 1\relax |
| 472 |
\setcounter{pointlabels}{0}% |
| 473 |
}, |
| 474 |
}, |
| 475 |
% \end{macrocode} |
| 476 |
%^^A |
| 477 |
% Styling the point labels. |
| 478 |
% \begin{macrocode} |
| 479 |
point labels/.is choice, |
| 480 |
point labels/arabic/.code={% |
| 481 |
\renewcommand\thepointlabels{\@arabic \c@pointlabels}% |
| 482 |
\def\rc@initial{48}% |
| 483 |
\def\rc@factor{10}% |
| 484 |
}, |
| 485 |
point labels/alph/.code={% |
| 486 |
\renewcommand\thepointlabels{\@alph \c@pointlabels}% |
| 487 |
\def\rc@initial{96}% |
| 488 |
\def\rc@factor{26}% |
| 489 |
}, |
| 490 |
point labels/Alph/.code={% |
| 491 |
\renewcommand\thepointlabels{\@Alph \c@pointlabels}% |
| 492 |
\def\rc@initial{64}% |
| 493 |
\def\rc@factor{26}% |
| 494 |
}, |
| 495 |
% \end{macrocode} |
| 496 |
%^^A |
| 497 |
% Styling the point labels with the \verb+alphalph+ package. |
| 498 |
% \begin{macrocode} |
| 499 |
point labels/alphalph/.code={% |
| 500 |
\@ifundefined{alphalph}{% |
| 501 |
\message{The "alphalph" option only works if the 'alphalph' package has been loaded (using "alph" instead).}% |
| 502 |
\renewcommand\thepointlabels{\@alph \c@pointlabels}% |
| 503 |
\def\rc@initial{96}% |
| 504 |
\def\rc@factor{26}% |
| 505 |
}{% |
| 506 |
\renewcommand\thepointlabels{\alphalph \c@pointlabels}% |
| 507 |
\def\rc@initial{96}% |
| 508 |
\def\rc@factor{26}% |
| 509 |
}% |
| 510 |
}, |
| 511 |
point labels/AlphAlph/.code={% |
| 512 |
\@ifundefined{alphalph}{% |
| 513 |
\message{The "AlphAlph" option only works if the 'alphalph' package has been loaded (using "Alph" instead).}% |
| 514 |
\renewcommand\thepointlabels{\@Alph \c@pointlabels}% |
| 515 |
\def\rc@initial{64}% |
| 516 |
\def\rc@factor{26}% |
| 517 |
}{% |
| 518 |
\renewcommand\thepointlabels{\AlphAlph \c@pointlabels}% |
| 519 |
\def\rc@initial{64}% |
| 520 |
\def\rc@factor{26}% |
| 521 |
}% |
| 522 |
}, |
| 523 |
% \end{macrocode} |
| 524 |
%^^A |
| 525 |
% Styles for if the path is still in use or not. |
| 526 |
% \begin{macrocode} |
| 527 |
construction in use/.style={ |
| 528 |
draw=blue |
| 529 |
}, |
| 530 |
construction not in use/.style={ |
| 531 |
draw=gray!75, |
| 532 |
}, |
| 533 |
% \end{macrocode} |
| 534 |
%^^A |
| 535 |
% Code for drawing a circle. |
| 536 |
% \begin{macrocode} |
| 537 |
compass/.code 2 args={% |
| 538 |
\rc@processpt\rc@pta#1\pgf@stop |
| 539 |
\rc@processpt\rc@ptb#2\pgf@stop |
| 540 |
\pgfkeysalso{ruler compass/compass aux={\rc@pta}{\rc@ptb}}% |
| 541 |
}, |
| 542 |
compass aux/.style 2 args={ |
| 543 |
alt if exist={c\rc@pathsep#1\rc@pathsep#2}{ |
| 544 |
ruler compass/construction in use/.try, |
| 545 |
}{ |
| 546 |
ruler compass/construction not in use/.try |
| 547 |
}, |
| 548 |
name path=c\rc@pathsep#1\rc@pathsep#2, |
| 549 |
ruler compass/every construction path/.try, |
| 550 |
ruler compass/every compass/.try, |
| 551 |
insert path={ |
| 552 |
(#1) to[circle through] (#2) |
| 553 |
node[name=c\rc@pathsep#1\rc@pathsep#2\rc@pathsep centre,ruler compass/aux point={#1}] {} |
| 554 |
node[name=c\rc@pathsep#1\rc@pathsep#2\rc@pathsep rim,ruler compass/aux point={#2}] {} |
| 555 |
}, |
| 556 |
}, |
| 557 |
% \end{macrocode} |
| 558 |
%^^A |
| 559 |
% Code for drawing a straight line. |
| 560 |
% \begin{macrocode} |
| 561 |
ruler/.code 2 args={% |
| 562 |
\rc@processpt\rc@pta#1\pgf@stop |
| 563 |
\rc@processpt\rc@ptb#2\pgf@stop |
| 564 |
\pgfkeysalso{ruler compass/ruler aux={\rc@pta}{\rc@ptb}}% |
| 565 |
}, |
| 566 |
ruler aux/.style 2 args={ |
| 567 |
overlay, |
| 568 |
alt if exist={r\rc@pathsep#1\rc@pathsep#2}{ |
| 569 |
ruler compass/construction in use/.try |
| 570 |
}{ |
| 571 |
ruler compass/construction not in use/.try |
| 572 |
}, |
| 573 |
name path=r\rc@pathsep#1\rc@pathsep#2, |
| 574 |
ruler compass/every construction path/.try, |
| 575 |
ruler compass/every ruler/.try, |
| 576 |
insert path={ |
| 577 |
($(#1)!\pgfkeysvalueof{/tikz/ruler compass/ruler length}!(#2)$) -- ($(#2)!\pgfkeysvalueof{/tikz/ruler compass/ruler length}!(#1)$) |
| 578 |
node[name=r\rc@pathsep#1\rc@pathsep#2\rc@pathsep start,ruler compass/aux point={#1}] {} |
| 579 |
node[name=r\rc@pathsep#1\rc@pathsep#2\rc@pathsep end,ruler compass/aux point={#2}] {} |
| 580 |
}, |
| 581 |
}, |
| 582 |
% \end{macrocode} |
| 583 |
%^^A |
| 584 |
% Sets the ruler length. |
| 585 |
% \begin{macrocode} |
| 586 |
ruler length/.initial=20, |
| 587 |
% \end{macrocode} |
| 588 |
%^^A |
| 589 |
% Auxiliary point style. |
| 590 |
% \begin{macrocode} |
| 591 |
aux point/.style={ |
| 592 |
node contents/.try={}, |
| 593 |
at={(#1)}, |
| 594 |
ruler compass/every aux point/.try |
| 595 |
}, |
| 596 |
% \end{macrocode} |
| 597 |
%^^A |
| 598 |
% Draws a point as a coordinate with another node for styling. |
| 599 |
% \begin{macrocode} |
| 600 |
point/.style={ |
| 601 |
ruler compass/name it, |
| 602 |
coordinate, |
| 603 |
node contents/.try={}, |
| 604 |
insert path={ |
| 605 |
node[ |
| 606 |
fill=#1, |
| 607 |
circle, |
| 608 |
minimum width=1mm, |
| 609 |
inner sep=0mm, |
| 610 |
reset label anchor, |
| 611 |
anchor=center, |
| 612 |
node contents/.try={}, |
| 613 |
ruler compass/every point/.try, |
| 614 |
] {} |
| 615 |
} |
| 616 |
}, |
| 617 |
% \end{macrocode} |
| 618 |
%^^A |
| 619 |
% Forces a point to be named. |
| 620 |
% \begin{macrocode} |
| 621 |
name it/.code={% |
| 622 |
\ifx\tikz@fig@name\pgfutil@empty |
| 623 |
\stepcounter{pointlabels}% |
| 624 |
\pgfkeysalso{name=\thepointlabels}% |
| 625 |
\expandafter\xdef\csname rc@id@\thepointlabels\endcsname{\the\rc@picture@id}% |
| 626 |
\ifrc@draft |
| 627 |
\pgfkeysalso{label={[ruler compass/draft label/.try]\thepointlabels}}% |
| 628 |
\fi |
| 629 |
\fi |
| 630 |
}, |
| 631 |
point/.default=black, |
| 632 |
} |
| 633 |
% \end{macrocode} |
| 634 |
%^^A |
| 635 |
% Sets the initial scale and offset of the enclosing box. |
| 636 |
% \begin{macrocode} |
| 637 |
\def\rc@scale{1} |
| 638 |
\def\rc@offset{0pt} |
| 639 |
% \end{macrocode} |
| 640 |
%^^A |
| 641 |
% Sets the bounding box from the auxiliary file. |
| 642 |
% \begin{macrocode} |
| 643 |
\def\jump@setbb#1#2#3{% |
| 644 |
\@ifundefined{jump@#1@maxbb}{% |
| 645 |
\expandafter\gdef\csname jump@#1@maxbb\endcsname{#3}% |
| 646 |
}{% |
| 647 |
\csname jump@#1@maxbb\endcsname |
| 648 |
\pgf@xa=\pgf@x |
| 649 |
\pgf@ya=\pgf@y |
| 650 |
#3 |
| 651 |
\pgfmathsetlength\pgf@x{max(\pgf@x,\pgf@xa)}% |
| 652 |
\pgfmathsetlength\pgf@y{max(\pgf@y,\pgf@ya)}% |
| 653 |
\expandafter\xdef\csname jump@#1@maxbb\endcsname{\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}% |
| 654 |
} |
| 655 |
\@ifundefined{jump@#1@minbb}{% |
| 656 |
\expandafter\gdef\csname jump@#1@minbb\endcsname{#2}% |
| 657 |
}{% |
| 658 |
\csname jump@#1@minbb\endcsname |
| 659 |
\pgf@xa=\pgf@x |
| 660 |
\pgf@ya=\pgf@y |
| 661 |
#2 |
| 662 |
\pgfmathsetlength\pgf@x{min(\pgf@x,\pgf@xa)}% |
| 663 |
\pgfmathsetlength\pgf@y{min(\pgf@y,\pgf@ya)}% |
| 664 |
\expandafter\xdef\csname jump@#1@minbb\endcsname{\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}% |
| 665 |
} |
| 666 |
} |
| 667 |
% \end{macrocode} |
| 668 |
%^^A |
| 669 |
% Installs the code to save the bounding box. |
| 670 |
% \begin{macrocode} |
| 671 |
\tikzset{ |
| 672 |
stop jumping/.style={ |
| 673 |
execute at end picture={% |
| 674 |
\pgfmathsetlength\pgf@xa{\pgf@picminx/\rc@scale}% |
| 675 |
\pgfmathsetlength\pgf@ya{\pgf@picminy/\rc@scale}% |
| 676 |
\pgfmathsetlength\pgf@xb{\pgf@picmaxx/\rc@scale}% |
| 677 |
\pgfmathsetlength\pgf@yb{\pgf@picmaxy/\rc@scale}% |
| 678 |
\immediate\write\pgfutil@auxout{% |
| 679 |
\noexpand\jump@setbb{\the\rc@picture@id}{\noexpand\pgfpoint{\the\pgf@xa}{\the\pgf@ya}}{\noexpand\pgfpoint{\the\pgf@xb}{\the\pgf@yb}}% |
| 680 |
}, |
| 681 |
\pgf@x=\pgf@picminx |
| 682 |
\pgf@y=\pgf@picminy |
| 683 |
\csname jump@\the\rc@picture@id @minbb\endcsname |
| 684 |
\pgf@xa=\pgf@x |
| 685 |
\pgf@ya=\pgf@y |
| 686 |
\pgf@x=\pgf@picmaxx |
| 687 |
\pgf@y=\pgf@picmaxy |
| 688 |
\csname jump@\the\rc@picture@id @maxbb\endcsname |
| 689 |
\edef\rc@temp{\noexpand\path (\the\pgf@xa - \rc@offset,\the\pgf@ya - \rc@offset) -- (\the\pgf@x + \rc@offset,\the\pgf@y + \rc@offset);}% |
| 690 |
\rc@temp |
| 691 |
}, |
| 692 |
}, |
| 693 |
% \end{macrocode} |
| 694 |
%^^A |
| 695 |
% Scales the picture to fit inside a given rectangle. |
| 696 |
% \begin{macrocode} |
| 697 |
max size/.code 2 args={% |
| 698 |
\pgfutil@ifundefined{jump@\the\rc@picture@id @maxbb}{}{% |
| 699 |
\csname jump@\the\rc@picture@id @maxbb\endcsname |
| 700 |
\pgf@xa=\pgf@x |
| 701 |
\pgf@ya=\pgf@y |
| 702 |
\csname jump@\the\rc@picture@id @minbb\endcsname |
| 703 |
\advance\pgf@xa by -\pgf@x |
| 704 |
\advance\pgf@ya by -\pgf@y |
| 705 |
\advance\pgf@xa by \rc@offset |
| 706 |
\advance\pgf@xa by \rc@offset |
| 707 |
\advance\pgf@ya by \rc@offset |
| 708 |
\advance\pgf@ya by \rc@offset |
| 709 |
\pgfmathsetmacro\rc@xratio{\pgf@xa > #1 ? \pgf@xa/#1 : 1}% |
| 710 |
\pgfmathsetmacro\rc@yratio{\pgf@ya > #2 ? \pgf@ya/#2 : 1}% |
| 711 |
\pgfmathsetmacro\rc@scale{1/max(\rc@xratio,\rc@yratio)}% |
| 712 |
\pgfkeysalso{scale=\rc@scale}% |
| 713 |
} |
| 714 |
}, |
| 715 |
% \end{macrocode} |
| 716 |
%^^A |
| 717 |
%^^A |
| 718 |
% \begin{macrocode} |
| 719 |
enclosing box/offset/.store in=\rc@offset, |
| 720 |
constrain/.style={ |
| 721 |
execute at begin picture=\constrain |
| 722 |
} |
| 723 |
} |
| 724 |
% \end{macrocode} |
| 725 |
%^^A |
| 726 |
% Defines a clip to the enclosing box. |
| 727 |
% \begin{macrocode} |
| 728 |
\newcommand\constrain{% |
| 729 |
\pgfutil@ifundefined{jump@\the\rc@picture@id @minbb}{}{% |
| 730 |
\csname jump@\the\rc@picture@id @minbb\endcsname |
| 731 |
\pgfmathsetlength\pgf@xa{\pgf@x-\rc@offset}% |
| 732 |
\pgfmathsetlength\pgf@ya{\pgf@y-\rc@offset}% |
| 733 |
\csname jump@\the\rc@picture@id @maxbb\endcsname |
| 734 |
\pgfmathsetlength\pgf@xb{\pgf@x+\rc@offset}% |
| 735 |
\pgfmathsetlength\pgf@yb{\pgf@y+\rc@offset}% |
| 736 |
\edef\rc@temp{\noexpand\clip (\the\pgf@xa,\the\pgf@ya) rectangle (\the\pgf@xb,\the\pgf@yb);} |
| 737 |
\ifpgf@relevantforpicturesize |
| 738 |
\pgf@relevantforpicturesizefalse |
| 739 |
\rc@temp |
| 740 |
\pgf@relevantforpicturesizetrue |
| 741 |
\else |
| 742 |
\rc@temp |
| 743 |
\fi |
| 744 |
}% |
| 745 |
} |
| 746 |
|
| 747 |
% \end{macrocode} |
| 748 |
%^^A |
| 749 |
% Defines the enclosing box node. |
| 750 |
% \begin{macrocode} |
| 751 |
\expandafter\def\csname pgf@sh@ns@enclosing box\endcsname{rectangle} |
| 752 |
\expandafter\def\csname pgf@sh@np@enclosing box\endcsname{% |
| 753 |
\pgfutil@ifundefined{jump@\the\rc@picture@id @minbb}{% |
| 754 |
\def\southwest{\pgfqpoint{\pgf@picminx}{\pgf@picminy}}% |
| 755 |
\def\northeast{\pgfqpoint{\pgf@picmaxx}{\pgf@picmaxy}}% |
| 756 |
}{% |
| 757 |
\csname jump@\the\rc@picture@id @minbb\endcsname |
| 758 |
\pgfmathsetlength\pgf@xa{\pgf@x-\rc@offset}% |
| 759 |
\pgfmathsetlength\pgf@ya{\pgf@y-\rc@offset}% |
| 760 |
\edef\southwest{\noexpand\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}% |
| 761 |
\csname jump@\the\rc@picture@id @maxbb\endcsname |
| 762 |
\pgfmathsetlength\pgf@xb{\pgf@x+\rc@offset}% |
| 763 |
\pgfmathsetlength\pgf@yb{\pgf@y+\rc@offset}% |
| 764 |
\edef\northeast{\noexpand\pgfqpoint{\the\pgf@xb}{\the\pgf@yb}}% |
| 765 |
}% |
| 766 |
} |
| 767 |
\expandafter\def\csname pgf@sh@nt@enclosing box\endcsname{{1}{0}{0}{1}{0pt}{0pt}} |
| 768 |
\expandafter\def\csname pgf@sh@pi@enclosing box\endcsname{\pgfpictureid} |
| 769 |
|
| 770 |
|
| 771 |
% \end{macrocode} |
| 772 |
%^^A |
| 773 |
% Defines the layer code for individual paths and nodes. |
| 774 |
% \begin{macrocode} |
| 775 |
\tikzset{ |
| 776 |
on layer/.code={ |
| 777 |
\pgfonlayer{#1}\begingroup |
| 778 |
\aftergroup\endpgfonlayer |
| 779 |
\aftergroup\endgroup |
| 780 |
}, |
| 781 |
node on layer/.code={ |
| 782 |
\gdef\node@@on@layer{% |
| 783 |
\setbox\tikz@tempbox=\hbox\bgroup\pgfonlayer{#1}\unhbox\tikz@tempbox\endpgfonlayer\egroup} |
| 784 |
\aftergroup\node@on@layer |
| 785 |
}, |
| 786 |
reset label anchor/.code={% |
| 787 |
\let\tikz@auto@anchor=\pgfutil@empty |
| 788 |
\def\tikz@anchor{#1} |
| 789 |
}, |
| 790 |
reset label anchor/.default=center |
| 791 |
} |
| 792 |
\def\node@on@layer{\aftergroup\node@@on@layer} |
| 793 |
% \end{macrocode} |
| 794 |
%^^A |
| 795 |
% Sets the point label style. |
| 796 |
% \begin{macrocode} |
| 797 |
\@ifpackageloaded{alphalph}% |
| 798 |
{ |
| 799 |
\tikzset{ruler compass/point labels=alphalph} |
| 800 |
} |
| 801 |
{ |
| 802 |
\tikzset{ruler compass/point labels=alph} |
| 803 |
} |
| 804 |
|
| 805 |
\endinput |
| 806 |
% \end{macrocode} |
| 807 |
% \iffalse |
| 808 |
%</tikzlibrary> |
| 809 |
% \fi |
| 810 |
% |
| 811 |
%\Finale |