TikZ 决策箭头中的故障

TikZ 决策箭头中的故障

我是 TikZ 流程图的新手,我获得了一个模板并根据我的要求对其进行了修改。流程是正确的,但从决策(到达目的地?)到另一过程的箭头有一个小故障。我尝试进行了一些修改,但失败了。如能提供任何帮助/提示,​​我将不胜感激。

\documentclass[border=5mm,tikz,preview]{standalone}
\usetikzlibrary{arrows, arrows.meta, 
                chains,
                positioning,
                shapes} \makeatletter

\tikzset{reset join/.code={\def\tikz@after@path{}}}
\makeatother

\begin{document}
\begin{tikzpicture}[
node distance= 7mm and 13 mm,
     start chain = going below,
     base/.style = {draw, thick, align=center, 
                    inner ysep=1mm, inner xsep=2mm,
                    join=by arrow, on chain},
startstop/.style = {base, rounded rectangle},
       io/.style = {trapezium, base,
                    trapezium left angle=70, trapezium right angle=110},
  process/.style = {base},
 decision/.style = {diamond, aspect=1.5, base, inner xsep=0pt},
    arrow/.style = {-{Stealth[scale=1.2]}, rounded corners, thick}
                    ]
% Shapes
\node (start)   [startstop] {Start};
\node (io1)     [io]        {Initial Body Motor Parameters = {Dir, Dest}};
\node (box6)    [process]   {Enable Motor Driver};
\node (box1)    [process]   {Sample Body Motor Current Sensors};
\node (branch1) [decision]  {$I_{BDY} < Limit$};
\node (box2)    [process]   {Read Dest Proximity Sensor};
\node (branch2) [decision]  {Reached Dest?};
\node (box7)    [process]   {Disable Motor Driver};
\node (end)     [startstop] {End};
\node (io2)     [io, right=1 of branch1,reset join] {Initialize Parameters to Stop};
\node (box4)    [process] {Update Error Status};
\node (box5)    [process]   {Enable Motor Driver};

%% Arrows
\draw[arrow] (branch1.east) node[above right] {False} -- (io2);
\node[below right] at (branch1.south) {True};
\node[above left] at (branch2.west) (m1) {False};
\node[below right] at (branch2.south) {True};
\draw[arrow] (branch2.west) |- + (-2.0,0) |- (box6.west); 
\draw[arrow] (box5.south) |- + (0,-1) |- (box7.east);

\end{tikzpicture}
\end{document}

在此处输入图片描述

答案1

对于未由join宏定义的箭头,我将使用 @Qrrbrbirlbel 包/tikzext.paths.ortho。除此之外,还会稍微重新设计流程图:使所有节点宽度相等,并在需要的地方启用多条线:

\documentclass[border=5mm,tikz,preview]{standalone}
\usetikzlibrary{arrows, arrows.meta,
                chains,
                ext.paths.ortho,
                positioning,
                shapes} 
                
\makeatletter
\tikzset{reset join/.code={\def\tikz@after@path{}}}
\makeatother

\begin{document}
    \begin{tikzpicture}[
node distance= 5mm and 13 mm,
     start chain = going below,
     base/.style = {draw, thick, align=flush center,
                    inner sep=1mm,
                    text width=34mm, font=\linespread{0.84}\selectfont,
                    join=by arrow, on chain},
startstop/.style = {draw, rounded rectangle, base, text width=3em},
       io/.style = {trapezium, base,
                    trapezium left angle=70, trapezium right angle=110},
  process/.style = {base},
 decision/.style = {diamond, aspect=1.5, base, 
                    text width=27mm, inner xsep=0pt},
    arrow/.style = {-{Stealth[scale=1.2]}, rounded corners, thick}
                        ]
% Shapes
\node (start)   [startstop] {Start};
\node (io1)     [io]        {Initial Body Motor Parameters = {Dir, Dest}};
\node (box6)    [process]   {Enable Motor Driver};
\node (box1)    [process]   {Sample Body Motor Current Sensors};
\node (branch1) [decision]  {$I_{\mathit{BDY}} < \mathit{Limit}$};
\node (box2)    [process]   {Read Dest Proximity Sensor};
\node (branch2) [decision]  {Reached Dest?};
\node (box7)    [process]   {Disable Motor Driver};
\node (end)     [startstop] {End};
\node (io2)     [io, right=1 of branch1,reset join] {Initialize Parameters to Stop};
\node (box4)    [process] {Update Error Status};
\node (box5)    [process]   {Enable Motor Driver};

%% Arrows
\draw[arrow] (branch1) -- node[above] {False} (io2);
\node[below right] at (branch1.south) {True};
\node[below right] at (branch2.south) {True};
\draw[arrow] (branch2.west) -|- [distance=-15mm] node[pos=0.1, above] {False} (box6);
\draw[arrow] (box5) |- (box7);
    \end{tikzpicture}
\end{document}

编辑:
哎呀,我上传了错误的图片。以上 MWE 生成:

在此处输入图片描述

相关内容