Debian Codegraph @

texmf-dist/source/latex/wargame/natoapp6c/shape.dtx

raw
1 % \iffalse
2 % --------------------------------------------------------------------
3 %<*natoapp6c>
4 % \fi
5 % \subsubsection{Text \texttt{natoapp6c} namespace}
6 %
7 % \begin{NatoAppKey}{/natoapp6c}
8 %
9 % Here, we set up the key path \spec{/natoapp6c}
10 %
11 % \begin{macrocode}
12 \def\natoapp@report{}
13 \tikzset{
14 /natoapp6c/.search also={/tikz},
15 /natoapp6c/.cd,
16 }
17 % \end{macrocode}
18 % \end{NatoAppKey}
19 %
20 % \subsubsubsection{Choices of faction, command, and echelon}
21 %
22 % \begin{NatoAppKey}{natoapp6c/id,
23 % natoapp6c/fac,
24 % natoapp6c/cmd,
25 % natoapp6c/ech}
26 %
27 % The keys \spec{id}, spec{fac}, \spec{cmd}, and \spec{ech} are
28 % internal keys used to store the choice of faction, command, and
29 % echelon, respectively, in.
30 %
31 % \begin{macrocode}
32 \tikzset{
33 /natoapp6c/.cd,
34 id/.store in=\natoapp@id,
35 fac/.store in=\natoapp@fac,
36 cmd/.store in=\natoapp@cmd,
37 ech/.store in=\natoapp@ech,
38 path/.store in=\n@to@ppp@th
39 }
40 % \end{macrocode}
41 % \end{NatoAppKey}
42 %
43 % \begin{NatoAppKey}{natoapp6c/faction}
44 %
45 % Choice of \meta{faction}. This is limited to predefined values.
46 % The choice is stored in the key \spec{natoapp6c/fac}.
47 %
48 % \begin{macrocode}
49 \tikzset{
50 /natoapp6c/.cd,
51 faction/.is choice,
52 faction/none/.code={\let\natoapp@fac\@undefined},
53 faction/friendly/.style={fac=friendly},
54 faction/friend/.style={fac=friendly},
55 faction/hostile/.style={fac=hostile},
56 faction/enemy/.style={fac=hostile},
57 faction/neutral/.style={fac=neutral},
58 faction/unknown/.style={fac=unknown},
59 faction/?/.style={fac=unknown},
60 faction/.initial=friendly,
61 }
62 % \end{macrocode}
63 % \end{NatoAppKey}
64 %
65 % \begin{NatoAppKey}{natoapp6c/command}
66 %
67 % Choice of \meta{command}. This is limited to predefined values.
68 % The choice is stored in the key \spec{natoapp6c/cmd}.
69 %
70 % \begin{macrocode}
71 \tikzset{
72 /natoapp6c/.cd,
73 command/.is choice,
74 command/base/.style={cmd=base},
75 command/activity/.style={cmd=activity},
76 command/air/.style={cmd=air},
77 command/missile/.style={cmd=air},
78 command/equipment/.style={cmd=equipment},
79 command/installation/.style={cmd=installation},
80 command/land/.style={cmd=land},
81 command/sea surface/.style={cmd=sea surface},
82 command/space/.style={cmd=space},
83 command/sub surface/.style={cmd=sub surface},
84 command/sea mine/.style={cmd=sub surface},
85 command/dismounted/.style={cmd=dismounted},
86 command/none/.style={cmd=none},
87 }
88 % \end{macrocode}
89 % \end{NatoAppKey}
90 %
91 % \begin{NatoAppKey}{natoapp6c/echolon}
92 %
93 % Unit size. The choice is limited to one of the below. The choice
94 % is stored in the key \spec{natoapp6c/ech}.
95 %
96 % \begin{macrocode}
97 \tikzset{
98 /natoapp6c/.cd,
99 echelon/.is choice,
100 echelon/none/.style={ech=},
101 echelon/team/.style={ech=},
102 echelon/squad/.style={ech=squad},
103 echelon/section/.style={ech=section},
104 echelon/platoon/.style={ech=platoon},
105 echelon/company/.style={ech=company},
106 echelon/battalion/.style={ech=battalion},
107 echelon/regiment/.style={ech=regiment},
108 echelon/brigade/.style={ech=brigade},
109 echelon/division/.style={ech=division},
110 echelon/corps/.style={ech=corps},
111 echelon/army/.style={ech=army},
112 echelon/army group/.style={ech=army group},
113 echelon/theatre/.style={ech=theatre},
114 echelon/command/.style={ech=command},
115 echelon/dummy/.style={ech=dummy},
116 }
117 % \end{macrocode}
118 % \end{NatoAppKey}
119 %
120 % \begin{NatoAppKey}{natoapp6c/main,
121 % natoapp6c/left,
122 % natoapp6c/right,
123 % natoapp6c/top,
124 % natoapp6c/bottom,
125 % natoapp6c/below,
126 % natoapp6c/frame}
127 % \begin{Macro}{\natoapp@main,
128 % \natoapp@left,
129 % \natoapp@right,
130 % \natoapp@upper,
131 % \natoapp@lower,
132 % \natoapp@below}
133 %
134 % The various parts of the symbols. The keys \spec{upper} and
135 % \spec{lower} are aliases for \spec{top} and \spec{bottom},
136 % respectively. The choices are stored in macros
137 %
138 % \begin{macrocode}
139 \newif\ifnatoapp@decoy\natoapp@decoyfalse
140 \tikzset{
141 /natoapp6c/.cd,
142 main/.store in=\natoapp@main, main/.initial=,%
143 left/.store in=\natoapp@left, left/.initial=,%
144 right/.store in=\natoapp@right, right/.initial=,%
145 upper/.store in=\natoapp@upper, upper/.initial=,%
146 lower/.store in=\natoapp@lower, lower/.initial=,%
147 top/.store in=\natoapp@upper,%
148 bottom/.store in=\natoapp@lower,%
149 below/.store in=\natoapp@below, below/.initial=,%
150 frame/.store in=\natoapp@frame, frame/.initial=,%
151 decoy/.is if=natoapp@decoy,%
152 }
153 % \end{macrocode}
154 % \end{Macro}
155 % \end{NatoAppKey}
156 %
157 % \begin{TikzKey}{/tikz/natoapp6c/main,
158 % /tikz/natoapp6c/modifiers,
159 % /tikz/natoapp6c/lower,
160 % /tikz/natoapp6c/upper,
161 % /tikz/natoapp6c/left,
162 % /tikz/natoapp6c/right,
163 % /tikz/natoapp6c/echelon,
164 % /tikz/natoapp6c/below}
165 %
166 % Styles used by the various parts of the symbol.
167 %
168 % \begin{macrocode}
169 \tikzset{
170 natoapp6c/parts/.style={
171 scale line widths,
172 draw,
173 shape=rectangle,
174 transform shape},
175 natoapp6c/main/.style={natoapp6c/parts},
176 natoapp6c/modifiers/.style={natoapp6c/parts,scale=.6},
177 natoapp6c/lower/.style={natoapp6c/parts},
178 natoapp6c/upper/.style={natoapp6c/parts},
179 natoapp6c/left/.style={natoapp6c/parts},
180 natoapp6c/right/.style={natoapp6c/parts},
181 natoapp6c/echelon/.style={natoapp6c/parts},
182 natoapp6c/below/.style={natoapp6c/parts}
183 }
184 % \end{macrocode}
185 % \end{TikzKey}
186 % \iffalse
187 % --------------------------------------------------------------------
188 % \fi
189 %
190 % \subsubsection{The \texttt{natoapp6c} styles}
191 %
192 % \begin{TikzKey}{/tikz/natoapp6c}
193 % This key sets up a node to make a NATO App6(c) symbol. The key
194 % takes a single argument which in turn must contain key--value
195 % pairs in the \texttt{/natoapp6c} (or \texttt{/tikz}) namespace(s). We
196 % set the \texttt{shape} parameter of the node, and calls the passed
197 % keys in the \texttt{/natoapp6c} namespace to set-up elements of the
198 % chit.
199 %
200 % \begin{macrocode}
201 \tikzset{%
202 natoapp6c/.code={%
203 \pgfkeys{/tikz/transform shape,/tikz/shape=natoapp6c}
204 \pgfkeys{/natoapp6c/.cd,path=natoapp6c/s/,#1}}}
205 % \end{macrocode}
206 % \end{TikzKey}
207 %
208 % We define a counter to set-up unique names for symbol nodes.
209 %
210 % \begin{macrocode}
211 \newcounter{natoappid}\setcounter{natoappid}{0}
212 % \end{macrocode}
213 %
214 % \iffalse
215 % --------------------------------------------------------------------
216 % \fi
217 % \subsubsection{The \cs{natoapp6c} shape}
218 %
219 % \begin{Macro}{\ifn@to@pp@below,\ifn@to@pp@mod}
220 %
221 % We define an \cs{if} to allow us to detect if something is
222 % rendered below the frame
223 %
224 % \begin{macrocode}
225 \newif\ifn@to@pp@below\n@to@pp@belowfalse%
226 \newif\ifn@to@pp@mod\n@to@pp@modfalse%
227 % \end{macrocode}
228 % \end{Macro}
229 %
230 % \begin{NatoAppFrame}{natoapp6c}
231 %
232 % Next, we define the mother shape of NATO App6(c) nodes. This is a
233 % composite node with sub-nodes for the various parts (including the
234 % frame) of the symbol.
235 %
236 % It is quite complex so we will go through the implementation in
237 % bits.
238 %
239 % First, we make some saved anchors (the centre) and macros
240 % (identifier, frame type, and frame options).
241 %
242 % \begin{macrocode}
243 % \def\wg@n@to@p@th{}
244 \pgfdeclareshape{natoapp6c}{%
245 \savedanchor\center{\pgf@x=0cm\pgf@y=0cm}
246 \savedmacro\id{%
247 \n@to@pp@dbg{3}{NATO App6(c) id (set): \meaning\natoapp@id}
248 \@ifundefined{natoapp@id}{\let\natoapp@id\pgfutil@empty}{}%
249 \ifx\natoapp@id\pgfutil@empty\relax%
250 \wg@r@ndom@id%
251 \edef\id{natoapp6c\wg@uuid}%
252 \else%
253 \edef\id{\natoapp@id}%
254 \fi%
255 \n@to@pp@dbg{3}{NATO App6(c) id: \meaning\id}}
256 \savedmacro\frameshape{%
257 \let\frameshape\pgfutil@empty%
258 \@ifundefined{natoapp@cmd}{\def\frameshape{base}}{%
259 \edef\frameshape{\natoapp@cmd}
260 \@ifundefined{natoapp@fac}{\def\frameshape{base}}{%
261 \edef\frameshape{\natoapp@fac\space\frameshape}}}
262 \n@to@pp@dbg{3}{NATO App6(c) frame shape: \meaning\frameshape}}
263 \savedmacro\frameopt{%
264 \let\frameopt\pgfutil@empty%
265 \@ifundefined{natoapp@frame}{}{%
266 \edef\frameopt{\natoapp@frame}}
267 \n@to@pp@dbg{3}{NATO App6(c) Frame options: \meaning\frameopt}%
268 }
269 \savedmacro\thisname{\def\thisname{natoapp6c}}
270 % \end{macrocode}
271 %
272 % Then we define a number of regular anchors
273 %
274 % \begin{macrocode}
275 \anchor{center} {\center}
276 % \end{macrocode}
277 %
278 % The remaining anchors depend on the shape being used. We reference
279 % the anchors of the embedded node of the frame.
280 %
281 % \begin{macrocode}
282 \anchor{north east}{\wg@sub@nchor{M\id}{north east}}
283 \anchor{north west}{\wg@sub@nchor{M\id}{north west}}
284 \anchor{south east}{\wg@sub@nchor{M\id}{south east}}
285 \anchor{south west}{\wg@sub@nchor{M\id}{south west}}
286 \anchor{north} {\wg@sub@nchor{M\id}{north}}
287 \anchor{west} {\wg@sub@nchor{M\id}{west}}
288 \anchor{south} {\wg@sub@nchor{M\id}{south}}
289 \anchor{east} {\wg@sub@nchor{M\id}{east}}
290 \anchor{upper} {\wg@sub@nchor{M\id}{upper}}
291 \anchor{lower} {\wg@sub@nchor{M\id}{lower}}
292 \anchor{left} {\wg@sub@nchor{M\id}{left}}
293 \anchor{right} {\wg@sub@nchor{M\id}{right}}
294 % \end{macrocode}
295 %
296 % The next two anchors are a little funny.
297 %
298 % \begin{macrocode}
299 \anchor{echelon} {%
300 \wg@sub@nchor{M}{north}%
301 \wg@tmpa\pgflinewidth% by 1.5%
302 %\wg@getscale%
303 %\pgfmathparse{ifthenelse(\wg@scale>0.00001,\wg@tmpa/\wg@scale,\wg@tmpa)}
304 %\edef\wg@a{\pgfmathresult}\pgfmathsetlength{\wg@tmpa}{\wg@a pt}
305 %\n@to@pp@dbg{0}{Scale is `\wg@scale' -> `\the\wg@tmpa'}%
306 %\divide\wg@tmpa by \wg@scale%
307 \advance\wg@tmpa by\n@to@pp@e@y cm%
308 \advance\pgf@y\wg@tmpa%
309 }
310 \anchor{below} {%
311 \n@to@pp@dbg{3}{NATO App6(c) get below anchor}%
312 \wg@sub@nchor{M}{south}%
313 \wg@tmpa=\n@to@pp@e@yy cm%
314 \advance\wg@tmpa-\pgflinewidth% by 1.5%
315 \advance\pgf@y-\wg@tmpa%
316 }
317 % \end{macrocode}
318 %
319 % All right, so time to make the actual frame. Note that we do this
320 % in a `behind' path so we can actually draw stuff. First, we flag
321 % that we're not in a modifier, nor in the `below' part.
322 %
323 % \begin{macrocode}
324 \behindbackgroundpath{%
325 \wg@ignore@sub@nchortrue%
326 \n@to@pp@dbg{3}{NATO App6(c) Before print}
327 \n@to@pp@dbg{3}{NATO App6(c) background path: \meaning\id
328 ^^J ID: \meaning\natoapp@id
329 ^^J Faction: \meaning\natoapp@fac
330 ^^J Command: \meaning\natoapp@cmd
331 ^^J Echelon: \meaning\natoapp@ech
332 ^^J Main: \meaning\natoapp@main
333 ^^J Left: \meaning\natoapp@left
334 ^^J Right: \meaning\natoapp@right
335 ^^J Upper: \meaning\natoapp@upper
336 ^^J Lower: \meaning\natoapp@lower
337 ^^J Below: \meaning\natoapp@below
338 ^^J Shape: \meaning\frameshape
339 ^^J Options: \meaning\frameopt}
340 \natoapp@report
341 \n@to@pp@modfalse
342 \n@to@pp@belowfalse
343 % \end{macrocode}
344 %
345 % If the symbol is empty, then do nothing.
346 %
347 % \begin{macrocode}
348 \ifx\frameshape\pgfutil@empty%
349 \n@to@pp@dbg{2}{NATO App6(c) has no frame!}
350 \else
351 % \end{macrocode}
352 %
353 % We start a scope because we want to do some clipping here. Then, we
354 % use the frame to clip the remaining part. Note that we do this via
355 % a node which we give the identifier \spec{M}. Various elements of
356 % the symbol can then refer to this shape to define paths, etc.
357 %
358 % \begin{macrocode}
359 \begin{scope}
360 \pgfinterruptboundingbox
361 %% Clip to shape in scope
362 %% \message{^^JClipping to NATO App6(c) shape}
363 \n@to@pp@iscliptrue%
364 \n@to@pp@dbg{1}{NATO App6(c) frame node M (clip)}
365 \pgfnode{natoapp6c \frameshape}{center}{}{M}{\pgfusepath{clip}}
366 \n@to@pp@isclipfalse%
367 % \end{macrocode}
368 %
369 % Next, we should see if we need to fill the frame. We do that by
370 % expanding the passed \spec{frame} key-values in a scope, and
371 % \emph{then} get the fill colour.
372 %
373 % \begin{macrocode}
374 %% Start new scope including frame key options
375 \edef\tmp@opt{[\frameopt]}
376 \expandafter\scope\tmp@opt
377 % Get fill color {possibly from frame key}
378 \expandafter\let\expandafter\tmp@fill%
379 \csname\string\color@pgffillcolor\endcsname%
380 % \end{macrocode}
381 %
382 % If the fill colour is not \cs{relax}, then we fill the frame. Note
383 % that this is done in the background, so when we draw in the
384 % foreground we will render on top of the fill.
385 %
386 % \begin{macrocode}
387 % Check if we need to fill shape (fill colour us not \relax)
388 \ifx\tmp@fill\relax\else%
389 \n@to@pp@dbg{2}{NATO App6(c) frame fill}
390 \pgfnode{natoapp6c \frameshape}{center}{}{}{\pgfusepath{fill}}%
391 \fi%
392 % End the fill scope
393 \endscope%
394 % \end{macrocode}
395 %
396 % Now we need to render some of the elements of the symbol. We start
397 % with the main elements. We can specify many main elements (to make
398 % composite symbols).
399 %
400 % \begin{macrocode}
401 % Render mains
402 \@ifundefined{natoapp@main}{}{
403 \n@to@pp@dbg{1}{NATO App6(c) mains: \meaning\natoapp@main}
404 \begin{scope}[natoapp6c/main]
405 \n@to@pp@dbg{1}{NATO symbol path `\n@to@ppp@th'}
406 \wg@pic@all{\natoapp@main}{\n@to@ppp@th}{M.center}{natoapp6c/main}%
407 \end{scope}}%
408 % Modififiers flagged
409 % \end{macrocode}
410 %
411 % The next thing is to render the various modifiers. We start by
412 % flagging this globally.
413 %
414 % \begin{macrocode}
415 \n@to@pp@modtrue
416 \n@to@pp@dbg{2}{NATO App6(c) modifiers}
417 % \end{macrocode}
418 %
419 % Below we render the lower, upper, left, and right elements. This is
420 % all done in the same way. Note that the elements positions are
421 % dictated by anchors of the frame shape (via shape identifier
422 % \spec{M}).
423 %
424 % \begin{macrocode}
425 % Render lowers
426 \@ifundefined{natoapp@lower}{}{%
427 \begin{scope}%
428 \wg@pic@all{\natoapp@lower}{natoapp6c/s/}{M.lower}{%
429 natoapp6c/modifiers,natoapp6c/lower}%
430 \end{scope}}%
431 % Render uppers
432 \@ifundefined{natoapp@upper}{}{%
433 \begin{scope}[]
434 \wg@pic@all{\natoapp@upper}{natoapp6c/s/}{M.upper}{%
435 natoapp6c/modifiers,natoapp6c/upper}%
436 \end{scope}}%
437 % Render lefts
438 \@ifundefined{natoapp@left}{}{%
439 \begin{scope}[]
440 \wg@pic@all{\natoapp@left}{natoapp6c/s/}{M.left}{%
441 natoapp6c/modifiers,natoapp6c/left}%
442 \end{scope}}%
443 % Render rights
444 \@ifundefined{natoapp@right}{}{%
445 \begin{scope}[]
446 \wg@pic@all{\natoapp@right}{natoapp6c/s/}{M.right}{%
447 natoapp6c/modifiers,natoapp6c/right}%
448 \end{scope}}%
449 % Modififiers end
450 \n@to@pp@modfalse%
451 \endpgfinterruptboundingbox
452 \end{scope}%
453 \fi%
454 \wg@ignore@sub@nchorfalse%
455 }
456 % \end{macrocode}
457 %
458 % That concludes rendering most of the symbol. We have not put in the
459 % echelon, below element, or drawn the frame yet. That we will do on
460 % the foreground path.
461 %
462 % \begin{macrocode}
463 % \end{macrocode}
464 %
465 % In the foreground `behind' path we render the echelon, below
466 % element, and draw the frame.
467 %
468 % \begin{macrocode}
469 \behindforegroundpath{%
470 \wg@ignore@sub@nchortrue%
471 \n@to@pp@dbg{2}{NATO App6(c) foreground path: `\meaning\id'
472 ^^J Echelon: \meaning\natoapp@ech
473 ^^J Symbol: \meaning\frameshape
474 ^^J Below: \meaning\natoapp@below
475 ^^J Frame: \meaning\frameopt}
476 %
477 %
478 % \end{macrocode}
479 %
480 % We check if we have a frame. If not, stop.
481 %
482 % \begin{macrocode}
483 \ifx\frameshape\pgfutil@empty%
484 \n@to@pp@dbg{2}{NATO App6(c) has no frame shape!}%
485 \else%
486 % \end{macrocode}
487 %
488 % We want to draw the rest of the symbol as a part of the frame, so we
489 % expand the \spec{frame} options in a scope.
490 %
491 % \begin{macrocode}
492 \edef\tmp@opt{[\frameopt]}
493 \expandafter\scope\tmp@opt
494 % \end{macrocode}
495 %
496 % First thing in this scope is to draw the actual frame. Again, this
497 % is done via a node with the right shape. Note that we label this
498 % node as \spec{M}\meta{id} so we way refer to it later on.
499 %
500 % \begin{macrocode}
501 \edef\mid{M\id{}}
502 \n@to@pp@dbg{1}{NATO App6(c) inner node `M\id' ===}
503 \pgfnode{natoapp6c \frameshape}{center}{}{M\id}{\pgfusepath{stroke}}
504 \wg@ignore@sub@nchorfalse%
505 % \end{macrocode}
506 %
507 % If the user gave an echelon, then put that in. Note that echelons
508 % are limited to predefined values.
509 %
510 % \begin{macrocode}
511 % Put in the echelon
512 \n@to@pp@dbg{2}{Echelon}
513 \@ifundefined{natoapp@ech}{}{%
514 \ifx\natoapp@ech\pgfutil@empty\else%
515 \def\args{echelon=\natoapp@ech}
516 \n@to@pp@dbg{3}{Make the echelon}%
517 \wg@nchor{\thisname}{echelon}%
518 \expandafter\wg@pic\args\@endwg@pic%
519 {natoapp6c/s/}{\pgf@x,\pgf@y}{natoapp6c/echelon}
520 \fi%
521 }
522 % \end{macrocode}
523 %
524 % If the user want something under the frame, put that in.
525 %
526 % \begin{macrocode}
527 % Put in stuff below main
528 \n@to@pp@dbg{2}{Below}
529 \@ifundefined{natoapp@below}{}{%
530 \n@to@pp@belowtrue
531 \begin{scope}
532 \n@to@pp@dbg{3}{Make below}%
533 \wg@nchor{\thisname}{below}%
534 \wg@pic@all{\natoapp@below}{natoapp6c/s/}{\pgf@x,\pgf@y}{%
535 natoapp6c/below}%
536 \end{scope}%
537 \n@to@pp@belowfalse}
538 % \end{macrocode}
539 %
540 % If the \spec{decoy} flag was set, we draw that.
541 %
542 % \begin{macrocode}
543 \n@to@pp@dbg{2}{Decoy}
544 \ifnatoapp@decoy%
545 \scope[dash pattern=on 3\pgflinewidth off 2\pgflinewidth]%
546 \n@to@pp@dbg{1}{Drawing decoy modifier}%
547 \wg@sub@nchor{M\id}{north east}
548 \wg@tmpa=\pgf@x%
549 \wg@tmpb=\pgf@y%
550 \pgfpathmoveto{\pgfqpoint{\wg@tmpa}{\wg@tmpb}}%
551 \wg@tmpc=\n@to@pp@e@yy cm%
552 \advance\wg@tmpc\n@to@pp@e@yy cm%
553 \advance\wg@tmpc\wg@tmpb%
554 \pgfpathlineto{\pgfqpoint{0cm}{\wg@tmpc}}%
555 \pgfpathlineto{\pgfqpoint{-\wg@tmpa}{\wg@tmpb}}%
556 \pgfusepath{stroke}%
557 \endscope%
558 \fi%
559 \endscope%
560 \fi%
561 \wg@ignore@sub@nchorfalse%
562 }
563 }
564 % \end{macrocode}
565 %
566 % That finished the shape for NATO App6(c) symbols. We could stop
567 % here, but for convenience we define a wrapper macro.
568 %
569 % \end{NatoAppFrame}
570 %
571 % \iffalse
572 % --------------------------------------------------------------------
573 % \fi
574 % \subsubsection{The \cs{natoapp} wrapper macro}
575 %
576 % \begin{Macro}{\natoapp}
577 %
578 % This is a wrapper macro for inserting a node with a NATO App6(c)
579 % symbol in it. The syntax of the macro is
580 %
581 % \begin{Syntax}
582 % \cs{natoapp}\oarg{natoapp6c options}\parg{position}\parg{identifier};
583 % \end{Syntax}
584 %
585 % Note that the trailing semi-colon (\spec{;}) is optional.
586 %
587 % This macro forwards to \cs{n@toapp}.
588 %
589 % \begin{macrocode}
590 \newcommand\natoapp[1][]{%
591 \n@to@pp@dbg{2}{NATO App6(c) macro -> `#1'}
592 \tikzset{/natoapp6c/.cd,faction=friendly,command=land}%
593 \@ifnextchar({\n@toapp{#1}}{\n@toapp{#1}(0,0)}%)
594 }
595 % \end{macrocode}
596 % \end{Macro}
597 %
598 % \begin{Macro}{\n@toapp}
599 %
600 % This macro takes care to parse the location argument --- if any.
601 % It forwards to \cs{n@to@pp}.
602 %
603 % \begin{macrocode}
604 \def\n@toapp#1(#2){%
605 \n@to@pp@dbg{2}{NATO App6(c) second macro -> `#1', `#2'}
606 \@ifnextchar({\n@to@pp{#1}{#2}}{\n@to@pp{#1}{#2}()}%)
607 }
608 % \end{macrocode}
609 % \end{Macro}
610 %
611 %
612 % \begin{Macro}{\n@to@pp}
613 % This is the main work-horse of the wrapper. It makes a node with
614 % the shape \spec{natoapp6c} passing the relevant parameters. The
615 % syntax of the macro is
616 %
617 % \begin{macrocode}
618 \def\n@to@pp#1#2(#3){%
619 \node[draw,transform shape,natoapp6c={#1}] (#3) at (#2) {};%
620 \@ifnextchar;{\@gobble}{}}
621 % \end{macrocode}
622 % \end{Macro}
623 %
624 %
625 % \iffalse
626 % --------------------------------------------------------------------
627 % \fi
628 % \subsubsection{Kriegspiel-like symbols}
629 %
630 % Style that selects Kriegspiel-like symbols by setting the symbols
631 % picture path.
632 %
633 % \begin{macrocode}
634 \tikzset{
635 kriegspiel symbol/.code={
636 \pgfkeys{%
637 /tikz/transform shape,%
638 /tikz/shape=kriegspiel symbol}
639 \n@to@pp@dbg{10}{Args for symbol `#1'}
640 \pgfkeys{/natoapp6c/.cd,%
641 path=kriegspiel/s/,%
642 #1}
643 }
644 }
645 % \end{macrocode}
646 %
647 % Shape of Kriegspiel-like symbols (always the same). This mainly
648 % inherits from the NATO shape. This hard-codes the frame shape to be
649 % \texttt{kriegspiel} (shape \texttt{natoapp6c kriegspiel}).
650 %
651 % \begin{macrocode}
652 \pgfdeclareshape{kriegspiel symbol}{
653 \inheritsavedanchors[from=natoapp6c]
654 \savedmacro\frameshape{%
655 \def\frameshape{kriegspiel}}
656 \inheritanchor[from=natoapp6c]{center}
657 \inheritanchor[from=natoapp6c]{north east}
658 \inheritanchor[from=natoapp6c]{north west}
659 \inheritanchor[from=natoapp6c]{south east}
660 \inheritanchor[from=natoapp6c]{south west}
661 \inheritanchor[from=natoapp6c]{north}
662 \inheritanchor[from=natoapp6c]{west}
663 \inheritanchor[from=natoapp6c]{south}
664 \inheritanchor[from=natoapp6c]{east}
665 \inheritanchor[from=natoapp6c]{upper}
666 \inheritanchor[from=natoapp6c]{lower}
667 \inheritanchor[from=natoapp6c]{left}
668 \inheritanchor[from=natoapp6c]{right}
669 \anchor{echelon} {%
670 \wg@sub@nchor{M\id}{north west}%
671 \wg@tmpa=\n@to@pp@e@y cm%
672 \divide\wg@tmpa by 2%
673 \advance\pgf@y\wg@tmpa%
674 }%
675 \inheritbackgroundpath[from=natoapp6c]
676 \inheritbehindforegroundpath[from=natoapp6c]
677 \inheritbehindbackgroundpath[from=natoapp6c]
678 \savedmacro\thisname{\def\thisname{kriegspiel symbol}}
679 }
680 % \end{macrocode}
681 %
682 % The shape of a Kriegspiel-like frame. Always the same. This never
683 % draws the background path.
684 %
685 % \begin{macrocode}
686 \pgfdeclareshape{natoapp6c kriegspiel}{
687 \inheritsavedanchors[from=rectangle]
688 \inheritbackgroundpath[from=rectangle]
689 \savedanchor\northeast{\pgf@x=1.4cm\pgf@y=.3125cm}
690 \savedanchor\southwest{\pgf@x=-1.4cm\pgf@y=-.3125cm}
691 \inheritanchor[from=rectangle]{center}
692 \inheritanchor[from=rectangle]{north east}
693 \inheritanchor[from=rectangle]{north west}
694 \inheritanchor[from=rectangle]{south east}
695 \inheritanchor[from=rectangle]{south west}
696 \inheritanchor[from=rectangle]{north}
697 \inheritanchor[from=rectangle]{west}
698 \inheritanchor[from=rectangle]{south}
699 \inheritanchor[from=rectangle]{east}
700 \backgroundpath{}
701 }
702 % \end{macrocode}
703 %
704 % Now some symbols. We do not define a whole lot, since we do not
705 % need that for Kriegspiel-like counters.
706 %
707 % \begin{macrocode}
708 \tikzset{
709 ks debug frame/.style={
710 draw=none,
711 %draw=magenta,
712 %dashed,
713 },
714 kriegspiel/s/infantry/.pic={
715 \coordinate(a) at (M.south west);
716 \coordinate(b) at ($(M.north east)+(0,-.2)$);
717 \@ifundefinedcolor{pgffillcolor}{}{
718 \path[fill=pgffillcolor](a)rectangle(b);}
719 \path[pic actions,fill=none](a)rectangle(b);
720 \path[pic actions,fill=none](a)--(b);
721 \path[pic actions,fill=none] let
722 \p1=(a),\p2=(b) in (\x2,\y1)--(\x1,\y2);
723 \path[fill=pgfstrokecolor] let
724 \p2=(b) in (-.05,\y2)rectangle++(.1,.2);
725 \draw[ks debug frame](M.south west)rectangle(M.north east);
726 },
727 kriegspiel/s/reconnaissance/.pic={
728 \coordinate(a) at (M.south west);
729 \coordinate(b) at ($(M.north east)+(0,-.2)$);
730 \@ifundefinedcolor{pgffillcolor}{}{
731 \path[fill=pgffillcolor](a)rectangle(b);}
732 \path[pic actions,fill=none](a)rectangle(b);
733 \path[fill=pgfstrokecolor] (a)--(b)--(a|-b)--cycle;
734 \path[fill=pgfstrokecolor] let
735 \p2=(b) in
736 (-.05,\y2)--++(0,.2)--++(-10:.4)--++(-170:.3)--(.05,\y2)--cycle;
737 \draw[ks debug frame](M.south west)rectangle(M.north east);
738 },
739 kriegspiel/s/artillery/.pic={
740 \coordinate(a) at (M.south west);
741 \coordinate(b) at ($(M.north east)+(0,-.5)$);
742 \@ifundefinedcolor{pgffillcolor}{}{
743 \path[fill=pgffillcolor](a)rectangle(b);}
744 \path[pic actions,fill=none](a)rectangle(b);
745 \foreach \s in {-.8,0,.8}{
746 \path[fill=pgfstrokecolor] let
747 \p2=(b),%
748 \n1={\y2+\pgflinewidth} in
749 (\s-.04,\y2)rectangle++( .08,.5)
750 ($(\s-.18,\n1)+(0,.05)$)rectangle++( .08,.2)
751 ($(\s+.18,\n1)+(0,.05)$)rectangle++(-.08,.2);
752 }
753 \draw[ks debug frame](M.south west)rectangle(M.north east);
754 },
755 kriegspiel/s/reconnaissance artillery/.pic={
756 \coordinate(a) at (M.south west);
757 \coordinate(b) at ($(M.north east)+(0,-.5)$);
758 \@ifundefinedcolor{pgffillcolor}{}{
759 \path[fill=pgffillcolor](a)rectangle(b);}
760 \path[pic actions,fill=none](a)rectangle(b);
761 \path[fill=pgfstrokecolor] (a)--(b)--(a|-b)--cycle;
762 \foreach \s in {-.8,0,.8}{
763 \path[fill=pgfstrokecolor] let
764 \p2=(b),%
765 \n1={\y2+\pgflinewidth} in
766 (\s-.04,\y2)rectangle++( .08,.5)
767 ($(\s-.18,\n1)+(0,.05)$)rectangle++( .08,.2)
768 ($(\s+.18,\n1)+(0,.05)$)rectangle++(-.08,.2);
769 }
770 \draw[ks debug frame](M.south west)rectangle(M.north east);
771 }
772 }
773
774 % \end{macrocode}
775 %
776 % \iffalse
777 % --------------------------------------------------------------------
778 % \fi
779 % \subsubsection{Macros for markings}
780 %
781 % \begin{Macro}{\natoappmark}
782 %
783 % A macro for making NATO App6(c) markings.
784 %
785 % \begin{macrocode}
786 \providecommand\natoappmark[2][]{%
787 \tikz[transform shape,
788 scale=.25,
789 baseline=(natoapp6c mark.south east),
790 natoapp6c mark/.try,
791 #1]{%1
792 \node[draw,transform
793 shape,natoapp6c={faction=friendly,command=land,
794 main=#2}] (natoapp6c mark){}}}
795 % \natoapp[faction=friendly,command=land,main=#2](0,0)(natoapp6c mark)}}
796 % \end{macrocode}
797 % \end{Macro}
798 %
799 % \begin{Macro}{\echelonmark}
800 % \begin{macrocode}
801 \providecommand\echelonmark[2][]{\tikz[transform shape,scale=.5,#1]{%
802 \pic[scale line widths,line width=1pt] {natoapp6c/s/echelon=#2};}}
803 % \end{macrocode}
804 % \end{Macro}
805 %
806 % Some specific NATO App6(c) markers.
807 %
808 % \begin{macrocode}
809 \DeclareRobustCommand\armouredmark[1][]{\natoappmark[#1]{armoured}}
810 \DeclareRobustCommand\infantrymark[1][]{\natoappmark[#1]{infantry}}
811 \DeclareRobustCommand\artillerymark[1][]{%
812 \natoappmark[#1]{{[fill=pgfstrokecolor]artillery}}}
813 \DeclareRobustCommand\combinedmark[1][]{\natoappmark[#1]{combined arms}}
814 \DeclareRobustCommand\pgmark[1][] {\natoappmark[#1]{{armoured,infantry}}}
815 \DeclareRobustCommand\reconnaissancemark[1][]{\natoappmark[#1]{reconnaissance}}
816 \DeclareRobustCommand\corpsmark[1][]{\natoappmark[#1]{,echelon=corps}}
817 \DeclareRobustCommand\divisionmark[1][]{\natoappmark[#1]{,echelon=division}}
818 \DeclareRobustCommand\brigademark[1][] {\natoappmark[#1]{,echelon=brigade}}
819 \DeclareRobustCommand\regimentmark[1][]{\natoappmark[#1]{,echelon=regiment}}
820 \DeclareRobustCommand\sofmark[1][] {\natoappmark[#1]{{infantry,text=SOF}}}
821 \DeclareRobustCommand\mountaineermark[1][]{%
822 \natoappmark[#1]{infantry,lower=mountain}}
823 \DeclareRobustCommand\airbornemark[1][]{%
824 \natoappmark[#1]{infantry,lower=airborne}}
825 \DeclareRobustCommand\amphibiousmark[1][]{\natoappmark[#1]{,lower=amphibious}}
826 \DeclareRobustCommand\airassaultmark[1][]{%
827 \natoappmark[#1]{infantry,upper=air assault}}
828 % \end{macrocode}
829 % \iffalse
830 % </natoapp6c>
831 % --------------------------------------------------------------------
832 % \fi