Debian Codegraph @

texmf-dist/source/latex/makeshape/ontesting.dtx

raw
1 % \iffalse meta-comment
2 %
3 % ontesting.dtx
4 % 22 January 2013
5 %
6 % This is version 1.1
7 % It generates a test bed (testsample.tex) for the sample shape,
8 % and an article (ontesting.pdf) on the tests.
9 %
10 % Generation of testsample.tex is with
11 % pdflatex makeshape.ins
12 % which contains
13 % \generate{\file{testsample.tex}
14 % {\from{ontesting.dtx}{testbed}}}
15 %
16 % Generation of ontesting.pdf is with
17 % pdflatex ontesting.dtx
18 %
19 % The \OnlyDescription command is not used for this document.
20 %
21 % This is part of Silhouette 2.1
22 %
23 % ------------------------------------------------------------------
24 % \fi
25 %
26 % \iffalse
27 %^^A---------------------------------------------------------
28 %^^A Preamble for documentation
29 %^^A---------------------------------------------------------
30 %<*driver>
31 \documentclass[10pt,a4paper]{ltxdoc}
32
33 \usepackage[T1]{fontenc}
34 \usepackage{lmodern}
35
36 \usepackage{hyperref}
37
38 \usepackage{makeshape}
39 \GetFileInfo{makeshape.sty}
40
41 \newcommand{\mnote}[1]
42 {\marginpar{\scriptsize \raggedright #1 }}
43
44 \EnableCrossrefs
45 \CodelineIndex
46 \RecordChanges
47
48 \begin{document}
49 \DocInput{ontesting.dtx}
50 \end{document}
51 %</driver>
52 % \fi
53 %
54 %^^A-------------------------------------------------------------------
55 %^^A Change log...
56 %^^A-------------------------------------------------------------------
57 %^^A
58 %^^A 0.0 - 6 January 2013
59 % \changes{0.0}{2013/01/06}{
60 % Experimental - part of Silhouette 2.0.1.
61 % Testing code is adopted from existing documents but improved.
62 % Monolithic testing code generation.
63 % User documentation is incomplete.
64 % }
65 %^^A
66 %^^A 1.0 - 9 January 2013 (started 7 January)
67 % \changes{1.0}{2013/01/09}{
68 % \emph{Experimental phase complete.}
69 % Testing code generation is embedded in the documentation.
70 % Testing code is updated with improved tests.
71 % Documentation on the role of the tests is completed.
72 % File names are finalised.
73 % }
74 %^^A
75 %^^A 1.1 - 22 January 2013
76 % \changes{1.1}{2013/01/22}{
77 % Tidied up the structure and layout of the test code.
78 % The description of the tests is improved.
79 % The report's title is changed.
80 % }
81 %^^A
82 %^^A-------------------------------------------------------------------
83 %^^A Check sums...
84 %^^A-------------------------------------------------------------------
85 %
86 %^^A no checksum required
87 %
88 % \CharacterTable
89 % {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
90 % 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
91 % Digits \0\1\2\3\4\5\6\7\8\9
92 % Exclamation \! Double quote \" Hash (number) \#
93 % Dollar \$ Percent \% Ampersand \&
94 % Acute accent \' Left paren \( Right paren \)
95 % Asterisk \* Plus \+ Comma \,
96 % Minus \- Point \. Solidus \/
97 % Colon \: Semicolon \; Less than \<
98 % Equals \= Greater than \> Question mark \?
99 % Commercial at \@ Left bracket \[ Backslash \\
100 % Right bracket \] Circumflex \^ Underscore \_
101 % Grave accent \` Left brace \{ Vertical bar \|
102 % Right brace \} Tilde \~}
103 %
104 %^^A===========================================================================
105 %^^A Start report body
106 %^^A===========================================================================
107 %
108 % \title{The {\sf makeshape} package\thanks{
109 % This document is part of \textsf{makeshape}~\fileversion, dated~\filedate.}\\
110 % {\tt testshape.tex}\\A Document for Testing the Package and \\Custom Shapes}
111 %
112 % \author{Adrian P. Robson\thanks{\texttt{[email protected]}}}
113 % \date{22 January 2013}
114 %
115 % \maketitle
116 %
117 % \tableofcontents
118 %
119 %\section{Introduction}
120 %
121 % Here we discus the |testsample.tex| document
122 % that is a test bed for the {\sf makeshape} package \cite{makeshape}
123 % and its sample shape.
124 % The package is in |makeshape.sty| and the sample shape is defined in |sampleshape.tex|.
125 % The test bed can be usefully adapted to work with any PGF \cite{pgfMan} shape
126 % developed with the {\sf makeshape} package.
127 %
128 % There are 11 test PGF pictures in the |testsample.tex| document,
129 % and we describe what each of these tests achieves, and what aspects are important for custom shapes.
130 %
131 %
132 %^^A#################################################################
133 %^^A# Test bed document - preamble - start
134 %^^A#################################################################
135 %\iffalse
136 %<*testbed>
137 %%--------------------------------------------------------
138 %%
139 %% This is a test bed for the makeshape package's
140 %% sampleshape in sampleshape.tex
141 %%
142 %% It can be easily adapted for other shapes.
143 %%
144 %% 22 January 2013
145
146 \documentclass[10pt,a4paper]{article}
147
148 \usepackage{enumitem}
149 \usepackage{tikz}
150 \usetikzlibrary{backgrounds}
151 \usetikzlibrary{arrows}
152
153 %%-------------------------------------------------
154 %% file and shape being tested
155 \def\filename{sampleshape} % file being tested
156 \input{\filename} % It is a .tex
157 %%\usepackage{\filename} % It is a .sty
158 \def\testshape{sample} % shape being tested
159 %%-------------------------------------------------
160
161 %%--------------------------------------------------------
162 %% Utility macros
163 %%--------------------------------------------------------
164
165 %% \spot{x}{y}
166 \newcommand{\spot}[2]{
167 \draw[help lines,red] (#1,#2) circle (1pt);
168 }
169
170 %% \markOrig
171 \def\mrksz{4pt}
172 \def\mrkcol{yellow}
173 \newcommand{\markOrig}{
174 \draw[help lines,\mrkcol] (0,0) circle (\mrksz);
175 \draw[help lines,\mrkcol] (-\mrksz,0) -- (\mrksz,0);
176 \draw[help lines,\mrkcol] (0,-\mrksz) -- (0,\mrksz);
177 }
178
179 %% \markOrigC{colour}
180 \def\mrksz{4pt}
181 \newcommand{\markOrigC}[1]{
182 \draw[help lines,#1] (0,0) circle (\mrksz);
183 \draw[help lines,#1] (-\mrksz,0) -- (\mrksz,0);
184 \draw[help lines,#1] (0,-\mrksz) -- (0,\mrksz);
185 }
186
187 %% Anchors ...
188 %% \***{node}{size}{colour}
189
190 \def\centeranchor#1#2#3{
191 \draw[help lines,#3] (#1.center) circle (#2);
192 }
193
194 \def\textanchor#1#2#3{
195 \draw[help lines,#3] (#1.text) circle (#2);
196 }
197
198 \def\cardinalanchors#1#2#3{
199 \draw[help lines,#3] (#1.north) circle (#2);
200 \draw[help lines,#3] (#1.west) circle (#2);
201 \draw[help lines,#3] (#1.south) circle (#2);
202 \draw[help lines,#3] (#1.east) circle (#2);
203 }
204
205 \def\corneranchors#1#2#3{
206 \draw[help lines,#3] (#1.north west) circle (#2);
207 \draw[help lines,#3] (#1.south west) circle (#2);
208 \draw[help lines,#3] (#1.south east) circle (#2);
209 \draw[help lines,#3] (#1.north east) circle (#2);
210 }
211
212 \def\allanchors#1#2#3{
213 \corneranchors{#1}{#2}{#3}
214 \cardinalanchors{#1}{#2}{#3}
215 }
216
217 %%--------------------------------------------------------
218
219 \title{The {\sf makeshape} package\\
220 Shape Test Bed
221 \vspace{-3ex} }
222 \author{}
223 \date{
224 \begin{tabular}{rl}
225 File & {\tt \filename}\\
226 Shape & {\tt \testshape}
227 \end{tabular}
228 \\[2ex]
229 \today}
230
231 \begin{document}
232
233 \maketitle
234
235 %</testbed>
236 %\fi
237 %^^A#################################################################
238 %^^A# Test bed document - preamble - end
239 %^^A#################################################################
240 %
241 % \section{The Tests}
242 %
243 % \subsection{Basic Shape}
244 %
245 % This section shows the shape with its default size and separation options.
246 % Cardinal anchor points are show in red; the centre anchor in blue;
247 % and the text anchor in green.
248 % The green lines show the the text box size.
249 %
250 % It tests the package's management of the text box, the text and centre anchors,
251 % and the shape's cardinal anchors.
252 % \emph{Check that the background path is correct,
253 % and that the anchors are in the correct positions.}
254 %
255 %^^A#################################################################
256 %^^A# Test bed document - basic shape tests - start
257 %^^A#################################################################
258 %\iffalse
259 %<*testbed>
260 %%--------------------------------------------------------
261 \section*{Basic Shape}
262
263 \begin{center}
264 \begin{tikzpicture}
265
266 \node at (0,0)
267 [\testshape, draw
268 ] (test) {\verb|x x|} ;
269
270 \allanchors{test}{2pt}{red}
271 \textanchor{test}{2pt}{green}
272 \draw[help lines,green] (test.text) -- ++(7pt,0);
273 \draw[help lines,green] (test.text) -- ++(0,5pt);
274 \centeranchor{test}{2pt}{blue}
275
276 %% mark the anchors with arrows from enclosing rectangle
277 \node at (0,0)
278 [rectangle, red,
279 minimum width=4cm,
280 minimum height=2cm
281 ] (outer) {} ;
282 \begin{scope}[>=latex']
283 \draw[->,help lines,red] (outer.north) -- (test.north);
284 \draw[->,help lines,red] (outer.east) -- (test.east);
285 \draw[->,help lines,red] (outer.south) -- (test.south);
286 \draw[->,help lines,red] (outer.west) -- (test.west);
287 \draw[->,help lines,red] (outer.north east) -- (test.north east);
288 \draw[->,help lines,red] (outer.south east) -- (test.south east);
289 \draw[->,help lines,red] (outer.south west) -- (test.south west);
290 \draw[->,help lines,red] (outer.north west) -- (test.north west);
291 \end{scope}
292
293 \begin{scope}[on background layer]
294 \node at (4cm,0)
295 [rectangle, draw
296 ] (rectRmin) {\verb|x x|};
297
298 \node at (0,-1.7cm)
299 [rectangle, draw
300 ] (rectBmin) {\verb|x x|};
301
302 \draw[help lines,green] (rectRmin.north west) -- ++(-4.5cm,0);
303 \draw[help lines,green] (rectRmin.south west) -- ++(-4.5cm,0);
304 \draw[help lines,green] (rectBmin.north west) -- ++(0,2.3cm);
305 \draw[help lines,green] (rectBmin.north east) -- ++(0,2.3cm);
306 \markOrig
307 \end{scope}
308
309 \end{tikzpicture}
310
311 \end{center}
312
313 %</testbed>
314 %\fi
315 %^^A#################################################################
316 %^^A# Test bed document - basic shape tests - end
317 %^^A#################################################################
318 %
319 % \subsection{Minimum Dimensions}
320 %
321 % This tests support for minimum width and height keys.
322 % Yellow lines mark the required sizes and centres, and
323 % green lines show the text box location.
324 % Cardinal anchors are shown in red.
325 %
326 % \emph{Check that the background path has scaled properly to the correct dimensions;
327 % and the anchors are in the right places.}
328 %
329 %^^A#################################################################
330 %^^A# Test bed document - minimum dimension tests - start
331 %^^A#################################################################
332 %\iffalse
333 %<*testbed>
334 \vfill
335 %%--------------------------------------------------------
336 \section*{Minimum Dimensions}
337
338 \def\minh{30pt}
339 \def\minw{80pt}
340
341 {\tt minimum width = \minw}\\
342 {\tt minimum height = \minh}
343
344 \begin{center}
345 \begin{tikzpicture}
346
347 %% The test shape
348 \node at (0,0)
349 [\testshape, draw,
350 minimum width=\minw,
351 minimum height=\minh,
352 ] (test) {\verb|x x|} ;
353
354 \allanchors{test}{1pt}{red}
355
356 %% Guide lines
357 \begin{scope}[on background layer]
358 \node at (4.5cm+\minw,0)
359 [rectangle, draw
360 ] (rectRmin) {\verb|x x|};
361
362 \node at (1.5cm+\minw,0)
363 [rectangle, draw,
364 minimum width=\minw,
365 minimum height=\minh
366 ] (rectR) {\verb|x x|};
367
368 \node at (0,-1cm-\minh)
369 [rectangle, draw,
370 minimum width=\minw,
371 minimum height=\minh
372 ] (rectB) {\verb|x x|};
373
374 \node at (0,-2.5cm-\minh)
375 [rectangle, draw,
376 ] (rectBmin) {\verb|x x|};
377
378 \markOrig
379 \draw[help lines,yellow] (rectR.north west) -- ++(-1.7cm-\minw,0);
380 \draw[help lines,yellow] (rectR.south west) -- ++(-1.7cm-\minw,0);
381 \draw[help lines,yellow] (rectR.west) -- ++(-1.7cm-\minw,0);
382 \draw[help lines,yellow] (rectR.west) -- ++(\minw+0.2cm,0);
383 \draw[help lines,yellow] (rectB.north west) -- ++(0,1.2cm+\minh);
384 \draw[help lines,yellow] (rectB.north east) -- ++(0,1.2cm+\minh);
385 \draw[help lines,yellow] (rectB.north) -- ++(0,1.2cm+\minh);
386 \draw[help lines,yellow] (rectB.north) -- ++(0,-\minh-0.2cm);
387
388 \draw[help lines,green] (rectRmin.north west) -- ++(-4.6cm-\minw,0);
389 \draw[help lines,green] (rectBmin.north west) -- ++(0,2.6cm+\minh);
390 \end{scope}
391
392 \end{tikzpicture}
393 \end{center}
394 \vfill
395
396 %</testbed>
397 %\fi
398 %^^A#################################################################
399 %^^A# Test bed document - minimum dimension tests - end
400 %^^A#################################################################
401 %
402 % \subsection{Inner Separation}
403 %
404 % This tests support for the inner separation keys.
405 % Inner separation is handled by the package and is included in
406 % the corrected text box.
407 % Green lines show the basic text box location, and
408 % blue lines show the corrected text box location.
409 % Cardinal anchors are shown in red.
410 %
411 % \emph{Check that the shape has scaled properly under the influence of the two keys;
412 % and the anchors are in the right places.}
413 %
414 %^^A#################################################################
415 %^^A# Test bed document - inner separation tests - start
416 %^^A#################################################################
417 %\iffalse
418 %<*testbed>
419 \newpage
420 %%--------------------------------------------------------
421 \section*{Inner Separation}
422
423 \def\insepx{20pt}
424 \def\insepy{10pt}
425
426 {\tt inner x seperation = \insepx}\\
427 {\tt inner y seperation = \insepy}
428
429 \begin{center}
430 \begin{tikzpicture}
431
432 %% The test shape
433 \node at (0,0)
434 [\testshape, draw,
435 inner xsep=\insepx, inner ysep=\insepy
436 ] (test) {\verb|x x|} ;
437
438 \allanchors{test}{1pt}{red}
439
440 %% Guide lines
441 \begin{scope}[on background layer]
442 \markOrig
443
444 \node at (2.5cm,0)
445 [rectangle, draw
446 ] (rectRmin) {\verb|x x|};
447
448 \node at (0,-1.5cm)
449 [rectangle, draw
450 ] (rectBmin) {\verb|x x|};
451
452 \node at (4cm,0)
453 [rectangle, draw,
454 inner ysep=\insepy
455 ] (rectRwithSep) {\verb|x x|};
456
457 \node at (0,-2.2cm)
458 [rectangle, draw,
459 inner xsep=\insepx
460 ] (rectBwithSep) {\verb|x x|};
461
462 \draw[help lines,green] (rectRmin.north west) -- ++(-3.4cm,0);
463 \draw[help lines,green] (rectBmin.north west) -- ++(0,2cm);
464 \draw[help lines,blue] (rectRwithSep.north west) -- ++(-4.9cm,0);
465 \draw[help lines,blue] (rectBwithSep.north west) -- ++(0,2.7cm);
466 \end{scope}
467
468 \end{tikzpicture}
469 \end{center}
470
471 %</testbed>
472 %\fi
473 %^^A#################################################################
474 %^^A# Test bed document - inner separation tests - end
475 %^^A#################################################################
476 %
477 % \subsection{Outer Separation}
478 %
479 % This section tests the outer separation keys.
480 % The actual shape is drawn in black.
481 % To shown the boundary of the outer separation surface,
482 % the shape is expanded and drawn in green.
483 % Anchors, which should be on this surface are displayed in red.
484 %
485 % \emph{Check that the expanded green shape is well formed,
486 % and that the anchors are in the correct place.}
487 %
488 %^^A#################################################################
489 %^^A# Test bed document - outer separation tests - start
490 %^^A#################################################################
491 %\iffalse
492 %<*testbed>
493 %%--------------------------------------------------------
494 \section*{Outer Separation}
495
496 \def\minh{20pt}
497 \def\minw{60pt}
498 \def\outerx{20pt}
499 \def\outery{10pt}
500
501 {\tt outer x separation = \outerx}\\
502 {\tt outer y separation = \outery}
503
504 \begin{center}
505 \begin{tikzpicture}
506
507 \markOrig
508
509 %% the shape with outer separation
510 \node at (0,0)
511 [\testshape, draw,
512 minimum width=\minw,
513 minimum height=\minh,
514 outer xsep=\outerx, outer ysep=\outery
515 ] (test) {\verb|x x|} ;
516
517 %% shape expanded to outer separation boundary
518 \node at (0,0)
519 [\testshape, draw, help lines, green,
520 minimum width=\minw+2*\outerx,
521 minimum height=\minh+2*\outery,
522 ] (bigger) {} ;
523
524 %% mark the anchors with arrows from enclosing rectangle
525 \node at (0,0)
526 [rectangle,
527 minimum width=\minw+1cm,
528 minimum height=\minh+1cm,
529 outer xsep=\outerx, outer ysep=\outery
530 ] (outer) {} ;
531
532 \begin{scope}[>=latex']
533 \draw[->,help lines,red] (outer.north) -- (test.north);
534 \draw[->,help lines,red] (outer.east) -- (test.east);
535 \draw[->,help lines,red] (outer.south) -- (test.south);
536 \draw[->,help lines,red] (outer.west) -- (test.west);
537 \draw[->,help lines,red] (outer.north east) -- (test.north east);
538 \draw[->,help lines,red] (outer.south east) -- (test.south east);
539 \draw[->,help lines,red] (outer.south west) -- (test.south west);
540 \draw[->,help lines,red] (outer.north west) -- (test.north west);
541 \end{scope}
542
543 %% mark anchors with circles
544 \allanchors{test}{2pt}{red}
545
546 %% mark text and centre anchors
547 \textanchor{test}{2pt}{green}
548 \draw[help lines,green] (test.text) -- ++(7pt,0);
549 \draw[help lines,green] (test.text) -- ++(0,5pt);
550 \centeranchor{test}{2pt}{blue}
551
552 \end{tikzpicture}
553 \end{center}
554
555 %</testbed>
556 %\fi
557 %^^A#################################################################
558 %^^A# Test bed document - outer separation tests - end
559 %^^A#################################################################
560 %
561 % \subsection{Anchorborder}
562 %
563 % There are three tests that are applied to verify the behaviour of
564 % the package's |\anchorborder|, and the shape's anchor path.
565 %
566 %\iffalse
567 %<*testbed>
568 %%--------------------------------------------------------
569 \section*{Anchorborder }
570
571 %</testbed>
572 %\fi
573 %
574 % \subsubsection{\texorpdfstring{External Points with Outer Separation and\\
575 % Minimum Dimensions}
576 % {External Points with Outer Separation and
577 % Minimum Dimensions}}
578 %
579 % This tests the connection of an external point to the shape's surface.
580 % It exercises outer separation and minimum dimensions.
581 % The black surface is the shape without any separation,
582 % and the outer green surface is where the outer separation surface should be.
583 % \emph{Check that the black arrows touch the outer green surface;
584 % and that the green shape is correct.}
585 %
586 %^^A#################################################################
587 %^^A# Test bed document - external points with outer separation and
588 %^^A# minimum dimensions tests - start
589 %^^A#################################################################
590 %\iffalse
591 %<*testbed>
592 %%--------------------------------------------------------
593 \subsection*{External Points with Outer Separation and\\Minimum Dimensions}
594
595 \def\width{2cm}
596 \def\height{1cm}
597 \def\testouter{10pt}
598
599 {\tt outer sep = \testouter}\\
600 {\tt minimum height = \height}\\
601 {\tt minimum width = \width}
602
603 \begin{center}
604 \begin{tikzpicture}
605
606 \markOrig
607
608 %% The test shape
609 \node at (0,0) [\testshape, draw, font={\sf \small},
610 minimum width=\width,
611 minimum height=\height,
612 outer sep=\testouter
613 ] (test) {Test};
614
615 %% green path where anchors should be
616 \node at (0,0) [\testshape, draw, help lines, green,
617 minimum width=\width+2*\testouter,
618 minimum height=\height+2*\testouter,
619 ] (bigger) {} ;
620
621 \def\n{20}
622 \def\radius{3cm}
623 \draw[dotted] (0,0) circle (\radius);
624 \foreach \s in {1,...,\n}
625 {
626 \draw[->, >=latex'] ({360/\n * (\s - 1)}:\radius) -- (test);
627 }
628 \end{tikzpicture}
629 \end{center}
630
631 %</testbed>
632 %\fi
633 %^^A#################################################################
634 %^^A# Test bed document - external points with outer separation and
635 %^^A# minimum dimensions tests - end
636 %^^A#################################################################
637 %
638 % \subsubsection{Internal Points with Minimum Dimensions}
639 %
640 % This tests the connection of an internal point to the shape's surface.
641 % It uses minimum dimensions.
642 % \emph{Check that the red arrows touch the outer black surface,
643 % and that the black shape is correct.}
644 %
645 %^^A#################################################################
646 %^^A# Test bed document - internal points with minimum dimensions
647 %^^A# tests - start
648 %^^A#################################################################
649 %\iffalse
650 %<*testbed>
651 %%--------------------------------------------------------
652 \subsection*{Internal Points with Minimum Dimensions}
653
654 \def\width{3cm}
655 \def\height{3cm}
656
657 {\tt minimum height = \height}\\
658 {\tt minimum width = \width}
659
660 \vspace{-3ex}
661 \begin{center}
662 \begin{tikzpicture}
663
664 \markOrig
665
666 %% The test shape
667 \node at (0,0) [\testshape, draw, font={\sf \small},
668 minimum width=\width,
669 minimum height=\height,
670 ] (test) {};
671
672 \def\n{20}
673 \def\radius{1cm}
674 \draw[dotted] (0,0) circle (\radius);
675 \foreach \s in {1,...,\n}
676 {
677 \draw[->, >=latex', red] ({360/\n * (\s - 1)}:\radius) -- (test);
678 }
679 \end{tikzpicture}
680 \end{center}
681
682 %</testbed>
683 %\fi
684 %^^A#################################################################
685 %^^A# Test bed document - internal points with minimum dimensions
686 %^^A# tests - end
687 %^^A#################################################################
688
689 % \subsubsection{Angles with Outer Separation and Minimum Dimensions}
690 %
691 % This tests the `connect a line at an angle' feature.
692 % Different x and y outer separations and minimum dimensions are used.
693 % The black surface is the shape without any separation,
694 % and the outer red surface is where the outer separation surface should be.
695 % \emph{Check that the blue dots are on the outer red surface,
696 % and that the red shape is correct.}
697 %
698 %^^A#################################################################
699 %^^A# Test bed document - angles with outer separation and minimum
700 %^^A# dimensions tests - start
701 %^^A#################################################################
702 %\iffalse
703 %<*testbed>
704 %%--------------------------------------------------------
705 \subsection*{Angles with Outer Separation and Minimum Dimensions}
706
707 \def\angle{120}
708 \def\width{2cm}
709 \def\height{1cm}
710 \def\testouterx{20pt}
711 \def\testoutery{10pt}
712
713 Marked angle = \angle\\
714 {\tt outer xsep = \testouterx}\\
715 {\tt outer ysep = \testoutery}\\
716 {\tt minimum height = \height}\\
717 {\tt minimum width = \width}
718
719 \vspace{-5ex}
720 \begin{center}
721 \begin{tikzpicture}
722
723 \markOrig
724
725 %% red path where anchors should be ?
726 \node at (0,0) [\testshape, draw, help lines, red,
727 minimum width=\width+2*\testouterx,
728 minimum height=\height+2*\testoutery,
729 ] (bigger) {};
730
731 \node at (0,0) [\testshape, draw,
732 minimum width=\width,
733 minimum height=\height,
734 outer xsep=\testouterx,
735 outer ysep=\testoutery
736 ] (test) {};
737
738 \foreach \angle in {0,5,...,355} {
739 \fill[blue] (test.\angle) circle[radius=1pt];
740 }
741
742 %% single angle test
743 \def\angle{120}
744 \draw [help lines] (test.center) -- ++(\angle:1.5cm);
745 \draw[green] (test.\angle) circle[radius=2pt];
746 \draw[green] (test.\angle) -- ++(3pt,3pt);
747 \draw[green] (test.\angle) -- ++(-3pt,-3pt);
748 \draw[green] (test.\angle) -- ++(-3pt,3pt);
749 \draw[green] (test.\angle) -- ++(3pt,-3pt);
750
751 \end{tikzpicture}
752 \end{center}
753
754 %</testbed>
755 %\fi
756 %^^A#################################################################
757 %^^A# Test bed document - angles with outer separation and minimum
758 %^^A# dimensions tests - end
759 %^^A#################################################################
760 %
761 % \subsection{Simple Node Connections}
762 %
763 % This tests simple node connection.
764 % \emph{Check that the centre shape is connect to the surrounding eight shapes.}
765 %
766 %^^A#################################################################
767 %^^A# Test bed document - simple node connections tests - start
768 %^^A#################################################################
769 %\iffalse
770 %<*testbed>
771 %%--------------------------------------------------------
772 \section*{Simple Node Connections}
773
774 \begin{center}
775 \begin{tikzpicture}
776 \def\ra{0} \def\rb{60pt} \def\rc{120pt}
777 \def\ca{0} \def\cb{100pt} \def\cc{200pt}
778
779 \draw[help lines,step=20pt,dotted] (0pt,0pt) grid (\cc,\rc);
780
781 \tikzset{node style/.style={ minimum width=40pt,minimum height=20pt}}
782
783 \markOrig
784
785 \node at (\ca,\ra) [draw, \testshape, node style] (A) {A};
786 \node at (\cb,\ra) [draw, \testshape, node style] (B) {B};
787 \node at (\cc,\ra) [draw, \testshape, node style] (C) {C};
788 %%
789 \node at (\ca,\rb) [draw, \testshape, node style] (D) {D};
790 \node at (\cb,\rb) [draw, \testshape, node style] (E) {E};
791 \node at (\cc,\rb) [draw, \testshape, node style] (F) {F};
792 %%
793 \node at (\ca,\rc) [draw, \testshape, node style] (G) {G};
794 \node at (\cb,\rc) [draw, \testshape, node style] (H) {H};
795 \node at (\cc,\rc) [draw, \testshape, node style] (I) {I};
796
797 \draw (E) -- (F);
798 \draw (E) -- (D);
799 \draw (E) -- (B);
800 \draw (E) -- (H);
801 \draw (E) -- (G);
802 \draw (E) -- (A);
803 \draw (E) -- (I);
804 \draw (E) -- (C);
805
806 \end{tikzpicture}
807 \end{center}
808
809 %</testbed>
810 %\fi
811 %^^A#################################################################
812 %^^A# Test bed document - simple node connections tests - end
813 %^^A#################################################################
814 %
815 % \subsection{Scaling}
816 %
817 % This is a simple scaling test that uses minimum dimensions to draw
818 % the shape at three sizes.
819 % There are guide lines showing dimensions for each size.
820 % \emph{Check that all of the shapes are correct.}
821 %
822 %^^A#################################################################
823 %^^A# Test bed document - scaling tests - start
824 %^^A#################################################################
825 %\iffalse
826 %<*testbed>
827 %%--------------------------------------------------------
828 \section*{Scaling}
829
830 \def\minh{20pt}
831 \def\minw{80pt}
832 \def\exd{5pt}
833
834 \begin{center}
835 \begin{tikzpicture}
836
837 \node at (0,0)
838 [\testshape, draw,
839 minimum width=\minw,
840 minimum height=\minh,
841 ] (test1) {} ;
842
843 \node at (0,0)
844 [\testshape, draw, blue,
845 minimum width=\minw+1cm,
846 minimum height=\minh+1cm,
847 ] (test2) {} ;
848
849 \node at (0,0)
850 [\testshape, draw, red,
851 minimum width=\minw+2cm,
852 minimum height=\minh+2cm,
853 ] (test3) {} ;
854
855 \def\tgridA#1#2{
856 \draw[help lines] ({0.5*(\minw+#1)+\exd},{0.5*(\minh+#1)}) -- ({-0.5*(\minw+#1)-\exd},{0.5*(\minh+#1)});
857 \draw[help lines] ({0.5*(\minw+#1)+\exd},{-0.5*(\minh+#1)}) -- ({-0.5*(\minw+#1)-\exd},{-0.5*(\minh+#1)});
858 \draw[help lines] ({0.5*(\minw+#1)},{0.5*(\minh+#1)+\exd}) -- ({0.5*(\minw+#1)},{-0.5*(\minh+#1)-\exd});
859 \draw[help lines] ({-0.5*(\minw+#1)},{0.5*(\minh+#1)+\exd}) -- ({-0.5*(\minw+#1)},{-0.5*(\minh+#1)-\exd});
860 }
861
862 \begin{scope}[on background layer]
863 \tgridA{0pt}{0pt}
864 \tgridA{1cm}{1cm}
865 \tgridA{2cm}{2cm}
866 \markOrig
867 \end{scope}
868
869 \end{tikzpicture}
870 \end{center}
871
872 %</testbed>
873 %\fi
874 %^^A#################################################################
875 %^^A# Test bed document - scaling tests - end
876 %^^A#################################################################
877 %
878 %
879 % \subsection{Package Tests}
880 %
881 %^^A#################################################################
882 %^^A# Test bed document - package tests peamble - start
883 %^^A#################################################################
884 %\iffalse
885 %<*testbed>
886 %%--------------------------------------------------------
887 \section*{Package Tests}
888
889 %</testbed>
890 %\fi
891 %^^A#################################################################
892 %^^A# Test bed document - package tests preamble- end
893 %^^A#################################################################
894 %
895 % \subsubsection{Text Alignment and the Text Box}
896 %
897 % This verifies the operation of the text box macros.
898 % All combinations of test ascenders and descenders are used.
899 % It tests the package's management of the text box and the text and centre anchors.
900 % The left hand shapes are standard text boxes.
901 %
902 % \emph{
903 % Check the shape's text boxes align with the standard boxes.
904 % Also that the blue centre anchor is at the yellow origin;
905 % and the green text anchor is in the correct place.
906 % Finally, the red cardinal anchors should be suitably located on the shapes boundary. }
907 %
908 %^^A#################################################################
909 %^^A# Test bed document - text alignment and
910 %^^A# the text box tests - start
911 %^^A#################################################################
912 %\iffalse
913 %<*testbed>
914 %%--------------------------------------------------------
915 \subsection*{Text Alignment and the Text Box}
916
917 \begin{center}
918 \begin{tikzpicture}
919
920 \node at (0,0)
921 [\testshape, draw
922 ] (test1) {\verb|x x|} ;
923
924 \node[ \testshape, draw,
925 below of=test1,
926 node distance=1cm
927 ] (test2) {\verb|x dx|} ;
928
929 \node[ \testshape, draw,
930 below of=test2, node distance=1cm
931 ] (test3) {\verb|xp x|} ;
932
933 \node[ \testshape, draw,
934 below of=test3, node distance=1cm
935 ] (test4) {\verb|xp dx|} ;
936
937 \allanchors{test1}{1pt}{red}
938 \corneranchors{test2}{1pt}{red}
939 \corneranchors{test3}{1pt}{red}
940 \corneranchors{test4}{1pt}{red}
941 \centeranchor{test1}{2pt}{blue}
942 \centeranchor{test2}{2pt}{blue}
943 \centeranchor{test3}{2pt}{blue}
944 \centeranchor{test4}{2pt}{blue}
945 \textanchor{test1}{1pt}{green}
946 \draw[help lines,green] (test1.text) -- ++(7pt,0);
947 \draw[help lines,green] (test1.text) -- ++(0,5pt);
948 \textanchor{test2}{1pt}{green}
949 \textanchor{test3}{1pt}{green}
950 \textanchor{test4}{1pt}{green}
951
952 \begin{scope}[on background layer]
953
954 \markOrig
955
956 \node at(4cm,0) [ rectangle, draw
957 ] (ref1) {\verb|x x|} ;
958 \draw[green] (ref1.north west) -- ++(-5cm,0);
959 \draw[green] (ref1.south west) -- ++(-5cm,0);
960
961 \node[rectangle, draw,
962 below of=ref1, node distance=1cm
963 ] (ref2) {\verb|x dx|} ;
964 \draw[green] (ref2.north west) -- ++(-5cm,0);
965 \draw[green] (ref2.south west) -- ++(-5cm,0);
966
967 \node[rectangle, draw,
968 below of=ref2, node distance=1cm
969 ] (ref3) {\verb|xp x|} ;
970 \draw[green] (ref3.north west) -- ++(-5cm,0);
971 \draw[green] (ref3.south west) -- ++(-5cm,0);
972
973 \node[rectangle, draw,
974 below of=ref3, node distance=1cm
975 ] (ref4) {\verb|xp dx|} ;
976 \draw[green] (ref4.north west) -- ++(-5cm,0);
977 \draw[green] (ref4.south west) -- ++(-5cm,0);
978
979 \end{scope}
980
981 \end{tikzpicture}
982 \end{center}
983
984 %</testbed>
985 %\fi
986 %^^A#################################################################
987 %^^A# Test bed document - text alignment and
988 %^^A# the text box tests - end
989 %^^A#################################################################
990 %
991 % \subsubsection{Inner, Outer and Angle for Shape Off Origin}
992 %
993 % This is a test for the correct operation of the package's |\anchorborder|
994 % with off-origin shapes.
995 % In particular, its use of the |\pgf@relevantforpicturesizefalse|
996 % and |\pgftransformreset| commands.
997 %
998 % \emph{Check that the outer box `closely' contains the picture,
999 % and that the green arrows and points are on the shape's boundary.}
1000 %
1001 %^^A#################################################################
1002 %^^A# Test bed document - inner, outer and angle for shape off
1003 %^^A# origin tests - start
1004 %^^A#################################################################
1005 %\iffalse
1006 %<*testbed>
1007 %%--------------------------------------------------------
1008 \subsection*{Inner, Outer and Angle for Shape Off Origin}
1009
1010 The box should closely contain picture if {\tt anchorborder} is working correctly.
1011 \bigskip
1012
1013 \begin{center}
1014 \begin{tikzpicture}[framed]
1015
1016 \markOrigC{black}
1017 \draw (2pt,0) node[anchor=west]{\tt \tiny origin};
1018
1019 %% The test shape
1020 \node at (70pt,40pt)
1021 [\testshape, draw,
1022 red, minimum width=60pt, minimum height=40pt
1023 ] (node) {};
1024
1025 %% outer test line
1026 \path (node);
1027 \pgfgetlastxy{\macrox}{\macroy}
1028 \coordinate (Xout) at (\macrox+20pt,\macroy+40pt);
1029
1030 \draw (Xout) circle(3pt);
1031 \draw [help lines] (node.center) -- (Xout);
1032 \draw [->, >=latex',green] (Xout) -- (node); % <<<
1033
1034 %% inner test line
1035 \path (node);
1036 \pgfgetlastxy{\macrox}{\macroy}
1037 \coordinate (Xin) at (\macrox-5pt,\macroy-5pt);
1038
1039 \draw (Xin) circle(3pt);
1040 \draw [help lines,shorten >=-1cm] (node.center) -- (Xin);
1041 \draw [->, >=latex',green] (Xin) -- (node); % <<<
1042
1043 %% test angle
1044 \def\angle{120}
1045 \draw [help lines] (node.center) -- ++(\angle:1.5cm);
1046 \draw[green] (node.\angle) circle[radius=2pt]; % <<<
1047
1048 \end{tikzpicture}
1049 \end{center}
1050
1051 %</testbed>
1052 %\fi
1053 %^^A#################################################################
1054 %^^A# Test bed document - inner, outer and angle for shape off
1055 %^^A# origin tests - end
1056 %^^A#################################################################
1057 %
1058 %^^A#################################################################
1059 %^^A# Test bed document - epilogue - start
1060 %^^A#################################################################
1061 %\iffalse
1062 %<*testbed>
1063 \end{document}
1064 %</testbed>
1065 %\fi
1066 %^^A#################################################################
1067 %^^A# Test bed document - epilogue - end
1068 %^^A#################################################################
1069 %
1070 % \section{Reuse}
1071 %
1072 % The |testsample.tex| file can be adapted to test other shapes developed using
1073 % the {\sf makeshape} package. Find the following section:
1074 %
1075 % \begin{verbatim}
1076 % %%-------------------------------------------------
1077 % %% file and shape being tested
1078 % \def\filename{sampleshape} % file being tested
1079 % \input{\filename} % It is a .tex
1080 % %%\usepackage{\filename} % It is a .sty
1081 % \def\testshape{sample} % shape being tested
1082 % %%-------------------------------------------------
1083 % \end{verbatim}
1084 % Then change |sampleshape| to the new file name, and |sample| to the particular shape's name.
1085 % Choose |\input| or |\usepackage| dependinmg on the file type.
1086 %
1087 % The report's ending `Package Test' section can be deleted, and additional shape specific tests added.
1088 % The file's {\sf makeshape} package oriented name
1089 % and its heading comment should probably be changed as well.
1090 %
1091 %^^A===========================================================================
1092 %^^A References
1093 %^^A===========================================================================
1094 %
1095 % \begin{thebibliography}{9}
1096 % \raggedright
1097 %
1098 % \bibitem{makeshape}
1099 % Adrian P. Robson,
1100 % \emph{The makeshape package
1101 % and a method for creating custom shapes in PGF}, 2013.
1102 %
1103 % \bibitem{pgfMan}
1104 % Till Tantau, \emph{The TikZ and PGF Packages, Manual for version 2.10},
1105 % 2010.
1106 % Available as
1107 % \href{http://mirrors.ctan.org/graphics/pgf/base/doc/generic/pgf/pgfmanual.pdf}
1108 % {\tt pgfmanual.pdf}
1109 % from the \href{http://ctan.org}{Comprehensive TeX Archive Network}.
1110 %
1111 % \end{thebibliography}
1112 %
1113 %^^A===========================================================================
1114 %^^A Print Changes
1115 %^^A
1116 %^^A -> Run pdfLaTeX ontesting.dtx
1117 %^^A makeindex -s gglo.ist -o ontesting.gls ontesting.glo
1118 %^^A pdfLaTeX ontesting.dtx
1119 %^^A===========================================================================
1120 %
1121 %^^A \PrintChanges
1122 %
1123 \endinput
1124