-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathtikz-flowchart.sty
More file actions
executable file
·235 lines (233 loc) · 9.21 KB
/
tikz-flowchart.sty
File metadata and controls
executable file
·235 lines (233 loc) · 9.21 KB
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
%%
%% This is file `tikz-flowchart.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% tikz-flowchart.dtx (with options: `package')
%%
%% This is a generated file.
%%
%% Copyright (C) 2019 by Geng Nan <[email protected]>
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%
%% http://www.latex-project.org/lppl.txt
%%
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%%
\NeedsTeXFormat{LaTeX2e}[2011/06/27]
\ProvidesPackage{tikz-flowchart}
[2019/08/20 v1.0.01 draw flowchart using TikZ]
\RequirePackage{tikz}
\RequirePackage{xifthen}
\RequirePackage{kvoptions}
\SetupKeyvalOptions{
family=flowchart,
prefix=flowchart@,
setkeys=\kvsetkeys
}
\DeclareBoolOption[false]{debug}
\DeclareDefaultOption{}
\kvsetkeys{flowchart}{}
\ProcessKeyvalOptions*
\usetikzlibrary{
arrows.meta, % 箭头形状
shapes.geometric, % 几何形状
chains, % 链式布局
calc, % 坐标计算
}
\pgfkeys{
/flowchart/.is family,
/flowchart/.search also={/tikz},
}
\def\flowchartset{\pgfqkeys{/flowchart}}
\flowchartset{
free color/.store in = \freecolor, % 自由连线颜色
norm color/.store in = \normcolor, % 常规连线颜色
cong color/.store in = \congcolor, % 关联连线颜色
proc fill color/.store in = \procfillcolor, % 顺序处理框填充颜色
test fill color/.store in = \testfillcolor, % 判断框填充颜色
io fill color/.store in = \iofillcolor, % 输入/输出框填充颜色
term fill color/.store in = \termfillcolor, % 开始/结束框填充颜色
proc text width/.store in = \proctxtwd, % 顺序处理框宽度
test text width/.store in = \testtxtwd, % 判断框宽度
io text width/.store in = \iotxtwd, % 输入/输出框宽度
term text width/.store in = \termtxtwd, % 开始/结束宽度
chain direction/.store in = \chaindir, % 结点自动布置方向
minimum node distance/.store in = \minnodedis, % 最小结点间距
maximum node distance/.store in = \maxnodedis, % 最大结点间距
border line width/.store in = \bdlinewd, % 各类流程框边框宽度
flow line width/.store in = \flowlinewd, % 各类流程线线条宽度
stealth length/.store in = \stealthlen, % 箭头长度
stealth width/.store in = \stealthwd, % 箭头宽度
}
\flowchartset{
free color = green, % 自由连线颜色(默认取green)
norm color = blue, % 常规连线颜色(默认取blue)
cong color = red, % 关联连线颜色(默认取red)
proc fill color = white, % 顺序处理框填充颜色(默认取白色)
test fill color = white, % 判断框填充颜色(默认取白色)
io fill color = white, % 输入/输出框填充颜色(默认取白色)
term fill color = white, % 开始/结束框填充颜色(默认取白色)
proc text width = 8em, % 顺序处理框宽度(默认取8em)
test text width = 5em, % 判断框宽度(默认取5em)
io text width = 6em, % 输入/输出框宽度(默认取6em)
term text width = 3em, % 开始/结束宽度(默认取3em)
chain direction = below, % 结点自动布置方向(默认取below)
minimum node distance = 6mm, % 最小结点间距(默认取6mm)
maximum node distance = 60mm, % 最大结点间距(默认取60mm)
border line width = \pgflinewidth, % 各类流程框边框宽度(默认取当前线条宽度)
flow line width = \pgflinewidth, % 各类流程线线条宽度(默认取当前线条宽度)
stealth length = 1.5mm, % 箭头长度(默认取1.5mm)
stealth width = 1.0mm, % 箭头宽度(默认取1.0mm)
}
\tikzset{
start chain = going \chaindir, % 结点自动布置方向(默认取below)
node distance = \minnodedis and \maxnodedis, % 结点间距
every join/.style = {norm}, % 默认自动连接线的连线样式
% 流程框样式的基础样式
base/.style = {line width = \bdlinewd, % 边框线宽
draw, % 绘制边框
on chain, % 沿布局方向绘制
on grid, % 沿网格布局
align=center, % 内容居中对齐
minimum height=2ex, % 流程框最小高度
},
% 顺序处理框样式
proc/.style={base, % 基础样式
rectangle, % 矩形边框
text width=\proctxtwd, % 最大文本宽度(超过会自动换行)
fill=\procfillcolor, % 填充色
},
% 判断框样式
test/.style={base, % 基础样式
diamond, % 菱形边框
aspect=2.5, % 长高比例
text width=\testtxtwd, % 最大文本宽度(超过会自动换行)
fill=\testfillcolor, % 填充色
},
% 输入/输出框样式
io/.style={base, % 基础样式
trapezium, % 平行四边形
trapezium left angle=70, % 平行四边形左倾角
trapezium right angle=110, % 平行四边形右倾角
text width=\iotxtwd, % 最大文本宽度(超过会自动换行)
fill=\iofillcolor, % 填充色
},
% 开始/结束框样式
term/.style={proc, % 基于proc样式
rounded corners=1.0mm, % 为矩形添加圆角属性
text width=\termtxtwd, % 最大文本宽度(超过会自动换行)
fill=\termfillcolor, % 填充色
},
% 流程连接点样式
connector/.style = {draw, % 绘制边框
circle, % 圆形
node distance=3cm, % 节点间距
},
% 绕接连线点样式(不相交的两个交汇路径)
connect/.style args={(#1) to (#2) over (#3) by #4}{
insert path={
let \p1=($(#1)-(#3)$), \n1={veclen(\x1,\y1)},
\n2={atan2(\y1,\x1)}, \n3={abs(#4)}, \n4={#4>0 ?-180:180} in
(#1) -- ($(#1)!\n1-\n3!(#3)$) arc (\n2:\n2+\n4:\n3) -- (#2)
}
},
% coord结点样式(用于布置流程线连接点)
coord/.style={coordinate, % 笛卡尔坐标系
%on chain, % 沿布局方向绘制
%on grid, % 沿网格布局
node distance=6mm and 25mm, % 节点间距
},
% nmark结点样式(用于布置调试坐标标记点)
nmark/.style={draw, % 绘制边框
cyan, % 青色
circle, % 圆形
font={\sffamily\bfseries}, % 字体
},
% -------------------------------------------------
% 无箭头连线样式
lnorm/.style={line width = \flowlinewd, % 线宽
draw, % 绘制
\normcolor, % 颜色
},
lfree/.style={line width = \flowlinewd,
draw,
\freecolor,
},
lcong/.style={line width = \flowlinewd,
draw,
\congcolor,
},
% 流程线实心交点样式
dotnorm/.style={draw, % 绘制
fill = \normcolor, % 填充颜色
\normcolor, % 颜色
},
dotfree/.style={draw,
fill = \freecolor,
\freecolor,
},
dotcong/.style={draw,
fill = \congcolor,
\congcolor,
},
% 流程线空心交点样式
cdotnorm/.style={draw, % 绘制
\normcolor, % 颜色
},
cdotfree/.style={draw,
\freecolor,
},
cdotcong/.style={draw,
\congcolor,
},
% 带箭头连线样式
norm/.style={line width = \flowlinewd, % 线宽
-{Stealth[length=\stealthlen, % 箭头长度
width=\stealthwd, % 箭头宽度
]
},
draw, % 绘制
\normcolor, % 颜色
},
free/.style={line width = \flowlinewd,
-{Stealth[length=\stealthlen,
width=\stealthwd,
]
},
draw,
\freecolor,
},
cong/.style={line width = \flowlinewd,
-{Stealth[length=\stealthlen,
width=\stealthwd,
]
},
draw,
\congcolor,
},
% 斜体字样式
it/.style={font={\small\itshape}},
}
%% 判断是否为宏包传入了debug参数以打开调试功能,若没有传入debug参数,则关闭调试功能。
\ifflowchart@debug
% 设置一个用于调试的标记符号图层,注意确保这一图层位于顶层
\pgfdeclarelayer{marx}
\pgfsetlayers{main,marx}
\newcommand{\cmark}[2][]{%
\begin{pgfonlayer}{marx}
\node [nmark] at (c#2#1) {#2};
\end{pgfonlayer}{marx}
}
\else
\newcommand{\cmark}[2][]{\relax}
\fi
\endinput
%%
%% End of file `tikz-flowchart.sty'.