Debian Codegraph @

texmf-dist/tex/latex/tikz-opm/tikz-opm.sty

raw
1 \NeedsTeXFormat{LaTeX2e}
2 \ProvidesPackage{tikz-opm}[2014/01/23 v0.1.1 OPM Digrams]
3
4
5 \RequirePackage{tikz}
6 \usetikzlibrary{shapes.geometric}
7 \usetikzlibrary{calc, positioning}
8 \usepgflibrary{shapes.multipart, arrows}
9
10 \RequirePackage{makeshape}
11 \RequirePackage{amsmath}
12
13 % Keys for tikzopm triangles
14 %
15 % /pgf/tikzopmGeneralization : side length (of the triangle)
16 \pgfkeys{/opm/.cd,
17 side length/.code=#1,
18 side length/.default=15pt,
19 side length/.initial=15pt}
20 %\pgfkeys{/opm/side length=12pt}
21
22 \def\defaulttriangleanchors{%
23 \savedanchor{\upper}{%
24 \pgfpoint{0pt}{.5\pgf@ya}%
25 \mincorrect{\pgf@y}{\pgfshapeminheight}%
26 \advance\pgf@y by -2\pgfshapeouterysep%
27 }%
28
29 \anchor{north}{\upper}%
30 \anchor{north west}{\upper}%
31 \anchor{north east}{\upper}%
32 \anchor{south west}{\pgfpoint{-7.5pt}{-.5\pgf@ya}}%
33 \anchor{south}{\pgfpoint{0pt}{-.5\pgf@ya}}%
34 \anchor{west}{\pgfpoint{-7.5pt}{-.5\pgf@ya}}%
35 \anchor{south east}{\pgfpoint{7.5pt}{-.5\pgf@ya}}%
36 \anchor{east}{\pgfpoint{7.5pt}{-.5\pgf@ya}}%
37 \anchor{center}{\pgfpointorigin}%
38 }
39
40 \def\defaulttrianglelengths{%
41 \pgfmathsetlength{\pgf@xa}{15pt}%\pgfkeysvalueof{/opm/side length}}%
42 \pgfmathsetlength{\pgf@ya}{ sqrt(3) * \pgf@xa / 2 }%
43 }
44
45 \def\trianglepath{%
46 \defaulttrianglelengths%
47 \pgfpathmoveto{\pgfpoint{0pt}{\pgf@ya}}%
48 \pgfpathlineto{\pgfpoint{-.5\pgf@xa}{0}}%
49 \pgfpathlineto{\pgfpoint{.5\pgf@xa}{0}}%
50 \pgfpathclose%
51 }
52
53 \pgfdeclareshape{tikzopmGeneralization}%
54 { \nodeparts{}% this is a symbol only
55 %% xa: length
56 %% ya: height
57 \defaulttrianglelengths%
58 \defaulttriangleanchors%
59
60 %% draw the triangle
61 \backgroundpath{
62 \trianglepath%
63 \pgfusepath{stroke}%
64 }%
65 }
66
67 \pgfdeclareshape{tikzopmAggregation}%
68 { \nodeparts{}%
69 \defaulttrianglelengths%
70 \defaulttriangleanchors%
71
72 \backgroundpath{%
73 \trianglepath%
74 \pgfusepath{fill}}
75 }
76
77 \pgfdeclareshape{tikzopmExhibition}{%
78 \nodeparts{}%
79 \defaulttrianglelengths%
80 \defaulttriangleanchors%
81
82 \backgroundpath{%
83 \defaulttrianglelengths%
84 \trianglepath\pgfusepath{stroke}%
85 \pgfpathmoveto{\pgfpoint{0pt}{.7\pgf@ya}}%
86 \pgfpathlineto{\pgfpoint{-4pt}{.15\pgf@ya}}%
87 \pgfpathlineto{\pgfpoint{4pt}{.15\pgf@ya}}%
88 \pgfpathclose\pgfusepath{fill}%
89 }%
90 }
91
92 \pgfdeclareshape{tikzopmInstantiation}{%
93 \nodeparts{}%
94 \defaulttrianglelengths%
95 \defaulttriangleanchors%
96
97 \backgroundpath{%
98 \defaulttrianglelengths%
99 \trianglepath\pgfusepath{stroke}%
100 \pgfpathmoveto{\pgfpoint{0pt}{0pt}}%
101 \pgfpathlineto{\pgfpoint{-4pt}{.5\pgf@ya}}%
102 \pgfpathlineto{\pgfpoint{4pt}{.5\pgf@ya}}%
103 \pgfpathclose\pgfusepath{fill}%
104 }%
105 }
106
107 % \pgfdeclareshap{tikzopmInstance}{%
108 % \nodeparts{text,instanceof}%
109 % %
110 % % Anchors
111 % %
112 % \savedanchor\centerpoint{%
113 % \pgf@x=.5\wd\gpfnodeparttextbox%
114 % \pgfmathsetlength{\pgf@y}{\pgfkeysvalueof{/pgf/inner ysep}}%
115 % \pgf@y=-\pgf@y%
116 % \advance\pgf@y by-\dp\pgfnodeparttextbox%
117 % \advance\pgf@y by-.5\pgflinewidth%
118 % }%
119
120 % \newcommand{\opmInstance}[4]{%
121 % \node [shape=rectangle, draw, font=\scriptsize, #4] (#1-inner) {#3};%
122 % \node [shape=rectangle, draw, minimum height=25pt,
123 % at=(#1-inner.northwest] (#1) {#2};%
124 % }
125
126 \newcommand{\opmInstance}[2]{%
127 \ensuremath{\genfrac{}{}{0pt}{}{\text{#1}}{\text{\tiny #2}}}}
128
129 \tikzset{every edge/.style={draw, thick}}
130 \tikzset{opmentity/.style={draw, thick}}
131
132
133 \tikzset{opminstance/.style={shape=rectangle, draw}}
134 \tikzset{opmobject/.style={shape=rectangle, opmentity}}
135 %\tikzset{opmobjectwithstate/.style={shape=rectangle, opmentity,text depth=8ex}}
136
137 \tikzset{opmstate/.style={opmentity, shape=rectangle, rounded corners=6pt}}
138 \tikzset{opmprocess/.style={shape=ellipse, opmentity}}
139 \tikzset{opmgeneralization/.style={shape=tikzopmGeneralization, draw, yshift=15pt}}
140 \tikzset{opmaggregation/.style={shape=tikzopmAggregation, draw, yshift=15pt}}
141 \tikzset{opmexhibition/.style={shape=tikzopmExhibition, draw, yshift=15pt}}
142 \tikzset{opminstantiation/.style={shape=tikzopmInstantiation, draw, yshift=15pt}}
143
144 %% edge styles
145 \tikzset{opmrelatesto/.style={-angle 45, draw, thick}}
146 \tikzset{opmbidirrelate/.style={left to-left to, draw, thick}}
147
148 %% the requires version allows for a more DSL like style
149 \tikzset{opminstrument/.style={-o, thick}}
150 \tikzset{opmrequires/.style={o-, thick}}
151
152 %% the handles version allows for a more DSL like style
153 \tikzset{opmagent/.style={-*, thick}}
154 \tikzset{opmhandles/.style={-*, thick}}
155
156 \tikzset{opminput/.style={-open triangle 45, thick}}
157
158 \tikzset{opmoutput/.style={-open triangle 45,thick}}
159
160 %% the consumes version allows for a more DSL like style
161 \tikzset{opmconsumption/.style={-open triangle 45, thick}}
162 \tikzset{opmconsumes/.style={open triangle 45-, thick}}
163
164 %% the yields version allows for a more DSL like style
165 \tikzset{opmresult/.style={-open triangle 45, thick}}
166 \tikzset{opmyields/.style={-open triangle 45, thick}}
167
168 %% the affects version allows for a more DSL like style
169 \tikzset{opmeffect/.style={open triangle 45-open triangle 45, thick}}
170 \tikzset{opmaffects/.style={open triangle 45-open triangle 45, thick}}
171
172 \pgfarrowsdeclarecombine*{twoopentriang}{twoopentriang}%
173 {open triangle 45}{open triangle 45}
174 {open triangle 45}{open triangle 45}
175 \tikzset{dbla/.style={postaction={draw,shorten >=-1pt, -open triangle 45}}}
176 %% the invkoes version allows for a more DSL like style
177 \tikzset{opminvocation/.style={-twoopentriang, thick}}
178 \tikzset{opminvokes/.style={-twoopentriang, thick}}