
다음 MWE를 고려하십시오.
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\usetikzlibrary{fit}
\usetikzlibrary{3d}
\makeatletter
\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
\tikzstyle{dr} = [draw, rectangle, line width=1pt, font=\Huge, align=left]
\tikzstyle{cl} = [>=latex,->,line width=1pt]
\begin{document}
\begin{tikzpicture}[
% x={(0.5cm,0.5cm)}, y={(1cm,0cm)}, z={(0cm,1cm)},
% every node/.append style={transform shape},
]
\draw[very thick] (0,0) rectangle (18,8) node[fitting node] (starter) {};
\begin{scope}[
shift={(1,1)},
% canvas is yx plane at z=0.25,
]
\node[dr] (NodeA) at (1,5) {Node A};
\draw[dr] (4.5,2.5) rectangle (11,6.5) node [fitting node] (NodeB) {Node B\\Slightly bigger};
\node[dr] (NodeC) [above=10pt of NodeB.south, anchor=south] {Node C};
\draw[cl] (NodeA) -- (NodeB);
\draw[cl] (NodeA) |- ($(NodeB.north west)-(10pt,10pt)$) -- ($(NodeB.south west)-(10pt,7.5pt)$) -| ($(NodeC.south west)+(10pt,0)$);
\end{scope}
\end{tikzpicture}
\end{document}
그대로 컴파일하면 예상되는 노드 배열과 연결선을 얻을 수 있습니다.
그러나 MWE에서 주석 처리된 줄의 주석 처리를 제거하여 3D를 활성화하면 다음과 같은 결과가 나타납니다.
NodeB 텍스트가 원근감에 맞지 않는 것은 나를 그다지 괴롭히지 않습니다. 나를 괴롭히는 것은 NodeB 피팅 노드 직사각형을 기반으로 한 좌표가 3D 변환에서 제대로 작동하지 않는다는 것입니다("적절한" 노드 사이에서는 모두 괜찮습니다(예: NodeC로 바로 들어가는 선 조각).)
(특히 이 예제는 피팅 노드 직사각형 없이도 수행할 수 있다는 것을 알고 있으므로 문제는 해결되었습니다. 문제는 이러한 예제가 TikzEdt의 GUI 편집에 매우 유용하다는 것입니다. 따라서 코드가 엄청나게 많습니다. 이것이 바로 "피팅 노드" 스타일에 대한 수정과 같은 솔루션을 선호하는 이유입니다.
답변1
문제가 어디에 있는지 모르겠습니다. 노드 transform shape
에 적용되지 않을 수 있습니다. fit
아무도 더 나은 솔루션을 제공하지 않는 경우 해결 방법이 있습니다.
노드 label={center:{node text}}
에 대한 옵션으로 사용 :fitting
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\usetikzlibrary{fit}
\usetikzlibrary{3d}
\makeatletter
\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
\tikzstyle{dr} = [draw, rectangle, line width=1pt, font=\Huge, align=left]
\tikzstyle{cl} = [>=latex,->,line width=1pt]
\begin{document}
\begin{tikzpicture}[
x={(0.5cm,0.5cm)}, y={(1cm,0cm)}, z={(0cm,1cm)},
every node/.append style={transform shape},
]
\draw[very thick] (0,0) rectangle (18,8) node[fitting node] (starter) {};
\begin{scope}[
shift={(1,1)},
canvas is yx plane at z=0.25,
]
\node[dr] (NodeA) at (1,5) {Node A};
\draw[dr] (4.5,2.5) rectangle (11,6.5) node [fitting node, label={center:{Node B\\Slightly bigger}}] (NodeB) {};
\node[dr] (NodeC) [above=10pt of NodeB.south, anchor=south] {Node C};
\draw[cl] (NodeA) -- (NodeB);
\draw[cl] (NodeA) |- ($(NodeB.north west)-(10pt,10pt)$) -- ($(NodeB.south west)-(10pt,7.5pt)$) -| ($(NodeC.south west)+(10pt,0)$);
\end{scope}
\end{tikzpicture}
\end{document}
답변2
편집: 이 답변은 Texlive 2014 고정에서 깨졌습니다.
좋아, 알 것 같아. 하지만 지금은 왜 그런지 이해가 안 돼.
첫째, 문제는 그것이 fit
말한 대로 정확히 수행된다는 것입니다. 우리는 마지막 pgf min 및 max x 및 y에 맞도록 지시하고 정확히 그렇게 합니다( draw=red
of 로 변경하여 볼 수 있음 fitting node
).
문제는 직사각형이 에 도달할 때 이미 변환되었지만 3D 변환을 인식하지 못하는 fit
것 같습니다.fit
그래서 변환을 중지하고 직사각형 피팅 노드를 수행한 다음 변환을 복원하려고 했습니다. 작동하지 않았습니다. pgf 그리기 명령을 그룹화한 다음 모든 명령에 변환을 적용하는 방법을 찾으려고 했지만 찾을 수 없었습니다.
그러다가 찾았어요#47797 (tikz) 직사각형 경로에 노드 앵커 같은 점을 설정하는 방법(설명된 것보다 더 나은 방법이 있습니까)?, 좌표 앵커가 직사각형에 추가되도록 사용했으며 무엇보다도 fit
직사각형의 앵커를 시도했습니다... 그리고 갑자기 작동합니까?? 그리고 위의 문제에 대한 내 이론과 마찬가지로 이것이 어떻게 좌표 변환을 방해하는지 알 수 없습니다.
그럼에도 불구하고 현재 출력은 다음과 같습니다.
... 불행하게도 스타일만 변경하고 계속 진행할 수는 없지만 fitting node
(사각형 및 해당 피팅 노드에 대한 참조를 모든 곳에 추가해야 합니다) -- 코드도 TikzEdt GUI에서와 동일한 방식으로 작동합니다. , 그럼 좋습니다. 코드는 다음과 같습니다
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\usetikzlibrary{fit}
\usetikzlibrary{3d}
\makeatletter
%https://tex.stackexchange.com/a/47797/2595
\tikzset{add reference/.style={insert path={%
coordinate [pos=0,xshift=-0.5\pgflinewidth,yshift=-0.5\pgflinewidth] (#1 south west)
coordinate [pos=1,xshift=0.5\pgflinewidth,yshift=0.5\pgflinewidth] (#1 north east)
coordinate [pos=.5] (#1 center)
(#1 south west |- #1 north east) coordinate (#1 north west)
(#1 center |- #1 north east) coordinate (#1 north)
(#1 center |- #1 south west) coordinate (#1 south)
(#1 south west -| #1 north east) coordinate (#1 south east)
(#1 center -| #1 south west) coordinate (#1 west)
(#1 center -| #1 north east) coordinate (#1 east)
}}}
\tikzset{
fitting node/.style={
inner sep=0pt,
fill=none,
draw=red,
fit={(#1 south west) (#1 north east)},
},
}
\makeatother
\tikzstyle{dr} = [draw, rectangle, line width=1pt, font=\Huge, align=left]
\tikzstyle{cl} = [>=latex,->,line width=1pt]
\begin{tikzpicture}[
x={(0.5cm,0.5cm)}, y={(1cm,0cm)}, z={(0cm,1cm)},
every node/.append style={transform shape},
]
\draw[very thick] (0,0) rectangle (18,8) [add reference=R1] node[fitting node=R1] (starter) {};
\begin{scope}[
shift={(1,1)},
canvas is yx plane at z=0.25,
]
\node[dr] (NodeA) at (1,5) {Node A};
\draw[dr] (4.5,2.5) rectangle (11,6.5) [add reference=R2] node [fitting node=R2] (NodeB) {Node B\\Slightly bigger};
\node[dr] (NodeC) [above=10pt of NodeB.south, anchor=south] {Node C};
\draw[cl] (NodeA) -- (NodeB);
\draw[cl] (NodeA) |- ($(NodeB.north west)-(10pt,10pt)$) -- ($(NodeB.south west)-(10pt,7.5pt)$) -| ($(NodeC.south west)+(10pt,0)$);
\end{scope}
\end{tikzpicture}