| 1 |
% ============================================================================ |
| 2 |
% File : tikz-network.sty -- Library for plotting networks in TikZ |
| 3 |
% Author : Juergen Hackl <[email protected]> |
| 4 |
% Creation : 2017-02-28 |
| 5 |
% Time-stamp: <Thu 2019-08-15 10:57 juergen> |
| 6 |
% Version : 1.1 (2019-08-15) |
| 7 |
% |
| 8 |
% Copyright (c) 2019 Juergen Hackl <[email protected]> |
| 9 |
% |
| 10 |
% This program is free software: you can redistribute it and/or modify |
| 11 |
% it under the terms of the GNU General Public License as published by |
| 12 |
% the Free Software Foundation, either version 3 of the License, or |
| 13 |
% (at your option) any later version. |
| 14 |
% |
| 15 |
% This program is distributed in the hope that it will be useful, |
| 16 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 |
% GNU General Public License for more details. |
| 19 |
% |
| 20 |
% You should have received a copy of the GNU General Public License |
| 21 |
% along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 22 |
% ============================================================================ |
| 23 |
|
| 24 |
\NeedsTeXFormat{LaTeX2e} |
| 25 |
\ProvidesPackage{tikz-network}[2019/08/15 tikz-network v1.1] |
| 26 |
|
| 27 |
%============================================================================= |
| 28 |
% Used packages |
| 29 |
%============================================================================= |
| 30 |
\RequirePackage{etex} |
| 31 |
\RequirePackage{xifthen} |
| 32 |
\RequirePackage{xkeyval}[2005/11/25] |
| 33 |
\RequirePackage{tikz} |
| 34 |
\RequirePackage{datatool} |
| 35 |
\RequirePackage{graphicx} |
| 36 |
\RequirePackage{trimspaces} |
| 37 |
\usetikzlibrary{arrows} |
| 38 |
\usetikzlibrary{positioning} |
| 39 |
\usetikzlibrary{3d} |
| 40 |
\usetikzlibrary{fit} |
| 41 |
\usetikzlibrary{calc} |
| 42 |
\usetikzlibrary{backgrounds} |
| 43 |
\usetikzlibrary{arrows.meta} |
| 44 |
\usetikzlibrary{shapes.geometric} |
| 45 |
%============================================================================= |
| 46 |
|
| 47 |
|
| 48 |
%============================================================================= |
| 49 |
% Predefined variables |
| 50 |
%============================================================================= |
| 51 |
|
| 52 |
%<---------------------------------------------------------------------------> |
| 53 |
% Vertex |
| 54 |
%<---------------------------------------------------------------------------> |
| 55 |
\definecolor{vertexfill}{HTML}{abd7e6} |
| 56 |
\newcommand*{\DefaultUnit}{cm} |
| 57 |
\newcommand*{\DistanceScale}{1} |
| 58 |
\newcommand*{\VertexShape}{circle} |
| 59 |
\newcommand*{\VertexInnerSep}{2pt} |
| 60 |
\newcommand*{\VertexOuterSep}{0pt} |
| 61 |
\newcommand*{\VertexMinSize}{0.6\DefaultUnit} |
| 62 |
\newcommand*{\VertexLineWidth}{1pt} |
| 63 |
\newcommand*{\VertexLineColor}{black} |
| 64 |
\newcommand*{\VertexLineOpacity}{1} |
| 65 |
\newcommand*{\VertexTextColor}{black} |
| 66 |
\newcommand*{\VertexFillColor}{vertexfill} |
| 67 |
\newcommand*{\VertexFillOpacity}{1} |
| 68 |
\newcommand*{\VertexTextFont}{\scriptsize}%\tiny} |
| 69 |
\newcommand*{\VertexTextRotation}{0} |
| 70 |
\newcommand*{\VertexTextOpacity}{1} |
| 71 |
|
| 72 |
%<---------------------------------------------------------------------------> |
| 73 |
% Edge |
| 74 |
%<---------------------------------------------------------------------------> |
| 75 |
\newcommand*{\EdgeArrow}{-latex} |
| 76 |
\newcommand*{\EdgeLineWidth}{1.5pt} |
| 77 |
\newcommand*{\EdgeColor}{black!75} |
| 78 |
\newcommand*{\EdgeOpacity}{1} |
| 79 |
\newcommand*{\EdgeTextFillColor}{white} |
| 80 |
\newcommand*{\EdgeTextFillOpacity}{1} |
| 81 |
\newcommand*{\EdgeInnerSep}{0pt} |
| 82 |
\newcommand*{\EdgeOuterSep}{1pt} |
| 83 |
\newcommand*{\EdgeTextRotation}{0} |
| 84 |
\newcommand*{\EdgeTextOpacity}{1} |
| 85 |
\newcommand*{\EdgeTextFont}{\scriptsize} |
| 86 |
|
| 87 |
|
| 88 |
%<---------------------------------------------------------------------------> |
| 89 |
% Plane |
| 90 |
%<---------------------------------------------------------------------------> |
| 91 |
\newcommand*{\PlaneLineWidth}{1.5pt} |
| 92 |
\newcommand*{\PlaneLineColor}{black} |
| 93 |
\newcommand*{\PlaneLineOpacity}{1} |
| 94 |
\newcommand*{\PlaneGridLineWidth}{.5pt} |
| 95 |
\newcommand*{\PlaneGridColor}{black} |
| 96 |
\newcommand*{\PlaneGridOpacity}{.5} |
| 97 |
\newcommand*{\PlaneFillColor}{vertexfill} |
| 98 |
\newcommand*{\PlaneFillOpacity}{.3} |
| 99 |
\newcommand*{\PlaneWidth}{5\DefaultUnit} |
| 100 |
\newcommand*{\PlaneHeight}{5\DefaultUnit} |
| 101 |
|
| 102 |
|
| 103 |
%<---------------------------------------------------------------------------> |
| 104 |
% Text |
| 105 |
%<---------------------------------------------------------------------------> |
| 106 |
|
| 107 |
\newcommand*{\TextInnerSep}{2pt} |
| 108 |
\newcommand*{\TextOuterSep}{0pt} |
| 109 |
\newcommand*{\TextFont}{\normalsize} |
| 110 |
\newcommand*{\TextColor}{black} |
| 111 |
\newcommand*{\TextRotation}{0} |
| 112 |
\newcommand*{\TextOpacity}{1} |
| 113 |
|
| 114 |
|
| 115 |
%<---------------------------------------------------------------------------> |
| 116 |
% Network |
| 117 |
%<---------------------------------------------------------------------------> |
| 118 |
\newcommand*{\NetworkLayerDistance}{-2} |
| 119 |
\newcommand*{\xAngle}{-12} |
| 120 |
\newcommand*{\xLength}{1} |
| 121 |
\newcommand*{\yAngle}{37} |
| 122 |
\newcommand*{\yLength}{1} |
| 123 |
\newcommand*{\zAngle}{90} |
| 124 |
\newcommand*{\zLength}{1} |
| 125 |
|
| 126 |
|
| 127 |
\tikzset{edge canvas/.style={}} |
| 128 |
|
| 129 |
\tikzset{multilayer 2d/.style={y={(0:1cm)},x={(90:1cm)},z={(90:0cm)},every |
| 130 |
node/.append style={transform shape},}} |
| 131 |
|
| 132 |
|
| 133 |
\def\Origin{\draw [->] (0,0,0) -- (2,0,0) node [at end, right] {$y$}; |
| 134 |
\draw [->] (0,0,0) -- (0,2,0) node [at end, right] {$x$}; |
| 135 |
\draw [->] (0,0,0) -- (0,0,2) node [at end, left] {$z$};} |
| 136 |
|
| 137 |
|
| 138 |
%============================================================================= |
| 139 |
% Predefined Styles |
| 140 |
%============================================================================= |
| 141 |
|
| 142 |
%<---------------------------------------------------------------------------> |
| 143 |
% Init Default Vertex Style |
| 144 |
%<---------------------------------------------------------------------------> |
| 145 |
\define@cmdkey [NW] {DVS} {Shape}{} |
| 146 |
\define@cmdkey [NW] {DVS} {MinSize}{} |
| 147 |
\define@cmdkey [NW] {DVS} {LineWidth}{} |
| 148 |
\define@cmdkey [NW] {DVS} {LineColor}{} |
| 149 |
\define@cmdkey [NW] {DVS} {LineOpacity}{} |
| 150 |
\define@cmdkey [NW] {DVS} {FillColor}{} |
| 151 |
\define@cmdkey [NW] {DVS} {FillOpacity}{} |
| 152 |
\define@cmdkey [NW] {DVS} {TextColor}{} |
| 153 |
\define@cmdkey [NW] {DVS} {TextFont}{} |
| 154 |
\define@cmdkey [NW] {DVS} {TextRotation}{} |
| 155 |
\define@cmdkey [NW] {DVS} {TextOpacity}{} |
| 156 |
\define@cmdkey [NW] {DVS} {InnerSep}{} |
| 157 |
\define@cmdkey [NW] {DVS} {OuterSep}{} |
| 158 |
\presetkeys [NW] {DVS} {Shape = \VertexShape, |
| 159 |
MinSize = \VertexMinSize, |
| 160 |
LineWidth = \VertexLineWidth, |
| 161 |
LineColor = \VertexLineColor, |
| 162 |
FillColor = \VertexFillColor, |
| 163 |
LineOpacity = \VertexLineOpacity, |
| 164 |
FillOpacity = \VertexFillOpacity, |
| 165 |
InnerSep = \VertexInnerSep, |
| 166 |
OuterSep = \VertexOuterSep, |
| 167 |
TextColor = \VertexTextColor, |
| 168 |
TextRotation = \VertexTextRotation, |
| 169 |
TextOpacity = \VertexTextOpacity, |
| 170 |
TextFont = \VertexTextFont}{} |
| 171 |
|
| 172 |
%<---------------------------------------------------------------------------> |
| 173 |
% Init Default Edge Style |
| 174 |
%<---------------------------------------------------------------------------> |
| 175 |
\define@cmdkey [NW] {DES} {Arrow}{} |
| 176 |
\define@cmdkey [NW] {DES} {LineWidth}{} |
| 177 |
\define@cmdkey [NW] {DES} {Color}{} |
| 178 |
\define@cmdkey [NW] {DES} {Opacity}{} |
| 179 |
\define@cmdkey [NW] {DES} {TextFillColor}{} |
| 180 |
\define@cmdkey [NW] {DES} {TextFillOpacity}{} |
| 181 |
\define@cmdkey [NW] {DES} {TextFont}{} |
| 182 |
\define@cmdkey [NW] {DES} {TextRotation}{} |
| 183 |
\define@cmdkey [NW] {DES} {TextOpacity}{} |
| 184 |
\define@cmdkey [NW] {DES} {InnerSep}{} |
| 185 |
\define@cmdkey [NW] {DES} {OuterSep}{} |
| 186 |
\presetkeys [NW] {DES} {Arrow = \EdgeArrow, |
| 187 |
LineWidth = \EdgeLineWidth, |
| 188 |
Color = \EdgeColor, |
| 189 |
Opacity = \EdgeOpacity, |
| 190 |
TextFillColor = \EdgeTextFillColor, |
| 191 |
TextFillOpacity = \EdgeTextFillOpacity, |
| 192 |
InnerSep = \EdgeInnerSep, |
| 193 |
OuterSep = \EdgeOuterSep, |
| 194 |
TextRotation = \EdgeTextRotation, |
| 195 |
TextOpacity = \EdgeTextOpacity, |
| 196 |
TextFont = \EdgeTextFont}{} |
| 197 |
|
| 198 |
|
| 199 |
%<---------------------------------------------------------------------------> |
| 200 |
% Init Default Plane Style |
| 201 |
%<---------------------------------------------------------------------------> |
| 202 |
\define@cmdkey [NW] {DPS} {LineWidth}{} |
| 203 |
\define@cmdkey [NW] {DPS} {LineColor}{} |
| 204 |
\define@cmdkey [NW] {DPS} {LineOpacity}{} |
| 205 |
\define@cmdkey [NW] {DPS} {GridLineWidth}{} |
| 206 |
\define@cmdkey [NW] {DPS} {GridColor}{} |
| 207 |
\define@cmdkey [NW] {DPS} {GridOpacity}{} |
| 208 |
\define@cmdkey [NW] {DPS} {FillColor}{} |
| 209 |
\define@cmdkey [NW] {DPS} {FillOpacity}{} |
| 210 |
\presetkeys [NW] {DPS} {LineWidth = \PlaneLineWidth, |
| 211 |
LineColor = \PlaneLineColor, |
| 212 |
LineOpacity = \PlaneLineOpacity, |
| 213 |
GridLineWidth = \PlaneGridLineWidth, |
| 214 |
GridColor = \PlaneGridColor, |
| 215 |
GridOpacity = \PlaneGridOpacity, |
| 216 |
FillColor = \PlaneFillColor, |
| 217 |
FillOpacity = \PlaneFillOpacity}{} |
| 218 |
|
| 219 |
|
| 220 |
%<---------------------------------------------------------------------------> |
| 221 |
% Init Default Text Style |
| 222 |
%<---------------------------------------------------------------------------> |
| 223 |
\define@cmdkey [NW] {DTS} {InnerSep}{} |
| 224 |
\define@cmdkey [NW] {DTS} {OuterSep}{} |
| 225 |
\define@cmdkey [NW] {DTS} {TextFont}{} |
| 226 |
\define@cmdkey [NW] {DTS} {TextColor}{} |
| 227 |
\define@cmdkey [NW] {DTS} {TextRotation}{} |
| 228 |
\define@cmdkey [NW] {DTS} {TextOpacity}{} |
| 229 |
\presetkeys [NW] {DTS} {InnerSep = \TextInnerSep, |
| 230 |
OuterSep = \TextOuterSep, |
| 231 |
TextFont = \TextFont, |
| 232 |
TextColor = \TextColor, |
| 233 |
TextRotation = \TextRotation, |
| 234 |
TextOpacity = \TextOpacity}{} |
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
%<---------------------------------------------------------------------------> |
| 239 |
% Init Default Coordinates 3D |
| 240 |
%<---------------------------------------------------------------------------> |
| 241 |
\define@cmdkey [NW] {COS} {xAngle}{} |
| 242 |
\define@cmdkey [NW] {COS} {xLength}{} |
| 243 |
\define@cmdkey [NW] {COS} {yAngle}{} |
| 244 |
\define@cmdkey [NW] {COS} {yLength}{} |
| 245 |
\define@cmdkey [NW] {COS} {zAngle}{} |
| 246 |
\define@cmdkey [NW] {COS} {zLength}{} |
| 247 |
\presetkeys [NW] {COS} {xAngle = \xAngle, |
| 248 |
xLength = \xLength, |
| 249 |
yAngle = \yAngle, |
| 250 |
yLength = \yLength, |
| 251 |
zAngle = \zAngle, |
| 252 |
zLength = \zLength}{} |
| 253 |
|
| 254 |
%<---------------------------------------------------------------------------> |
| 255 |
% Default Style |
| 256 |
%<---------------------------------------------------------------------------> |
| 257 |
\newcommand*{\SetVertexStyle}[1][]{\NW@SetVertexStyleDefault[#1]}% |
| 258 |
\def\NW@SetVertexStyleDefault[#1]{% |
| 259 |
\setkeys[NW]{DVS}{#1}% |
| 260 |
\tikzset{VertexStyle/.style = {draw, |
| 261 |
shape = \cmdNW@DVS@Shape, |
| 262 |
color = \cmdNW@DVS@LineColor, |
| 263 |
fill = \cmdNW@DVS@FillColor, |
| 264 |
inner sep = \cmdNW@DVS@InnerSep, |
| 265 |
outer sep = \cmdNW@DVS@OuterSep, |
| 266 |
minimum size = \cmdNW@DVS@MinSize, |
| 267 |
line width = \cmdNW@DVS@LineWidth, |
| 268 |
font = \cmdNW@DVS@TextFont, |
| 269 |
fill opacity = \cmdNW@DVS@FillOpacity, |
| 270 |
draw opacity = \cmdNW@DVS@LineOpacity}} |
| 271 |
\tikzset{LabelStyle/.style={ \cmdNW@DVS@TextColor, |
| 272 |
font = \cmdNW@DVS@TextFont, |
| 273 |
rotate = \cmdNW@DVS@TextRotation, |
| 274 |
opacity = \cmdNW@DVS@TextOpacity,}} |
| 275 |
}% |
| 276 |
|
| 277 |
\newcommand*{\SetEdgeStyle}[1][]{\NW@SetEdgeStyleDefault[#1]}% |
| 278 |
\def\NW@SetEdgeStyleDefault[#1]{% |
| 279 |
\setkeys[NW]{DES}{#1}% |
| 280 |
\tikzset{EdgeStyle/.style = {\cmdNW@DES@Arrow, |
| 281 |
line width = \cmdNW@DES@LineWidth, |
| 282 |
color = \cmdNW@DES@Color, |
| 283 |
opacity = \cmdNW@DES@Opacity}} |
| 284 |
\tikzset{EdgeLabelStyle/.style={circle, |
| 285 |
fill = \cmdNW@DES@TextFillColor, |
| 286 |
fill opacity = \cmdNW@DES@TextFillOpacity, |
| 287 |
inner sep = \cmdNW@DES@InnerSep, |
| 288 |
outer sep = \cmdNW@DES@OuterSep, |
| 289 |
rotate = \cmdNW@DES@TextRotation, |
| 290 |
text opacity = \cmdNW@DES@TextOpacity, |
| 291 |
font = \cmdNW@DES@TextFont}} |
| 292 |
}% |
| 293 |
|
| 294 |
|
| 295 |
\newcommand*{\SetPlaneStyle}[1][]{\NW@SetPlaneStyleDefault[#1]}% |
| 296 |
\def\NW@SetPlaneStyleDefault[#1]{% |
| 297 |
\setkeys[NW]{DPS}{#1}% |
| 298 |
\tikzset{PlaneBorderStyle/.style = {draw, |
| 299 |
line width = \cmdNW@DPS@LineWidth, |
| 300 |
color = \cmdNW@DPS@LineColor, |
| 301 |
draw opacity = \cmdNW@DPS@LineOpacity}} |
| 302 |
\tikzset{PlaneFillStyle/.style = { |
| 303 |
fill = \cmdNW@DPS@FillColor, |
| 304 |
fill opacity = \cmdNW@DPS@FillOpacity}} |
| 305 |
\tikzset{PlaneGridStyle/.style = {draw, |
| 306 |
line width = \cmdNW@DPS@GridLineWidth, |
| 307 |
color = \cmdNW@DPS@GridColor, |
| 308 |
opacity = \cmdNW@DPS@GridOpacity}} |
| 309 |
}% |
| 310 |
|
| 311 |
|
| 312 |
\newcommand*{\SetTextStyle}[1][]{\NW@SetTextStyleDefault[#1]}% |
| 313 |
\def\NW@SetTextStyleDefault[#1]{% |
| 314 |
\setkeys[NW]{DTS}{#1}% |
| 315 |
\tikzset{TextStyle/.style = {inner sep = \cmdNW@DTS@InnerSep, |
| 316 |
outer sep = \cmdNW@DTS@OuterSep, |
| 317 |
color = \cmdNW@DTS@TextColor, |
| 318 |
rotate = \cmdNW@DTS@TextRotation, |
| 319 |
text opacity = \cmdNW@DTS@TextOpacity, |
| 320 |
font = \cmdNW@DTS@TextFont}} |
| 321 |
}% |
| 322 |
|
| 323 |
|
| 324 |
\tikzset{ |
| 325 |
multilayer/.code={% |
| 326 |
\ifthenelse{\equal{#1}{3d}}{ |
| 327 |
\tikzset{edge canvas/.style={canvas is yx plane at z=0}} |
| 328 |
\tikzset{multilayer 3d} |
| 329 |
}{ |
| 330 |
\tikzset{edge canvas/.style={}} |
| 331 |
\tikzset{multilayer 2d} |
| 332 |
} |
| 333 |
}, |
| 334 |
} |
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
\newcommand*{\SetCoordinates}[1][]{\NW@SetCoordinates[#1]}% |
| 339 |
\def\NW@SetCoordinates[#1]{% |
| 340 |
\setkeys[NW]{COS}{#1}% |
| 341 |
\tikzset{multilayer 3d/.style={ |
| 342 |
y={(\cmdNW@COS@xAngle:\cmdNW@COS@xLength \DefaultUnit)}, |
| 343 |
x={(\cmdNW@COS@yAngle:\cmdNW@COS@yLength \DefaultUnit)}, |
| 344 |
z={(\cmdNW@COS@zAngle:\cmdNW@COS@zLength \DefaultUnit)}, |
| 345 |
every node/.append style={transform shape}, |
| 346 |
}} |
| 347 |
%\tikzset{edge canvas/.style={canvas is yx plane at z=0}} |
| 348 |
}% |
| 349 |
|
| 350 |
|
| 351 |
%<---------------------------------------------------------------------------> |
| 352 |
% Apply default settings |
| 353 |
%<---------------------------------------------------------------------------> |
| 354 |
|
| 355 |
\SetCoordinates |
| 356 |
\SetVertexStyle |
| 357 |
\SetEdgeStyle |
| 358 |
\SetPlaneStyle |
| 359 |
\SetTextStyle |
| 360 |
|
| 361 |
%<---------------------------------------------------------------------------> |
| 362 |
% Redefine settings |
| 363 |
%<---------------------------------------------------------------------------> |
| 364 |
|
| 365 |
\newcommand*{\SetLayerDistance}[1]{\renewcommand{\NetworkLayerDistance}{#1}} |
| 366 |
\newcommand*{\SetDefaultUnit}[1]{\renewcommand{\DefaultUnit}{#1}} |
| 367 |
\newcommand*{\SetDistanceScale}[1]{\renewcommand{\DistanceScale}{#1}} |
| 368 |
\newcommand*{\SetPlaneWidth}[1]{\renewcommand{\PlaneWidth}{#1}} |
| 369 |
\newcommand*{\SetPlaneHeight}[1]{\renewcommand{\PlaneHeight}{#1}} |
| 370 |
\newcommand*{\EdgesInBG}{\presetkeys [NW] {edge} {NotInBG = false}{}} |
| 371 |
\newcommand*{\EdgesNotInBG}{\presetkeys [NW] {edge} {NotInBG = true}{}} |
| 372 |
|
| 373 |
%============================================================================= |
| 374 |
% Vertex and Edge creation |
| 375 |
%============================================================================= |
| 376 |
|
| 377 |
%<---------------------------------------------------------------------------> |
| 378 |
% Init Vertex |
| 379 |
%<---------------------------------------------------------------------------> |
| 380 |
\define@cmdkey [NW] {vertex} {x}{} |
| 381 |
\define@cmdkey [NW] {vertex} {y}{} |
| 382 |
\define@cmdkey [NW] {vertex} {label}{} |
| 383 |
\define@cmdkey [NW] {vertex} {size}{} |
| 384 |
\define@cmdkey [NW] {vertex} {color}{} |
| 385 |
\define@cmdkey [NW] {vertex} {opacity}{} |
| 386 |
\define@cmdkey [NW] {vertex} {style}{} |
| 387 |
\define@cmdkey [NW] {vertex} {layer}{} |
| 388 |
\define@cmdkey [NW] {vertex} {shape}{} |
| 389 |
\define@cmdkey [NW] {vertex} {fontsize}{} |
| 390 |
\define@cmdkey [NW] {vertex} {fontcolor}{} |
| 391 |
\define@cmdkey [NW] {vertex} {fontscale}{} |
| 392 |
\define@boolkey [NW] {vertex} {RGB}[true]{} |
| 393 |
\define@boolkey [NW] {vertex} {IdAsLabel}[true]{} |
| 394 |
\define@boolkey [NW] {vertex} {NoLabel}[true]{} |
| 395 |
\define@boolkey [NW] {vertex} {Math}[true]{} |
| 396 |
\define@boolkey [NW] {vertex} {Network}[true]{} |
| 397 |
\define@boolkey [NW] {vertex} {Pseudo}[true]{} |
| 398 |
\define@cmdkey [NW] {vertex} {distance}{} |
| 399 |
\define@cmdkey [NW] {vertex} {position}{} |
| 400 |
\presetkeys [NW] {vertex} {Network = false,}{} |
| 401 |
|
| 402 |
|
| 403 |
%<---------------------------------------------------------------------------> |
| 404 |
% Vertex |
| 405 |
%<---------------------------------------------------------------------------> |
| 406 |
\newcommand*{\Vertex}[1][]{\@vertex[#1]}% |
| 407 |
\def\@vertex[#1]#2{% |
| 408 |
\setkeys[NW]{vertex}{#1}% |
| 409 |
% Check if Vertex is used in a network, if so no default settings are |
| 410 |
% necessary, otherwise default settings are applied. |
| 411 |
\ifNW@vertex@Network |
| 412 |
\cmdNW@vertex@opacity |
| 413 |
\else |
| 414 |
\setkeys[NW]{vertex}{x = {0}, |
| 415 |
y = {0}, |
| 416 |
label = {}, |
| 417 |
size = {}, |
| 418 |
color = {}, |
| 419 |
opacity = {}, |
| 420 |
layer = {}, |
| 421 |
shape = {}, |
| 422 |
style = {}, |
| 423 |
fontsize = {}, |
| 424 |
fontcolor = {}, |
| 425 |
fontscale = {}, |
| 426 |
NoLabel = false, |
| 427 |
IdAsLabel = false, |
| 428 |
Math = false, |
| 429 |
RGB = false, |
| 430 |
Pseudo = false, |
| 431 |
distance = {0}, |
| 432 |
position = {center},} |
| 433 |
\setkeys[NW]{vertex}{#1}% |
| 434 |
\fi |
| 435 |
\@@vertex{#2}% |
| 436 |
} |
| 437 |
\def\@@vertex#1{% |
| 438 |
\def\vstyle{VertexStyle} |
| 439 |
\begin{scope} |
| 440 |
% [ |
| 441 |
% scale=1,yshift=0,every node/.append style={yslant=0.5,xslant=-1},yslant=0.5,xslant=-1 |
| 442 |
% ] |
| 443 |
% If option NoLabel is true, no labels are printed in the network |
| 444 |
\ifNW@vertex@NoLabel |
| 445 |
\def\vertex@L{}% |
| 446 |
\def\vertex@Name{}% |
| 447 |
\else |
| 448 |
% if IdAsLabel is true, the label of the vertex is equal to the vertex id |
| 449 |
\ifNW@vertex@IdAsLabel |
| 450 |
\def\vertex@Name{#1} |
| 451 |
\def\vertex@L{\vertex@Name} |
| 452 |
% Otherwise the label is equal to the label if it is non empty |
| 453 |
\else |
| 454 |
\ifthenelse{\not\equal{\cmdNW@vertex@label}{}}{ |
| 455 |
\def\vertex@L{\cmdNW@vertex@label} |
| 456 |
\def\vertex@Name{#1} |
| 457 |
}{ |
| 458 |
\def\vertex@Name{#1} |
| 459 |
\def\vertex@L{} |
| 460 |
} |
| 461 |
\fi |
| 462 |
\fi |
| 463 |
% Check if Math is true, if so the label will be in math mode |
| 464 |
\ifNW@vertex@Math |
| 465 |
\def\vertex@Label{$\vertex@L$}% |
| 466 |
\else |
| 467 |
\def\vertex@Label{\vertex@L}% |
| 468 |
\fi |
| 469 |
% Check if the size of the vertex is redefined, if so the new style is used |
| 470 |
\ifthenelse{\not\equal{\cmdNW@vertex@size}{}}{ |
| 471 |
\tikzset{LocalVertexSize/.style={minimum size = \cmdNW@vertex@size |
| 472 |
\DefaultUnit}} |
| 473 |
}{ |
| 474 |
\tikzset{LocalVertexSize/.style={}} |
| 475 |
} |
| 476 |
% Check if the font size of the vertex label is redefined, if so the new style is used |
| 477 |
\ifthenelse{\not\equal{\cmdNW@vertex@fontsize}{}}{ |
| 478 |
\tikzset{LocalVertexFontSize/.style={font = \cmdNW@vertex@fontsize}} |
| 479 |
}{ |
| 480 |
\tikzset{LocalVertexFontSize/.style={}} |
| 481 |
} |
| 482 |
% Check if the font scale of the vertex label is redefined, if so the new style is used |
| 483 |
\ifthenelse{\not\equal{\cmdNW@vertex@fontscale}{}}{ |
| 484 |
\tikzset{LocalVertexFontScale/.style={scale = \cmdNW@vertex@fontscale}} |
| 485 |
}{ |
| 486 |
\tikzset{LocalVertexFontScale/.style={}} |
| 487 |
} |
| 488 |
% Check if the opacity of the vertex is redefined, if so the new style is used |
| 489 |
\ifthenelse{\not\equal{\cmdNW@vertex@opacity}{}}{ |
| 490 |
\tikzset{LocalVertexOpacity/.style={fill opacity = \cmdNW@vertex@opacity}} |
| 491 |
}{ |
| 492 |
\tikzset{LocalVertexOpacity/.style={}} |
| 493 |
} |
| 494 |
% Check if the shape of the vertex is redefined, if so the new style is used |
| 495 |
\ifthenelse{\not\equal{\cmdNW@vertex@shape}{}}{ |
| 496 |
\tikzset{LocalVertexShape/.style={shape = \cmdNW@vertex@shape}} |
| 497 |
}{ |
| 498 |
\tikzset{LocalVertexShape/.style={}} |
| 499 |
} |
| 500 |
% Check if the color of the vertex is redefined, if so the new style is |
| 501 |
% used. If the option RGB is true, RGB values can be used to define the |
| 502 |
% color of the vertex entered in the form {R,G,B}. If RGB is not true the |
| 503 |
% default colors of tikz can be used (e.g. blue!50!green) |
| 504 |
\ifNW@vertex@RGB |
| 505 |
\ifthenelse{\not\equal{\cmdNW@vertex@color}{}}{ |
| 506 |
\pgfutil@definecolor{LocalColor}{RGB}{\cmdNW@vertex@color} |
| 507 |
\tikzset{LocalVertexFill/.style={fill = LocalColor}} |
| 508 |
}{ |
| 509 |
\tikzset{LocalVertexFill/.style={}} |
| 510 |
} |
| 511 |
\ifthenelse{\not\equal{\cmdNW@vertex@fontcolor}{}}{ |
| 512 |
\pgfutil@definecolor{LocalFontColor}{RGB}{\cmdNW@vertex@fontcolor} |
| 513 |
\tikzset{LocalVertexFontColor/.style={color = LocalFontColor}} |
| 514 |
}{ |
| 515 |
\tikzset{LocalVertexFontColor/.style={}} |
| 516 |
} |
| 517 |
\else |
| 518 |
\ifthenelse{\not\equal{\cmdNW@vertex@color}{}}{ |
| 519 |
\tikzset{LocalVertexFill/.style={fill = \cmdNW@vertex@color}} |
| 520 |
}{ |
| 521 |
\tikzset{LocalVertexFill/.style={}} |
| 522 |
} |
| 523 |
\ifthenelse{\not\equal{\cmdNW@vertex@fontcolor}{}}{ |
| 524 |
\tikzset{LocalVertexFontColor/.style={color = \cmdNW@vertex@fontcolor}} |
| 525 |
}{ |
| 526 |
\tikzset{LocalVertexFontColor/.style={}} |
| 527 |
} |
| 528 |
|
| 529 |
\fi |
| 530 |
% Define empty style for the vertex |
| 531 |
\ifNW@vertex@Pseudo |
| 532 |
\tikzset{LocalPseudo/.style={opacity = 0}} |
| 533 |
\else |
| 534 |
\tikzset{LocalPseudo/.style={}} |
| 535 |
\fi |
| 536 |
% Define local style for the label |
| 537 |
\tikzset{LocalLabel/.style={label = {[LabelStyle, LocalVertexFontColor, |
| 538 |
LocalVertexFontSize, LocalVertexFontScale, label |
| 539 |
distance=\cmdNW@vertex@distance]\cmdNW@vertex@position:\vertex@Label}}} |
| 540 |
\ifthenelse{\equal{\cmdNW@vertex@layer}{}}{ |
| 541 |
\protected@edef\@tempa{% |
| 542 |
\noexpand\node[\vstyle,LocalVertexSize,LocalVertexOpacity,LocalVertexFill,LocalVertexShape,LocalLabel,\cmdNW@vertex@style,LocalPseudo](#1)% |
| 543 |
at (\cmdNW@vertex@x*\DistanceScale\DefaultUnit,\cmdNW@vertex@y*\DistanceScale\DefaultUnit){}}% |
| 544 |
\@tempa; |
| 545 |
}{ |
| 546 |
\begin{scope}[canvas is yx plane at z=(\cmdNW@vertex@layer-1)*\NetworkLayerDistance] |
| 547 |
\protected@edef\@tempa{% |
| 548 |
\noexpand\node[\vstyle,LocalVertexSize,LocalVertexOpacity,LocalVertexFill,LocalVertexShape,LocalLabel,\cmdNW@vertex@style,LocalPseudo](#1)% |
| 549 |
at (\cmdNW@vertex@x*\DistanceScale\DefaultUnit,\cmdNW@vertex@y*\DistanceScale\DefaultUnit){}}% |
| 550 |
\@tempa; |
| 551 |
\end{scope} |
| 552 |
} |
| 553 |
\end{scope} |
| 554 |
} |
| 555 |
|
| 556 |
%<---------------------------------------------------------------------------> |
| 557 |
% Init Edge |
| 558 |
%<---------------------------------------------------------------------------> |
| 559 |
\define@cmdkey [NW] {edge} {label}{} |
| 560 |
\define@cmdkey [NW] {edge} {lw}{} |
| 561 |
\define@cmdkey [NW] {edge} {color}{} |
| 562 |
\define@cmdkey [NW] {edge} {opacity}{} |
| 563 |
\define@cmdkey [NW] {edge} {style}{} |
| 564 |
\define@cmdkey [NW] {edge} {fontcolor}{} |
| 565 |
\define@cmdkey [NW] {edge} {fontsize}{} |
| 566 |
\define@cmdkey [NW] {edge} {fontscale}{} |
| 567 |
\define@boolkey [NW] {edge} {RGB}[true]{} |
| 568 |
\define@boolkey [NW] {edge} {Math}[true]{} |
| 569 |
\define@boolkey [NW] {edge} {Direct}[true]{} |
| 570 |
\define@boolkey [NW] {edge} {Network}[true]{} |
| 571 |
\define@cmdkey [NW] {edge} {bend}{} |
| 572 |
\define@cmdkey [NW] {edge} {position}{} |
| 573 |
\define@cmdkey [NW] {edge} {distance}{} |
| 574 |
\define@cmdkey [NW] {edge} {loopsize}{} |
| 575 |
\define@cmdkey [NW] {edge} {loopposition}{} |
| 576 |
\define@cmdkey [NW] {edge} {loopshape}{} |
| 577 |
\define@boolkey [NW] {edge} {NotInBG}[true]{} |
| 578 |
\define@cmdkey [NW] {edge} {path}{} |
| 579 |
\presetkeys [NW] {edge} {Network = false,}{} |
| 580 |
% NotInBG = false,}{} |
| 581 |
|
| 582 |
%<---------------------------------------------------------------------------> |
| 583 |
% Edge |
| 584 |
%<---------------------------------------------------------------------------> |
| 585 |
\newcommand*{\Edge}[1][]{\@edge[#1]}% |
| 586 |
\def\@edge[#1](#2)(#3){% |
| 587 |
\setkeys[NW]{edge}{#1}% |
| 588 |
% Check if Vertex is used in a network, if so no default settings are |
| 589 |
% necessary, otherwise default settings are applied. |
| 590 |
\ifNW@edge@Network |
| 591 |
\else |
| 592 |
\setkeys[NW]{edge}{label = {}, |
| 593 |
lw = {}, |
| 594 |
path = {}, |
| 595 |
color = {}, |
| 596 |
opacity = {}, |
| 597 |
style = {}, |
| 598 |
fontcolor = {}, |
| 599 |
fontsize = {}, |
| 600 |
fontscale = {}, |
| 601 |
RGB = false, |
| 602 |
Math = false, |
| 603 |
Direct = false, |
| 604 |
NotInBG = false, |
| 605 |
bend = {0}, |
| 606 |
loopsize = {1\DefaultUnit}, |
| 607 |
position = {}, |
| 608 |
loopposition= {0}, |
| 609 |
loopshape = {90}, |
| 610 |
distance = {.5}} |
| 611 |
\setkeys[NW]{edge}{#1}% |
| 612 |
\fi |
| 613 |
\def\estyle{EdgeStyle} |
| 614 |
% |
| 615 |
\ifNW@edge@NotInBG |
| 616 |
\tikzset{EdgeInBG/.style={}} |
| 617 |
\else |
| 618 |
\tikzset{EdgeInBG/.style={on background layer}} |
| 619 |
\fi |
| 620 |
\begin{scope}[edge canvas,EdgeInBG] |
| 621 |
% [ |
| 622 |
% scale=1,yshift=0,every node/.append style={yslant=0.5,xslant=-1},yslant=0.5,xslant=-1 |
| 623 |
% ] |
| 624 |
% Check if Direct is true, if so use default arrow style |
| 625 |
\ifNW@edge@Direct |
| 626 |
\tikzset{LocalArrow/.style={}} |
| 627 |
\else |
| 628 |
\tikzset{LocalArrow/.style={-}} |
| 629 |
\fi |
| 630 |
% Check if the line width of the vertex is redefined, if so the new style is |
| 631 |
% used |
| 632 |
\ifthenelse{\not\equal{\cmdNW@edge@lw}{}}{ |
| 633 |
\tikzset{LocalEdgeLW/.style={line width = \cmdNW@edge@lw}} |
| 634 |
}{ |
| 635 |
\tikzset{LocalEdgeLW/.style={}} |
| 636 |
} |
| 637 |
% Check if the opacity of the vertex is redefined, if so the new style is used |
| 638 |
\ifthenelse{\not\equal{\cmdNW@edge@opacity}{}}{ |
| 639 |
\tikzset{LocalEdgeOpacity/.style={opacity = \cmdNW@edge@opacity}} |
| 640 |
\tikzset{LocalTextOpacity/.style={text opacity = \cmdNW@edge@opacity}} |
| 641 |
}{ |
| 642 |
\tikzset{LocalEdgeOpacity/.style={}} |
| 643 |
\tikzset{LocalTextOpacity/.style={}} |
| 644 |
} |
| 645 |
% Check if the font size of the edge is redefined, if so the new style is |
| 646 |
% used |
| 647 |
\ifthenelse{\not\equal{\cmdNW@edge@fontsize}{}}{ |
| 648 |
\tikzset{LocalEdgeFontSize/.style={font = \cmdNW@edge@fontsize}} |
| 649 |
}{ |
| 650 |
\tikzset{LocalEdgeFontSize/.style={}} |
| 651 |
} |
| 652 |
% Check if the font scale of the edge is redefined, if so the new style is |
| 653 |
% used |
| 654 |
\ifthenelse{\not\equal{\cmdNW@edge@fontscale}{}}{ |
| 655 |
\tikzset{LocalEdgeFontScale/.style={scale = \cmdNW@edge@fontscale}} |
| 656 |
}{ |
| 657 |
\tikzset{LocalEdgeFontScale/.style={}} |
| 658 |
} |
| 659 |
% Check if the color of the vertex is redefined, if so the new style is |
| 660 |
% used. If the option RGB is true, RGB values can be used to define the |
| 661 |
% color of the vertex entered in the form {R,G,B}. If RGB is not true the |
| 662 |
% default colors of tikz can be used (e.g. blue!50!green) |
| 663 |
\ifNW@edge@RGB |
| 664 |
\ifthenelse{\not\equal{\cmdNW@edge@color}{}}{ |
| 665 |
\pgfutil@definecolor{LocalColor}{RGB}{\cmdNW@edge@color} |
| 666 |
\tikzset{LocalEdgeColor/.style={color = LocalColor}} |
| 667 |
}{ |
| 668 |
\tikzset{LocalEdgeColor/.style={}} |
| 669 |
} |
| 670 |
\ifthenelse{\not\equal{\cmdNW@edge@fontcolor}{}}{ |
| 671 |
\pgfutil@definecolor{LocalFontColor}{RGB}{\cmdNW@edge@fontcolor} |
| 672 |
\tikzset{LocalEdgeFontColor/.style={text = LocalFontColor}} |
| 673 |
}{ |
| 674 |
\tikzset{LocalEdgeFontColor/.style={}} |
| 675 |
} |
| 676 |
|
| 677 |
\else |
| 678 |
\ifthenelse{\not\equal{\cmdNW@edge@color}{}}{ |
| 679 |
\tikzset{LocalEdgeColor/.style={color = \cmdNW@edge@color}} |
| 680 |
}{ |
| 681 |
\tikzset{LocalEdgeColor/.style={}} |
| 682 |
} |
| 683 |
\ifthenelse{\not\equal{\cmdNW@edge@fontcolor}{}}{ |
| 684 |
\tikzset{LocalEdgeFontColor/.style={text = \cmdNW@edge@fontcolor}} |
| 685 |
}{ |
| 686 |
\tikzset{LocalEdgeFontColor/.style={}} |
| 687 |
} |
| 688 |
|
| 689 |
\fi |
| 690 |
% Check if Math is true, if so the label will be in math mode |
| 691 |
\ifNW@edge@Math |
| 692 |
\def\edge@L{$\cmdNW@edge@label$}% |
| 693 |
\else |
| 694 |
\def\edge@L{\cmdNW@edge@label}% |
| 695 |
\fi |
| 696 |
% Check if a label is assigned, if so create a label variable |
| 697 |
\ifthenelse{\not\equal{\cmdNW@edge@label}{}}{ \def\edge@Label{node[EdgeLabelStyle,LocalTextOpacity,LocalEdgeFontColor,LocalEdgeFontSize,LocalEdgeFontScale,pos=\cmdNW@edge@distance,\cmdNW@edge@position]{\edge@L}} |
| 698 |
}{ |
| 699 |
\def\edge@Label{} |
| 700 |
} |
| 701 |
% Check if it is a self loop or a normal edge |
| 702 |
% Normal edge |
| 703 |
\ifthenelse{\not\equal{#2}{#3}}{ |
| 704 |
\ifthenelse{\not\equal{\cmdNW@edge@path}{}}{ |
| 705 |
\def\edge@pts{}% |
| 706 |
\@for\tmp:=\cmdNW@edge@path\do{ |
| 707 |
\edef\edge@pts{\edge@pts (\tmp) --} |
| 708 |
} |
| 709 |
\protected@edef\@tempa{% |
| 710 |
\noexpand\draw[\estyle,LocalEdgeLW,LocalEdgeOpacity,LocalEdgeColor,LocalArrow,\cmdNW@edge@style] (#2) -- \edge@pts (#3)} \@tempa; |
| 711 |
}{ |
| 712 |
\protected@edef\@tempa{% |
| 713 |
\noexpand\path[\estyle,LocalEdgeLW,LocalEdgeOpacity,LocalEdgeColor,LocalArrow,\cmdNW@edge@style] (#2) edge [bend left = \cmdNW@edge@bend] \edge@Label (#3)}% |
| 714 |
\@tempa; |
| 715 |
} |
| 716 |
}{% Self loop |
| 717 |
\protected@edef\@tempa{% |
| 718 |
\noexpand\path[\estyle,LocalEdgeLW,LocalEdgeOpacity,LocalEdgeColor,LocalArrow,\cmdNW@edge@style] |
| 719 |
(#2) edge [in=-\cmdNW@edge@loopshape/2+\cmdNW@edge@loopposition,out=\cmdNW@edge@loopshape/2+\cmdNW@edge@loopposition,loop,distance=\cmdNW@edge@loopsize,] \edge@Label (#3)}% |
| 720 |
\@tempa; |
| 721 |
} |
| 722 |
\end{scope} |
| 723 |
} |
| 724 |
|
| 725 |
|
| 726 |
%============================================================================= |
| 727 |
% Vertices and Edges creation |
| 728 |
%============================================================================= |
| 729 |
|
| 730 |
%<---------------------------------------------------------------------------> |
| 731 |
% Init Vertices |
| 732 |
%<---------------------------------------------------------------------------> |
| 733 |
\define@cmdkey [NW] {vertices} {layer}{} |
| 734 |
\define@cmdkey [NW] {vertices} {size}{} |
| 735 |
\define@cmdkey [NW] {vertices} {color}{} |
| 736 |
\define@cmdkey [NW] {vertices} {opacity}{} |
| 737 |
\define@cmdkey [NW] {vertices} {style}{} |
| 738 |
\define@cmdkey [NW] {vertices} {shape}{} |
| 739 |
\define@boolkey [NW] {vertices} {RGB}[true]{} |
| 740 |
\define@boolkey [NW] {vertices} {IdAsLabel}[true]{} |
| 741 |
\define@boolkey [NW] {vertices} {NoLabel}[true]{} |
| 742 |
\define@boolkey [NW] {vertices} {Math}[true]{} |
| 743 |
\define@boolkey [NW] {vertices} {Pseudo}[true]{} |
| 744 |
\presetkeys [NW] {vertices} {layer = {}, |
| 745 |
opacity = {}, |
| 746 |
size = {}, |
| 747 |
color = {}, |
| 748 |
style = {}, |
| 749 |
shape = {}, |
| 750 |
RGB = false, |
| 751 |
IdAsLabel = false, |
| 752 |
NoLabel = false, |
| 753 |
Math = false, |
| 754 |
Pseudo = false,}{} |
| 755 |
|
| 756 |
\newcommand*{\setkeysexpanded}[2]{% |
| 757 |
\expandafter\setkeysexpandedaux\expandafter{#2}{#1}} |
| 758 |
\newcommand*{\setkeysexpandedaux}[2]{% |
| 759 |
\setkeys[NW]{#2}{#1}} |
| 760 |
|
| 761 |
% \newcommand*{\setkeysexpandedx}[2]{% |
| 762 |
% \expandafter\setkeysexpandedauxx\expandafter{#2}{#1}} |
| 763 |
% \newcommand*{\setkeysexpandedauxx}[2]{% |
| 764 |
% \setkeys[NW]{#2}{#1}} |
| 765 |
|
| 766 |
|
| 767 |
|
| 768 |
%<---------------------------------------------------------------------------> |
| 769 |
% Vertices |
| 770 |
%<---------------------------------------------------------------------------> |
| 771 |
\newcommand*{\Vertices}[1][]{\@vertices[#1]}% |
| 772 |
\def\@vertices[#1]#2{% |
| 773 |
\setkeys[NW]{vertices}{#1}% |
| 774 |
\@@vertices{#2}% |
| 775 |
} |
| 776 |
\def\@@vertices#1{% |
| 777 |
% Check if data base already exist |
| 778 |
\DTLifdbexists{#1}{}{ |
| 779 |
% create dummy data base to store name |
| 780 |
\DTLnewdb{#1} |
| 781 |
% delete existing vertices data base |
| 782 |
\DTLifdbexists{vertices}{ |
| 783 |
\DTLgdeletedb{vertices} |
| 784 |
}{} |
| 785 |
% Load data file for vertices |
| 786 |
\DTLloaddb[noheader=false]{vertices}{#1} |
| 787 |
} |
| 788 |
% Define variables to store option values |
| 789 |
\def\vertex@Options{}% |
| 790 |
\def\vertex@id{}% |
| 791 |
\def\vertex@rgbValues{}% |
| 792 |
% Go through each row and create vertices |
| 793 |
\DTLforeach*{vertices}{}{% |
| 794 |
% reset storage variable to default values |
| 795 |
\edef\vertex@Options{x=0,y=0,label={},size={},color={},fontcolor={},fontsize={},fontscale={}, |
| 796 |
opacity={},layer={},style={},NoLabel=false,IdAsLabel=false, |
| 797 |
Math=false,RGB=false,Pseudo=false,distance={0},position={center},shape={},}% |
| 798 |
\edef\vertex@rgbValues{}% |
| 799 |
% Go through each row element |
| 800 |
\DTLforeachkeyinrow{\thisValue}{ |
| 801 |
% Remove leading and trailing spaces |
| 802 |
\trim@spaces@in\dtlkey |
| 803 |
\DTLifeq{\dtlkey}{id}{ |
| 804 |
% Assign vertex id to storage variable |
| 805 |
\edef\vertex@id{\thisValue}% |
| 806 |
}{ |
| 807 |
\DTLifeq{\dtlkey}{R}{ |
| 808 |
\edef\vertex@rgbValues{\vertex@rgbValues \thisValue,} |
| 809 |
}{ |
| 810 |
\DTLifeq{\dtlkey}{G}{ |
| 811 |
\edef\vertex@rgbValues{\vertex@rgbValues \thisValue,} |
| 812 |
}{ |
| 813 |
\DTLifeq{\dtlkey}{B}{ |
| 814 |
\edef\vertex@rgbValues{\vertex@rgbValues \thisValue,} |
| 815 |
}{ |
| 816 |
% Assign option to storage variable |
| 817 |
\edef\vertex@Options{\vertex@Options \dtlkey=\thisValue,} |
| 818 |
}}}} |
| 819 |
} |
| 820 |
% Add general settings for the Vertex |
| 821 |
% NoLabel |
| 822 |
\ifNW@vertices@NoLabel |
| 823 |
\edef\vertex@Options{\vertex@Options NoLabel=true,} |
| 824 |
\fi |
| 825 |
% Pseudo |
| 826 |
\ifNW@vertices@Pseudo |
| 827 |
\edef\vertex@Options{\vertex@Options Pseudo=true,} |
| 828 |
\fi |
| 829 |
% IdAsLabel |
| 830 |
\ifNW@vertices@IdAsLabel |
| 831 |
\edef\vertex@Options{\vertex@Options IdAsLabel=true,} |
| 832 |
\fi |
| 833 |
% Math |
| 834 |
\ifNW@vertices@Math |
| 835 |
\edef\vertex@Options{\vertex@Options Math=true,} |
| 836 |
\fi |
| 837 |
% RGB |
| 838 |
\ifNW@vertices@RGB |
| 839 |
\edef\vertex@Options{\vertex@Options RGB=true,color={\vertex@rgbValues},} |
| 840 |
\fi |
| 841 |
% opacity |
| 842 |
\ifthenelse{\not\equal{\cmdNW@vertices@opacity}{}} |
| 843 |
{ |
| 844 |
\edef\vertex@Options{\vertex@Options opacity=\cmdNW@vertices@opacity,} |
| 845 |
}{} |
| 846 |
% size |
| 847 |
\ifthenelse{\not\equal{\cmdNW@vertices@size}{}} |
| 848 |
{ |
| 849 |
\edef\vertex@Options{\vertex@Options size=\cmdNW@vertices@size,} |
| 850 |
}{} |
| 851 |
% shape |
| 852 |
\ifthenelse{\not\equal{\cmdNW@vertices@shape}{}} |
| 853 |
{ |
| 854 |
\edef\vertex@Options{\vertex@Options shape=\cmdNW@vertices@shape,} |
| 855 |
}{} |
| 856 |
% color |
| 857 |
\ifthenelse{\not\equal{\cmdNW@vertices@color}{}} |
| 858 |
{ |
| 859 |
\edef\vertex@Options{\vertex@Options color=\cmdNW@vertices@color,} |
| 860 |
}{} |
| 861 |
\ifthenelse{\not\equal{\cmdNW@vertices@style}{}}{ |
| 862 |
\edef\vertex@Options{\vertex@Options style={\cmdNW@vertices@style},} |
| 863 |
}{} |
| 864 |
% Apply settings for the Vertex |
| 865 |
\setkeysexpanded{vertex}{\vertex@Options}% |
| 866 |
\ifthenelse{\not\equal{\cmdNW@vertices@layer}{}}{ |
| 867 |
\ifthenelse{\equal{\cmdNW@vertices@layer}{\cmdNW@vertex@layer}}{ |
| 868 |
\Vertex[Network]{\vertex@id} |
| 869 |
}{} |
| 870 |
}{ |
| 871 |
\Vertex[Network]{\vertex@id} |
| 872 |
} |
| 873 |
% Create Vertex |
| 874 |
} |
| 875 |
% Delete data base |
| 876 |
% \DTLgdeletedb{#1} |
| 877 |
} |
| 878 |
|
| 879 |
%<---------------------------------------------------------------------------> |
| 880 |
% Init Edges |
| 881 |
%<---------------------------------------------------------------------------> |
| 882 |
\def\myvariable{\KeySettingCommand{false}} |
| 883 |
\define@cmdkey [NW] {edges} {layer}{} |
| 884 |
\define@cmdkey [NW] {edges} {vertices}{} |
| 885 |
\define@cmdkey [NW] {edges} {style}{} |
| 886 |
\define@cmdkey [NW] {edges} {lw}{} |
| 887 |
\define@cmdkey [NW] {edges} {color}{} |
| 888 |
\define@cmdkey [NW] {edges} {opacity}{} |
| 889 |
\define@boolkey [NW] {edges} {RGB}[true]{} |
| 890 |
\define@boolkey [NW] {edges} {Math}[true]{} |
| 891 |
\define@boolkey [NW] {edges} {Direct}[true]{} |
| 892 |
\define@boolkey [NW] {edges} {NoLabel}[true]{} |
| 893 |
\define@boolkey [NW] {edges} {NotInBG}[true]{} |
| 894 |
\presetkeys [NW] {edges} {layer = {}, |
| 895 |
vertices = {}, |
| 896 |
style = {}, |
| 897 |
lw = {}, |
| 898 |
color = {}, |
| 899 |
opacity = {}, |
| 900 |
RGB = false, |
| 901 |
Math = false, |
| 902 |
Direct = false, |
| 903 |
NoLabel = false, |
| 904 |
NotInBG = false,}{} |
| 905 |
|
| 906 |
\newcommand{\shortcut}[1]{% |
| 907 |
\@tempswafalse |
| 908 |
\@for\next:=#1\do |
| 909 |
{\if@tempswa+\else\@tempswatrue\fi\textbf{\next}}% |
| 910 |
} |
| 911 |
|
| 912 |
\newcounter{LayerCounter} |
| 913 |
|
| 914 |
|
| 915 |
\newcommand\myfunc[1]{\setcounter{LayerCounter}{0}\@for\tmp:=#1\do{ |
| 916 |
\stepcounter{LayerCounter} |
| 917 |
\arabic{LayerCounter}-a-\textbf{\tmp}} |
| 918 |
} |
| 919 |
|
| 920 |
|
| 921 |
%<---------------------------------------------------------------------------> |
| 922 |
% Edges |
| 923 |
%<---------------------------------------------------------------------------> |
| 924 |
\newcommand*{\Edges}[1][]{\@edges[#1]}% |
| 925 |
\def\@edges[#1]#2{% |
| 926 |
\setkeys[NW]{edges}{#1}% |
| 927 |
\@@edges{#2}% |
| 928 |
} |
| 929 |
\def\@@edges#1{% |
| 930 |
\begin{scope} |
| 931 |
% Check if data base already exist |
| 932 |
\DTLifdbexists{#1}{}{ |
| 933 |
% create dummy data base to store name |
| 934 |
\DTLnewdb{#1} |
| 935 |
% delete existing vertices data base |
| 936 |
\DTLifdbexists{edges}{ |
| 937 |
\DTLgdeletedb{edges} |
| 938 |
}{} |
| 939 |
% Load data file for vertices |
| 940 |
\DTLloaddb[noheader=false]{edges}{#1} |
| 941 |
} |
| 942 |
|
| 943 |
% % Load data file for vertices |
| 944 |
% \DTLloaddb[noheader=false]{#1}{#1} |
| 945 |
% Define variables to store option values |
| 946 |
\def\edge@Options{}% |
| 947 |
\def\edge@u{}% |
| 948 |
\def\edge@v{}% |
| 949 |
\def\edge@u@layer{}% |
| 950 |
\def\edge@v@layer{}% |
| 951 |
\def\edge@rgbValues{}% |
| 952 |
\def\u@layer{}% |
| 953 |
\def\v@layer{}% |
| 954 |
% |
| 955 |
% Assign where the edges are drawn from to |
| 956 |
\ifthenelse{\not\equal{\cmdNW@edges@layer}{}}{ |
| 957 |
% set layer count back to 0 |
| 958 |
\setcounter{LayerCounter}{0} |
| 959 |
\@for\tmp:=\cmdNW@edges@layer\do{ |
| 960 |
\stepcounter{LayerCounter} |
| 961 |
\ifthenelse{\value{LayerCounter}=1}{ |
| 962 |
\edef\u@layer{\tmp}% |
| 963 |
}{ |
| 964 |
\edef\v@layer{\tmp}% |
| 965 |
} |
| 966 |
} |
| 967 |
}{} |
| 968 |
% Go through each row and create edges |
| 969 |
\DTLforeach*{edges}{}{% |
| 970 |
% reset storage variable to default values |
| 971 |
\edef\edge@Options{label = {}, lw = {}, color = {}, opacity = {}, style = |
| 972 |
{}, RGB = false, Math = false, Direct = false, NotInBG = false, bend = {0}, loopsize = |
| 973 |
{1\DefaultUnit}, position = {}, loopposition = {0}, loopshape = {90}, |
| 974 |
distance = {.5}, path = {}, fontcolor = {}, fontsize = {}, fontscale ={},} |
| 975 |
\edef\edge@rgbValues{}% |
| 976 |
% Go through each row element |
| 977 |
\DTLforeachkeyinrow{\thisValue}{ |
| 978 |
% Remove leading and trailing spaces |
| 979 |
\trim@spaces@in\dtlkey |
| 980 |
\DTLifeq{\dtlkey}{u}{ |
| 981 |
% Assign edge id to storage variable |
| 982 |
\edef\edge@u{\thisValue}% |
| 983 |
}{ |
| 984 |
\DTLifeq{\dtlkey}{v}{ |
| 985 |
\edef\edge@v{\thisValue}% |
| 986 |
}{ |
| 987 |
\DTLifeq{\dtlkey}{R}{ |
| 988 |
\edef\edge@rgbValues{\edge@rgbValues \thisValue,} |
| 989 |
}{ |
| 990 |
\DTLifeq{\dtlkey}{G}{ |
| 991 |
\edef\edge@rgbValues{\edge@rgbValues \thisValue,} |
| 992 |
}{ |
| 993 |
\DTLifeq{\dtlkey}{B}{ |
| 994 |
\edef\edge@rgbValues{\edge@rgbValues \thisValue,} |
| 995 |
}{ |
| 996 |
% Assign option to storage variable |
| 997 |
\edef\edge@Options{\edge@Options \dtlkey=\thisValue,} |
| 998 |
}}}}} |
| 999 |
} |
| 1000 |
% Add general settings for the Edges |
| 1001 |
% NoLabel |
| 1002 |
\ifNW@edges@NoLabel |
| 1003 |
\edef\edge@Options{\edge@Options label={},} |
| 1004 |
\fi |
| 1005 |
% Direct |
| 1006 |
\ifNW@edges@Direct |
| 1007 |
\edef\edge@Options{\edge@Options Direct=true,} |
| 1008 |
\fi |
| 1009 |
% Math |
| 1010 |
\ifNW@edges@Math |
| 1011 |
\edef\edge@Options{\edge@Options Math=true,} |
| 1012 |
\fi |
| 1013 |
% RGB |
| 1014 |
\ifNW@edges@RGB |
| 1015 |
\edef\edge@Options{\edge@Options RGB=true,color={\edge@rgbValues},} |
| 1016 |
\fi |
| 1017 |
\ifthenelse{\not\equal{\cmdNW@edges@style}{}}{ |
| 1018 |
\edef\edge@Options{\edge@Options style={\cmdNW@edges@style},} |
| 1019 |
}{} |
| 1020 |
% lw |
| 1021 |
\ifthenelse{\not\equal{\cmdNW@edges@lw}{}} |
| 1022 |
{ |
| 1023 |
\edef\edge@Options{\edge@Options lw=\cmdNW@edges@lw,} |
| 1024 |
}{} |
| 1025 |
% color |
| 1026 |
\ifthenelse{\not\equal{\cmdNW@edges@color}{}} |
| 1027 |
{ |
| 1028 |
\edef\edge@Options{\edge@Options color=\cmdNW@edges@color,} |
| 1029 |
}{} |
| 1030 |
% opacity |
| 1031 |
\ifthenelse{\not\equal{\cmdNW@edges@opacity}{}} |
| 1032 |
{ |
| 1033 |
\edef\edge@Options{\edge@Options opacity=\cmdNW@edges@opacity,} |
| 1034 |
}{} |
| 1035 |
% NoLabel |
| 1036 |
\ifNW@edges@NotInBG |
| 1037 |
\edef\edge@Options{\edge@Options NotInBG=true,} |
| 1038 |
\fi |
| 1039 |
% Apply settings for the Edge |
| 1040 |
\setkeysexpanded{edge}{\edge@Options}% |
| 1041 |
% Create Edge |
| 1042 |
\ifthenelse{\equal{\cmdNW@edges@layer}{}}{ |
| 1043 |
\Edge[Network](\edge@u)(\edge@v) |
| 1044 |
}{ |
| 1045 |
\ifthenelse{\not\equal{\cmdNW@edges@vertices}{}}{ |
| 1046 |
% Generate pseudo vertices |
| 1047 |
\Vertices[Pseudo,NoLabel]{\cmdNW@edges@vertices} |
| 1048 |
% Delete existing vertices data base |
| 1049 |
\DTLifdbexists{vertices}{ |
| 1050 |
\DTLgdeletedb{vertices} |
| 1051 |
}{} |
| 1052 |
% Load data file for vertices |
| 1053 |
\DTLloaddb[noheader=false]{vertices}{\cmdNW@edges@vertices} |
| 1054 |
}{} |
| 1055 |
% find assigned layer to the used vertices |
| 1056 |
\DTLforeach*{vertices}{\id=id,\layer=layer}{% |
| 1057 |
\ifthenelse{\equal{\id}{\edge@u}}{ |
| 1058 |
\edef\edge@u@layer{\layer}% |
| 1059 |
\dtlbreak |
| 1060 |
}{} |
| 1061 |
} |
| 1062 |
\DTLforeach*{vertices}{\id=id,\layer=layer}{% |
| 1063 |
\ifthenelse{\equal{\id}{\edge@v}}{ |
| 1064 |
\edef\edge@v@layer{\layer}% |
| 1065 |
\dtlbreak |
| 1066 |
}{} |
| 1067 |
} |
| 1068 |
% if the edge is an intra layer edge |
| 1069 |
\ifthenelse{\equal{\u@layer}{\v@layer}}{ |
| 1070 |
\ifthenelse{\equal{\u@layer}{\edge@u@layer}}{ |
| 1071 |
\ifthenelse{\equal{\v@layer}{\edge@v@layer}}{ |
| 1072 |
\Edge[Network](\edge@u)(\edge@v) |
| 1073 |
}{} |
| 1074 |
}{} |
| 1075 |
}{ |
| 1076 |
\ifthenelse{\equal{\u@layer}{\edge@u@layer}}{ |
| 1077 |
\ifthenelse{\equal{\v@layer}{\edge@v@layer}}{ |
| 1078 |
\Edge[Network](\edge@u)(\edge@v) |
| 1079 |
}{} |
| 1080 |
}{} |
| 1081 |
\ifthenelse{\equal{\v@layer}{\edge@u@layer}}{ |
| 1082 |
\ifthenelse{\equal{\u@layer}{\edge@v@layer}}{ |
| 1083 |
\Edge[Network](\edge@u)(\edge@v) |
| 1084 |
}{} |
| 1085 |
}{} |
| 1086 |
|
| 1087 |
} |
| 1088 |
|
| 1089 |
} |
| 1090 |
} |
| 1091 |
\end{scope} |
| 1092 |
% Delete data base |
| 1093 |
% \DTLgdeletedb{#1} |
| 1094 |
} |
| 1095 |
|
| 1096 |
|
| 1097 |
%<---------------------------------------------------------------------------> |
| 1098 |
% Init Layer |
| 1099 |
%<---------------------------------------------------------------------------> |
| 1100 |
\define@cmdkey [NW] {layer} {layer}{} |
| 1101 |
\define@cmdkey [NW] {layer} {z}{} |
| 1102 |
\define@cmdkey [NW] {layer} {opacity}{} |
| 1103 |
\presetkeys [NW] {layer} {layer = {1}, |
| 1104 |
opacity = {}, |
| 1105 |
z = {},}{} |
| 1106 |
|
| 1107 |
%<---------------------------------------------------------------------------> |
| 1108 |
% Layer |
| 1109 |
%<---------------------------------------------------------------------------> |
| 1110 |
%\def\@layer{canvas is yx plane at z=-3,} |
| 1111 |
|
| 1112 |
\def\@layer[#1]#2{ |
| 1113 |
\setkeys[NW]{layer}{#1} |
| 1114 |
\ifthenelse{\not\equal{\cmdNW@layer@z}{}}{ |
| 1115 |
\tikzset{LocalLayerZ/.style={canvas is yx plane at z=\cmdNW@layer@z}} |
| 1116 |
}{ |
| 1117 |
\tikzset{LocalLayerZ/.style={canvas is yx plane at z=(\cmdNW@layer@layer-1)*\NetworkLayerDistance}} |
| 1118 |
} |
| 1119 |
\ifthenelse{\not\equal{\cmdNW@layer@opacity}{}}{ |
| 1120 |
\tikzset{LocalLayerOpacity/.style={fill opacity = \cmdNW@layer@opacity}} |
| 1121 |
}{ |
| 1122 |
\tikzset{LocalLayerOpacity/.style={}} |
| 1123 |
} |
| 1124 |
\begin{scope}[LocalLayerZ,LocalLayerOpacity] |
| 1125 |
} |
| 1126 |
%\newcommand*{\Layer}[1][]{\@layer[#1]}% |
| 1127 |
\newenvironment{Layer}[1][]{\@layer[#1]1}{\end{scope}} |
| 1128 |
%\def\@layer[#1]#2{} |
| 1129 |
% \newcommand*{\Edges}[1][]{\@edges[#1]}% |
| 1130 |
% \def\@edges[#1]#2{% |
| 1131 |
% \setkeys[NW]{edges}{#1}% |
| 1132 |
% \@@edges{#2}% |
| 1133 |
% } |
| 1134 |
% \def\@@edges#1{% |
| 1135 |
|
| 1136 |
|
| 1137 |
|
| 1138 |
%<---------------------------------------------------------------------------> |
| 1139 |
% Init Plane |
| 1140 |
%<---------------------------------------------------------------------------> |
| 1141 |
\define@cmdkey [NW] {plane} {x}{} |
| 1142 |
\define@cmdkey [NW] {plane} {y}{} |
| 1143 |
\define@cmdkey [NW] {plane} {width}{} |
| 1144 |
\define@cmdkey [NW] {plane} {height}{} |
| 1145 |
\define@cmdkey [NW] {plane} {color}{} |
| 1146 |
\define@cmdkey [NW] {plane} {opacity}{} |
| 1147 |
\define@cmdkey [NW] {plane} {style}{} |
| 1148 |
\define@cmdkey [NW] {plane} {layer}{} |
| 1149 |
\define@cmdkey [NW] {plane} {grid}{} |
| 1150 |
\define@cmdkey [NW] {plane} {image}{} |
| 1151 |
\define@boolkey [NW] {plane} {RGB}[true]{} |
| 1152 |
\define@boolkey [NW] {plane} {InBG}[true]{} |
| 1153 |
\define@boolkey [NW] {plane} {NoFill}[true]{} |
| 1154 |
\define@boolkey [NW] {plane} {NoBorder}[true]{} |
| 1155 |
\define@boolkey [NW] {plane} {ImageAndFill}[true]{} |
| 1156 |
\presetkeys [NW] {plane} {x = {0}, |
| 1157 |
y = {0}, |
| 1158 |
width = {\PlaneWidth}, |
| 1159 |
height = {\PlaneHeight}, |
| 1160 |
color = {}, |
| 1161 |
opacity = {}, |
| 1162 |
style = {}, |
| 1163 |
layer = {1}, |
| 1164 |
grid = {}, |
| 1165 |
image = {}, |
| 1166 |
RGB = false, |
| 1167 |
InBG = false, |
| 1168 |
NoFill = false, |
| 1169 |
NoBorder= false, |
| 1170 |
ImageAndFill= false,}{} |
| 1171 |
|
| 1172 |
|
| 1173 |
%<---------------------------------------------------------------------------> |
| 1174 |
% Plane |
| 1175 |
%<---------------------------------------------------------------------------> |
| 1176 |
\newcommand*{\Plane}[1][]{\@plane[#1]}% |
| 1177 |
\def\@plane[#1]{% |
| 1178 |
\setkeys[NW]{plane}{#1}% |
| 1179 |
\ifNW@plane@ImageAndFill |
| 1180 |
\setkeys[NW]{plane}{#1}% |
| 1181 |
\else |
| 1182 |
\ifthenelse{\not\equal{\cmdNW@plane@image}{}}{ |
| 1183 |
\setkeys[NW]{plane}{#1,NoFill} |
| 1184 |
}{} |
| 1185 |
\fi |
| 1186 |
\@@plane% |
| 1187 |
} |
| 1188 |
\def\@@plane{% |
| 1189 |
% Draw Plane on the Background layer |
| 1190 |
\ifNW@plane@InBG |
| 1191 |
\tikzset{InBGStyle/.style={on background layer}} |
| 1192 |
\else |
| 1193 |
\tikzset{InBGStyle/.style={}} |
| 1194 |
\fi |
| 1195 |
\begin{scope}[InBGStyle] |
| 1196 |
% Check if the color of the plane is redefined, if so the new style is |
| 1197 |
% used. If the option RGB is true, RGB values can be used to define the |
| 1198 |
% color of the plane entered in the form {R,G,B}. If RGB is not true the |
| 1199 |
% default colors of tikz can be used (e.g. blue!50!green) |
| 1200 |
\ifNW@plane@RGB |
| 1201 |
\ifthenelse{\not\equal{\cmdNW@plane@color}{}}{ |
| 1202 |
\pgfutil@definecolor{LocalColor}{RGB}{\cmdNW@plane@color} |
| 1203 |
\tikzset{LocalPlaneFill/.style={fill = LocalColor}} |
| 1204 |
}{ |
| 1205 |
\tikzset{LocalPlaneFill/.style={}} |
| 1206 |
} |
| 1207 |
\else |
| 1208 |
\ifthenelse{\not\equal{\cmdNW@plane@color}{}}{ |
| 1209 |
\tikzset{LocalPlaneFill/.style={fill = \cmdNW@plane@color}} |
| 1210 |
}{ |
| 1211 |
\tikzset{LocalPlaneFill/.style={}} |
| 1212 |
} |
| 1213 |
\fi |
| 1214 |
% Check if the opacity of the plane is redefined, if so the new style is used |
| 1215 |
\ifthenelse{\not\equal{\cmdNW@plane@opacity}{}}{ |
| 1216 |
\tikzset{LocalPlaneOpacity/.style={fill opacity = \cmdNW@plane@opacity}} |
| 1217 |
}{ |
| 1218 |
\tikzset{LocalPlaneOpacity/.style={}} |
| 1219 |
} |
| 1220 |
\begin{scope}[canvas is yx plane at z=(\cmdNW@plane@layer-1)*\NetworkLayerDistance] |
| 1221 |
% Draw the fill of the Plane |
| 1222 |
\ifNW@plane@NoFill |
| 1223 |
\else |
| 1224 |
\protected@edef\@tempa{% |
| 1225 |
\noexpand\fill[PlaneFillStyle,LocalPlaneFill,LocalPlaneOpacity](\cmdNW@plane@x*\DistanceScale,\cmdNW@plane@y*\DistanceScale) |
| 1226 |
rectangle ++ (\cmdNW@plane@width*\DistanceScale,\cmdNW@plane@height*\DistanceScale)}% |
| 1227 |
\@tempa; |
| 1228 |
\fi |
| 1229 |
% Draw image on the Plane |
| 1230 |
\ifthenelse{\not\equal{\cmdNW@plane@image}{}}{ |
| 1231 |
%\protected@edef\@tempa{% |
| 1232 |
%\noexpand |
| 1233 |
\node[inner sep=0pt,LocalPlaneOpacity] at |
| 1234 |
($(\cmdNW@plane@width/2,\cmdNW@plane@height/2)+(\cmdNW@plane@x,\cmdNW@plane@y)$) |
| 1235 |
{\includegraphics[width=\cmdNW@plane@width\DefaultUnit,height=\cmdNW@plane@height\DefaultUnit]{\cmdNW@plane@image}}; |
| 1236 |
%}% |
| 1237 |
%\@tempa; |
| 1238 |
}{} |
| 1239 |
% Draw grid on the Plane |
| 1240 |
\ifthenelse{\not\equal{\cmdNW@plane@grid}{}}{ |
| 1241 |
\protected@edef\@tempa{% |
| 1242 |
\noexpand\draw[PlaneGridStyle,step=\cmdNW@plane@grid*\DistanceScale](\cmdNW@plane@x*\DistanceScale,\cmdNW@plane@y*\DistanceScale) |
| 1243 |
grid ++ (\cmdNW@plane@width*\DistanceScale,\cmdNW@plane@height*\DistanceScale)}% |
| 1244 |
\@tempa; |
| 1245 |
}{} |
| 1246 |
% Draw the border of the Plane |
| 1247 |
\ifNW@plane@NoBorder |
| 1248 |
\else |
| 1249 |
\protected@edef\@tempa{% |
| 1250 |
\noexpand\draw[PlaneBorderStyle,\cmdNW@plane@style](\cmdNW@plane@x*\DistanceScale,\cmdNW@plane@y*\DistanceScale) |
| 1251 |
rectangle ++ (\cmdNW@plane@width*\DistanceScale,\cmdNW@plane@height*\DistanceScale)}% |
| 1252 |
\@tempa; |
| 1253 |
\fi |
| 1254 |
\end{scope} |
| 1255 |
\end{scope} |
| 1256 |
} |
| 1257 |
|
| 1258 |
|
| 1259 |
%<---------------------------------------------------------------------------> |
| 1260 |
% Init Text |
| 1261 |
%<---------------------------------------------------------------------------> |
| 1262 |
\define@cmdkey [NW] {text} {x}{} |
| 1263 |
\define@cmdkey [NW] {text} {y}{} |
| 1264 |
\define@cmdkey [NW] {text} {layer}{} |
| 1265 |
\define@cmdkey [NW] {text} {color}{} |
| 1266 |
\define@cmdkey [NW] {text} {opacity}{} |
| 1267 |
\define@cmdkey [NW] {text} {rotation}{} |
| 1268 |
\define@cmdkey [NW] {text} {fontsize}{} |
| 1269 |
\define@cmdkey [NW] {text} {anchor}{} |
| 1270 |
\define@cmdkey [NW] {text} {position}{} |
| 1271 |
\define@cmdkey [NW] {text} {distance}{} |
| 1272 |
\define@cmdkey [NW] {text} {style}{} |
| 1273 |
\define@cmdkey [NW] {text} {width}{} |
| 1274 |
\define@boolkey [NW] {text} {RGB}[true]{} |
| 1275 |
\presetkeys [NW] {text} {x = {0}, |
| 1276 |
y = {0}, |
| 1277 |
layer = {}, |
| 1278 |
color = {}, |
| 1279 |
opacity = {}, |
| 1280 |
fontsize = {}, |
| 1281 |
anchor = {}, |
| 1282 |
position = {}, |
| 1283 |
rotation = {}, |
| 1284 |
distance = {0\DefaultUnit}, |
| 1285 |
style = {}, |
| 1286 |
width = {}, |
| 1287 |
RGB = false,}{} |
| 1288 |
|
| 1289 |
|
| 1290 |
%<---------------------------------------------------------------------------> |
| 1291 |
% Text |
| 1292 |
%<---------------------------------------------------------------------------> |
| 1293 |
\newcommand*{\Text}[1][]{\@text[#1]}% |
| 1294 |
\def\@text[#1]#2{% |
| 1295 |
\setkeys[NW]{text}{#1}% |
| 1296 |
\@@text{#2}% |
| 1297 |
} |
| 1298 |
\def\@@text#1{% |
| 1299 |
% Check if the color of the text is redefined, if so the new style is |
| 1300 |
% used. If the option RGB is true, RGB values can be used to define the |
| 1301 |
% color of the text entered in the form {R,G,B}. If RGB is not true the |
| 1302 |
% default colors of tikz can be used (e.g. blue!50!green) |
| 1303 |
\ifNW@text@RGB |
| 1304 |
\ifthenelse{\not\equal{\cmdNW@text@color}{}}{ |
| 1305 |
\pgfutil@definecolor{LocalColor}{RGB}{\cmdNW@text@color} |
| 1306 |
\tikzset{LocalTextColor/.style={color = LocalColor}} |
| 1307 |
}{ |
| 1308 |
\tikzset{LocalTextColor/.style={}} |
| 1309 |
} |
| 1310 |
\else |
| 1311 |
\ifthenelse{\not\equal{\cmdNW@text@color}{}}{ |
| 1312 |
\tikzset{LocalTextColor/.style={color = \cmdNW@text@color}} |
| 1313 |
}{ |
| 1314 |
\tikzset{LocalTextColor/.style={}} |
| 1315 |
} |
| 1316 |
\fi |
| 1317 |
% Check if the opacity of the text is redefined, if so the new style is used |
| 1318 |
\ifthenelse{\not\equal{\cmdNW@text@opacity}{}}{ |
| 1319 |
\tikzset{LocalTextOpacity/.style={text opacity = \cmdNW@text@opacity}} |
| 1320 |
}{ |
| 1321 |
\tikzset{LocalTextOpacity/.style={}} |
| 1322 |
} |
| 1323 |
% Check if the rotation of the text is redefined, if so the new style is used |
| 1324 |
\ifthenelse{\not\equal{\cmdNW@text@rotation}{}}{ |
| 1325 |
\tikzset{LocalTextRotation/.style={rotate = \cmdNW@text@rotation}} |
| 1326 |
}{ |
| 1327 |
\tikzset{LocalTextRotation/.style={}} |
| 1328 |
} |
| 1329 |
% Check if the font size of the text is redefined, if so the new style is used |
| 1330 |
\ifthenelse{\not\equal{\cmdNW@text@fontsize}{}}{ |
| 1331 |
\tikzset{LocalTextFontSize/.style={font = \cmdNW@text@fontsize}} |
| 1332 |
}{ |
| 1333 |
\tikzset{LocalTextFontSize/.style={}} |
| 1334 |
} |
| 1335 |
% Check if the position of the text is redefined, if so the new style is used |
| 1336 |
\ifthenelse{\not\equal{\cmdNW@text@position}{}}{ |
| 1337 |
\tikzset{LocalTextPosition/.style={\cmdNW@text@position = \cmdNW@text@distance}} |
| 1338 |
}{ |
| 1339 |
\tikzset{LocalTextPosition/.style={}} |
| 1340 |
} |
| 1341 |
% Check if the anchor of the text is redefined, if so the new style is used |
| 1342 |
\ifthenelse{\not\equal{\cmdNW@text@anchor}{}}{ |
| 1343 |
\tikzset{LocalTextAnchor/.style={anchor = \cmdNW@text@anchor}} |
| 1344 |
}{ |
| 1345 |
\tikzset{LocalTextAnchor/.style={}} |
| 1346 |
} |
| 1347 |
% Check if the text width of the text is redefined, if so the new style is used |
| 1348 |
\ifthenelse{\not\equal{\cmdNW@text@width}{}}{ |
| 1349 |
\tikzset{LocalTextWidth/.style={text width = \cmdNW@text@width}} |
| 1350 |
}{ |
| 1351 |
\tikzset{LocalTextWidth/.style={}} |
| 1352 |
} |
| 1353 |
\ifthenelse{\equal{\cmdNW@text@layer}{}}{ |
| 1354 |
\protected@edef\@tempa{% |
| 1355 |
\noexpand\node[TextStyle, LocalTextColor, LocalTextOpacity, |
| 1356 |
LocalTextFontSize, LocalTextRotation, LocalTextPosition, |
| 1357 |
LocalTextAnchor, LocalTextWidth, \cmdNW@text@style] at |
| 1358 |
(\cmdNW@text@x*\DistanceScale,\cmdNW@text@y*\DistanceScale){#1} |
| 1359 |
}\@tempa;% |
| 1360 |
}{ |
| 1361 |
\begin{scope}[canvas is yx plane at z=(\cmdNW@text@layer-1)*\NetworkLayerDistance] |
| 1362 |
\protected@edef\@tempa{% |
| 1363 |
\noexpand\node[TextStyle, LocalTextColor, LocalTextOpacity, |
| 1364 |
LocalTextFontSize, LocalTextRotation, LocalTextPosition, |
| 1365 |
LocalTextAnchor, LocalTextWidth, \cmdNW@text@style] at |
| 1366 |
(\cmdNW@text@x*\DistanceScale,\cmdNW@text@y*\DistanceScale){#1} |
| 1367 |
}\@tempa;% |
| 1368 |
\end{scope} |
| 1369 |
} |
| 1370 |
} |
| 1371 |
|
| 1372 |
|
| 1373 |
|
| 1374 |
|
| 1375 |
|
| 1376 |
|
| 1377 |
|
| 1378 |
|
| 1379 |
|
| 1380 |
|
| 1381 |
|
| 1382 |
|
| 1383 |
|
| 1384 |
|
| 1385 |
|
| 1386 |
|
| 1387 |
|
| 1388 |
|
| 1389 |
|
| 1390 |
\endinput |
| 1391 |
%============================================================================= |
| 1392 |
% eof |
| 1393 |
% |
| 1394 |
% Local Variables: |
| 1395 |
% mode: latex |
| 1396 |
% mode: flyspell |
| 1397 |
% mode: auto-fill |
| 1398 |
% fill-column: 80 |
| 1399 |
% TeX-master: t |
| 1400 |
% End: |