Debian Codegraph @

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

raw
1 %% bondgraph.sty
2 %% Copyright (c) 2010, Jean-Francois Dupuis
3 %
4 % This work may be distributed and/or modified under the
5 % conditions of the LaTeX Project Public License, either version 1.3
6 % of this license or (at your option) any later version.
7 % The latest version of this license is in
8 % http://www.latex-project.org/lppl.txt
9 % and version 1.3 or later is part of all distributions of LaTeX
10 % version 2005/12/01 or later.
11 %
12 % This work has the LPPL maintenance status `maintained'.
13 %
14 % The Current Maintainer of this work is Jean-Francois Dupuis.
15 %
16 % This work consists of the files bondgraph.sty, bondgraph_arrows.tex
17 % and bondgraph_example.tex.
18
19
20 % The Defines commands to draw bond graph using the graph layout tools
21 % TikZ and PGF.
22
23 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
24 \ProvidesPackage{bondgraph}[2010/06/04 v1.0]
25 \RequirePackage{tikz}
26 \RequirePackage{ifthen}
27
28 \usepgflibrary{arrows}
29 \usetikzlibrary{positioning}
30
31 % % Arrow definition
32 \pgfarrowsdeclarecombine[\pgflinewidth]
33 {combined}{combined}{left to}{left to}{|}{|}%
34
35 \tikzstyle{outbond}=[-left to]
36 \tikzstyle{inbond}=[left to-]
37 \tikzstyle{outbonde}=[-combined]
38 \tikzstyle{inbonde}=[combined-]
39 \tikzstyle{outbondf}=[|-left to]
40 \tikzstyle{inbondf}=[left to-|]
41
42
43
44 %usefull command
45 \newcommand{\bondleft}[2]{
46 \begin{tikzpicture}[auto,baseline]
47 \draw [left to-] (0pt,0.7ex) to node {\scriptsize$\textstyle #1$} node [swap] {\scriptsize$\textstyle #2$} (3ex,0.7ex);
48 \end{tikzpicture}
49 }
50
51 \newcommand{\bondright}[2]{
52 \begin{tikzpicture}[auto,baseline]
53 \draw [-left to] (0pt,0.7ex) to node {\scriptsize$\textstyle #1$} node [swap] {\scriptsize$\textstyle #2$} (3ex,0.7ex);
54 \end{tikzpicture}
55 }
56
57 \newcommand{\bondrighte}[2]{
58 \begin{tikzpicture}[auto,baseline]
59 \draw[-combined] (0pt,0.7ex) to node {\scriptsize$\textstyle #1$} node [swap] {\scriptsize$\textstyle #2$} (3ex,0.7ex);
60 \end{tikzpicture}
61 }
62 \newcommand{\bondrightf}[2]{
63 \begin{tikzpicture}[auto,baseline]
64 \draw[|-left to] (0pt,0.7ex) to node {\scriptsize$\textstyle #1$} node [swap] {\scriptsize$\textstyle #2$} (3ex,0.7ex);
65 \end{tikzpicture}
66 }
67 \newcommand{\bondlefte}[2]{
68 \begin{tikzpicture}[auto, baseline]
69 \draw[combined-] (0pt,0.7ex) to node {\scriptsize$\textstyle #1$} node [swap] {\scriptsize$\textstyle #2$} (3ex,0.7ex);
70 \end{tikzpicture}
71 }
72 \newcommand{\bondleftf}[2]{
73 \begin{tikzpicture}[auto, baseline]
74 \draw[left to-|] (0pt,0.7ex) to node {\scriptsize$\textstyle #1$} node [swap] {\scriptsize$\textstyle #2$} (3ex,0.7ex);
75 \end{tikzpicture}
76 }
77
78 % % % Style definition
79
80 \tikzstyle{nodemodpoint}=[
81 % The shape:
82 rectangle,
83 % The size:
84 minimum size=6mm,
85 % The border:
86 very thick,
87 draw=red!50!black!50, % 50% red and 50% black, and that mixed with 50% white
88 % The filling:
89 top color=white, % a shading that is white at the top...
90 bottom color=red!50!black!20, % and something else at the bottom
91 % Font
92 %font=\itshape,
93 % Seperation
94 outer sep=2pt
95 ]
96
97 \tikzstyle{bondmodpoint}=[
98 % The shape:
99 rectangle,
100 % The size:
101 minimum size=2.5mm,
102 % The border:
103 very thick,
104 draw=red!50!black!50, % 50% red and 50% black, and that mixed with 50% white
105 % Seperation
106 outer sep=2pt
107 ]
108
109 \tikzstyle{newelement}=[
110 color=red!50!black!75,
111 thick
112 ]
113
114
115 % % Bond graph creation command
116
117 \newcommand{\bgComponentNoBond} [2] {
118 %1 Node style
119 %2 Node reference name
120 %3 Node displayed name
121 \node (#1) {#2};
122 }
123
124 \newcommand{\bgComponent} [6] {
125 %1 Node style
126 %2 Node reference
127 %3 Node name
128 %4 Position
129 %5 Position reference
130 %6 Bond style
131 \node [#1] (#2) [#4 #5] {#3}
132 edge [#6] (#5);
133 }
134
135 \newcommand{\bgComponentWithBondLabel} [9] {
136 %1 Node style
137 %2 Node reference
138 %3 Node name
139 %4 Position
140 %5 Position reference
141 %6 Bond style
142 %7 Label style
143 %8 Effort label name
144 %9 Flow label name
145 \ifthenelse{\equal{#4}{right of=}\or\equal{#4}{left of=}}%
146 { %Place label above and below
147 \node [#1] (#2) [#4 #5] {#3}
148 edge [#6] node [#7] [above]{#8} node [#7] [below]{#9} (#5);
149 }{ %Place labels left and right
150 \node [#1] (#2) [#4 #5] {#3}
151 edge [#6] node [#7] [left]{#8} node [#7] [right]{#9} (#5);
152 }
153 }
154
155 \newcommand{\bgComponentWithPosBondLabel} [9] {
156 %1 Node style
157 %2 Node reference
158 %3 Node name
159 %4 Position
160 %5 Position reference
161 %6 Bond style
162 %7 Label style
163 %8 Label position
164 %9 Label name
165 \node [#1] (#2) [#4 #5] {#3}
166 edge [#6] node [#7] [#8]{#9} (#5);
167 }
168
169 \newcommand{\bgComponentWithBondMarkup} [7] {
170 %1 Node style
171 %2 Node reference
172 %3 Node name
173 %4 Position
174 %5 Position reference
175 %6 Bond style
176 %7 Markup style
177 \node [#1] (#2) [#4 #5] {#3}
178 edge [#6] node [#7] {} (#5);
179 }
180
181 \newcommand{\bgComponentWithBondMarkupTagged} [8] {
182 %1 Node style
183 %2 Node reference
184 %3 Node name
185 %4 Position
186 %5 Position reference
187 %6 Bond style
188 %7 Markup style
189 %8 Tag
190 \ifthenelse{\equal{#4}{right of=}\or\equal{#4}{left of=}}%
191 { %Place label above and below
192 \node [#1] (#2) [#4 #5] {#3}
193 edge [#6] node [font=\scriptsize,above=0.75ex]{#8} node [#7] {} (#5);
194 }{ %Place labels left and right
195 \node [#1] (#2) [#4 #5] {#3}
196 edge [#6] node [font=\scriptsize, left=0.75ex]{#8} node [#7] {} (#5);
197 }
198 }
199
200
201