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