-
Notifications
You must be signed in to change notification settings - Fork 31
Description
Hi Jurgen - really love this package - well done! I have forked it and am willing to do some development on the issue below, but thought I'd see what you think is a good approach first.
Problem
A typical use case is to present the same structure multiple times as a basis for some other plots; e.g. BMD, SFD, deflected shape, etc. Repeating the structure drawing code makes no sense, and so using a \tikzset and pic is really useful. Using this approach, styles can be altered as needed using scopes as suggested in the package documentation:
\tikzset{
pics/grid/.style args = {#1/#2}{
code={
\dpoint{c}{0}{0}{0};
\dpoint{d}{ -#1 }{0}{0};
\dpoint{e}{0}{ #1 }{0};
\dpoint{f}{ #1 }{0}{0};
\dpoint{g}{0}{-#1 }{0};
\dpoint{z}{ -#1 }{ -#1 }{0};
\daxis{1}{z};
\begin{scope}[#2]
\foreach \startn/\endn in {c/d,c/e,c/f,c/g}
\dbeam{1}{\startn}{\endn};
\support{1}{d}; \hinge{1}{d}
\support{3}{e}[90];
\support{1}{f}; \hinge{1}{f}
\support{3}{g}[270];
\end{scope}
\dnotation{1}{c}{$C$}[below=2mm];
\dnotation{1}{d}{$D$}[above right];
\dnotation{1}{e}{$E$}[above left];
\dnotation{1}{f}{$F$}[above right];
\dnotation{1}{g}{$G$}[below right];
}},
pics/grid/.default=4/black
}One issue I have found is that line thicknesses cannot be changed using this approach. This is because the library defines line thickness as follows:
\tikzstyle{hugeLine}=[line width=\DhugeLineWidth,]where \DhugeLineWidth is
\newcommand{\DhugeLineWidth}{2pt}as a result, including line width in argument #2 of my pic above has no effect.
The problem can be solved by doing the following:
\begin{scope}[hugeLine/.append style={line width=1mm}]
\pic{grid};
\end{scope}but this requires the user to access the undocumented innards of the library (i.e. hugeLine in this case), and it may change the line width on elements other than those expected (wherever hugeLine is used to draw elements in the scope.
Question
So my question is: what is the best way to adapt the library code to allow for line thickness specifications?
Solutions?
In a bid to be helpful, I'm wondering if the solution is something like:
- Alter the
commands definitions to include the option of overriding line widths; - Documenting and exposing the library
tikzsetstyles
I don't like (1) because it means editing all the library commands (lots of work); it also means more complex commands (additional argument); and it is inconsistent tikz design which should be all updateable through /.style appends or scope (which I prefer for simplicity).
I don't like (2) because it would mean introducing tikz styles for every type of element drawn, e.g. bending beam, truss rod, invisible just to name the ones possible for \dbeam.
On balance I think (2) is easier for both normal and advanced users. Is there a third (and better) solution?
Thanks!