我想让下图中的外框具有相同的高度:
以下是代码:
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,fit, calc}
\definecolor{craneColor}{RGB}{105,97,140}
\definecolor{sysColor}{RGB}{115,174,66}
\begin{document}
\begin{tikzpicture}
[
craneComponent/.style={rectangle, draw=black!50, font=\scriptsize\ttfamily, anchor=west, fill=craneColor, text=white, minimum width=3cm },
systemComponent/.style={rectangle, draw=black!50, font=\scriptsize\ttfamily, anchor=north west, fill=sysColor, text=white, minimum width=3cm},
%domainBox/.style={rectangle, minimum height=7.5cm, align=center},
domainBox/.style={rectangle},
title/.style={font=\sffamily, anchor=north west}
]
\node [title] (adminDom) at (0,0) {Administrative Domain};
% dom0 contents
\node [ craneComponent, below = of adminDom ] (hostDaemon) {Host Migration Daemon};
\node [ domainBox, draw=black!50, fit={ (adminDom) (hostDaemon) }] (bigAdminBox) {};
%%%%%%%%%%%%%%%%%%%%
\node[title, right = of adminDom] (guestDom) {Guest Domain};
% domU contents
% user
\node [ craneComponent, below = of guestDom ] (guestDaemon) {Guest Migration Daemon};
\node [ craneComponent, right = of guestDaemon ] (ourLib) {Interposition Library};
\node [ systemComponent, above = of ourLib ] (app) {OpenCL Application};
\node [ systemComponent, below = of ourLib ] (sysLib) {OpenCL Library};
% kernel
\node[ systemComponent, below = of sysLib] (GpuDriver) {GPU Driver};
\node[ systemComponent, below = of GpuDriver] (Gpu) {GPU};
\node [ domainBox, draw=black!50, fit={ (guestDom) (guestDaemon) (ourLib) (app) (sysLib) (GpuDriver) (Gpu) }] (bigGuestBox) {};
%%%%%%%%%%%%%%%%%%%%
%\node[title, right = of guestDom] (proxyDom) {Proxy Domain};
%\node[title, right = of bigGuestBox] (proxyDom) {Proxy Domain};
\node [title] (proxyDom) at (12, 0) {Proxy Domain};
% proxy contents
% user
\node[ craneComponent, below = of proxyDom] (proxyProcess) {Proxy Process};
\node[ craneComponent, below = of proxyProcess] (rpcStub) {RPC Stub};
\node[ systemComponent, below = of rpcStub] (proxySysLib) {OpenCL Library};
% kernel
\node[ systemComponent, below = of proxySysLib] (proxyGpuDriver) {GPU Driver};
\node[ systemComponent, below = of proxyGpuDriver] (proxyGpu) {GPU};
%\node [ domainBox, right of =right of = bigGuestBox, bigGuestBox, draw=black!50, fit={ (proxyDom) (proxyProcess) (rpcStub) (proxySysLib) (proxyGpuDriver) (proxyGpu) }] {};
\node [ domainBox, draw=black!50, fit={ (proxyDom) (proxyProcess) (rpcStub) (proxySysLib) (proxyGpuDriver) (proxyGpu) }] {};
% edges:
\draw[->] (hostDaemon) -- (guestDaemon);
\draw[->] (guestDaemon) -- (ourLib);
\draw[->] (ourLib) -- (sysLib);
\draw[->] (app) -- (ourLib);
\draw[->] (ourLib) -- (rpcStub);
\draw[->] (rpcStub) -- (proxySysLib);
\end{tikzpicture}
\end{document}
我尝试设置 domainBox 类的属性minimum height
。以下是我得到的结果:
外框现在高度相同,但对齐不正确。你知道原因吗?
答案1
在第一种和第二种情况下,可以为fit
节点添加一个坐标。例如,
\node [ domainBox, draw=black!50, fit={ (adminDom) (hostDaemon) (adminDom.south|-proxyGpu.south) }] (bigAdminBox) {};
这里我添加了(adminDom.south|-proxyGpu.south)
,即 x 坐标为adminDom.south
, y 坐标为 的坐标proxyGpu.south
。
当然,proxyGpu
节点必须可用,因此我将前两个fit
节点移至代码末尾附近。
\documentclass[border=5pt]{standalone}%{article}
\usepackage{tikz}
\usetikzlibrary{positioning,fit}
\definecolor{craneColor}{RGB}{105,97,140}
\definecolor{sysColor}{RGB}{115,174,66}
\begin{document}
\begin{tikzpicture}
[
craneComponent/.style={rectangle, draw=black!50, font=\scriptsize\ttfamily, anchor=west, fill=craneColor, text=white, minimum width=3cm },
systemComponent/.style={rectangle, draw=black!50, font=\scriptsize\ttfamily, anchor=north west, fill=sysColor, text=white, minimum width=3cm},
%domainBox/.style={rectangle, minimum height=7.5cm, align=center},
domainBox/.style={rectangle},
title/.style={font=\sffamily, anchor=north west}
]
\node [title] (adminDom) at (0,0) {Administrative Domain};
% dom0 contents
\node [ craneComponent, below = of adminDom ] (hostDaemon) {Host Migration Daemon};
%%%%%%%%%%%%%%%%%%%%
\node[title, right = of adminDom] (guestDom) {Guest Domain};
% domU contents
% user
\node [ craneComponent, below = of guestDom ] (guestDaemon) {Guest Migration Daemon};
\node [ craneComponent, right = of guestDaemon ] (ourLib) {Interposition Library};
\node [ systemComponent, above = of ourLib ] (app) {OpenCL Application};
\node [ systemComponent, below = of ourLib ] (sysLib) {OpenCL Library};
% kernel
\node[ systemComponent, below = of sysLib] (GpuDriver) {GPU Driver};
\node[ systemComponent, below = of GpuDriver] (Gpu) {GPU};
%%%%%%%%%%%%%%%%%%%%
%\node[title, right = of guestDom] (proxyDom) {Proxy Domain};
%\node[title, right = of bigGuestBox] (proxyDom) {Proxy Domain};
\node [title] (proxyDom) at (12, 0) {Proxy Domain};
% proxy contents
% user
\node[ craneComponent, below = of proxyDom] (proxyProcess) {Proxy Process};
\node[ craneComponent, below = of proxyProcess] (rpcStub) {RPC Stub};
\node[ systemComponent, below = of rpcStub] (proxySysLib) {OpenCL Library};
% kernel
\node[ systemComponent, below = of proxySysLib] (proxyGpuDriver) {GPU Driver};
\node[ systemComponent, below = of proxyGpuDriver] (proxyGpu) {GPU};
%\node [ domainBox, right of =right of = bigGuestBox, bigGuestBox, draw=black!50, fit={ (proxyDom) (proxyProcess) (rpcStub) (proxySysLib) (proxyGpuDriver) (proxyGpu) }] {};
% boxes
\node [ domainBox, draw=black!50, fit={ (adminDom) (hostDaemon) (adminDom.south|-proxyGpu.south) }] (bigAdminBox) {};
\node [ domainBox, draw=black!50, fit={ (guestDom) (guestDaemon) (ourLib) (app) (sysLib) (GpuDriver) (Gpu) (guestDom.south|-proxyGpu.south) }] (bigGuestBox) {};
\node [ domainBox, draw=black!50, fit={ (proxyDom) (proxyProcess) (rpcStub) (proxySysLib) (proxyGpuDriver) (proxyGpu) }] {};
% edges:
\draw[->] (hostDaemon) -- (guestDaemon);
\draw[->] (guestDaemon) -- (ourLib);
\draw[->] (ourLib) -- (sysLib);
\draw[->] (app) -- (ourLib);
\draw[->] (ourLib) -- (rpcStub);
\draw[->] (rpcStub) -- (proxySysLib);
\end{tikzpicture}
\end{document}