我想画一条这样的边:
从标有“Si”的边到节点“Especificar tareas TD/CD/FF”,但我不知道如何继续。
这是我的代码。谢谢
\documentclass{article}
\usepackage{tikz}
\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}
\usepackage{csquotes}
\usetikzlibrary{calc}
\tikzset{
every node/.style={
rounded corners=1mm,
align=center,
font=\sffamily
},
main/.style={
draw,
text width=5cm
}
}
\begin{document}
\centering
\begin{tikzpicture}
% Nodes
\node[main, label=180:(1)] (origen) {¿Se conoce la relacion confiabilidad/edad para esta falla?};
\node[main,anchor=east, label=180:(2)] (dos) at ($(origen.south)+(0,-1.5)$) {¿Es posible aplicar tareas TD?};
\node[main] (tareasTD) at ($(origen.south)+(-4,-3)$) {Especifique tareas TD};
\node[main, label=180:(3)] (tres) at ($(origen.south)+(0,-4.5)$) {¿Es posible aplicar tareas CD?};
\node[main] (tareasCD) at ($(origen.south)+(-3,-6)$) {Especifique tareas CD};
\node[main, text width=6cm, label=180:(4)] (cuatro) at ($(origen.south)+(0,-7.5)$) {¿Es un modo de falla categoria D?};
\node[main, label=180:(5)] (cinco) at ($(origen.south)+(-3,-9)$) {¿Es posible aplicar tareas FF?};
\node[main] (tareasFF) at ($(origen.south)+(-4.5,-10.5)$) {Especifique tareas FF};
\node[main, text width=6cm, label=180:(6)] (efectivas) at ($(origen.south)+(0,-12)$) {¿Las tareas son efectivas?};
\node[main, text width=6cm, label=180:(7)] (ultimapregunta) at ($(origen.south)+(3,-14)$) {¿Puede una modificacion de diseño eliminar el modo de falla o su efecto?};
\node[main, text width=4cm] (especificar) at ($(origen.south)+(-5,-16.5)$) {Especificar tareas TD/CD/FF};
\node[main, text width=4cm] at ($(especificar.west)+(7,0)$) {Aceptar los riesgos de propios de la falla};
\node[main, text width=4cm] at ($(especificar.west)+(12,0)$) {Modificacion de diseño};
\node[main, text width=3.5cm, circle, anchor=west] (circ) at ($(origen.south east)+(0,-1.5)$) {Si esta relacion Puede ser determinada con analisis adicionales entonces asigne ... etc. };
% Edges
\draw (origen.220) -- (origen.220|-dos.north) node[midway, right] {Parcial};
\draw (origen.195) -- (origen.195|-dos.north) node[midway, left] {Sí};
\draw (dos.300) -- (dos.300|-tareasTD.north) node[midway, left] {Sí};
\draw (tareasTD.350) -- (tareasTD.350|-tres.north);
\draw (origen.340) -- (origen.340|-tres.north) node[pos=.2, right] {No};
\draw (dos.350) -- (dos.350|-tres.north) node[midway, right] {No};
\draw (tres.187) -- (tres.187|-tareasCD.north) node[midway, left] {Sí};
\draw (tres.340) -- (tres.340|-cuatro.north) node[midway, right] {No};
\draw (tareasCD.340) -- (tareasCD.340|-cuatro.north);
\draw (cuatro.187) -- (cuatro.187|-cinco.north) node[midway, left] {Sí};
\draw (cinco.195) -- (cinco.195|-tareasFF.north) node[midway, left] {Sí};
\draw (cinco.350) -- (cinco.350|-efectivas.north) node[midway, right] {No};
\draw (cuatro.330) -- (cuatro.330|-efectivas.north) node[midway, right] {No};
\draw (efectivas.330) -- (efectivas.330|-ultimapregunta.north) node[midway, right] {No};
%This is the "half edge" labeled "Si" that I want to extend until "Especificar tareas TD/CD/FF"
\draw (efectivas.186) -- (efectivas.186|-ultimapregunta.north) node[midway, right] {Si};
\draw[dashed] (circ.west) -- (circ.west-|origen.340);
\end{tikzpicture}
\end{document}
答案1
您已经使用|-
语法作为交叉点:
\draw[dashed] (circ.west) -- (circ.west-|origen.340);
在这种情况下,表示 的水平线circ.west
与 的垂直线的交点origen.340
。附注:您可以说(circ)--(circ-|origen.340)
因为路径在节点边界处停止,并且circ
相当于与circ.center
位于同一水平线上circ.west
。
该语法也可以用作路径定义,而不是--
,-|
表示从原点开始的水平路径,然后是到目的地的垂直路径,该路径从两条路径的交叉处开始。
举个例子,你可以用
\draw (efectivas) -| (especificar) node[pos=0.75, right] {Si};
efectivas.center
这意味着从到画一条水平线,efectivas.center-|especificar.center
从该点到 画一条垂直路径especificar.center
。虽然线是在节点中心之间定义的,但它们会在节点边界处停止。您不需要说efectivas.west
或especificar.north
。
当您使用-|
或|-
作为路径声明时,midway
参考是角、pos=0.25
第一段的中心和pos=0.75
第二段的中心。在上一个命令中,标签Si
将写在垂直路径中心点的右侧位置。