Forum: PC Hard- und Software TikZ: Wie komplexe Nodes gruppieren und wiederverwemden?


von Tobias P. (hubertus)


Lesenswert?

Hallo,

ich möchte mit TikZ einfache Nachrichtentechnikblockschaltbilder 
zeichnen. Dazu habe ich einfache Blöcke definiert, z.B. Mischer und 
Filter etc. Die Blöcke bestehen aus mehreren Teilen. Beispiel:
1
\documentclass{standalone}
2
3
4
\usepackage{tikz}
5
\usetikzlibrary{decorations,arrows}
6
7
\begin{document}
8
9
\pgfdeclaredecoration{complete sines}{initial}
10
{
11
    \state{initial}[
12
        width=+0pt,
13
        next state=sine,
14
        persistent precomputation={\pgfmathsetmacro\matchinglength{
15
            \pgfdecoratedinputsegmentlength / int(\pgfdecoratedinputsegmentlength/\pgfdecorationsegmentlength)}
16
            \setlength{\pgfdecorationsegmentlength}{\matchinglength pt}
17
        }] {}
18
    \state{sine}[width=\pgfdecorationsegmentlength]{
19
        \pgfpathsine{\pgfpoint{0.25\pgfdecorationsegmentlength}{0.5\pgfdecorationsegmentamplitude}}
20
        \pgfpathcosine{\pgfpoint{0.25\pgfdecorationsegmentlength}{-0.5\pgfdecorationsegmentamplitude}}
21
        \pgfpathsine{\pgfpoint{0.25\pgfdecorationsegmentlength}{-0.5\pgfdecorationsegmentamplitude}}
22
        \pgfpathcosine{\pgfpoint{0.25\pgfdecorationsegmentlength}{0.5\pgfdecorationsegmentamplitude}}
23
}
24
    \state{final}{}
25
}
26
27
\tikzset{
28
auto,
29
node distance=10mm,
30
>=latex',
31
block/.style={draw, rectangle, minimum height=10mm, minimum width=10mm},
32
wave/.style={decorate, draw=black, decoration={complete sines,amplitude=1mm, segment length=6mm}}
33
}
34
35
36
\begin{tikzpicture}
37
    % Mixer
38
    \node[draw,circle,inner sep = 0pt, minimum width=4mm,label={Mixer}] at (0,0)  (x) {};
39
    \clip (0,0) circle [radius=2mm];
40
    \draw ([xshift=-5mm,yshift=-5mm]x.center) -- ([xshift=5mm,yshift=5mm]x.center) {};
41
    \draw ([xshift=-5mm,yshift=5mm]x.center) -- ([xshift=5mm,yshift=-5mm]x.center) {};
42
\end{tikzpicture}
43
44
45
46
\begin{tikzpicture}
47
    \node at (0,0) [block,label={BPF}]     (bpf)  [anchor=center]    {};
48
    \draw[wave] ([xshift=-3mm, yshift=2mm]bpf.center) -- +(0.6,0) {};
49
    \draw[wave] ([xshift=-3mm]bpf.center) -- +(0.6,0) {};
50
    \draw[wave] ([xshift=-3mm, yshift=-2mm]bpf.center) -- +(0.6,0) {};
51
    \draw[transform canvas={yshift=2mm}] ([xshift=1mm,yshift=0.75mm]bpf.center) -- ([xshift=-1mm,yshift=-0.75mm]bpf.center) {};
52
    \draw[transform canvas={yshift=-2mm}] ([xshift=1mm,yshift=0.75mm]bpf.center) -- ([xshift=-1mm,yshift=-0.75mm]bpf.center) {};
53
\end{tikzpicture}
54
55
\end{document}

Meine Frage dazu: wie kann ich den Code für das Bandpassfilter irgendwie 
so zusammensetzen, dass ich zukünftig nicht diesen ganzen Code schreiben 
muss, sondern nur z.B.
1
 \draw [bandpass]
 ? Natürlich sollte dieser Node dann auch benannt werden können, sodass 
ich mit <nodename>.west und dergleichen Verbinder einfügen kann.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.