我正在尝试链接一个三角形和一个点,但我不知道该怎么做。下面是我得到的图像:
\documentclass[border=3mm]{standalone}
\usepackage{etex}
\usepackage[version=0.96]{pgf}
\usepackage{tikz}
\usetikzlibrary{plotmarks,calc,arrows,shapes,snakes,automata,backgrounds,petri,positioning,fit}
\begin{document}
\begin{tikzpicture}[->,node distance=1.3cm,>=stealth',bend angle=20,auto,
place/.style={circle,thick,draw=blue!75,fill=blue!20,minimum size=10mm},
red place/.style={place,draw=red!75,fill=red!20}
every label/.style={red},
every node/.style={scale=.4},
dots/.style={fill=black,circle,inner sep=2pt}]
\node (rec1) at (0,0) [draw, thick,minimum width=2cm,minimum height=2cm]{$B_{1}$};
\node (rec2) [draw, left=of rec1,thick,minimum width=2cm,minimum height=2cm]{$B_{2}$};
\node (rec3) [draw, right=of rec1,thick,minimum width=2cm,minimum height=2cm]{$B_{3}$};
\node [dots,label=-90:$p_{0}$] (p1) at ($(rec1.north west)!0.3!(rec1.north east)$) {};
\node [dots,label=-90:$p_{1}$] (pp1) at ($(rec1.north west)!0.7!(rec1.north east)$) {};
\node [dots,label=-90:$q_{1}$] (q1) at ($(rec1.north west)!0.5!(rec1.north east)$) {};
\node [dots,label=-90:$q_{2}$] (q2) at ($(rec2.north west)!0.3!(rec2.north east)$) {};
\node [dots,label=-90:$p_{2}$] (p2) at ($(rec2.north west)!0.7!(rec2.north east)$) {};
\node [dots,label=-90:$q_{3}$] (q3) at ($(rec3.north west)!0.7!(rec3.north east)$) {};
\node [dots,label=-90:$p_{3}$] (p3) at ($(rec3.north west)!0.3!(rec3.north east)$) {};
\draw [-] (q1) to[ncbar=-7.5mm] (q2) node[xshift=5cm,yshift=2.2cm]{a3};
\draw [-] (q3) to[ncbar=-7.5mm] (q2);
\draw [-] (p2) to[ncbar] (p1) node[xshift=-2cm,yshift=1cm]{a2};
\draw [-] (p3) to[ncbar=-5mm] (pp1) node[xshift=2cm,yshift=1cm]{a1};
\node (rec4) [draw, right=of rec3,yshift=3cm,thick,minimum width=13cm,minimum height=2cm]{Scheduler};
\node (rec5) [draw, below=of rec4,yshift=1cm,thick,minimum width=2cm,minimum height=2cm]{$B_{1}^{SR}$};
\node (rec6) [draw, right=of rec5,thick,minimum width=2cm,minimum height=2cm]{$B_{3}^{SR}$};
\node (rec7) [draw, left=of rec5,thick,minimum width=2cm,minimum height=2cm]{$B_{2}^{SR}$};
\node [mark size = 4pt,color=black,label=-90:$o_{1}$] (o1) at ($(rec5.north west)!0.15!(rec5.north east)$) {\pgfuseplotmark{triangle*}};
\node [dots,label=-90:$p_{0}$] (rp0) at ($(rec5.north west)!0.4!(rec5.north east)$) {};
\node [dots,label=-90:$p_{1}$] (rp1) at ($(rec5.north west)!0.6!(rec5.north east)$) {};
\node [dots,label=-90:$q_{1}$] (rq1) at ($(rec5.north west)!0.8!(rec5.north east)$) {};
\node [mark size = 4pt,color=black,label=-90:$o_{3}$] (o3) at ($(rec6.north west)!0.15!(rec6.north east)$) {\pgfuseplotmark{triangle*}};
\node [dots,label=-90:$q_{3}$] (rq3) at ($(rec6.north west)!0.5!(rec6.north east)$) {};
\node [dots,label=-90:$p_{3}$] (rp3) at ($(rec6.north west)!0.75!(rec6.north east)$) {};
\node [mark size = 4pt,color=black,label=-90:$o_{2}$] (o2) at ($(rec7.north west)!0.15!(rec7.north east)$) {\pgfuseplotmark{triangle*}};
\node [dots,label=-90:$q_{2}$] (rq2) at ($(rec7.north west)!0.5!(rec7.north east)$) {};
\node [dots,label=-90:$p_{2}$] (rp2) at ($(rec7.north west)!0.75!(rec7.north east)$) {};
\node [dots,label=90:$o_{1}$] (so1) at ($(rec4.south west)!0.46!(rec4.south east)$) {};
\node [dots,label=90:$o_{2}$] (so2) at ($(rec4.south west)!0.06!(rec4.south east)$) {};
\node [dots,label=90:$o_{3}$] (so3) at ($(rec4.south west)!0.87!(rec4.south east)$) {};
\node [mark size = 4pt,color=black,label=-90:$q_{2}$,rotate=180] (sq2) at ($(rec4.south west)!0.11!(rec4.south east)$) {\pgfuseplotmark{triangle*}};
\node [mark size = 4pt,color=black,label=-90:$p_{2}$,rotate=180] (sp2) at ($(rec4.south west)!0.15!(rec4.south east)$) {\pgfuseplotmark{triangle*}};
\node [mark size = 4pt,color=black,label=-90:$q_{3}$,rotate=180] (sq3) at ($(rec4.south west)!0.92!(rec4.south east)$) {\pgfuseplotmark{triangle*}};
\node [mark size = 4pt,color=black,label=-90:$p_{3}$,rotate=180] (sp3) at ($(rec4.south west)!0.96!(rec4.south east)$) {\pgfuseplotmark{triangle*}};
\node [mark size = 4pt,color=black,label=-90:$p_{0}$,rotate=180] (sp0) at ($(rec4.south west)!0.50!(rec4.south east)$) {\pgfuseplotmark{triangle*}};
\node [mark size = 4pt,color=black,label=-90:$p_{1}$,rotate=180] (sp1) at ($(rec4.south west)!0.525!(rec4.south east)$) {\pgfuseplotmark{triangle*}};
\node [mark size = 4pt,color=black,label=-90:$q_{1}$,rotate=180] (sq1) at ($(rec4.south west)!0.55!(rec4.south east)$) {\pgfuseplotmark{triangle*}};
\draw [-] (o1) -- (so1);
\draw [-] (o2) -- (so2);
\draw [-] (o3) -- (so3);
\end{tikzpicture}
\end{document}
任何帮助都非常感谢。
答案1
由于某种原因,绘图标记似乎没有位于节点的中心。另一种方法是使用regular polygon
节点的形状,请参阅triangle
我定义的样式。您需要shapes.geometric
库才能使用它,但您已经在加载shapes
,所以没问题。注意我使用三角形的顶角作为线的端点。
\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{plotmarks,calc,arrows,shapes,snakes,automata,backgrounds,petri,positioning,fit}
\tikzset{
ncbar angle/.initial=90,
ncbar/.style={
to path=(\tikztostart)
-- ($(\tikztostart)!#1!\pgfkeysvalueof{/tikz/ncbar angle}:(\tikztotarget)$)
-- ($(\tikztotarget)!($(\tikztostart)!#1!\pgfkeysvalueof{/tikz/ncbar angle}:(\tikztotarget)$)!\pgfkeysvalueof{/tikz/ncbar angle}:(\tikztostart)$)
-- (\tikztotarget)
},
ncbar/.default=0.5cm,
}
\begin{document}
\begin{tikzpicture}[->,node distance=1.3cm,>=stealth',bend angle=20,auto,
every node/.style={scale=.4},
dots/.style={fill=black,circle,inner sep=2pt},
triangle/.style={fill=black,regular polygon,regular polygon sides=3,minimum size=10pt,inner sep=0pt,}]
\node (rec4) [draw, thick,minimum width=13cm,minimum height=2cm]{Scheduler};
\node (rec5) [draw, below=of rec4,yshift=1cm,thick,minimum width=2cm,minimum height=2cm]{$B_{1}^{SR}$};
\node [triangle,label=-90:$o_{1}$] (o1) at ($(rec5.north west)!0.15!(rec5.north east)$) {};
\node [dots,label=90:$o_{1}$] (so1) at ($(rec4.south west)!0.46!(rec4.south east)$) {};
\draw [-] (o1.corner 1) -- (so1);
\end{tikzpicture}
\end{document}