使用方框和虚线箭头的分层设计

使用方框和虚线箭头的分层设计

我正在尝试为我的论文设计一个多层架构,但遇到了很多困难。请为其中一层提供建议,我会尝试完成其余部分。预期图附在下面,到目前为止我编写的代码如下

我之前也问过问题,但进展不大。以下代码来自我之前的问题

\documentclass{elsarticle}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{epstopdf}
\usepackage[ruled,vlined,linesnumbered]{algorithm2e}
\usepackage{algpseudocode}
\usepackage{tikz,pgfplots,pgfplotstable}
\usepackage{tikz-qtree}
\usepackage{forest}
\usepackage{lettrine}
\usepackage{mathtools}
\usepackage{lscape}
\usepackage{pgf-pie}

\usetikzlibrary{positioning,shapes,arrows,shadows,patterns,intersections,calc,fit}

\tikzset{
myRectangle/.style={
    rectangle,
    draw,
    node distance=0.65 cm,
    text width=7 em,
    text centered,
    rounded corners,
    minimum height=4 em,
    minimum width=3 cm,
    thick
},
redRectangle/.style={
    myRectangle,
    fill=red!20,
},
container/.style={
    rectangle,
    draw,
    inner sep=0.5 cm,
    rounded corners 
},
line/.style={
    draw,
    -latex',
    thick
}
}
\begin{document}
\begin{figure*}
\centering
\begin{tikzpicture}[transform shape]
\node [](origin){};
\node [redRectangle, right=of origin] (aa) {aa};
\node [redRectangle, left=of origin] (bb) {bb};
\node [redRectangle, below=of bb] (cc) {cc};
\node [redRectangle, below=of aa] (dd) {dd};
\path [line] (bb) -- (aa);
\path [line] (bb) -- (cc);
\path [line] (aa) -- (dd);

\node [redRectangle, right=15mm of aa] (pp) {pp}; % question 1
\node [redRectangle, right=of pp] (rr) {rr};
\node [redRectangle] (qq) at ($(pp)!.5!(rr) + (0,-2)$) {qq}; % question 2

\node [container, fit=(aa)(origin)(bb)(cc)(dd)] (container1) {};
\node [container, fit=(pp)(rr)(qq)] (container2) {};    

\node [redRectangle] (xx) at ($(aa)!.5!(pp) + (0,3)$) {xx};
\node [container, fit=(xx)] (container3) {};    

\node [container, fit=(container1)(container2)(container3)] (containerAll) {};
\end{tikzpicture}
\end{figure*}
\end{document}

Expected Figure

答案1

替代 ...

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows,
                calc,
                fit,
                positioning,
                shapes.geometric}

\tikzset{
rrbox/.style={%rounded red box,
    rectangle,
    draw, rounded corners, thick, fill=red!20,
    minimum height=8mm, minimum width=24mm,
    text width =\pgfkeysvalueof{/pgf/minimum width}-2*\pgfkeysvalueof{/pgf/inner xsep},
    align=center
            },
sum/.style={% summation
    circle,
    draw=black, minimum size=8mm,
    append after command={\pgfextra{\let\LN\tikzlastnode
        \draw[thick,shorten >=1mm, shorten <=1mm, -]
            (\LN.north) edge (\LN.south)
            (\LN.west)   to  (\LN.east);
%        \draw[blue] (\LN.center)  circle (1.414*4 mm);
                }},% end of nappend after command
    node contents={}
            },
disk/.style={% cylinder
    cylinder, shape border rotate=90,
    draw, fill=red!20,
    aspect=0.25,
    minimum height=12mm, minimum width=54mm,
    align=center
            },
container/.style={
    rectangle,
    draw, rounded corners,
    inner sep=4mm, yshift=2mm,
    node contents={}
                },
line/.style={
    draw, thick, dashed, -latex',
            },
        }% end of tikzset

\begin{document}
    \begin{tikzpicture}[
node distance=8mm and 4mm,
                        ]
% Container 1, on the left side
\node (sum) [sum]; % sumation
\node (a11) [rrbox, above left=4mm and 18mm of sum.west] {some text a11};
\node (a12) [rrbox, left =of a11] {some text a12};
\node (a21) [rrbox, below=of a11] {some text a21};
\node (a22) [rrbox, below=of a12] {some text a22};
\draw[line] (a12) edge (a11)
            (a12) edge (a22)
            (a11) edge (a21)
            (a22)  to  (a21);
\node (container1) [container, fit=(a11) (a22),
                    label={[anchor=north]Some more Text}];
% Container 2, on the right side
\node (b11) [rrbox, above right=4mm and 18mm of sum.east] {some text b11};
\node (b12) [rrbox, right =of b11] {some text b12};
\node (b21) [rrbox, below=of $(b11.south)!0.5!(b12.south)$] {some text b21};
\draw[line] (b12) edge (b11)
            (b11) edge (b21)
            (b12)  to  (b21);
\node (container2) [container, fit=(b11) (b12) (b21),
                    label={[anchor=north]Some more Text}];
% Container 3, on the upper side
\node (c11) [rrbox, above=of sum] {some text c11};
\node (c12) [rrbox, above=of c11] {some text c12};
\draw[line] (c12)  to  (c11);
\node (container3) [container, fit=(c11) (c12),
                    label={[anchor=north]text}];
% cylinder
\node (d) [disk, below=of sum |- container1.south] {some text here\\in two lines};
% Lines to and from the summation
\draw[line] (container1.east |- sum) edge (sum)
            (container2.west |- sum) edge (sum)
            (container3) edge (sum)
            (sum) to ($(d.before top)!0.5!(d.after top)$);
%
\node [container, yshift=-2mm,
       fit=(container1)(container2)(container3) (d)];
    \end{tikzpicture}
\end{document}

enter image description here

答案2

我添加了一些样式,更改了 tikz 代码,删除了未使用的包并将文档类设置为独立。

我用了tikz 节点的左/右侧没有边框绘制我自己制作的圆柱体。像这样绘制圆柱体可能不是最简单的方法,但它确实有效。

A平均能量损失

\documentclass{standalone}
\usepackage{tikz,pgfplots}
\usetikzlibrary{positioning,arrows,intersections,calc,fit, shapes.geometric,backgrounds}

\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}

\tikzset{
myFilling/.style={
    fill=red!20
},
myRectangle/.style={
    rectangle,
    draw,
    node distance=0.65 cm,
    text width=7 em,
    text centered,
    rounded corners,
    minimum height=4 em,
    minimum width=3 cm,
    thick,
},
myCircle/.style={
    draw,
    node distance=0.65 cm,
    text centered,
    circle,
    minimum height=1 cm,
    minimum width=1 cm,
    thick
},
myEllipse/.style={
    minimum height=1.5cm,
    minimum width=6cm,
    myFilling,
},
redRectangle/.style={
    myRectangle,
    myFilling
},
container/.style={
    rectangle,
    black,
    draw,
    inner sep=0.5 cm,
    rounded corners,
    draw=black,
},
line/.style={
    draw,
    -latex',
    thick,
    dashed,
    shorten >=0.2cm % shorten the lines a bit
},
c/.style={line width=0, myFilling, append after command={% this is from https://tex.stackexchange.com/questions/161542/no-borders-on-left-right-side-of-tikz-nodes
    \pgfextra{%
        \begin{pgfinterruptpath}\begin{pgfonlayer}{foreground}
        \draw[] let \p1=($(\tikzlastnode.north east)+(-0\pgflinewidth,-0.5\pgflinewidth)$),
            \p2=($(\tikzlastnode.north west)+(0\pgflinewidth,-0.5\pgflinewidth)$),
            \p3=($(\tikzlastnode.south west)+(0\pgflinewidth,0.5\pgflinewidth)$),
            \p4=($(\tikzlastnode.south east)+(-0\pgflinewidth,0.5\pgflinewidth)$) in
            (\p1) (\p2) -- (\p3)  (\p4) -- (\p1);
        \end{pgfonlayer}\end{pgfinterruptpath}
    }
}},
}

\begin{document}

\begin{tikzpicture}[transform shape]

% Container 1, on the left side
\node [myCircle](origin){+}; % this is the plus
\node [redRectangle, left= 2cm of origin, label=above left:{Some more Text}] (aa) {aa};
\node [redRectangle, left=of aa] (bb) {Text of this node called bb};
\node [redRectangle, below=of bb] (cc) {cc};
\node [redRectangle, below=of aa] (dd) {dd};
\path [line] (bb) -- (aa);
\path [line] (bb) -- (cc);
\path [line] (aa) -- (dd);
\path [line] (cc) -- (dd);

% create a container that contains all rectangles
\node [container, fit=(aa)(bb)(cc)(dd)] (container1) {};

% Container 2, on the right side\\
\node [redRectangle, right=2cm of origin] (pp) {pp};
\node [redRectangle, right=of pp, label=above left:{Even more Text}] (rr) {rr};
\node [redRectangle] (qq) at ($(pp)!.5!(rr) + (0,-2)$) {qq}; % calcualte the middle of pp and rr and go down
\path [line] (rr) -- (pp);
\path [line] (rr) -- (qq);
\path [line] (pp) -- (qq);

\node [container, fit=(pp)(rr)(qq)] (container2) {};    


% Container 3, on the upper side
\node [redRectangle] (xx) at ($(aa)!.5!(pp) + (0,3)$) {xx};  % calculate the middle of aa and pp and go up
\node [redRectangle, above=of xx, label=above:{Text} ] (yy) {yy}; % set a label above the rectangle
\path [line] (yy) -- (xx);
\node [container, fit=(xx) (yy)] (container3) {};    

% This is a selfmade cyclinder-ish thing
\node[shape=ellipse, draw, below=5cm of origin, myEllipse] (cylinderBottom) {};
\node[shape=rectangle, above=-0.75cm of cylinderBottom, myEllipse, c] (cylinderMiddle) {};
\node[shape=ellipse, draw, above=0cm of cylinderBottom, myEllipse] (cylinderTop) {};
\node[above=-0.75cm of cylinderBottom]  {Some text here};

% Lines to and from the plus
\draw[line] (node cs:name=container1, anchor=east)|- (node cs:name=origin,anchor=west);
\draw[line] (node cs:name=container2,anchor=west)|- (node cs:name=origin,anchor=east);
\draw[line] (node cs:name=container3,anchor=south) -| (node cs:name=origin,anchor=north);
\draw[line] (node cs:name=origin,anchor=south) -| (node cs:name=cylinderTop,anchor=north);


\node [container, fit=(container1)(container2)(container3) (cylinderBottom)] (containerAll) {};
\end{tikzpicture}

\end{document}

生成以下内容:

Layered diagram

去做

从容器到加号的线条从容器中间开始,这看起来不太好。我必须等待建议来改进这一点。

相关内容