[Tex/LaTex] Tikz- complicated shapes as nodes

nodesshapestikz-pgf

I'm trying to reproduce the following picture

enter image description here

In this picture, there are some shapes that are repeated. For instance 5, 6, 8, 10 and 11. My idea is to use ./style in order to define these shapes and place them in the appropriate positions.

Although I know how to create simple styles in tikz(like pipe in my code), I am not aware how to create more complicated shapes and repeat them in my picture.
For instance I can't draw shape 5 as is, but I drew it as a simple orthogonal box.

Any idea on how to draw them and reproduce the image?

EDIT I am also trying to create shapes 4 and 12, but I can't seem to be able to draw them and place them in the right position.

My code so far is

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}

\tikzset{
  pipe/.style = {
    draw,
    minimum width=4cm, 
    minimum height=.1cm, 
    anchor=east,
  },
  source/.style = {
    draw,
    fill=black, 
    minimum width=.8cm, 
    minimum height=.4cm, 
  },
  lenses/.style = {
    draw,
    fill=yellow,
    minimum width=.7cm, 
    minimum height=.1mm, 
  },
  steerer/.style = {
    draw,
    fill=blue,
    minimum width=.7cm, 
    minimum height=.5cm, 
    rounded corners
  }
  }

\begin{document}
 \definecolor{tank}{RGB}{98,190,177}
 \begin{tikzpicture}
  %tank
  \coordinate (tank) at (0,0);
  \draw[tank, fill=tank] (-2,0.5)--(-0.5,1)--(0.5,1)--(2,0.5)--(2,-0.5)--(0.5,-1)--(-0.5,-1)--(-2,-0.5)--cycle;
  %pipes
  \coordinate (pipe1) at (-2,0);
  \node[pipe] at (pipe1) (pipe1) {};%left pipe
  \coordinate (pipe2) at (2,0);
  \node[pipe,anchor=west] at (pipe2) (pipe2) {};%right pipe
  \node[pipe, right=0mm of pipe2,rotate=-90] (pipe3) {};
  \node[pipe, right=0mm of pipe3,rotate=-160] (R3) {};
  \node[pipe, right=0mm of pipe3,rotate=-130] (R2) {};
  \node[pipe, right=0mm of pipe3,rotate=-110] (R1) {};
  \node[pipe, right=0mm of pipe3,rotate=-80] (L1) {};
  \node[pipe, right=0mm of pipe3,rotate=-50] (L2) {};
  \node[pipe, right=0mm of pipe3,rotate=-20] (L3) {};
  \node[pipe, left=0mm of pipe1,rotate=-30] (sputter) {};
  \node[pipe, left=0mm of pipe1,rotate=30] (duoplasmatron) {};
  %experimental chamber
  \node[circle,fill=red,right=-1.5mm of L1] {};
  %sources  
  \node[source, left=0mm of sputter,rotate=60,anchor=south] (spusource) {};
  \node[source, left=0mm of duoplasmatron,rotate=-60,anchor=north] (duosource) {};
  %electrostatic lenses
  \node[lenses,rotate=60,fill=yellow] at (sputter) (lenses1) {};
  \node[lenses,rotate=-60,fill=yellow] at (duoplasmatron) (lenses2) {};
  \node[lenses,rotate=90, left=-7.5mm of pipe1, anchor=south,fill=yellow] (lenses3) {};
  \node[lenses,rotate=90, right=-7.5mm of pipe1, anchor=north,fill=yellow] (lenses3) {};
  %steerers
  \node[steerer,rotate=90, right=-15mm of pipe1, anchor=north] (steerer1) {};
  \node[steerer,rotate=90, left=-15mm of pipe2, anchor=south] (steerer2) {};
  %analyser
  \draw[red,fill=white] (5.6,-0.25)--(5.5,-0.25)--(5.5,0.25)--(5.9,0.25)arc(90:0:0.375cm)--+(0,-0.5)--+(-0.5,-0.5)--+(-0.5,-0.3)arc(0:90:0.175cm);
  %inflector
  \draw[red, thick] (-5.95,-0.1cm)--(-5.95,0.1cm)--+(135:0.3cm)--(-6.4,0.33);
  %walls
  \draw[very thick] (-3,-4)--(5,-4)arc(180:270:1)--(6,-8)--(6,-5)arc(270:360:1)--(9,-4);
 \end{tikzpicture}
\end{document}

and my output is

enter image description here

EDIT After @Symbol 's answer the code has been modified

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}

\tikzset{
  pipe/.style = {
    draw,
    minimum width=4cm, 
    minimum height=.1cm, 
    anchor=east,
  },
  steerer/.style = {
    draw,
    fill=white,
    minimum width=.2cm, 
    minimum height=.5cm, 
    anchor=east,
    rounded corners=0.5mm
  }
}

\begin{document}
 \definecolor{tank}{RGB}{98,190,177}
 \makeatletter

\pgfdeclareshape{slits}{
    \savedanchor\centerpoint{\pgf@x=0cm \pgf@y=0cm}
    \saveddimen\halfwidth{
        \pgf@x=.25cm
        \pgfmathsetlength\pgf@xa{.5\pgfkeysvalueof{/pgf/minimum width}}
        \ifdim\pgf@x<\pgf@xa\pgf@x=\pgf@xa\fi}
    \saveddimen\halfheight{
        \pgf@x=.25cm
        \pgfmathsetlength\pgf@xa{.5\pgfkeysvalueof{/pgf/minimum height}}
        \ifdim\pgf@x<\pgf@xa\pgf@x=\pgf@xa\fi}
    \anchor{center}\centerpoint
    \anchor{north}{
        \pgf@process\halfheight
        \pgf@x=0cm
        \pgf@y=.2cm\advance\pgf@y by\halfheight}
    \anchorborder{\centerpoint}
    \backgroundpath{
        \draw[rounded corners=.1cm, fill=white](-\halfwidth,-\halfheight)rectangle(\halfwidth,\halfheight);
        \draw[rounded corners=.04cm](-.8*\halfwidth,-.4*\halfheight)rectangle(.8*\halfwidth,-.8*\halfheight)(-.8*\halfwidth,.4*\halfheight)rectangle(.8*\halfwidth,.8*\halfheight);}}

\pgfdeclareshape{quadrapole}{
    \savedanchor\centerpoint{\pgf@x=0cm \pgf@y=0cm}
    \saveddimen\halfwidth{
        \pgf@x=.25cm
        \pgfmathsetlength\pgf@xa{.5\pgfkeysvalueof{/pgf/minimum width}}
        \ifdim\pgf@x<\pgf@xa\pgf@x=\pgf@xa\fi}
    \saveddimen\halfheight{
        \pgf@x=.25cm
        \pgfmathsetlength\pgf@xa{.5\pgfkeysvalueof{/pgf/minimum height}}
        \ifdim\pgf@x<\pgf@xa\pgf@x=\pgf@xa\fi}
    \anchor{center}\centerpoint
    \anchor{north}{
        \pgf@process\halfheight
        \pgf@x=0cm
        \pgf@y=.2cm\advance\pgf@y by\halfheight}
    \anchorborder{\centerpoint}
    \backgroundpath{
        \draw[rounded corners=.1cm,fill=white](-\halfwidth,-\halfheight)rectangle(\halfwidth,\halfheight);
        \filldraw[rounded corners=.04cm,fill=red](-.8*\halfwidth,-.4*\halfheight)rectangle(.8*\halfwidth,-.8*\halfheight)(-.8*\halfwidth,-.2*\halfheight)rectangle(.8*\halfwidth,.2*\halfheight)(-.8*\halfwidth,.4*\halfheight)rectangle(.8*\halfwidth,.8*\halfheight);}}

\pgfdeclareshape{lens}{
    \savedanchor\centerpoint{\pgf@x=0cm \pgf@y=0cm}
    \saveddimen\halfwidth{
        \pgf@x=.05cm
        \pgfmathsetlength\pgf@xa{.5\pgfkeysvalueof{/pgf/minimum width}}
        \ifdim\pgf@x<\pgf@xa\pgf@x=\pgf@xa\fi}
    \saveddimen\halfheight{
        \pgf@x=.3cm
        \pgfmathsetlength\pgf@xa{.5\pgfkeysvalueof{/pgf/minimum height}}
        \ifdim\pgf@x<\pgf@xa\pgf@x=\pgf@xa\fi}
    \anchor{center}\centerpoint
    \anchor{north}{
        \pgf@process\halfheight
        \pgf@x=0cm
        \pgf@y=.2cm\advance\pgf@y by\halfheight}
    \anchorborder{\centerpoint}
    \backgroundpath{
        \draw(0,-1.2*\halfheight)--(0,-\halfheight);
        \draw(0,\halfheight)--(0,1.2*\halfheight);
        \draw[fill=white](-\halfwidth,-\halfheight)rectangle(\halfwidth,\halfheight);
        }}

\pgfdeclareshape{pump}{
    \savedanchor\centerpoint{\pgf@x=0cm \pgf@y=0cm}
    \saveddimen\halfwidth{
        \pgf@x=.025cm
        \pgfmathsetlength\pgf@xa{.5\pgfkeysvalueof{/pgf/minimum width}}
        \ifdim\pgf@x<\pgf@xa\pgf@x=\pgf@xa\fi}
    \saveddimen\halfheight{
        \pgf@x=.2cm
        \pgfmathsetlength\pgf@xa{.5\pgfkeysvalueof{/pgf/minimum height}}
        \ifdim\pgf@x<\pgf@xa\pgf@x=\pgf@xa\fi}
    \anchor{center}\centerpoint
    \anchor{north}{
        \pgf@process\halfheight
        \pgf@x=0cm
        \pgf@y=.18cm\advance\pgf@y by\halfheight}
    \anchorborder{\centerpoint}
    \backgroundpath{
        \draw[fill=black](-\halfwidth,-\halfheight)rectangle(\halfwidth,\halfheight);
        \draw[fill=white](0,-1.8*\halfheight)circle(0.75*\halfheight);
        }}

\pgfdeclareshape{source}{
    \savedanchor\centerpoint{\pgf@x=0cm \pgf@y=0cm}
    \saveddimen\halfwidth{
        \pgf@x=1cm
        \pgfmathsetlength\pgf@xa{.5\pgfkeysvalueof{/pgf/minimum width}}
        \ifdim\pgf@x<\pgf@xa\pgf@x=\pgf@xa\fi}
    \saveddimen\halfheight{
        \pgf@x=.3cm
        \pgfmathsetlength\pgf@xa{.5\pgfkeysvalueof{/pgf/minimum height}}
        \ifdim\pgf@x<\pgf@xa\pgf@x=\pgf@xa\fi}
    \anchor{center}\centerpoint
    \anchor{north}{
        \pgf@process\halfheight
        \pgf@x=0cm
        \pgf@y=.2cm\advance\pgf@y by\halfheight}
    \anchor{south}{
        \pgf@process\halfheight
        \pgf@x=0cm
        \pgf@y=-.2cm\advance\pgf@y by-\halfheight}
    \backgroundpath{
        \draw(-\halfwidth,-\halfheight)rectangle(\halfwidth,\halfheight)(-.8*\halfwidth,-1.2*\halfheight)--(-.8*\halfwidth,1.2*\halfheight)(-.4*\halfwidth,-1.2*\halfheight)--(-.4*\halfwidth,1.2*\halfheight)(0,-1.2*\halfheight)--(0,1.2*\halfheight)(.4*\halfwidth,-1.2*\halfheight)--(.4*\halfwidth,1.2*\halfheight)(.8*\halfwidth,-1.2*\halfheight)--(.8*\halfwidth,1.2*\halfheight);}}
 \begin{tikzpicture}
  %tank
  \coordinate (tank) at (0,0);
  \draw[tank, fill=tank] (-2,0.5)--(-0.5,1)--(0.5,1)--(2,0.5)--(2,-0.5)--(0.5,-1)--(-0.5,-1)--(-2,-0.5)--cycle;
  %pipes
  \coordinate (pipe1) at (-2,0);
  \node[pipe] at (pipe1) (pipe1) {};%left pipe
  \coordinate (pipe2) at (2,0);
  \node[pipe,anchor=west] at (pipe2) (pipe2) {};%right pipe
  \node[pipe, right=0mm of pipe2,rotate=-90] (pipe3) {};
  \node[pipe, right=0mm of pipe3,rotate=-160] (R3) {};
  \node[pipe, right=0mm of pipe3,rotate=-130] (R2) {};
  \node[pipe, right=0mm of pipe3,rotate=-110] (R1) {};
  \node[pipe, right=0mm of pipe3,rotate=-80] (L1) {};
  \node[pipe, right=0mm of pipe3,rotate=-50] (L2) {};
  \node[pipe, right=0mm of pipe3,rotate=-20] (L3) {};
  \node[pipe, left=0mm of pipe1,rotate=-30] (sputter) {};
  \node[pipe, left=0mm of pipe1,rotate=30] (duoplasmatron) {};
  %experimental chamber
  \node[circle,fill=red,right=-1.5mm of L1] {};
  %sources  
  \node[source,rotate=-30,above left=8mm and 7mm of sputter,anchor=north] (spusource) {};
  \node[source,rotate=30,above left=-1.75mm and 10.5mm of duoplasmatron,anchor=north] (duosource) {};
  %electrostatic lenses
  \node[lens,rotate=-30] at (sputter) (lenses1) {};
  \node[lens,rotate=30] at (duoplasmatron) (lenses2) {};
  \node[lens,rotate=0] at (-5.5,0) (lenses3) {};
  \node[lens,rotate=0] at (-2.5,0) (lenses4) {};
  %quadrapoles
  \node(st1)at(2.5,0)[quadrapole]{};
  \node(st2)at(6,-3)[quadrapole,rotate=90]{};
  %slits
  \node(sl1)at(-5,0)[slits]{};
  \node(sl2)at(4.5,0)[slits]{};
  \node(sl3)at(6,-1.5)[slits]{};
  %steerers
  \node[steerer] (steerer1)at(-3.5,0) {};
  \node[steerer] (steerer2)at(3.6125,0) {};
  %pumps
  \node(p1)at(-2.15,-0.325)[pump]{};
  \node(p2)at(2.15,-0.325)[pump]{};
  \node(p3)at(5.15,0.325)[pump,rotate=180]{};
  \node(p4)at(5.7,-3.5)[pump,rotate=-90]{};
  \node(p5)at(-8.5,-1.8)[pump,rotate=30]{};
  \node(p6)at(-8.5,1.8)[pump,rotate=150]{};
  %analyser
  \draw[red,fill=white] (5.6,-0.25)--(5.5,-0.25)--(5.5,0.25)--(5.9,0.25)arc(90:0:0.375cm)--+(0,-0.5)--+(-0.5,-0.5)--+(-0.5,-0.3)arc(0:90:0.175cm);
  %inflector  <----------------------------------
  \draw[red, thick] (-5.95,-0.1cm)--(-5.95,0.1cm)--+(135:0.3cm)--(-6.4,0.33);
  %walls
  \draw[very thick] (-3,-4)--(5,-4)arc(180:270:1)--(6,-8)--(6,-5)arc(270:360:1)--(9,-4);
 \end{tikzpicture}
\end{document}

and the output is

enter image description here

Best Answer

I have no time to do all of them. Here are some examples. (forget \newcommand)

\documentclass{minimal}
\usepackage{tikz}
\begin{document}
\makeatletter

\pgfdeclareshape{slits}{
    \savedanchor\centerpoint{\pgf@x=0cm \pgf@y=0cm}
    \saveddimen\halfwidth{
        \pgf@x=.25cm
        \pgfmathsetlength\pgf@xa{.5\pgfkeysvalueof{/pgf/minimum width}}
        \ifdim\pgf@x<\pgf@xa\pgf@x=\pgf@xa\fi}
    \saveddimen\halfheight{
        \pgf@x=.25cm
        \pgfmathsetlength\pgf@xa{.5\pgfkeysvalueof{/pgf/minimum height}}
        \ifdim\pgf@x<\pgf@xa\pgf@x=\pgf@xa\fi}
    \anchor{center}\centerpoint
    \anchor{north}{
        \pgf@process\halfheight
        \pgf@x=0cm
        \pgf@y=.2cm\advance\pgf@y by\halfheight}
    \anchorborder{\centerpoint}
    \backgroundpath{
        \draw[rounded corners=.1cm](-\halfwidth,-\halfheight)rectangle(\halfwidth,\halfheight);
        \draw[rounded corners=.04cm](-.8*\halfwidth,-.4*\halfheight)rectangle(.8*\halfwidth,-.8*\halfheight)(-.8*\halfwidth,.4*\halfheight)rectangle(.8*\halfwidth,.8*\halfheight);}}

\pgfdeclareshape{steerer}{
    \savedanchor\centerpoint{\pgf@x=0cm \pgf@y=0cm}
    \saveddimen\halfwidth{
        \pgf@x=.25cm
        \pgfmathsetlength\pgf@xa{.5\pgfkeysvalueof{/pgf/minimum width}}
        \ifdim\pgf@x<\pgf@xa\pgf@x=\pgf@xa\fi}
    \saveddimen\halfheight{
        \pgf@x=.25cm
        \pgfmathsetlength\pgf@xa{.5\pgfkeysvalueof{/pgf/minimum height}}
        \ifdim\pgf@x<\pgf@xa\pgf@x=\pgf@xa\fi}
    \anchor{center}\centerpoint
    \anchor{north}{
        \pgf@process\halfheight
        \pgf@x=0cm
        \pgf@y=.2cm\advance\pgf@y by\halfheight}
    \anchorborder{\centerpoint}
    \backgroundpath{
        \draw[rounded corners=.1cm](-\halfwidth,-\halfheight)rectangle(\halfwidth,\halfheight);
        \filldraw[rounded corners=.04cm,fill=red](-.8*\halfwidth,-.4*\halfheight)rectangle(.8*\halfwidth,-.8*\halfheight)(-.8*\halfwidth,-.2*\halfheight)rectangle(.8*\halfwidth,.2*\halfheight)(-.8*\halfwidth,.4*\halfheight)rectangle(.8*\halfwidth,.8*\halfheight);}}

\pgfdeclareshape{lens}{
    \savedanchor\centerpoint{\pgf@x=0cm \pgf@y=0cm}
    \saveddimen\halfwidth{
        \pgf@x=.05cm
        \pgfmathsetlength\pgf@xa{.5\pgfkeysvalueof{/pgf/minimum width}}
        \ifdim\pgf@x<\pgf@xa\pgf@x=\pgf@xa\fi}
    \saveddimen\halfheight{
        \pgf@x=.3cm
        \pgfmathsetlength\pgf@xa{.5\pgfkeysvalueof{/pgf/minimum height}}
        \ifdim\pgf@x<\pgf@xa\pgf@x=\pgf@xa\fi}
    \anchor{center}\centerpoint
    \anchor{south}{
        \pgf@process\halfheight
        \pgf@x=0cm
        \pgfmathsetlength\pgf@y{-1.2*\halfheight-.2cm}}
    \anchorborder{\centerpoint}
    \backgroundpath{
        \draw(0,-1.2*\halfheight)--(0,-\halfheight)(0,\halfheight)--(0,1.2*\halfheight)(-\halfwidth,-\halfheight)rectangle(\halfwidth,\halfheight);}}

\pgfdeclareshape{lollipop}{
    \savedanchor\centerpoint{\pgf@x=0cm \pgf@y=0cm}
    \saveddimen\halfwidth{
        \pgf@x=.1cm
        \pgfmathsetlength\pgf@xa{.5\pgfkeysvalueof{/pgf/minimum width}}
        \ifdim\pgf@x<\pgf@xa\pgf@x=\pgf@xa\fi}
    \saveddimen\halfheight{
        \pgf@x=.3cm
        \pgfmathsetlength\pgf@xa{.5\pgfkeysvalueof{/pgf/minimum height}}
        \ifdim\pgf@x<\pgf@xa\pgf@x=\pgf@xa\fi}
    \anchor{center}\centerpoint
    \anchor{south}{
        \pgf@process\halfheight
        \pgf@process\halfwidth
        \pgf@x=0cm
        \pgfmathsetlength\pgf@y{-\halfheight-\halfwidth-.2cm}}
    \anchorborder{\centerpoint}
    \backgroundpath{
        \draw[ultra thick](0,0)--(0,-\halfheight);
        \filldraw[fill=white](0,-\halfheight)circle(\halfwidth);}}

\pgfdeclareshape{皿}{
    \savedanchor\centerpoint{\pgf@x=0cm \pgf@y=0cm}
    \saveddimen\halfwidth{
        \pgf@x=1cm
        \pgfmathsetlength\pgf@xa{.5\pgfkeysvalueof{/pgf/minimum width}}
        \ifdim\pgf@x<\pgf@xa\pgf@x=\pgf@xa\fi}
    \saveddimen\halfheight{
        \pgf@x=.3cm
        \pgfmathsetlength\pgf@xa{.5\pgfkeysvalueof{/pgf/minimum height}}
        \ifdim\pgf@x<\pgf@xa\pgf@x=\pgf@xa\fi}
    \anchor{center}\centerpoint
    \anchor{north}{
        \pgf@process\halfheight
        \pgf@x=0cm
        \pgf@y=.2cm\advance\pgf@y by\halfheight}
    \anchor{south}{
        \pgf@process\halfheight
        \pgf@x=0cm
        \pgf@y=-.2cm\advance\pgf@y by-\halfheight}
    \backgroundpath{
        \draw(-\halfwidth,-\halfheight)rectangle(\halfwidth,\halfheight)(-.8*\halfwidth,-1.2*\halfheight)--(-.8*\halfwidth,1.2*\halfheight)(-.4*\halfwidth,-1.2*\halfheight)--(-.4*\halfwidth,1.2*\halfheight)(0,-1.2*\halfheight)--(0,1.2*\halfheight)(.4*\halfwidth,-1.2*\halfheight)--(.4*\halfwidth,1.2*\halfheight)(.8*\halfwidth,-1.2*\halfheight)--(.8*\halfwidth,1.2*\halfheight);}}

    \begin{tikzpicture}
        \node(sl1)at(2,2)[slits]{};
        \node(st1)at(3,2)[steerer]{};
        \node(le1)at(5,2)[lens]{};
        \node(lo1)at(6,2)[lollipop]{};
        \node(皿1)at(4,0)[皿]{};
        \draw(sl1.north)node{$6$};
        \draw(st1.north)node{$10$};
        \draw(le1.south)node{$5$};
        \draw(lo1.south)node{$8$};
        \draw(皿1.north)node{$2$};
        \draw(皿1.south)node{$3$};
    \end{tikzpicture}

\end{document}
Related Question