I have seen How to allow labels' anchors in TikZ to be affected by rotations without rotating the text itself?; but that question doesn't seem to answer my problem, so here it goes.
With the MWE below, I get this as the node diagram that I want:
If I uncomment rotate=180
and anchor=center
, I get this below – it is good the text in labels is not rotated, as I want it, but the composition is otherwise a mess:
Finally, if I also enable/uncomment the transform shape
– the composition is better for some elements, worse for others, but now also text in labels is rotated, which I don't want:
So the question is – is there a way to rotate the whole composition correctly, AND not have the text in nodes rotated? My desired output, faked in GIMP:
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\usetikzlibrary{fit}
\makeatletter
% https://tex.stackexchange.com/a/47709/2595
\tikzset{
fitting node/.style={
inner sep=0pt,
fill=none,
draw=none,
reset transform,
fit={(\pgf@pathminx,\pgf@pathminy) (\pgf@pathmaxx,\pgf@pathmaxy)}
},
reset transform/.code={\pgftransformreset},
}
\makeatother
\begin{tikzpicture}
\tikzstyle{drc} = [draw, rectangle, line width=1pt, align=center]
\tikzstyle{arr_edge} = [>=latex,->, line width=1pt]
\node[] (tdrag3) at (27.5,1.5) {};
\begin{scope}[shift={(tdrag3)},
%rotate=180,
%anchor=center,
%transform shape,
]
\node[drc,anchor=south west] (nd01) at (0,0) {Some \\ Words};
\node[drc,anchor=south] (nd02) at (3.5,2) {Some Terms};
\node[drc] (nd03) [above=0pt of nd02] {Something};
\node[drc] (nd04) [above=0pt of nd03] {Some Notions \\ Emulation \\ (Next)};
\draw[drc] (5.5,1.5) rectangle (12,5.5) node[fitting node] (nd05) {};
\node[drc,anchor=south,minimum width=6cm,minimum height=0.8cm] (nd06) [above=5pt of nd05.south] {Generic Definition Terms};
\node[drc] (nd07) [above=5pt of nd06.north east,anchor=south east] {Tests \\ (Conversion, Exchange, etc.)};
\draw[drc] let \p1=(nd06.north west), \p2=(nd07.south west), \p3=($(nd07.north west)+(-5pt,5pt)$), \p4=($(nd07.north east)+(0,5pt)$) in (\x1,\y2) -| (\x3,\y3) to node[above left=2pt and -2em]{Plain access} (\x4,\y4) -- ++(0,0.8cm) -| (\x1,\y2);
\node[align=center] (nd05titl) [below=2pt of nd05.north,anchor=north] {Generic Definition};
\draw[drc] (-0.5,6) rectangle (7.5,9) node[fitting node] (nd08) {};
\node[drc] (nd09) [above right=0pt of nd08.south east, anchor=south east] {Generic List Terms\\Word\ Number\ Variable\ Constant} ;
\draw let \p1=(nd01.center), \p2=(nd09.north) in node[drc] (nd10) at (\x1,\y2) [below=0pt,anchor=north] {Some Terms};
\node[drc] (nd11) [above=0pt of nd10.north,anchor=south] {More Than\\Interesting};
\node[drc] (nd12) [above=0pt of nd09.north,anchor=south] {Generic\\List One};
\node[align=center] (nd13) [below=2pt of nd08.north,anchor=north] {Another List};
\draw[arr_edge] (nd01) -- (nd10);
\draw[arr_edge] (nd11) -- (nd12);
\draw[arr_edge] (nd09) -| (nd05);
% wrap in calc $$ for tikzedt
\draw[arr_edge] (nd04) |- ($(nd05.north west)-(10pt,10pt)$) -- ($(nd05.south west)-(10pt,7.5pt)$) -| ($(nd06.south west)+(10pt,0)$);
\end{scope}
\end{tikzpicture}
\end{document}
Best Answer
Ok, here is a fix - for a halfway fix, using the
add reference
andfitting nodeR
styles (as per Connecting line calculations with fitting node in 3D tikz?), seems to fix the layout of nodes withrotate
andtransform shape
-I'd just need help now on having the text not rotated in that case(see below); here is the image:Then, thanks to #168052 Referencing the contents of lasttikznode, and overlaying them on a node, I've found that it is possible to implement a node style, where the
turn
environment from therotating
package can be used to rotate the node content box only, implemented as a separate stylerotnt
; then thedrc
node style can simply inherit it - and the only inline change in the nodes' code, would be to style unstyled nodes withrotnt
, so they also get rotated. And finally, I obtain the desired image:... and here is the code: