-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmacros-ph.tex
128 lines (120 loc) · 3.98 KB
/
macros-ph.tex
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
\usepackage{ifthen}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes}
\definecolor{lightgray}{rgb}{0.8,0.8,0.8}
\definecolor{lightgrey}{rgb}{0.8,0.8,0.8}
\tikzstyle{boxed ph}=[]
\tikzstyle{sort}=[fill=lightgray,rounded corners]
\tikzstyle{process}=[circle,draw,minimum size=15pt,fill=white,
font=\footnotesize,inner sep=1pt]
\tikzstyle{black process}=[process, fill=black,text=white, font=\bfseries]
\tikzstyle{gray process}=[process, draw=black, fill=lightgray]
\tikzstyle{current process}=[process, draw=black, fill=lightgray]
\tikzstyle{process box}=[white,draw=black,rounded corners]
\tikzstyle{tick label}=[font=\footnotesize]
\tikzstyle{tick}=[black,-]%,densely dotted]
\tikzstyle{hit}=[->,>=angle 45]
\tikzstyle{selfhit}=[min distance=30pt,curve to]
\tikzstyle{bounce}=[densely dotted,>=stealth',->]
\tikzstyle{hl}=[font=\bfseries,very thick]
\tikzstyle{hl2}=[hl]
\tikzstyle{nohl}=[font=\normalfont,thin]
\newcommand{\currentScope}{}
\newcommand{\currentSort}{}
\newcommand{\currentSortLabel}{}
\newcommand{\currentAlign}{}
\newcommand{\currentSize}{}
\newcounter{la}
\newcommand{\TSetSortLabel}[2]{
\expandafter\repcommand\expandafter{\csname TUserSort@#1\endcsname}{#2}
}
\newcommand{\TSort}[4]{
\renewcommand{\currentScope}{#1}
\renewcommand{\currentSort}{#2}
\renewcommand{\currentSize}{#3}
\renewcommand{\currentAlign}{#4}
\ifcsname TUserSort@\currentSort\endcsname
\renewcommand{\currentSortLabel}{\csname TUserSort@\currentSort\endcsname}
\else
\renewcommand{\currentSortLabel}{\currentSort}
\fi
\begin{scope}[shift={\currentScope}]
\ifthenelse{\equal{\currentAlign}{l}}{
\filldraw[process box] (-0.5,-0.5) rectangle (0.5,\currentSize-0.5);
\node[sort] at (-0.2,\currentSize-0.4) {\currentSortLabel};
}{\ifthenelse{\equal{\currentAlign}{r}}{
\filldraw[process box] (-0.5,-0.5) rectangle (0.5,\currentSize-0.5);
\node[sort] at (0.2,\currentSize-0.4) {\currentSortLabel};
}{
\filldraw[process box] (-0.5,-0.5) rectangle (\currentSize-0.5,0.5);
\ifthenelse{\equal{\currentAlign}{t}}{
\node[sort,anchor=east] at (-0.3,0.2) {\currentSortLabel};
}{
\node[sort] at (-0.6,-0.2) {\currentSortLabel};
}
}}
\setcounter{la}{\currentSize}
\addtocounter{la}{-1}
\foreach \i in {0,...,\value{la}} {
\TProc{\i}
}
\end{scope}
}
\newcommand{\TTickProc}[2]{ % pos, label
\ifthenelse{\equal{\currentAlign}{l}}{
\draw[tick] (-0.6,#1) -- (-0.4,#1);
\node[tick label, anchor=east] at (-0.55,#1) {#2};
}{\ifthenelse{\equal{\currentAlign}{r}}{
\draw[tick] (0.6,#1) -- (0.4,#1);
\node[tick label, anchor=west] at (0.55,#1) {#2};
}{
\ifthenelse{\equal{\currentAlign}{t}}{
\draw[tick] (#1,0.6) -- (#1,0.4);
\node[tick label, anchor=south] at (#1,0.55) {#2};
}{
\draw[tick] (#1,-0.6) -- (#1,-0.4);
\node[tick label, anchor=north] at (#1,-0.55) {#2};
}
}}
}
\newcommand{\TSetTick}[3]{
\expandafter\repcommand\expandafter{\csname TUserTick@#1_#2\endcsname}{#3}
}
\newcommand{\myProc}[3]{
\ifcsname TUserTick@\currentSort_#1\endcsname
\TTickProc{#1}{\csname TUserTick@\currentSort_#1\endcsname}
\else
\TTickProc{#1}{#1}
\fi
\ifthenelse{\equal{\currentAlign}{l}\or\equal{\currentAlign}{r}}{
\node[#2] (\currentSort_#1) at (0,#1) {#3};
}{
\node[#2] (\currentSort_#1) at (#1,0) {#3};
}
}
\newcommand{\TSetProcStyle}[2]{
\expandafter\repcommand\expandafter{\csname TUserProcStyle@#1\endcsname}{#2}
}
\newcommand{\TProc}[1]{
\ifcsname TUserProcStyle@\currentSort_#1\endcsname
\myProc{#1}{\csname TUserProcStyle@\currentSort_#1\endcsname}{}
\else
\myProc{#1}{process}{}
\fi
}
\newcommand{\repcommand}[2]{
\providecommand{#1}{#2}
\renewcommand{#1}{#2}
}
\newcommand{\THit}[5]{
\path[hit] (#1) edge[#2] (#3#4);
\expandafter\repcommand\expandafter{\csname TBounce@#3@#5\endcsname}{#4}
}
\newcommand{\TBounce}[4]{
(#1\csname TBounce@#1@#3\endcsname) edge[#2] (#3#4)
}
\newcommand{\TState}[1]{
\foreach \proc in {#1} {
\node[current process] (\proc) at (\proc.center) {};
}
}