我想用 Tikz 重现 UMTS 系统的 RRC 状态机,如附件中的图像。有人能帮我吗?
答案1
你应该先尝试编写自己的代码,参与编码过程。之后,你可以用最小工作示例(MWE)。这个网站上有很多会员都愿意提供帮助,但很多人并不热衷于从头开始写作。此外,一开始自己学习写作很有趣,而且我相信,奖励经验。如果你有足够的时间,我建议你阅读前几页非常详细的例子pgf 手册。
我从注释中给出的链接中借鉴了一些想法,以便您可以将下面的代码与注释中给出的链接进行比较。如今,有很多方法可以绘制这个tikz
。一种方法是使用矩阵。下面的代码主要使用手动放置节点。尝试%
在每行之前放置以查看每行的作用。另外,我把线条的绘制留给你去尝试。尝试一下,然后在遇到问题时再回来。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,calc,fit,backgrounds}
% Define a few styles and constants
\tikzset{sensor/.style={draw, rounded corners, text width=6em, text centered, minimum height=2.5em},
box/.style = {minimum width=16pt,minimum height=16pt,draw},
idles/.style = {very thick,draw=violet,text width=6em, align=center, minimum height=12em, rounded corners},
line/.style = {,>=latex,->,draw=blue!50}}
\def\blockdist{4}
\def\tdist{2.25}
\begin{document}
\begin{tikzpicture}[very thick]
\node (idle) [idles] {IDLE Mode};
\path ([yshift=1.5cm]idle)+(\blockdist,0) node [draw=blue!50] (dch) [sensor] {CELL DCH};
\path (idle)+(\blockdist,0) node [draw=orange] (fach) [sensor] {CELL FACH};
\path ([yshift=-1.45cm]idle)+(\blockdist,0) node [draw=yellow!50!green] (pch) [sensor] {CELL PCH};
% Draw connections between nodes
\draw [line] (dch.east) -- +(12pt,0) |- ([yshift=5pt]fach);
\draw [line] (fach.east) -- +(12pt,0) |- (pch);
\draw [line] (pch) -- (fach);
\draw [line] (fach) -- (dch);
\node (t1) [box,fill=blue!50] at ($(dch)!0.5!(fach)+(\tdist,0)$) {T1}; % You can create a style for the boxes used in this line and the next
\node (t2) [box,fill=orange!50] at ($(fach)!0.5!(pch)+(\tdist,0)$) {T2};
% Exercise: Discover how to place Connected Mode label
\begin{pgfonlayer}{background}
\path (dch.west)+(-0.5cm,0.25cm) node (dchleft) {};
\path (t2.east)+(0.5cm,0cm) node (t2right) {};
\node [idles,fit=(dchleft) (pch) (t2right),draw] {};
\end{pgfonlayer}
\end{tikzpicture}
\end{document}
玩得开心!