summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/wargame/source/natoapp6c/core.dtx
blob: 8a2caf322eaf8408980d48ad81e3667842adae21 (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
% \iffalse
% ====================================================================
% \fi
% 
% \subsection{The \texttt{wargame.natoapp6c} \TikZ{} library}
%
% In this section we define the code for the Tikz library. The
% library defines a number of \spec{pic} keys we can use to draw
% various parts of a marker.  The markers conform to NATO App~6(c)
% specification.  The implementation here is heavily inspired by the
% package \textsf{milsymb} \cite{milsymb} available at CTAN.
%
% \iffalse
%<*natoapp6c>
% \fi
%
%
% \iffalse
% --------------------------------------------------------------------
% \fi
% \subsubsection{Debugging}
% \begin{Macro}{\natoappdbglvl,\n@to@pp@dbg}
%
%   Set the debug level, and make debug message. 
%
%    \begin{macrocode}
\usetikzlibrary{wargame.util}
\usetikzlibrary{calc}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{shapes.symbols}
\usetikzlibrary{positioning,intersections}
\newcount\natoappdbglvl\natoappdbglvl=\wargamedbglvl
\def\n@to@pp@dbg#1#2{%
  \ifnum#1>\natoappdbglvl\relax\else\message{^^J#2}\fi}
%    \end{macrocode}
% \end{Macro}
% 
% \iffalse
% --------------------------------------------------------------------
% \fi
% \subsubsection{Colours}
%
% \begin{Macro}{\c@friendly,
%               \c@hostile,
%               \c@neutral,
%               \c@unknown}
%
%   Define standard colours for marker affiliations.
%
% \begin{tabular}{|l|c|}
%     \hline
%     \rowcolor{headbg}
%     {\color{headfg}\textbf{Name}}
%     & {}\\
%     \hline
%     \spec{friendly} & \tikz{\draw[fill=friendly] (0,0) rectangle(1,.2);}\\ 
%     \spec{hostile}  & \tikz{\draw[fill=hostile ] (0,0) rectangle(1,.2);}\\
%     \spec{neutral}  & \tikz{\draw[fill=neutral ] (0,0) rectangle(1,.2);}\\
%     \spec{unknown}  & \tikz{\draw[fill=unknown ] (0,0) rectangle(1,.2);}\\
%     \hline
%   \end{tabular}
%
%    \begin{macrocode}
\definecolor{friendly}{RGB}{128, 224, 255}
\definecolor{hostile}{RGB}{255, 128, 128}
\definecolor{neutral}{RGB}{170, 255, 170}
\definecolor{unknown}{RGB}{255, 255, 128}
\tikzset{%
  faction/.code={%
    \@ifundefined{natoapp@fac}{%
    }{\tikzset{fill=\natoapp@fac}}}}
%    \end{macrocode}
% \end{Macro}
%
% 
% \iffalse
% --------------------------------------------------------------------
% \fi
% \subsubsection{Some dimensions}
%
% We define a number of dimensions which we will use in the
% following.  They provide a rough parameterisation of the node
% shapes, but shouldn't really be changed.  We have them here so that
% the code uses as few hard coded numbers as possible.
%
% The dimensions are
% \begin{itemize}
% \item Installation `hat' $x$ coordinate
% \item Installation `hat' height
% \item Activity width of boxes
% \item Height of space bar
% \item Radius of the symbol 
% \end{itemize}
% 
%    \begin{macrocode}
\newdimen\n@to@pp@inst@x\n@to@pp@inst@x=0.2cm
\newdimen\n@to@pp@inst@h\n@to@pp@inst@h=0.15cm
\newdimen\n@to@pp@act@w\n@to@pp@act@w=0.15cm
\newdimen\n@to@pp@space@h\n@to@pp@space@h=0.1cm
\newdimen\n@to@pp@r\n@to@pp@r=0.5cm
%    \end{macrocode}
% 
% \iffalse
% --------------------------------------------------------------------
% \fi
% \subsubsection{Some utilities}
%
% \begin{Macro}{\n@to@pp@isclip}
%   This detects if we're in a node that is being used for clipping
%
%    \begin{macrocode}
%\def\n@to@pp@cliptoken{clip}
%\def\n@to@pp@isclip{FF\fi%
%  % \message{^^Jclip is \meaning\pgf@up@clip}%
%  \ifx\pgf@up@clip\n@to@pp@cliptoken}
\newif\ifn@to@pp@isclip\n@to@pp@isclipfalse
%    \end{macrocode}
% \end{Macro}
%
%
% \begin{Macro}{\n@to@pp@saved@fill@color,\n@to@pp@saved@stroke@color}
%
%   Macros to hold saved colours.

%    \begin{macrocode}
\let\n@to@pp@saved@stroke@color\relax
\let\n@to@pp@saved@fill@color\relax
%    \end{macrocode}
% \end{Macro}
%
% \begin{Macro}{\n@to@pp@stroke@to@fill,\n@to@pp@restore@fill}
%   Macro to get stroke and fill colours and set the fill colour to
%   the stroke colour, and to restore to the old setting.  This is
%   used by the frame shapes below to make sure that filled elements
%   of the frame uses the same colour as the for strokes.
%   
%    \begin{macrocode}
\newcommand\n@to@pp@stroke@to@fill{%
  %
  \expandafter\let\expandafter\n@to@pp@saved@stroke@color%
  \csname\string\color@pgfstrokecolor\endcsname%
  %                           
  \expandafter\let\expandafter\n@to@pp@saved@fill@color%
  \csname\string\color@pgffillcolor\endcsname%
  %
  \expandafter\pgf@setfillcolor\n@to@pp@saved@stroke@color%
  %
  % \message{^^J=== Set fill to stroke color
  %   ^^J  Old fill:   \meaning\n@to@pp@saved@fill@color
  %   ^^J  Old stroke: \meaning\n@to@pp@saved@stroke@color}
}
%    \end{macrocode}
%
%
% 
%    \begin{macrocode}
\newcommand\n@to@pp@restore@fill{%
  % \message{^^J=== Restore fill color
  %   ^^J  Old fill:   \meaning\n@to@pp@saved@fill@color
  %   ^^J  Old stroke: \meaning\n@to@pp@saved@stroke@color}
  %
  \ifx\n@to@pp@saved@fill@color\relax\else%
    \expandafter\pgf@setfillcolor\n@to@pp@saved@fill@color%
  \fi%
  \global\let\n@to@pp@saved@fill@color\relax
  \global\let\n@to@pp@saved@stroke@color\relax
}
%    \end{macrocode}
%
% We also make an environment, just to simplify the use
% 
%    \begin{macrocode}
\newenvironment{n@to@pp@stroketofill}{%
  \pgfscope%
  \n@to@pp@stroke@to@fill%
}{%
  \n@to@pp@restore@fill%
  \endpgfscope%
}
%    \end{macrocode}
% \end{Macro}
%
% \iffalse
% --------------------------------------------------------------------
% \fi
% \subsubsection{Faction names as macros}
% 
%    \begin{macrocode}
\def\n@to@pp@friendly{friendly}
\def\n@to@pp@hostile{hostile}
\def\n@to@pp@neutral{neutral}
\def\n@to@pp@unknown{unknown}
%    \end{macrocode}
%
% \iffalse
% --------------------------------------------------------------------
% \fi
% \subsubsection{Node shapes}
%
% Here we define bases for all commands and affiliations.  These are
% defined as node shapes.  This means we will render the NATO App6(c)
% symbols as nodes with embedded nodes of the relevant shape. 
%
%
%
% \input{natoapp6c/frames/base.dtx}
% \input{natoapp6c/frames/friendly.dtx}
% \input{natoapp6c/frames/hostile.dtx}
% \input{natoapp6c/frames/neutral.dtx}
% \input{natoapp6c/frames/unknown.dtx}
% 
% \iffalse
% --------------------------------------------------------------------
% \fi
%
% \input{natoapp6c/echelon.dtx}
% \input{natoapp6c/text.dtx}
% \input{natoapp6c/shape.dtx}
% \input{natoapp6c/util.dtx}
% \input{natoapp6c/weaponry.dtx}
% \input{natoapp6c/symbols.dtx}
% \input{natoapp6c/list.dtx}
% \iffalse
% </natoapp6c>
% --------------------------------------------------------------------
% \fi