Сделал несколько узлов, но появился вопрос: как увеличить высоту node-ов, чтобы сохранить расстояние между ними?
Например, у меня есть node 'branch-name':
и node 'address':
Когда я располагаю их один под другим, то расстояние уменьшается на величину "крыши домика":
Исходники можете скачать в архиве:
http://www.live-wtr.ru/leo/diagram.zipДля тех, кто не хочет качать - даю их здесь:
pgfmoduleaddress.code.tex
Код:
\pgfdeclareshape{address}{ \inheritsavedanchors[from=rectangle]
% this is nearly a rectangle
\inheritanchorborder[from=rectangle]
\inheritanchor[from=rectangle]{center}
\inheritanchor[from=rectangle]{north} \inheritanchor[from=rectangle]{south}
\inheritanchor[from=rectangle]{west} \inheritanchor[from=rectangle]{east}
\anchor{north}{
\southwest \pgf@xa=\pgf@x \pgf@ya=\pgf@y
\northeast \pgf@xb=\pgf@x \pgf@yb=\pgf@y
\pgf@process{\northeast}%
\pgfmathparse{(\pgf@xb-\pgf@xa)/2}
\advance\pgf@x by -\pgfmathresult pt
\advance\pgf@y by 10pt
}
\backgroundpath{
%{{{ store lower left in xa/ya and upper right in xb/yb
\southwest \pgf@xa=\pgf@x \pgf@ya=\pgf@y
\northeast \pgf@xb=\pgf@x \pgf@yb=\pgf@y
%}}}
\pgf@xc = .5\wd\pgfnodeparttextbox
\pgf@yc = \pgf@yb
\advance\pgf@yc by 10pt % this should be a parameter
%{{{ construct 2 bottom lines
\pgfpathmoveto{\pgfpoint{\pgf@xa}{\pgf@ya}}
\pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@ya}}
\pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@yb}}
\pgfpathlineto{\pgfpoint{\pgf@xc}{\pgf@yc}}
\pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@yb}}
\pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@ya}}
%}}}
}
}
pgfmodulebranch-name.code.tex
Код:
\pgfdeclareshape{branch-name}{ \inheritsavedanchors[from=rectangle]
% this is nearly a rectangle
\inheritanchorborder[from=rectangle] \inheritanchor[from=rectangle]{center}
\inheritanchor[from=rectangle]{north} \inheritanchor[from=rectangle]{south}
\inheritanchor[from=rectangle]{west} \inheritanchor[from=rectangle]{east}
\anchor{south}{
\southwest \pgf@xa=\pgf@x \pgf@ya=\pgf@y
\northeast \pgf@xb=\pgf@x \pgf@yb=\pgf@y
\pgf@process{\southwest}%
\pgfmathparse{(\pgf@xb-\pgf@xa)/2}
\advance\pgf@x by \pgfmathresult pt
\advance\pgf@y by -10pt
}
\saveddimen{\depth}{
\pgf@y = \pgf@y - 10pt
}
\backgroundpath{
%{{{ store lower left in xa/ya and upper right in xb/yb
\southwest \pgf@xa=\pgf@x \pgf@ya=\pgf@y
\northeast \pgf@xb=\pgf@x \pgf@yb=\pgf@y
%}}}
\pgf@xc = .5\wd\pgfnodeparttextbox
\pgf@yc = \pgf@ya
\advance\pgf@yc by - 10pt % this should be a parameter
\southwest \pgf@xa=\pgf@x \pgf@ya=\pgf@y
%{{{ construct 2 bottom lines
\pgfpathmoveto{\pgfpoint{\pgf@xa}{\pgf@ya}}
\pgfpathlineto{\pgfpoint{\pgf@xc}{\pgf@yc}}
\pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@ya}}
\pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@yb}}
\pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@yb}}
\pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@ya}}
%}}}
}
}
diagram.tex
Код:
\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{calc,shapes,arrows}
\usepgfmodule{branch-name}
\usepgfmodule{address}
\begin{document}
\pagestyle{empty}
\def\len{1cm}
\begin{tikzpicture}
\tikzset{
line/.style = {draw},
comment/.style = {rectangle, draw, text centered, rounded corners, minimum height=2em,fill=white},
terminator/.style = {shape=rounded rectangle, draw, inner sep=2mm},
pause/.style = {shape=trapezium, inner sep=2mm, trapezium right angle = -70, trapezium left angle = -70},
}
\node[draw,shape=branch-name,inner sep=2ex, ] (x1) {Remark text text text $\frac{x}{2} + \pi^2$};
\node[draw,shape=address,inner sep=2ex, below of=x1, node distance=2cm] (x2) {Remark text text text $\frac{x}{2} + \pi^2$};
\draw[line] (x1.south) -- (x2.north);
\end{tikzpicture}
\end{document}