| 1 |
% \iffalse |
| 2 |
% ==================================================================== |
| 3 |
% \fi |
| 4 |
% |
| 5 |
% \subsection{The \texttt{wargame.natoapp6c} \TikZ{} library} |
| 6 |
% |
| 7 |
% In this section we define the code for the Tikz library. The |
| 8 |
% library defines a number of \spec{pic} keys we can use to draw |
| 9 |
% various parts of a marker. The markers conform to NATO App~6(c) |
| 10 |
% specification. The implementation here is heavily inspired by the |
| 11 |
% package \textsf{milsymb} \cite{milsymb} available at CTAN. |
| 12 |
% |
| 13 |
% \iffalse |
| 14 |
%<*natoapp6c> |
| 15 |
% \fi |
| 16 |
% |
| 17 |
% |
| 18 |
% \iffalse |
| 19 |
% -------------------------------------------------------------------- |
| 20 |
% \fi |
| 21 |
% \subsubsection{Debugging} |
| 22 |
% \begin{Macro}{\natoappdbglvl,\n@to@pp@dbg} |
| 23 |
% |
| 24 |
% Set the debug level, and make debug message. |
| 25 |
% |
| 26 |
% \begin{macrocode} |
| 27 |
\usetikzlibrary{wargame.util} |
| 28 |
\usetikzlibrary{calc} |
| 29 |
\usetikzlibrary{arrows.meta} |
| 30 |
\usetikzlibrary{shapes.symbols} |
| 31 |
\usetikzlibrary{positioning,intersections} |
| 32 |
\newcount\natoappdbglvl\natoappdbglvl=\wargamedbglvl |
| 33 |
\def\n@to@pp@dbg#1#2{% |
| 34 |
\ifnum#1>\natoappdbglvl\relax\else\message{^^J#2}\fi} |
| 35 |
% \end{macrocode} |
| 36 |
% \end{Macro} |
| 37 |
% |
| 38 |
% \iffalse |
| 39 |
% -------------------------------------------------------------------- |
| 40 |
% \fi |
| 41 |
% \subsubsection{Colours} |
| 42 |
% |
| 43 |
% \begin{Macro}{\c@friendly, |
| 44 |
% \c@hostile, |
| 45 |
% \c@neutral, |
| 46 |
% \c@unknown} |
| 47 |
% |
| 48 |
% Define standard colours for marker affiliations. |
| 49 |
% |
| 50 |
% \begin{tabular}{|l|c|} |
| 51 |
% \hline |
| 52 |
% \rowcolor{headbg} |
| 53 |
% {\color{headfg}\textbf{Name}} |
| 54 |
% & {}\\ |
| 55 |
% \hline |
| 56 |
% \spec{friendly} & \tikz{\draw[fill=friendly] (0,0) rectangle(1,.2);}\\ |
| 57 |
% \spec{hostile} & \tikz{\draw[fill=hostile ] (0,0) rectangle(1,.2);}\\ |
| 58 |
% \spec{neutral} & \tikz{\draw[fill=neutral ] (0,0) rectangle(1,.2);}\\ |
| 59 |
% \spec{unknown} & \tikz{\draw[fill=unknown ] (0,0) rectangle(1,.2);}\\ |
| 60 |
% \hline |
| 61 |
% \end{tabular} |
| 62 |
% |
| 63 |
% \begin{macrocode} |
| 64 |
\definecolor{friendly}{RGB}{128, 224, 255} |
| 65 |
\definecolor{hostile}{RGB}{255, 128, 128} |
| 66 |
\definecolor{neutral}{RGB}{170, 255, 170} |
| 67 |
\definecolor{unknown}{RGB}{255, 255, 128} |
| 68 |
\tikzset{% |
| 69 |
faction/.code={% |
| 70 |
\@ifundefined{natoapp@fac}{% |
| 71 |
}{\tikzset{fill=\natoapp@fac}}}} |
| 72 |
% \end{macrocode} |
| 73 |
% \end{Macro} |
| 74 |
% |
| 75 |
% |
| 76 |
% \iffalse |
| 77 |
% -------------------------------------------------------------------- |
| 78 |
% \fi |
| 79 |
% \subsubsection{Some dimensions} |
| 80 |
% |
| 81 |
% We define a number of dimensions which we will use in the |
| 82 |
% following. They provide a rough parameterisation of the node |
| 83 |
% shapes, but shouldn't really be changed. We have them here so that |
| 84 |
% the code uses as few hard coded numbers as possible. |
| 85 |
% |
| 86 |
% The dimensions are |
| 87 |
% \begin{itemize} |
| 88 |
% \item Installation `hat' $x$ coordinate |
| 89 |
% \item Installation `hat' height |
| 90 |
% \item Activity width of boxes |
| 91 |
% \item Height of space bar |
| 92 |
% \item Radius of the symbol |
| 93 |
% \end{itemize} |
| 94 |
% |
| 95 |
% \begin{macrocode} |
| 96 |
\newdimen\n@to@pp@inst@x\n@to@pp@inst@x=0.2cm |
| 97 |
\newdimen\n@to@pp@inst@h\n@to@pp@inst@h=0.15cm |
| 98 |
\newdimen\n@to@pp@act@w\n@to@pp@act@w=0.15cm |
| 99 |
\newdimen\n@to@pp@space@h\n@to@pp@space@h=0.1cm |
| 100 |
\newdimen\n@to@pp@r\n@to@pp@r=0.5cm |
| 101 |
% \end{macrocode} |
| 102 |
% |
| 103 |
% \iffalse |
| 104 |
% -------------------------------------------------------------------- |
| 105 |
% \fi |
| 106 |
% \subsubsection{Some utilities} |
| 107 |
% |
| 108 |
% \begin{Macro}{\n@to@pp@isclip} |
| 109 |
% This detects if we're in a node that is being used for clipping |
| 110 |
% |
| 111 |
% \begin{macrocode} |
| 112 |
%\def\n@to@pp@cliptoken{clip} |
| 113 |
%\def\n@to@pp@isclip{FF\fi% |
| 114 |
% % \message{^^Jclip is \meaning\pgf@up@clip}% |
| 115 |
% \ifx\pgf@up@clip\n@to@pp@cliptoken} |
| 116 |
\newif\ifn@to@pp@isclip\n@to@pp@isclipfalse |
| 117 |
% \end{macrocode} |
| 118 |
% \end{Macro} |
| 119 |
% |
| 120 |
% |
| 121 |
% \begin{Macro}{\n@to@pp@saved@fill@color,\n@to@pp@saved@stroke@color} |
| 122 |
% |
| 123 |
% Macros to hold saved colours. |
| 124 |
|
| 125 |
% \begin{macrocode} |
| 126 |
\let\n@to@pp@saved@stroke@color\relax |
| 127 |
\let\n@to@pp@saved@fill@color\relax |
| 128 |
% \end{macrocode} |
| 129 |
% \end{Macro} |
| 130 |
% |
| 131 |
% \begin{Macro}{\n@to@pp@stroke@to@fill,\n@to@pp@restore@fill} |
| 132 |
% Macro to get stroke and fill colours and set the fill colour to |
| 133 |
% the stroke colour, and to restore to the old setting. This is |
| 134 |
% used by the frame shapes below to make sure that filled elements |
| 135 |
% of the frame uses the same colour as the for strokes. |
| 136 |
% |
| 137 |
% \begin{macrocode} |
| 138 |
\newcommand\n@to@pp@stroke@to@fill{% |
| 139 |
% |
| 140 |
\expandafter\let\expandafter\n@to@pp@saved@stroke@color% |
| 141 |
\csname\string\color@pgfstrokecolor\endcsname% |
| 142 |
% |
| 143 |
\expandafter\let\expandafter\n@to@pp@saved@fill@color% |
| 144 |
\csname\string\color@pgffillcolor\endcsname% |
| 145 |
% |
| 146 |
\expandafter\pgf@setfillcolor\n@to@pp@saved@stroke@color% |
| 147 |
% |
| 148 |
% \message{^^J=== Set fill to stroke color |
| 149 |
% ^^J Old fill: \meaning\n@to@pp@saved@fill@color |
| 150 |
% ^^J Old stroke: \meaning\n@to@pp@saved@stroke@color} |
| 151 |
} |
| 152 |
% \end{macrocode} |
| 153 |
% |
| 154 |
% |
| 155 |
% |
| 156 |
% \begin{macrocode} |
| 157 |
\newcommand\n@to@pp@restore@fill{% |
| 158 |
% \message{^^J=== Restore fill color |
| 159 |
% ^^J Old fill: \meaning\n@to@pp@saved@fill@color |
| 160 |
% ^^J Old stroke: \meaning\n@to@pp@saved@stroke@color} |
| 161 |
% |
| 162 |
\ifx\n@to@pp@saved@fill@color\relax\else% |
| 163 |
\expandafter\pgf@setfillcolor\n@to@pp@saved@fill@color% |
| 164 |
\fi% |
| 165 |
\global\let\n@to@pp@saved@fill@color\relax |
| 166 |
\global\let\n@to@pp@saved@stroke@color\relax |
| 167 |
} |
| 168 |
% \end{macrocode} |
| 169 |
% |
| 170 |
% We also make an environment, just to simplify the use |
| 171 |
% |
| 172 |
% \begin{macrocode} |
| 173 |
\newenvironment{n@to@pp@stroketofill}{% |
| 174 |
\pgfscope% |
| 175 |
\n@to@pp@stroke@to@fill% |
| 176 |
}{% |
| 177 |
\n@to@pp@restore@fill% |
| 178 |
\endpgfscope% |
| 179 |
} |
| 180 |
% \end{macrocode} |
| 181 |
% \end{Macro} |
| 182 |
% |
| 183 |
% \iffalse |
| 184 |
% -------------------------------------------------------------------- |
| 185 |
% \fi |
| 186 |
% \subsubsection{Faction names as macros} |
| 187 |
% |
| 188 |
% \begin{macrocode} |
| 189 |
\def\n@to@pp@friendly{friendly} |
| 190 |
\def\n@to@pp@hostile{hostile} |
| 191 |
\def\n@to@pp@neutral{neutral} |
| 192 |
\def\n@to@pp@unknown{unknown} |
| 193 |
% \end{macrocode} |
| 194 |
% |
| 195 |
% \iffalse |
| 196 |
% -------------------------------------------------------------------- |
| 197 |
% \fi |
| 198 |
% \subsubsection{Node shapes} |
| 199 |
% |
| 200 |
% Here we define bases for all commands and affiliations. These are |
| 201 |
% defined as node shapes. This means we will render the NATO App6(c) |
| 202 |
% symbols as nodes with embedded nodes of the relevant shape. |
| 203 |
% |
| 204 |
% |
| 205 |
% |
| 206 |
% \input{natoapp6c/frames/base.dtx} |
| 207 |
% \input{natoapp6c/frames/friendly.dtx} |
| 208 |
% \input{natoapp6c/frames/hostile.dtx} |
| 209 |
% \input{natoapp6c/frames/neutral.dtx} |
| 210 |
% \input{natoapp6c/frames/unknown.dtx} |
| 211 |
% |
| 212 |
% \iffalse |
| 213 |
% -------------------------------------------------------------------- |
| 214 |
% \fi |
| 215 |
% |
| 216 |
% \input{natoapp6c/echelon.dtx} |
| 217 |
% \input{natoapp6c/text.dtx} |
| 218 |
% \input{natoapp6c/shape.dtx} |
| 219 |
% \input{natoapp6c/util.dtx} |
| 220 |
% \input{natoapp6c/weaponry.dtx} |
| 221 |
% \input{natoapp6c/symbols.dtx} |
| 222 |
% \input{natoapp6c/list.dtx} |
| 223 |
% \iffalse |
| 224 |
% </natoapp6c> |
| 225 |
% -------------------------------------------------------------------- |
| 226 |
% \fi |