Debian Codegraph @

texmf-dist/tex/latex/bondgraphs/bondgraphs.sty

raw
1 %%
2 %% This is file `bondgraphs.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% bondgraphs.dtx (with options: `package')
8 %% This is a generated file.
9 %%
10 %% Copyright (C) ⟨2014⟩ by ⟨Geert Folkertsma⟩
11 %% This file may be distributed and/or modified under the
12 %% conditions of the LaTeX Project Public License, either
13 %% version 1.3 of this license or (at your option) any later
14 %% version. The latest version of this license is in:
15 %% http://www.latex-project.org/lppl.txt
16 %% and version 1.3 or later is part of all distributions of
17 %% LaTeX version 2008/05/04 or later.
18 %%
19 \NeedsTeXFormat{LaTeX2e}
20 \ProvidesPackage{bondgraphs}[2015/03/23 v1.0.1 TikZ-based Bond graphs formatting package]
21 \RequirePackage{tikz}[2013/12/13]
22 \usetikzlibrary{arrows,arrows.meta,decorations.pathreplacing}
23 \usetikzlibrary{positioning}
24 \usetikzlibrary{shapes}
25 \RequirePackage{amsfonts}
26 \RequirePackage{bm}
27 \RequirePackage{kvoptions}
28 \SetupKeyvalOptions{family=bondgraphs,prefix=bondgraphs@}
29 \DeclareStringOption[blue]{labelcolour}
30 \DeclareStringOption[green!50!black]{bondlabelcolour}
31 \DeclareBoolOption[false]{grey}
32 \DeclareComplementaryOption{colour}{grey}
33 \DeclareBoolOption[false]{curly}
34 \ProcessLocalKeyvalOptions{bondgraphs}
35 \ifbondgraphs@grey
36 \message{Bondgraphs package: greyscale set}
37 \colorlet{diff}{black!60!white}
38 \colorlet{error}{black!40!white}
39 \def\bondgraphs@labelcolour{black!50!white}
40 \def\bondgraphs@bondlabelcolour{black!50!white}
41 %TODO: would be nice to have this as a style instead of a colour...
42 \else
43 \message{Bondgraphs package: using colour}
44 \colorlet{diff}{orange}
45 \colorlet{error}{red}
46 \fi
47 \tikzset{bond/.style args={#1}{
48 decoration={show path construction,
49 lineto code={
50 \draw[#1,thick]
51 \pgfextra{% +45 i.s.o. -1 for to left or to under, always
52 \pgfmathparse{int((\pgfdecoratedangle-1)/90)}
53 \ifcase\pgfmathresult
54 \ifbondgraphs@curly
55 \tikzset{-{Classical TikZ Rightarrow[length=3 2 0.8,right]}}
56 \else
57 \tikzset{-{Straight Barb[length=3 2 0.8,right]}}
58 \fi
59 \or
60 \ifbondgraphs@curly
61 \tikzset{-{Classical TikZ Rightarrow[length=3 2 0.8,left]}}
62 \else
63 \tikzset{-{Straight Barb[length=3 2 0.8,left]}}
64 \fi
65 \or
66 \ifbondgraphs@curly
67 \tikzset{-{Classical TikZ Rightarrow[length=3 2 0.8,left]}}
68 \else
69 \tikzset{-{Straight Barb[length=3 2 0.8,left]}}
70 \fi
71 \else
72 \ifbondgraphs@curly
73 \tikzset{-{Classical TikZ Rightarrow[length=3 2 0.8,right]}}
74 \else
75 \tikzset{-{Straight Barb[length=3 2 0.8,right]}}
76 \fi
77 \fi
78 } (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast);
79 }
80 },
81 postaction=decorate
82 },
83 bond/.default={}
84 }
85 \tikzset{mbond/.style={bond={double,#1}}}
86 \tikzset{bonds/.style={every edge/.append style={bond}}}
87 \tikzset{
88 bondlabel/.style={
89 font=\small,
90 color=\bondgraphs@bondlabelcolour,
91 sloped,
92 },
93 effort/.style args={#1}{
94 edge node={node [bondlabel,above]{#1}}
95 },
96 effort/.default={},
97 flow/.style args={#1}{
98 edge node={node [bondlabel,below]{#1}}
99 },
100 flow/.default={}
101 }
102 \tikzset{
103 e_out/.style args={#1}{
104 -{|[line width=1.2pt,width=7pt,#1]}
105 },
106 e_out/.default={black},
107 f_in/.style args={#1}{
108 e_out={#1}
109 },
110 e_in/.style args={#1}{
111 {|[line width=1.2pt,width=7pt,#1]}-
112 },
113 e_in/.default={black},
114 f_out/.style args={#1}{
115 e_in={#1}
116 }
117 }
118 \newcommand\bond[1][]{%
119 \tikz \draw(0,0) edge[bond,#1] (1,0);
120 }
121 \tikzset{
122 bgelement/.style={
123 font=\bfseries,
124 prefix after command= {\pgfextra{
125 \tikzset{every label/.style={
126 % Element label style
127 \bondgraphs@labelcolour,
128 font={\mdseries}
129 }
130 }}}
131 }
132 }
133 \tikzset{
134 multiport/.style={
135 execute at begin node=$\mathbb\bgroup,
136 execute at end node=\egroup$
137 }
138 }
139 \tikzset{
140 wordbgelement/.style={
141 draw,ellipse,minimum size=12pt,thick,font=\mdseries
142 }
143 }
144 \newif\ifbondgraphs@bgelement@multiport
145 \newif\ifbondgraphs@bgelement@wordbg
146 \pgfkeys{
147 /bgelement/.is family, %automatically cd to /bgelement when present
148 /bgelement/n/.store in=\bondgraphs@bgelement@n,
149 /bgelement/n=1,
150 %
151 /bgelement/multiport/.is if=bondgraphs@bgelement@multiport,
152 /bgelement/multiport=false,
153 /bgelement/wordbg/.is if=bondgraphs@bgelement@wordbg,
154 /bgelement/wordbg=false,
155 }
156 \newcommand\bgelement[2][]{%
157 \pgfkeys{/bgelement,multiport=false,wordbg=false,#1}%
158 \ifbondgraphs@bgelement@wordbg
159 \tikz[baseline=(the_elm.base)] \node[wordbgelement] (the_elm) {#2};%
160 \else
161 \ifbondgraphs@bgelement@multiport
162 \ifnum\bondgraphs@bgelement@n=1
163 \ensuremath{\mathbb{#2}}%
164 \else
165 \ensuremath{\mathbb{#2}_{\bondgraphs@bgelement@n}}%
166 \fi
167 \else
168 \ifnum\bondgraphs@bgelement@n=1
169 \textrm{\textbf{#2}}%
170 \else
171 \textrm{\textbf{#2}$_{\bondgraphs@bgelement@n}$}%
172 \fi
173 \fi
174 \fi
175 }
176 \newenvironment{bondgraph}[1][]{%
177 \begin{tikzpicture}%
178 [#1,every node/.style={bgelement},every edge/.append style={bond}]%
179 }{%
180 \end{tikzpicture}
181 }
182 \endinput
183 %%
184 %% End of file `bondgraphs.sty'.