TikZ: My own block diagram library
<p>I have written some TikZ code to draw simple block diagrams for electrical engineering purposes. My code is written such that it just works, but in my opinion it is ugly and not very easy to use. What I would like to do is draw block diagrams like the following</p>

<p><a href="http://i.stack.imgur.com/Y06NZ.png" rel="nofollow">simple example for a block diagram</a></p>

<p>and for this I would like to have sort of a "library" which contains my TikZ blocks. This is my current TikZ code to produce the figure shown:</p>

<pre><code>\begin{tikzpicture}[%
,auto
,node distance=10mm
,&gt;=latex'
,block/.style={text depth=.25ex,draw, fill=anti-flashwhite, rectangle, minimum height=10mm, minimum width=10mm}
,gluon/.style={decorate, draw=black, decoration={complete sines,amplitude=1mm, segment length=6mm}}
,osci/.style={decorate, draw=black, decoration={complete sines,amplitude=2mm, segment length=6mm}}
]

% bpf
\node at (0,0) [block,label={BPF}]     (bpf)  [anchor=center]    {};
\draw[gluon] ([xshift=-4mm, yshift=2mm]bpf.center) -- +(0.8,0) {};
\draw[gluon] ([xshift=-4mm]bpf.center) -- +(0.8,0) {};
\draw[gluon] ([xshift=-4mm, yshift=-2mm]bpf.center) -- +(0.8,0) {};
\draw[transform canvas={yshift=2mm}] ([xshift=1mm,yshift=1mm]bpf.center) -- ([xshift=-1mm,yshift=-1mm]bpf.center) {};
\draw[transform canvas={yshift=-2mm}] ([xshift=1mm,yshift=1mm]bpf.center) -- ([xshift=-1mm,yshift=-1mm]bpf.center) {};

% hpf
\node at (2,0) [block,label={HPF}]     (hpf)   {};
\draw[gluon] ([xshift=-4mm, yshift=1mm]hpf.center) -- +(0.8,0) {};
\draw[gluon] ([xshift=-4mm, yshift=-1mm]hpf.center) -- +(0.8,0) {};
\draw[transform canvas={yshift=-1mm}] ([xshift=1mm,yshift=1mm]hpf.center) -- ([xshift=-1mm,yshift=-1mm]hpf.center) {};

% lpf
\node at (5,0) [block,label={LPF}]     (lpf)  {};
\draw[gluon] ([xshift=-4mm, yshift=1mm]lpf.center) -- +(0.8,0) {};
\draw[gluon] ([xshift=-4mm, yshift=-1mm]lpf.center) -- +(0.8,0) {};
\draw[transform canvas={yshift=1mm}] ([xshift=1mm,yshift=1mm]lpf.center) -- ([xshift=-1mm,yshift=-1mm]lpf.center) {};

% mixer
\node[draw,circle,radius=1mm, label={Mixer}] at (3.5,0)  (x) {};
\begin{scope}
\clip (3.5,0) circle [radius=2mm];
\draw ([xshift=-5mm,yshift=-5mm]x.center) -- ([xshift=5mm,yshift=5mm]x.center) {};
\draw ([xshift=-5mm,yshift=5mm]x.center) -- ([xshift=5mm,yshift=-5mm]x.center) {};
\end{scope}

% oscillator
\node[draw,circle,inner sep=2.5mm] at (3.5,-2)  (osc) {};
\draw[osci] ([xshift=-2mm]osc.center) -- +(0.4,0) {};

% integrator
\node at (7,0) [block,label={Int}]     (int)   {$\int$};

% arrow stuff
\draw[-&gt;] (bpf.east) -- (hpf.west);
\draw[-&gt;] (hpf.east) -- (x.west);
\draw[-&gt;] (x.east) -- (lpf.west);
\draw[-&gt;] (osc.north) -- (x.south);
\draw[-&gt;] (lpf.east) -- (int.west);

\end{tikzpicture}
</code></pre>

<p>A huge improvement would be if I only had to write "bpf" or something similar to use a BPF block, and not all those 6 rows together which make a BPF block. How can I achieve that?</p>