5

I would like to know how to make this image better, maybe with a more "compact" code.

Also I would like to place the label IMT to better fit the arrow. Is it possible to fill the axis between pompa and turbina with a shade? Lastly I would like that the arrows between boxes ends before touching the boxes.

Thank you, and sorry for my English.

This is my code:

\documentclass{article} 
\usepackage{tikz}
\usetikzlibrary{positioning,intersections,shapes.geometric,fit,arrows,decorations.pathmorphing,decorations.pathreplacing,decorations.shapes,decorations.markings}


\begin{document}

\begin{tikzpicture}[>=latex',auto,inner sep=2mm,node distance=2cm and 3cm]

%set styles for the axis between turbine and pump and for the boxes

\tikzset{asse/.style   = {thick, double,double distance = 6pt}}
\tikzset{box1/.style={draw,minimum width=2.5cm,rectangle,thick}}

% draw nodes

\node[box1] (setA) {\textit{SET A}};
\node[box1] (evaporatore) [below=of setA] {\textit{Evaporatore}};
\node[draw,trapezium,shape border rotate=90,inner sep=1pt,minimum width=2.5cm,trapezium stretches=true,trapezium angle=80] (turbina) [on grid,below right= of evaporatore] {\textit{Turbina}};
\node[box1] (sem) [right=of turbina] {\textit{SEM}};
\node[box1] (condensatore) [on grid,below left=of turbina] {\textit{Condensatore}};
\node[draw,circle] (pompa) [on grid,below left= of evaporatore] {\textit{Pompa}};
\node[box1] (setB) [below=of condensatore] {\textit{SET B}};

%draw axis between turbine and pump

\node (imt) [draw, dashed,inner sep=3pt, rectangle, fit = (evaporatore) (turbina) (condensatore)(pompa)] {};


%connecting evaporatore-turbina-condensatore-pompa (with arrows in the middle of the path)
\begin{scope}[>=triangle 60]
 \draw [decoration={markings, mark=at position 0.6 with {\arrow{>}}},postaction={decorate}] (evaporatore) -| (turbina.top right corner);
 \draw [decoration={markings, mark=at position 0.6 with {\arrow{>}}},postaction={decorate}]  (turbina.bottom left corner) |- (condensatore);
 \draw [decoration={markings, mark=at position 0.4 with {\arrow{>}}},postaction={decorate}] (condensatore) -| (pompa);
 \draw [decoration={markings, mark=at position 0.6 with {\arrow{>}}},postaction={decorate}] (pompa) |- (evaporatore);
 \end{scope}


%draw the IMT label

\node[] (labelimt) [above right=0.5cm and 0.5cm of imt] {\textit{IMT}};
\draw[->,decorate,decoration={bent,amplitude=-2,aspect=0.3}] (labelimt) -- (imt);

%draw the "asse"

 \draw[asse](pompa) to node[]{asse} (turbina);

 %draw arrows

 \begin{scope}[>=stealth']
 \path[->] (setA) edge node[] {$q_A$} (evaporatore);
 \path[->] (turbina) edge node[] {$l$} (sem);
 \path[->] (condensatore) edge node[] {$q_B$} (setB);
\end{scope}

\end{tikzpicture}
\end{document}
Jake
  • 232,450
Angelo
  • 413
  • 2
    You can format your code samples by highlighting the code and pressing the {} button in the interface. – Jake May 01 '12 at 11:32
  • 2
    Just a minor tip: You can use the standalone class instead of article for single tikzpictures. This way the resulting file holds only the picture. – Martin Scharrer May 01 '12 at 11:35
  • @MartinScharrer That makes me feel somewhat claustrophobic... :D – Alenanno May 01 '12 at 22:26
  • Use \documentclass[border=5mm]{standalone} and will have some more 'fresh air' around the figure. – Ignasi May 02 '12 at 08:28

2 Answers2

6

Instead of \draw[asse](pompa) to node[]{asse} (turbina);

\path(pompa) to node[]{asse} (turbina);
\draw[pattern=north east lines] ($(pompa.east)+(0,-3pt)$) rectangle ($(turbina.west)+(0,3pt)$);

and

\node[] (labelimt) at ([shift={(2,2)}]imt.north east) {\textit{IMT}};
\draw[->,decorate,decoration={bent,amplitude=-2,aspect=0.3}] (labelimt) -- (imt.north east);

To get a new arrow but I'm not sure if you want that

and shorten >=0.1cm for the arrows. I add a new style : deco and reformat the code

\documentclass{article} 
\usepackage{tikz}
\usetikzlibrary{positioning,
               intersections,
               shapes.geometric,
               decorations.pathmorphing,
               decorations.pathreplacing,
               decorations.shapes,
               decorations.markings,
               patterns,
               calc,
               fit,
               arrows, }

\begin{document}

\begin{tikzpicture}[>=latex',auto,inner sep=2mm,node distance=2cm and 3cm]

%set styles for the axis between turbine and pump and for the boxes

\tikzset{box1/.style={draw,minimum width=2.5cm,rectangle,thick}}
\tikzset{deco/.style={decoration={markings,
                       mark=at position #1 with {\arrow{>}}},
                       postaction={decorate}}}
\tikzset{turb/.style={draw,trapezium,shape border rotate=90,inner sep=1pt,minimum width=2.5cm,trapezium stretches=true,trapezium angle=80,on grid,below right= of evaporatore}}                       
% draw nodes

\node[box1] (setA)                       {\textit{SET A}};
\node[box1,below=of setA] (evaporatore)  {\textit{Evaporatore}};
\node[turb] (turbina)                    {\textit{Turbina}};
\node[box1,right=of turbina] (sem)                            {\textit{SEM}};
\node[box1,on grid,below left=of turbina] (condensatore)      {\textit{Condensatore}};
\node[draw,circle,on grid,below left= of evaporatore] (pompa) {\textit{Pompa}};
\node[box1] (setB)         [below=of condensatore]            {\textit{SET B}};

%draw axis between turbine and pump

\node (imt) [draw, 
             dashed,
             inner sep=3pt,
             fit = (evaporatore) (turbina) (condensatore)(pompa)] {};

%connecting evaporatore-turbina-condensatore-pompa (with arrows in the middle of the path)
\begin{scope}[>=triangle 60]
 \draw [deco=0.6]  (evaporatore)                -| (turbina.top right corner);
 \draw [deco=0.6]  (turbina.bottom left corner) |- (condensatore);
 \draw [deco=0.4]  (condensatore)               -| (pompa);
 \draw [deco=0.6]  (pompa)                      |- (evaporatore);
 \end{scope}

%draw the IMT label

\node[] (labelimt) at ([shift={(2,2)}]imt.north east) {\textit{IMT}};
\draw[->,decorate,decoration={bent,amplitude=-2,aspect=0.3}] (labelimt) -- (imt.north east);

%draw the "asse"

\path(pompa) to node[]{asse} (turbina);
\draw[pattern=north east lines] ($(pompa.east)+(0,-3pt)$) rectangle ($(turbina.west)+(0,3pt)$);
 %draw arrows

 \begin{scope}[>=stealth']
 \path[shorten >=0.1cm,->] (setA) edge node[]         {$q_A$} (evaporatore);
 \path[shorten >=0.1cm,->] (turbina) edge node[]      {$l$}   (sem);
 \path[shorten >=0.1cm,->] (condensatore) edge node[] {$q_B$} (setB);
\end{scope}

\end{tikzpicture}
\end{document}

enter image description here

Alain Matthes
  • 95,075
2

Great job. I worked a bit on your code to fit my needs and this is what i get. I'm just wondering if there is a better way to put labels (1,2,3,4) upon the arrow marks in the connection lines.

enter image description here

\documentclass{article} 
\usepackage{tikz}
\usetikzlibrary{positioning,
                intersections,
                shapes.geometric,
                decorations.pathmorphing,
                decorations.pathreplacing,
                decorations.shapes,
                decorations.markings,
                patterns,
                calc,
                fit,
                arrows,
                backgrounds}
\usepackage{bm}
\begin{document}


\begin{tikzpicture}[>=latex',auto,inner sep=2mm,node distance=2cm and 3cm]

%setting styles

\tikzset{box1/.style={draw,minimum width=2cm,rectangle,thick}}
\tikzset{deco/.style={decoration={markings, mark=at position #1 with {\arrow{>} }},postaction={decorate}}}
\tikzset{turb/.style={draw,trapezium,shape border rotate=90,inner sep=1pt,minimum width=2.5cm,trapezium stretches=true,trapezium angle=80,on grid,below right= of evaporatore}}                       
\tikzset{every pin edge/.style={<-,shorten >=-0.2cm,decorate,decoration={bent,amplitude=-2,aspect=0.3}}}

%define nodes and labels
\node[box1] (setA)   [label=right:$T_A$]                                               {\textit{SET A}};
\node[box1,below=1cm of setA] (evaporatore)                                            {\textit{Evaporatore}};
\node[turb,fill=white] (turbina)                                                       {\textit{Turbina}};
\node[box1,right=1cm of turbina] (sem)                                                 {\textit{SEM}};
\node[box1,on grid,below left=of turbina] (condensatore)                               {\textit{Condensatore}};
\node[draw,circle,fill=white,on grid,below left= of evaporatore,inner sep=1mm] (pompa) {\textit{Pompa}};
\node[box1] (setB)  [below=1 cm of condensatore] [label=right:$T_B$]                   {\textit{SET B}};

%the "IMT" dashed box and label
\node (imt) [draw,dashed,inner sep=3pt,fit = (evaporatore) (turbina) (condensatore)(pompa),pin={[pin distance=10mm] 30:\textit{IMT}}]  {};


%drawing connections between components
\begin{scope}[>=triangle 60]
 \draw [deco=0.6]  (evaporatore)                -| node[pos=0.6]{2} (turbina.top right corner);
 \draw [deco=0.6]  (turbina.bottom left corner) |- node[above=1mm,pos=0.71]{3} (condensatore);
 \draw [deco=0.4]  (condensatore)               -| node[above=1mm,pos=0.31]{4} (pompa);
 \draw [deco=0.6]  (pompa)                      |- node[below=1mm,pos=0.63]{1} (evaporatore);
\end{scope}

%drawing the arrows

\begin{scope}[>=stealth', shorten >=-0.0cm,shorten <=-0.0cm,->]
 \path[thick] (setA)         edge node[] {$\bm{q_A}$} (evaporatore)
                  (turbina)      edge node[] {$\bm{l}$}   (sem)
                  (condensatore) edge node[] {$\bm{q_B}$} (setB);
\end{scope}

% drawing the shaded axis between "pompa" and "turbina"

\begin{scope}[on background layer]
\draw[shading=axis] ($(pompa.center)+(0,-3pt)$) rectangle ($(turbina.center)+(0,3pt)$);
\end{scope}

\end{tikzpicture}
\end{document}
percusse
  • 157,807
Angelo
  • 413