tikzkit.sty 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. %% Tikz-Styles for Palladio Component Model symbols
  2. %% by Erik Burger
  3. %%
  4. %% version 2010-12-13
  5. %%
  6. %% Problems, bugs and comments to
  7. %% burger@kit.edu
  8. \usepackage{tikz}
  9. \usetikzlibrary{positioning}
  10. \usetikzlibrary{arrows}
  11. \usetikzlibrary{fit}
  12. \usetikzlibrary{petri}
  13. \usetikzlibrary{decorations.markings}
  14. \usetikzlibrary{decorations.pathmorphing}
  15. \usetikzlibrary{decorations.text}
  16. \usetikzlibrary{fit}
  17. \usetikzlibrary{automata}
  18. \usetikzlibrary{shapes}
  19. \usetikzlibrary{shadows}
  20. \usetikzlibrary{calc}
  21. %% Vertikal geteilter Kreis
  22. \pgfdeclareshape{circle vertical split}
  23. {
  24. \inheritsavedanchors[from=circle]
  25. \inheritanchorborder[from=circle]
  26. \inheritanchor[from=circle]{north}
  27. \inheritanchor[from=circle]{north west}
  28. \inheritanchor[from=circle]{north east}
  29. \inheritanchor[from=circle]{center}
  30. \inheritanchor[from=circle]{west}
  31. \inheritanchor[from=circle]{east}
  32. \inheritanchor[from=circle]{mid}
  33. \inheritanchor[from=circle]{mid west}
  34. \inheritanchor[from=circle]{mid east}
  35. \inheritanchor[from=circle]{base}
  36. \inheritanchor[from=circle]{base west}
  37. \inheritanchor[from=circle]{base east}
  38. \inheritanchor[from=circle]{south}
  39. \inheritanchor[from=circle]{south west}
  40. \inheritanchor[from=circle]{south east}
  41. \inheritbackgroundpath[from=circle]
  42. \foregroundpath{
  43. \centerpoint%
  44. \pgf@xc=\pgf@x%
  45. \pgf@yc=\pgf@y%
  46. \pgfutil@tempdima=\radius%
  47. \pgfmathsetlength{\pgf@xb}{\pgfkeysvalueof{/pgf/outer xsep}}%
  48. \pgfmathsetlength{\pgf@yb}{\pgfkeysvalueof{/pgf/outer ysep}}%
  49. \ifdim\pgf@xb<\pgf@yb%
  50. \advance\pgfutil@tempdima by-\pgf@yb%
  51. \else%
  52. \advance\pgfutil@tempdima by-\pgf@xb%
  53. \fi%
  54. \advance\pgfutil@tempdima by-.5\pgflinewidth%
  55. \pgfsetshortenstart{0pt}%
  56. \pgfsetshortenend{0pt}%
  57. \pgfsetarrows{-}%
  58. \pgfpathmoveto{\pgfpointadd{\centerpoint}{\pgfqpoint{0pt}{-1\pgfutil@tempdima}}}%
  59. \pgfpathlineto{\pgfpointadd{\centerpoint}{\pgfqpoint{0pt}{\pgfutil@tempdima}}}%
  60. \pgfusepath{stroke}%
  61. }
  62. }
  63. \tikzset{
  64. %% Color Shadings
  65. blueshading/.style={shade, top color=white, bottom color=kit-blue30, draw=kit-blue100, thick},
  66. greyshading/.style={shade, top color=white, bottom color=black!30, draw=black!50, thick},
  67. lightgreyshading/.style={shade, top color=white, bottom color=black!15, draw=black!50, thick},
  68. blackshading/.style={shade, top color=black!50, bottom color=black!95, middle color=black!95, draw=black!95, thick},
  69. greenshading/.style={shade, top color=white, bottom color=kit-green30, draw=kit-green100, thick},
  70. redshading/.style={shade, top color=white, bottom color=kit-red30, draw=kit-red100, thick},
  71. yellowshading/.style={shade, top color=white, bottom color=kit-yellow30, draw=kit-orange100, thick},
  72. %% Boxes
  73. roundbox/.style={rectangle, rounded corners=.5ex},
  74. %% PCM Actions
  75. seffaction/.style={rectangle split, rectangle split parts=2, rectangle split part align={center}, text centered, rounded corners},
  76. pcmball/.style={shade, ball color=kit-blue100,circle,fill},
  77. startaction/.style={pcmball,minimum size=1ex},
  78. stopaction/.style={startaction,draw=black,double},
  79. %% Petri net/Queueing Petri net symbols
  80. pnplace/.style={circle, draw, minimum size=2em},
  81. pntrans/.style={rectangle, draw, minimum height=2em},
  82. qpnplace/.style={circle vertical split, draw, minimum size=2em},
  83. subnetplace/.style={qpnplace, double},
  84. }
  85. %% Baseline adaptation for PCM symbols
  86. \tikzstyle{pcm} = [baseline=-.2ex]
  87. %% Ragged left text for boxes
  88. \tikzoption{text badly
  89. raggedleft}[]{\def\tikz@text@action{\raggedleft\relax}}
  90. \tikzoption{text raggedleft}[]%
  91. {\def\tikz@text@action{\raggedleft\rightskip\z@ plus2em
  92. \spaceskip.3333em \xspaceskip.5em\relax}}
  93. %% Layers
  94. \pgfdeclarelayer{l1}
  95. \pgfdeclarelayer{l2}
  96. \pgfdeclarelayer{l3}
  97. \pgfdeclarelayer{l4}
  98. \pgfdeclarelayer{l5}
  99. \pgfdeclarelayer{l6}
  100. \pgfdeclarelayer{l7}
  101. \pgfdeclarelayer{l8}
  102. \pgfdeclarelayer{l9}
  103. \pgfsetlayers{main,l1,l2,l3,l4,l5,l6,l7,l8,l9}
  104. % Internal Action
  105. \newcommand{\pcmintaction}[2][]{
  106. \node[pcmball, minimum size=.7ex, text width=0ex, #1] (#2) {};
  107. \draw[thick] (#2.north) -- ([yshift=.5ex]#2.north);
  108. \draw[thick] (#2.south) -- ([yshift=-.5ex]#2.south);
  109. }
  110. \newcommand{\pcmextaction}[2][]{
  111. \node[pcmball, minimum size=.7ex, text width=0ex, #1] (#2) {};
  112. \draw[thick,<-] (#2.north) -- ([yshift=1ex]#2.north);
  113. \draw[thick,->] (#2.south) -- ([yshift=-.8ex]#2.south);
  114. \draw[ultra thick,->,color=red!70!black] (#2.east) -- ([xshift=1ex]#2.east);
  115. }
  116. \newcommand{\pcmloopaction}[2][]{
  117. \node[pcmball, minimum size=.7ex, text width=0ex, #1] (#2) {}
  118. edge [->, in=30, out=90, looseness=1, distance=2ex, thick] node {} (#2);
  119. }
  120. \newcommand{\pcmiterator}[2][]{
  121. \begin{scope}[decoration={
  122. markings, mark=at position .5 with {\arrow[red, line width=.2ex]{>}}}, #1]
  123. \node[matrix,draw=black!75, row sep=.3ex, inner sep=.3ex] (#2) {
  124. \draw[red,thick] (0,0) -- (.7ex,0);\\
  125. \draw[red,thick] (0,0) -- (.7ex,0);\\
  126. \draw[red,thick] (0,0) -- (.7ex,0);\\ };
  127. \draw [thick,black!75,postaction=decorate]
  128. (#2.south) .. controls (0,-1.5ex) and (1.4ex,-1.5ex) ..
  129. (1.4ex,0) .. controls (1.4ex,1.5ex) and (0,1.5ex) .. (#2.north);
  130. \end{scope}
  131. }
  132. \newcommand{\pcmbranch}[2][]{
  133. {\pgfsetcornersarced{\pgfpointorigin}
  134. \scriptsize
  135. \node[diamond, shade, ball color=kit-blue100, inner sep=.1ex, text width=1.2ex, #1] (#2) {\color{white}\scriptsize\textbf?};
  136. \draw[thick] (#2.north) -- ([yshift=.8ex]#2.north);
  137. \draw[thick] (#2.south west) -- ([xshift=-.7ex,yshift=-.7ex]#2.south west);
  138. \draw[thick] (#2.south east) -- ([xshift=.7ex, yshift=-.7ex]#2.south east);
  139. }
  140. }
  141. \newcommand{\pcmfork}{
  142. \begin{scope}[very thick,black!75]
  143. \draw (0,0) -- (0,.4em) -- (1em,.4em) -- (1em,0em);
  144. \draw (.33em,.4em) -- (.33em,0em);
  145. \draw (.66em,.4em) -- (.66em,0em);
  146. \draw (.5em,1em) -- (.5em,.4em);
  147. \draw (.2em,.75em) -- (.5em,.45em) -- (.8em,.75em);
  148. \end{scope}
  149. }
  150. \newcommand{\pcmnote}{
  151. {\pgfsetcornersarced{\pgfpointorigin}
  152. \path[draw, black!75, thick, shade, top color=white, bottom color=yellow] (0,0) -- (2ex,0) -- (2ex,1ex) -- (1.5ex,1.5ex) -- (0,1.5ex) -- cycle;
  153. \draw[black!75, thick] (2ex,1ex) -- (1.5ex,1ex) -- (1.5ex,1.5ex);
  154. }
  155. }
  156. \newcommand{\pcmstart}[2][]{
  157. \node[startaction, text width=0cm, #1] (#2) {};
  158. }
  159. \newcommand{\pcmstop}[2][]{
  160. \node[stopaction, text width=0cm, #1] (#2) {};
  161. }
  162. \newcommand{\pcmsetvar}[2][]{
  163. \node[rectangle,draw=gray,ultra thick,dashed,#1] (#2) {\$x};
  164. }
  165. \newcommand{\pcmacq}{
  166. \begin{scope}[every token/.style={color=kit-blue100,minimum size=.2ex}]
  167. \node[place, minimum size=1em,shade,
  168. bottom color=kit-blue30,top color=white,shading angle=30] {}
  169. [children are tokens, token distance=.4ex]
  170. child {node [token] {}}
  171. child {node [token] {}}
  172. child {node (inlier) [token] {}}
  173. child {node [token] {}}
  174. child {node [token] {}}
  175. child {node [token] {}}
  176. child {node [token] {}};
  177. \node[token] (outlier) at (.6em,.6em) {};
  178. \draw[->, red, very thick] (inlier) -- (outlier);
  179. \end{scope}
  180. }
  181. \newcommand{\pcmrel}{
  182. \begin{scope}[every token/.style={color=kit-blue100,minimum size=.2ex}]
  183. \node[place, minimum size=1em,shade,
  184. bottom color=kit-blue30,top color=white,shading angle=30] {}
  185. [children are tokens, token distance=.4ex]
  186. child {node [token] {}}
  187. child {node [token] {}}
  188. child {node (inlier) [token] {}}
  189. child {node [token] {}}
  190. child {node [token] {}}
  191. child {node [token] {}}
  192. child {node [token] {}};
  193. \node[token] (outlier) at (.6em,.6em) {};
  194. \draw[<-, red, very thick] (inlier) -- (outlier);
  195. \end{scope}
  196. }
  197. \newcommand{\pcmdice}{
  198. \tikzset{point/.style={circle,fill=black,minimum size=.4ex,inner sep=0pt}}
  199. \begin{scope}[every node/.append style={yslant=-0.5},yslant=-0.5]
  200. \shade[right color=white, left color=kit-blue30, draw=black,
  201. rounded corners=.1ex] (0,0) rectangle +(1em,1em);
  202. \node [point] at (.25em,.25em) {};
  203. \node [point] at (.25em,.75em) {};
  204. \node [point] at (.5em,.5em) {};
  205. \node [point] at (.75em,.25em) {};
  206. \node [point] at (.75em,.75em) {};
  207. \end{scope}
  208. \begin{scope}[every node/.append style={yslant=0.5},yslant=0.5]
  209. \shade[left color=white, right color=kit-blue30, draw=black,
  210. rounded corners=.1ex] (1em,-1em) rectangle +(1em,1em);
  211. \node [point] at (1.25em,-.25em) {};
  212. \node [point] at (1.25em,-.75em) {};
  213. \node [point] at (1.75em,-.25em) {};
  214. \node [point] at (1.75em,-.75em) {};
  215. \end{scope}
  216. \begin{scope}[every node/.append style={
  217. yslant=0.5,xslant=-1},yslant=0.5,xslant=-1
  218. ]
  219. \shade[bottom color=white, top color=kit-blue30, draw=black,
  220. rounded corners=.1ex] (2em,1em) rectangle +(-1em,-1em);
  221. \node [point] at (1.25em,.25em) {};
  222. \node [point] at (1.25em,.75em) {};
  223. \node [point] at (1.5em,.25em) {};
  224. \node [point] at (1.5em,.75em) {};
  225. \node [point] at (1.75em,.25em) {};
  226. \node [point] at (1.75em,.75em) {};
  227. \end{scope}
  228. \draw[thick, color=black] (.5em,-.25em) -- +(-.7ex,-.7ex);
  229. \draw[thick, color=black] (1.5em,-.25em) -- +(.7ex,-.7ex);
  230. }
  231. \newcommand{\pcmcertsign}{
  232. \begin{scope}[rotate=30]
  233. \node [draw, red, thick, circle, rotate=30] (certified) at (0,0) {\scriptsize CERTIFIED};
  234. \draw [red, thick] (.67,.2) arc (16.6:163.4:7mm) -- cycle;
  235. \draw [red, thick] (-.67,-.2) arc (196.6:343.4:7mm) -- cycle;
  236. \end{scope}
  237. }
  238. % #1 = Formatierung
  239. % #2 = Name des Nodes
  240. % #3 = Position
  241. \newcommand{\pcmcomponentsymbol}[3]{
  242. \node[rectangle, minimum width=1.2em, minimum height=1.2em, #1]
  243. (#2) #3 {};
  244. \filldraw[#1]
  245. ($(#2)+(-1em,.1em)$) rectangle +(.7em,.3em)
  246. ($(#2)+(-1em,-.1em)$) rectangle +(.7em,-.3em);
  247. }
  248. % #1 = Formatierung
  249. % #2 = Name des Nodes
  250. % #3 = Text
  251. % #4 = oberer Layer
  252. % #5 = unterer Layer
  253. % #6 = Position
  254. \newcommand{\pcmcomponentbodyonlayers}[6]{
  255. \begin{pgfonlayer}{#4}
  256. \node[minimum width=4em] (#2text) #6 {\small #3};
  257. \pcmcomponentsymbol{fill=white, draw=black}{#2componentsymbol}{at ($(#2text.east)+(-1em,1.5em)$)}
  258. \end{pgfonlayer}
  259. \begin{pgfonlayer}{#5}
  260. \node[draw=black, rectangle, inner sep = .2em, #1] (#2) [fit=(#2text) (#2componentsymbol)] {};
  261. \end{pgfonlayer}
  262. }
  263. % #1 = Formatierung
  264. % #2 = Name des Nodes
  265. % #3 = Text
  266. % #4 = Position
  267. \newcommand{\pcmcomponentbody}[4]{
  268. \pcmcomponentbodyonlayers{#1}{#2}{#3}{l4}{l3}{#4}
  269. }
  270. % #1 = Formatierung
  271. % #2 = Name des Nodes
  272. % #3 = Position
  273. \newcommand{\pcmlolliwest}[3]{
  274. \node[circle, minimum size=1ex, draw, anchor=east, xshift=-1em, #1] (#2) at #3 {};
  275. \draw[#1] #3 -- (#2);
  276. }
  277. % #1 = Formatierung
  278. % #2 = Name des Nodes
  279. % #3 = Position
  280. \newcommand{\pcmarceast}[3]{
  281. \node[xshift=1em] (#2) at #3 {};
  282. \draw[#1] #3 -- (#2.center);
  283. \draw[#1, fill opacity=transparent] ($(#2)+(1.4ex,1.4ex)$) arc (90:270:1.4ex);
  284. }
  285. % #1 = Formatierung
  286. % #2 = Name des Nodes
  287. % #3 = Text
  288. % #4 = oberer Layer
  289. % #5 = unterer Layer
  290. % #6 = Position
  291. \newcommand{\pcmcomponentonlayers}[6]{
  292. \pcmcomponentbodyonlayers{#1}{#2}{#3}{#4}{#5}{#6}
  293. \begin{pgfonlayer}{#5}
  294. \pcmlolliwest{#1}{#2lolli}{(#2.west)}
  295. \pcmarceast{#1}{#2arc}{(#2.east)}
  296. \end{pgfonlayer}
  297. }
  298. % #1 = Formatierung
  299. % #2 = Name des Nodes
  300. % #3 = Text
  301. % #4 = Position
  302. \newcommand{\pcmcomponent}[4]{
  303. \pcmcomponentonlayers{#1}{#2}{#3}{l4}{l3}{#4}
  304. }
  305. % Extrudieren von rechteckigen Shapes
  306. %
  307. % #1 = Name des Nodes
  308. % #2 = Abstand
  309. % #3 = Zeichenoptionen
  310. \newcommand{\pcmextrude}[3]{
  311. \path[#3] (#1.north west) -- (#1.north east) -- (#1.south east) -- (#1.south west) -- (#1.north west) -- ++(#2,#2) -- ($(#1.north east)+(#2,#2)$) -- ($(#1.south east)+(#2,#2)$) -- (#1.south east) (#1.north east) -- ($(#1.north east)+(#2,#2)$);
  312. }
  313. % Dummy-Bild
  314. \newcommand{\dummypic}[2]{
  315. \tikz \draw[kit-red100] (0,0) -- (#1,0) -- (#1,#2) -- (0,#2) -- (0,0) -- (#1,#2) (0,#2) -- (#1,0);
  316. }