summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/pgf/incoming/KarlheinzOchs/signalflowdiagram.sty
blob: c258eb7a9d975fb2f3c51585bf6c5c1b13006666 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
% A simple library for signal flow diagrams
% based on the pgf/tikz package of Till Tantau
%
% Author: Dr. Karlheinz Ochs, Ruhr-University of Bochum, Germany
% Version: 0.1
% Date: 2007/01/05
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{tikz}
\ProvidesPackage{signalflowdiagram}
              [2006/12/30 v0.1 Signal flow diagrams]

%
% Libraries for signal flow diagrams.
%
\usetikzlibrary{signalflowdiagram,signalflowarrows,signalflowoperators,signalflowblocks}


%
% Colors
%
\newcommand{\pathdrawcolor}{\blockdrawcolor}     % draw color of signal paths
\newcommand{\pathfillcolor}{\blockfillcolor}     % fill color of signal paths
\newcommand{\operatordrawcolor}{\blockdrawcolor} % draw color of operators
\newcommand{\operatorfillcolor}{\blockfillcolor} % fill color of operators
\newcommand{\blockdrawcolor}{black}              % draw color of blocks
\newcommand{\blockfillcolor}{white}              % fill color of blocks

%
% line widths of
%
\newcommand{\diagramlinewidth}{0.5mm}  % signal flow diagram frames
\newcommand{\pathlinewidth}{0.3mm}     % signal paths
\newcommand{\operatorlinewidth}{0.3mm} % operator frames
\newcommand{\blocklinewidth}{0.5mm}    % building block styles

%
% line widths, sizes, etc.
%
\newcommand{\nodesize}{1.5mm}         % size of nodes
\newcommand{\terminalsize}{\nodesize} % size of terminals
\newcommand{\operatorsize}{3mm}       % size of circular shaped operator symbols
\newcommand{\delaysize}{6mm}          % minimum size of delay elements
\newcommand{\blockwidth}{24mm}        % minimum width of blocks
\newcommand{\blockheight}{12mm}       % minimum height of blocks
\newcommand{\blocktextwidth}{22mm}    % minimum text width of blocks
\newcommand{\filterwidth}{12mm}       % minimum width of filters
\newcommand{\filterheight}{8mm}       % minimum height of filters
\newcommand{\filtertextwidth}{6mm}    % minimum text width of filters

%
% misc.
%
\newcommand{\pathlineextend}{0.025mm} % shortens the end of the signal paths
\newcommand{\vbullets}[1]{% vertical bullets
\node[rectangle,anchor=center,at=(#1),text width=2ex]{%
$\bullet$\\[-1ex] $\bullet$\\[-1ex] $\bullet$}
}%


%
% Signal flow diagram.
%
% #1 = optional parameter(s)
% #2 = title text
\tikzstyle{signal flow diagram} =
  [rectangle,
   sharp corners,
   line width=\diagramlinewidth,
   draw=black,
   inner sep=3mm]
\newenvironment{signalflow}[2][]{%
\begin{center}
  \begin{tikzpicture}
    \node[% title
      signal flow diagram,
      fill=blue!90!black,
      text=white] (title) {#2};% title text
    \node at (title.south west) [%
      signal flow diagram,
      fill=blue!20!white,
      anchor=north west,
      yshift=\pgflinewidth]
    \bgroup
      \begin{minipage}{0.9\textwidth}
        \centering
        \begin{tikzpicture}[%
          node distance=8mm,
          pin distance=8mm,
          label distance=-0.5mm,
          inner sep=1mm,
          anchor=center,
          text centered,
          #1]% optional parameter(s)
}{%
        \end{tikzpicture}
      \end{minipage}
    \egroup;
  \end{tikzpicture}
\end{center}
}%


%
% Positioning of node text.
%
% #1 = node label
% #2 = label text
\newcommand{\textaboveof}[2]{\pgftext[bottom,at=\pgfpointanchor{#1}{north},y=+1mm]{#2}}%
\newcommand{\textrightof}[2]{\pgftext[left,  at=\pgfpointanchor{#1}{east}, x=+1mm]{#2}}%
\newcommand{\textbelowof}[2]{\pgftext[top   ,at=\pgfpointanchor{#1}{south},y=-1mm]{#2}}%
\newcommand{\textleftof} [2]{\pgftext[right, at=\pgfpointanchor{#1}{west}, x=-1mm]{#2}}%

\makeatletter
\newcounter{r}
\newcommand{\tikzgrid}{%
  \pgfsetxvec{\pgfpoint{\tikz@node@distance}{0mm}}%
  \pgfsetyvec{\pgfpoint{0mm}{\tikz@node@distance}}%
  \tikz@matrix%
}
\newcommand{\tikz@matrix}[1]{\tikz@@matrix#1@}%
\def\tikz@@matrix#1@{\do@rows#1\\@\\}%
\def\do@rows#1\\{%
  \ifx#1@%
  \else%
    \setcounter{r}{0}%
    \do@columns#1&@&%
    \pgftransformshift{\pgfpointxy{-\ther}{-1}}%
    \expandafter\do@rows%
  \fi}%
\def\do@columns#1&{%
  \if#1@%
  \else%
    \stepcounter{r}%
    \pgftransformshift{\pgfpointxy{1}{0}}%
    #1;%
    \expandafter\do@columns%
  \fi}%
\makeatother