diff options
Diffstat (limited to 'macros/latex/contrib/wargame/source/chit/shape.dtx')
-rw-r--r-- | macros/latex/contrib/wargame/source/chit/shape.dtx | 220 |
1 files changed, 180 insertions, 40 deletions
diff --git a/macros/latex/contrib/wargame/source/chit/shape.dtx b/macros/latex/contrib/wargame/source/chit/shape.dtx index 8ad0614cb8..8a3d70fbd0 100644 --- a/macros/latex/contrib/wargame/source/chit/shape.dtx +++ b/macros/latex/contrib/wargame/source/chit/shape.dtx @@ -4,6 +4,19 @@ % \fi % % \subsubsection{The \texttt{chit} key namespace} +% +% Some stuff to consider wrt.~line widths. Setting the line width in +% the \texttt{chit} scope overrides frame settings. The frame stroke +% can be larger but not smaller. Setting the stroke width in the +% symbol scope sets it for the symbol only. Thus, to get a thin +% border, we need to +% \begin{itemize} +% \item Set a small line width in the top chit scope. +% \item Possible set a larger line width in the frame sub-scope. +% \item Set a larger line width in the symbol sub-scope. +% \end{itemize} +% I do not know why this is. +% % \begin{TikzKey}{/chit/full, % /chit/symbol, % /chit/left, @@ -13,12 +26,15 @@ % /chit/lower left, % /chit/lower right, % /chit/factors, +% /chit/extra, % /chit/setup, +% /chit/bevel, % /chit/id} % % The parts of a chit % % \begin{macrocode} +\newif\ifchit@clip\chit@cliptrue \tikzset{% /chit/.search also={/tikz}, /chit/.cd, @@ -36,6 +52,21 @@ setup/.store in=\chit@setup, setup/.initial=,% id/.store in=\chit@id, id/.initial=,% frame/.store in=\chit@frame, frame/.initial=,% + extra/.store in=\chit@extra, extra/.initial=,% + bev/.store in=\chit@bevel, bev/.initial=, + bevel fraction/.store in=\chit@bevel@frac,bevel fraction/.initial=10, + bevel/.is choice, + bevel/none/.style = {/chit/bev=}, + bevel/north west/.style = {/chit/bev=1}, + bevel/north east/.style = {/chit/bev=2}, + bevel/south west/.style = {/chit/bev=3}, + bevel/south east/.style = {/chit/bev=4}, + bevel/NW/.style = {/chit/bev=1}, + bevel/NE/.style = {/chit/bev=2}, + bevel/SW/.style = {/chit/bev=3}, + bevel/SE/.style = {/chit/bev=4}, + bevel/.default = north west, + clip/.is if=chit@clip% } % \end{macrocode} % \end{TikzKey} @@ -69,7 +100,28 @@ chit/lower right/.style={chit/parts,anchor=south east}, chit/setup/.style={chit/parts}, chit/full/.style={chit/parts}, + chit/frame/.try={draw=pgfstrokecolor}, + chit/bevel highlight/.style={fill=white,opacity=.25}, + chit/bevel shadow/.style={fill=black,opacity=.25}, } +\def\chit@bevel@frac{10} +\newif\ifchit@draw@frame\chit@draw@frametrue +\tikzset{ + chit/frame style/.search also={/tikz}, + chit/frame style/.cd, + none/.code={\chit@draw@framefalse}, + draw/.code={% + \chit@dbg{2}{Frame draw option `#1'} + \edef\tikz@temp{#1}% + \ifx\tikz@temp\tikz@nonetext% + \chit@draw@framefalse% + \else% + \chit@draw@frametrue% + \tikzset{/tikz/draw=#1} + \fi + } +} + % \end{macrocode} % \end{TikzKey} % @@ -116,7 +168,7 @@ % \begin{macrocode} \def\chit@n@to#1#2{% %% Without a following start square bracket '[' by-pass to final - \chit@dbg{4}{Chit NATO App6(c) first step `#1' `#2'} + \chit@dbg{1}{Chit NATO App6(c) first step `#1' `#2'} \@ifnextchar[{% %\message{^^JStart square bracket}% \@chit@n@to{#1}{#2}}{% @@ -129,7 +181,7 @@ % % \begin{macrocode} \def\@chit@n@to@#1#2#3\@end@chit@n@to{% - \chit@dbg{4}{Chit NATO App6(c) w/o offset: + \chit@dbg{1}{Chit NATO App6(c) w/o offset: ^^J Options: #3 ^^J ID: #1 ^^J Position: #2} @@ -143,7 +195,7 @@ % % \begin{macrocode} \def\@chit@n@to#1#2[#3]{% - \chit@dbg{4}{Chit NATO App6(c) second step `#1' `#2' `#3'} + \chit@dbg{1}{Chit NATO App6(c) second step `#1' `#2' `#3'} \@ifnextchar({\@@chit@n@to{#1}{#2}{#3}}{\@@chit@n@to{#1}{#2}{#3}(0,0)}%) } % \end{macrocode} @@ -152,7 +204,7 @@ % % \begin{macrocode} \def\@@chit@n@to#1#2#3(#4)\@end@chit@n@to{% - \chit@dbg{4}{Chit NATO App6(c) w/offset: + \chit@dbg{1}{Chit NATO App6(c) w/offset: ^^J Options: #3 ^^J ID: #1 ^^J Position: #2 @@ -186,8 +238,39 @@ % % Now follows the actual \text{chit} shape. This is rather long, so % we will break it up a bit -% -% +% \begin{macrocode} +\def\chit@bevel@path#1{ + \scope[#1] + \wg@tmpc=\wg@tmpa\multiply\wg@tmpc by \chit@bevel@frac + \wg@tmpd=\wg@tmpb\multiply\wg@tmpd by \chit@bevel@frac + \divide\wg@tmpc100 + \divide\wg@tmpd100 + \pgfpathmoveto{\pgfqpoint{\wg@tmpa}{\wg@tmpb}}% + % Move down along edge + \wg@tmpb=-\wg@tmpb + \pgfpathlineto{\pgfqpoint{\wg@tmpa}{\wg@tmpb}}% + % Move left along edge + \wg@tmpa=-\wg@tmpa + \pgfpathlineto{\pgfqpoint{\wg@tmpa}{\wg@tmpb}}% + % Move in and up + \advance\wg@tmpa\wg@tmpc% + \advance\wg@tmpb\wg@tmpd% + \pgfpathlineto{\pgfqpoint{\wg@tmpa}{\wg@tmpb}}% + % Move right, but in + \advance\wg@tmpa-\wg@tmpc\wg@tmpa=-\wg@tmpa% + \advance\wg@tmpa-\wg@tmpc% + \pgfpathlineto{\pgfqpoint{\wg@tmpa}{\wg@tmpb}}% + % Move up but down + \advance\wg@tmpb-\wg@tmpd\wg@tmpb=-\wg@tmpb% + \advance\wg@tmpb-\wg@tmpd% + \pgfpathlineto{\pgfqpoint{\wg@tmpa}{\wg@tmpb}}% + \pgfclosepath% + \pgfusepath{fill} + \endscope +} + +% \end{macrocode} +% % The first thing is we declare some saved anchors. These are % computed (and defined as internal macros) when the shape is % instantised. The anchors give the centre and north east corner of @@ -224,7 +307,7 @@ \let\chitframeopt\pgfutil@empty% \@ifundefined{chit@frame}{}{% \edef\chitframeopt{\chit@frame}} - \n@to@pp@dbg{3}{Chit Frame options: \meaning\chitframeopt}% + \chit@dbg{3}{Chit Frame options: \meaning\chitframeopt}% } % \end{macrocode} % @@ -296,6 +379,7 @@ \backgroundpath{% %% This is the outline of the chit only. The rest of the chit is %% made on the foreground "path". + \chit@dbg{1}{Chit drawing background path} \northeast% \wg@tmpa=\pgf@x\wg@tmpb=\pgf@y% \pgfpathmoveto{\pgfqpoint{\wg@tmpa}{\wg@tmpb}}% @@ -314,29 +398,38 @@ % % \begin{macrocode} \behindforegroundpath{% - \chit@dbg{4}{% - Chit foreground: \meaning\id - ^^J ID (set): \meaning\chit@id - ^^J Symbol: \meaning\chit@symbol - ^^J Full: \meaning\chit@full - ^^J Factors: \meaning\chit@factors - ^^J Left: \meaning\chit@left - ^^J Right: \meaning\chit@right - ^^J Upper left: \meaning\chit@upper@left - ^^J Lower left: \meaning\chit@lower@left - ^^J Upper right: \meaning\chit@upper@right - ^^J Lower right: \meaning\chit@lower@right} + \chit@dbg{1}{Chit drawing foreground path} + % \chit@dbg{4}{% + % Chit foreground: \meaning\id + % ^^J ID (set): \meaning\chit@id + % ^^J Symbol: \meaning\chit@symbol + % ^^J Full: \meaning\chit@full + % ^^J Factors: \meaning\chit@factors + % ^^J Left: \meaning\chit@left + % ^^J Right: \meaning\chit@right + % ^^J Upper left: \meaning\chit@upper@left + % ^^J Lower left: \meaning\chit@lower@left + % ^^J Upper right: \meaning\chit@upper@right + % ^^J Lower right: \meaning\chit@lower@right + % ^^J Extra: \meaning\chit@extra + % ^^J Bevel: \meaning\chit@bevel + % ^^J Frame: \meaning\chit@frame} + \chit@dbg{1}{Chit report} \chit@report{} + \chit@dbg{1}{Chit start scope} \pgfscope % - \northeast% - \wg@tmpa=\pgf@x\wg@tmpb=\pgf@y% - \pgfpathmoveto{\pgfqpoint{\wg@tmpa}{\wg@tmpb}}% - \wg@tmpa=-\wg@tmpa \pgfpathlineto{\pgfqpoint{\wg@tmpa}{\wg@tmpb}}% - \wg@tmpb=-\wg@tmpb \pgfpathlineto{\pgfqpoint{\wg@tmpa}{\wg@tmpb}}% - \wg@tmpa=-\wg@tmpa \pgfpathlineto{\pgfqpoint{\wg@tmpa}{\wg@tmpb}}% - \pgfclosepath - \pgfusepath{clip} + \ifchit@clip% + \chit@dbg{1}{Chit clip path} + \northeast% + \wg@tmpa=\pgf@x\wg@tmpb=\pgf@y% + \pgfpathmoveto{\pgfqpoint{\wg@tmpa}{\wg@tmpb}}% + \wg@tmpa=-\wg@tmpa \pgfpathlineto{\pgfqpoint{\wg@tmpa}{\wg@tmpb}}% + \wg@tmpb=-\wg@tmpb \pgfpathlineto{\pgfqpoint{\wg@tmpa}{\wg@tmpb}}% + \wg@tmpa=-\wg@tmpa \pgfpathlineto{\pgfqpoint{\wg@tmpa}{\wg@tmpb}}% + \pgfclosepath% + \pgfusepath{clip}% + \fi% % \end{macrocode} % % If we do not have the \texttt{symbol} key set, then we set the @@ -346,19 +439,22 @@ \@ifundefined{chit@symbol}{% %% Draw full stuff \@ifundefined{chit@full}{}{% + \chit@dbg{1}{Chit draw full image: `\meaning\chit@full'} \center\wg@tmpa=\pgf@x\wg@tmpb=\pgf@y% \wg@pic@all{\chit@full}{}{\the\wg@tmpa,\the\wg@tmpb}{chit/full}}% - }{% + }{% With NATO symbol % \end{macrocode} % % Otherwise, we put in a node with shape \texttt{natoapp6c} and pass % the \texttt{symbol} key--value pairs as options. % % \begin{macrocode} + \chit@dbg{1}{Chit draw symbol image} \edef\symid{\id symbol}% \symbol% \edef\args{{\symid}{\the\pgf@x,\the\pgf@y}\chit@symbol}% \chit@dbg{6}{Arguments to chit NATO symbol: \meaning\args}% + \chit@dbg{1}{Chit draw nato image} \expandafter\chit@n@to\args\@end@chit@n@to% \chit@dbg{6}{After making NATO symbol in chit}% % \end{macrocode} @@ -378,6 +474,7 @@ % \begin{macrocode} % Put in left of symbol \@ifundefined{chit@left}{}{% + \chit@dbg{1}{Chit draw left: `\meaning\chit@left'} \begin{scope}[] \pgfpointanchor{\symid}{west}% \wg@tmpa=\pgf@x\advance\wg@tmpa-\margin% @@ -386,6 +483,7 @@ \end{scope}}% % Put in right of symbol \@ifundefined{chit@right}{}{% + \chit@dbg{1}{Chit draw left: `\meaning\chit@right'} \begin{scope}[] \pgfpointanchor{\symid}{east}% \wg@tmpa=\pgf@x\advance\wg@tmpa+\margin% @@ -416,24 +514,28 @@ % \begin{macrocode} % Put in upper left corner \@ifundefined{chit@upper@left}{}{% + \chit@dbg{1}{Chit draw upper left: `\meaning\chit@upper@left'} \begin{scope}[] \wg@pic@all{\chit@upper@left}{}{-\the\wg@tmpa,\the\wg@tmpb}{% chit/upper left}% \end{scope}} % Put in upper right corner \@ifundefined{chit@upper@right}{}{% + \chit@dbg{1}{Chit draw upper right: `\meaning\chit@upper@right'} \begin{scope}[] \wg@pic@all{\chit@upper@right}{}{\the\wg@tmpa,\the\wg@tmpb}{% chit/upper right}% \end{scope}} % Put in lower left corner \@ifundefined{chit@lower@left}{}{% + \chit@dbg{1}{Chit draw lower left: `\meaning\chit@lower@left'} \begin{scope}[] \wg@pic@all{\chit@lower@left}{}{-\the\wg@tmpa,-\the\wg@tmpb}{% chit/lower left}% \end{scope}} % Put in lower right corner \@ifundefined{chit@lower@right}{}{% + \chit@dbg{1}{Chit draw lower right: `\meaning\chit@lower@right'} \begin{scope}[] \wg@pic@all{\chit@lower@right}{}{\the\wg@tmpa,-\the\wg@tmpb}{% chit/lower right}% @@ -448,24 +550,62 @@ % \begin{macrocode} % Put in factors \@ifundefined{chit@factors}{}{% + \chit@dbg{1}{Chit draw factors: `\meaning\chit@factors'} \advance\wg@tmpb-\margin% \begin{scope}[] \wg@pic@all{\chit@factors}{}{0,-\the\wg@tmpb}{chit/factors}% \end{scope}}% - }% + % Put in extra + \@ifundefined{chit@extra}{}{% + \chit@dbg{1}{Chit draw extra: `\meaning\chit@extra'} + \begin{scope}[] + \wg@pic@all{\chit@extra}{}{0,0}{chit/factors}% + \end{scope}}% + }% End of full or symbol \endpgfscope% + % Make bevel? + \@ifundefined{chit@bevel}{\let\chit@bevel\empty}{} + \ifx\chit@bevel\empty\else% + \chit@dbg{1}{Chit draw bevel} + %% South east bevel + \northeast% + \wg@tmpa=-\pgf@x\wg@tmpb=-\pgf@y% + \ifcase\chit@bevel\relax% + \or% 1 + \or\wg@tmpa=-\wg@tmpa% 2 + \or\wg@tmpb=-\wg@tmpb% 3 + \or\wg@tmpa=-\wg@tmpa\wg@tmpb=-\wg@tmpb%4 + \fi + \chit@bevel@path{chit/bevel highlight} + %% North west bevel + \northeast% + \wg@tmpa=\pgf@x\wg@tmpb=\pgf@y% + \ifcase\chit@bevel\relax% + \or% 1 + \or\wg@tmpa=-\wg@tmpa% 2 + \or\wg@tmpb=-\wg@tmpb% 3 + \or\wg@tmpa=-\wg@tmpa\wg@tmpb=-\wg@tmpb%4 + \fi + \chit@bevel@path{chit/bevel shadow} + \fi % Draw frame? - \edef\tmp@opt{[\chitframeopt]} + \chit@dbg{1}{Chit draw frame: `\meaning\chitframeopt'} + \edef\tmp@opt{[chit/frame style/.cd,chit/frame/.try,\chitframeopt]} + \chit@dbg{1}{Chit draw frame: `\meaning\tmp@opt} \expandafter\scope\tmp@opt - \northeast% - \wg@tmpa=\pgf@x\wg@tmpb=\pgf@y% - \pgfpathmoveto{\pgfqpoint{\wg@tmpa}{\wg@tmpb}}% - \wg@tmpa=-\wg@tmpa \pgfpathlineto{\pgfqpoint{\wg@tmpa}{\wg@tmpb}}% - \wg@tmpb=-\wg@tmpb \pgfpathlineto{\pgfqpoint{\wg@tmpa}{\wg@tmpb}}% - \wg@tmpa=-\wg@tmpa \pgfpathlineto{\pgfqpoint{\wg@tmpa}{\wg@tmpb}}% - \pgfclosepath - \pgfusepath{stroke} - \endscope + \northeast% + \wg@tmpa=\pgf@x\wg@tmpb=\pgf@y% + \pgfpathmoveto{\pgfqpoint{\wg@tmpa}{\wg@tmpb}}% + \wg@tmpa=-\wg@tmpa \pgfpathlineto{\pgfqpoint{\wg@tmpa}{\wg@tmpb}}% + \wg@tmpb=-\wg@tmpb \pgfpathlineto{\pgfqpoint{\wg@tmpa}{\wg@tmpb}}% + \wg@tmpa=-\wg@tmpa \pgfpathlineto{\pgfqpoint{\wg@tmpa}{\wg@tmpb}}% + \pgfclosepath% + \chit@dbg{3}{Line width for frame: `\the\pgflinewidth'} + \ifchit@draw@frame\pgfusepath{stroke}\fi% + \chit@draw@frametrue% + %\iftikz@mode@fill\pgfusepath{fill}\fi% + \endscope% + \chit@dbg{1}{Chit end of shape} } } % \end{macrocode} @@ -527,7 +667,7 @@ ^^J Name: `#3'} \let\name\pgfutil@empty% \chit@dbg{1}{=== Before chit node}% - \node[draw,chit={every chit/.try,id=#3,#1}] (tmp) at (#2) {}; + \node[chit={every chit/.try,id=#3,#1}] (tmp) at (#2) {}; \chit@dbg{2}{=== After chit node}% \ifx|#3|\relax% \else% |