2

I am trying to design a multi-layered architecture for my thesis but struggling a lot. Please advise for one layer and I ll try for the rest. The expected figure is attached below and the code I have written so far is as follows

I asked questions earlier as well but couldn't progress much. Following code is from my earlier question

\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

2 Answers 2

0

an alternative ...

\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

4

I have added some styles, change the tikz code, deleted unused packages and set the document class to standalone.

I used No borders on left/right side of tikz nodes for drawing my self-made cylinder. Drawing the cyclinder like this is propbably not the easiest way, but it worked.

A MWE:

\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}

The following is produced:

Layered diagram

TODO

The lines from the containers to the plus-sign start in the middle of the container, this does not look good. I have to wait for suggestions to improve this.

2
  • 1
    +1. To get the + node centered, you could just draw it after the left and right containers using midway. And there exist predefined cylinder shapes in the shapes.geometric library, which you load already, and which you could simply use here.
    – user121799
    Commented Jul 28, 2018 at 5:02
  • what distance is -0\pgflinewidth? is not shorter to write 0 instead -0\pgflinewidth or0\pgflinewidth?
    – Zarko
    Commented Jul 29, 2018 at 21:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .