对称使用蛇形装饰来连接一些节点

对称使用蛇形装饰来连接一些节点

这是一个MWE

\documentclass[border=2pt]{standalone}

\usepackage{tikz}

\usetikzlibrary{shapes,arrows,positioning,calc,decorations.pathmorphing}

\begin{document}

\tikzstyle{snakeline} = [->,thick, decorate, decoration={pre length=0.2cm,
    post length=0.2cm, snake, amplitude=.4mm,
    segment length=2mm},thick, magenta, ->]

\tikzstyle{block} = [draw, fill=blue!20, rectangle, 
    minimum height=3em, minimum width=3em]

\tikzstyle{qq} = [draw, fill=blue!50, rectangle, 
    minimum height=1em, minimum width=1em]

\tikzstyle{left} = [coordinate]

\tikzstyle{right} = [coordinate]

\tikzstyle{pinstyle} = [pin edge={to-,thin,black}]

\begin{tikzpicture}[auto, node distance=2cm,>=latex',]

    \node [left] (left){};

    \node [block, right of=left, xshift=-7mm] (a) {A};

    \node [block, right of=a, xshift=3mm, 
    node distance=3cm, align = center] (scc) {B};

    \node [block, right of=scc, xshift=3mm, 
    node distance=3cm] (c) {C};

    \node [right, right of=c] (right) {};

    \node [block, right of=c, xshift=13mm, align=center] (g) {G};

    \draw [->] (a) -- node[name=z, align=center] {\small z} (scc);

    \draw [->] (scc) -- node[name=u, align=center] {xx} (c);

    \node [block, below of=scc] (feedback) {D};

    \draw [-] (c) -- node [name=y, align = center,xshift=3mm] {\small xxx}(right);

    \draw [->] (c) -- (g);

    \draw [->] (y) |- (feedback);

    \draw [->] (feedback) -| node {} 
        node [near end] {} (left) -- (a);

    \coordinate [above of=g] (temp) {};

    \draw [->] (g) -- (temp) -| ([xshift=-7mm]scc);

    \draw [->] (g) -- (temp) -| ([xshift=14mm]c);

    \node [right of=g, xshift=-7mm, yshift = 1.3cm,align=center] (x) {{\small some other}\\ {\small explanations}};

    \draw [snakeline, swap] ($(c.north) + (-0.4cm, 7mm)$) -- node [align = center, yshift=4mm,xshift=0mm]
    {{\small Some} \\ {\small explantions}} ($(c.north) - (0.4cm, 0.0cm)$);
\end{tikzpicture}

\end{document}

最终

在此处输入图片描述

我想将定义的蛇形风格应用到图中的某些连接中,如下所示。

\draw [snakeline] (g) -- (temp) -| ([xshift=-7mm]scc);

\draw [snakeline] (g) -- (temp) -| ([xshift=14mm]c);

然而结果并不是那么美好:

在此处输入图片描述

特别是,带有暗区的标记连接并不对称,就像下面的草图一样。

在此处输入图片描述

我应该对风格进行什么样的改变snakeline才能满足我的需要?

答案1

您可以稍微改进一下,但实际上,这种装饰不太适合这种用途。

稍微好一点,可能

我还尝试清理了其余部分的代码。总之,清理了一点。

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,positioning,calc,decorations.pathmorphing}
\begin{document}
\tikzset{
  snakeline/.style = {->,thick, decorate, decoration={pre length=0.2cm, post length=0.2cm, snake, amplitude=.4mm, segment length=2mm}, magenta},
  block/.style = {draw, fill=blue!20, minimum height=3em, minimum width=3em},
  pinstyle/.style={pin edge={to-,thin,black}},
}

\begin{tikzpicture}[auto, node distance=2cm,>={Latex[length=1.5mm]}, every node/.style={align=center}]
  \coordinate (left);
  \node [block, right=of left, xshift=-7mm] (a) {A};
  \node [block, right=of a.center, xshift=3mm, node distance=3cm, ] (scc) {B};
  \node [block, right=of scc.center, xshift=3mm, node distance=3cm] (c) {C};
  \coordinate [right=of c.center] (right);
  \node [block, right=of c.center, xshift=13mm, ] (g) {G};
  \draw [->] (a) -- node[name=z,  font=\small] {z} (scc);
  \draw [->] (scc) -- node[name=u, ] {xx} (c);
  \node [block, below of=scc] (feedback) {D};
  \draw [-] (c) -- node [name=y, , font=\small, xshift=3mm] {xxx}(right);
  \draw [->] (c) -- (g);
  \draw [->] (y) |- (feedback);
  \draw [->] (feedback) -|   (left) -- (a);
  \coordinate [above=of g.center] (temp) {};
  \draw [snakeline, <->] (g) |- ($(c.north east |- temp)-(2mm,0pt)$) coordinate (gw) edge [snakeline] (gw |- c.north) -- ($(temp -| scc.west)+(2mm,0pt)$) coordinate (wy) -- (wy |- scc.north);
  \node [right=3mm of g.center, yshift = 1.3cm, font=\small] (x) {some other\\explanations};
  \draw [snakeline, swap] ($(c.north) + (-0.4cm, 7mm)$) -- node [, yshift=4mm, font=\small, xshift=0mm] {Some \\explantions} ($(c.north) - (0.4cm, 0.0cm)$);
\end{tikzpicture}
\end{document}

相关内容