
絶対座標を使用せずに長方形ノードと垂直線を接続する方法という問題に苦労しています。2 本の線の交点はドットでマークする必要があります。これを実現するには、もっとエレガントな方法があるはずだと強く感じています。
ありがとう、マルセル
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,arrows.meta,positioning,decorations.pathreplacing}
\usetikzlibrary{intersections}
\begin{document}
\begin{figure}
\begin{tikzpicture}
\draw[thick] (-4,10) node (dpdata) [above] {Data} -- (-4,0);
\node[ draw,
align=center,
left=of dpdata,
yshift=-4cm,
minimum width=2cm,
minimum height=3cm,
] (ram) {Transient \\ Memory \\ (RAM)};
\node[ draw,
align=center,
above=of ram,
minimum width=1.5cm,
minimum height=1cm
] (mar) {MAR};
\node[ draw,
align=center,
below=of ram,
minimum width=1.5cm,
minimum height=1cm
] (mdr) {MDR};
\draw[color=blue,thick] (mar.east) -- (-4,9.25);
\fill (-4,9.25) circle [radius=2pt];
\draw[color=blue,thick] (mdr.east) -- (-4,3.25);
\fill (-4,3.25) circle [radius=2pt];
\draw[color=blue,thick] (mdr.north) -- (ram.south);
\draw[color=blue,thick] (mar.south) -- (ram.north);
\end{tikzpicture}
\end{figure}
\end{document}
答え1
すべてのポイントと接続が長方形のグリッド上にある限り、座標を抽出するためにこのシンプルでエレガントな構文を使用できます (簡単な例を示します)。
\begin{tikzpicture}
\path
(0,0) node[draw] (joe) {Joe}
(2,2) node[draw] (blow) {Blow};
;
\draw[blue] (joe -| blow) circle (2pt);
\end{tikzpicture}
演算子-|
は、最初のポイント (joe) から x 座標を抽出し、2 番目のポイント (blow) から y 座標を抽出します。
答え2
このような?
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta, calc, chains, intersections, positioning}
\begin{document}
\begin{tikzpicture}[
node distance = 3mm and 9mm,
start chain = going below,
box/.style = {rectangle, draw,
text width=22mm, align=center, inner sep=2mm,
on chain}
]
\node (mar) [box] {MAR};
\node (ram) [box] {Transient Memory (RAM)};
\node (mdr) [box] {MDR};
%
\coordinate[above right=of mar] (data);
\draw[thick, name path=A] (data) node[above] {Data} -- + (0,-4);
\path[overlay,name path=B] (mar) -- ++ (3,0);
\path[overlay,name path=C] (mdr) -- ++ (3,0);
%
\draw[color=blue,thick,fill,
name intersections={of=A and B, by={a}}]
(mar) -- (a) circle (2pt);
\draw[color=blue,thick,fill,
name intersections={of=A and C, by={b}}]
(mdr) -- (b) circle (2pt);
\draw[color=blue,thick] (mar) -- (ram) (ram) -- (mdr);
\end{tikzpicture}
\end{document}
補遺: よりシンプルなソリューションの提供マイケル・パーマー答え。上記の MWE にこれを適用すると、次のように簡単に記述できます。
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta, calc, chains, intersections, positioning}
\begin{document}
\begin{tikzpicture}[
node distance = 3mm and 9mm,
start chain = going below,
box/.style = {rectangle, draw,
text width=22mm, align=center, inner sep=2mm,
on chain}
]
\node (mar) [box] {MAR};
\node (ram) [box] {Transient Memory (RAM)};
\node (mdr) [box] {MDR};
%
\coordinate[above right=of mar] (data);
\draw[thick] (data) node[above] {Data} -- + (0,-4);% changed
\draw[color=blue,thick,fill]
(mar) -- (mar -| data) circle (2pt)% changed
(mdr) -- (mdr -| data) circle (2pt)% changed
(mar) -- (ram)
(ram) -- (mdr);
\end{tikzpicture}
\end{document}
結果は前と同じです。