diff options
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryautomata.code.tex')
-rw-r--r-- | Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryautomata.code.tex | 189 |
1 files changed, 189 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryautomata.code.tex b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryautomata.code.tex new file mode 100644 index 00000000000..be801d0a7df --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryautomata.code.tex @@ -0,0 +1,189 @@ +\ProvidesPackageRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/pgflibraryautomata.code.tex,v 1.1 2005/10/13 10:12:31 tantau Exp $ + +% Copyright 2005 by Till Tantau <tantau@cs.tu-berlin.de>. +% +% This program can be redistributed and/or modified under the terms +% of the GNU Public License, version 2. + +\newbox\pgfnodepartoutputbox + + + +% +% Node for states without output. This is just an alias for a circle +% node. +% +\pgfdeclareshape{state} +{ + \inheritsavedanchors[from=circle] % this is a circle + \inheritanchorborder[from=circle] + \inheritanchor[from=circle]{north} + \inheritanchor[from=circle]{north west} + \inheritanchor[from=circle]{north east} + \inheritanchor[from=circle]{center} + \inheritanchor[from=circle]{west} + \inheritanchor[from=circle]{east} + \inheritanchor[from=circle]{mid} + \inheritanchor[from=circle]{mid west} + \inheritanchor[from=circle]{mid east} + \inheritanchor[from=circle]{base} + \inheritanchor[from=circle]{base west} + \inheritanchor[from=circle]{base east} + \inheritanchor[from=circle]{south} + \inheritanchor[from=circle]{south west} + \inheritanchor[from=circle]{south east} + \inheritbackgroundpath[from=circle] +} + + +% +% Moore state node (a state with output). +% +% This node consists of two parts: The main part is the state +% name. The second part is the (optional) state output. This output is +% shown in the lower half of the node. +% +% Parts: text (=state name), output + +\pgfdeclareshape{state with output} +{ + % + % Node parts + % + \nodeparts{text,output} + + % + % Anchors + % + \savedanchor\centerpoint{% + \pgf@x=.5\wd\pgfnodeparttextbox% + \setlength{\pgf@y}{\pgfshapeinnerysep}% + \pgf@y=-\pgf@y% + \advance\pgf@y by-\dp\pgfnodeparttextbox% + \advance\pgf@y by-.5\pgflinewidth% + }% + \savedanchor\outputanchor{% + \pgf@x=-.5\wd\pgfnodepartoutputbox% + \advance\pgf@x by.5\wd\pgfnodeparttextbox% + \setlength{\pgf@y}{\pgfshapeinnerysep}% + \pgf@y=-2\pgf@y% + \advance\pgf@y by-\ht\pgfnodepartoutputbox% + \advance\pgf@y by-.5\pgflinewidth% + \advance\pgf@y by-\dp\pgfnodeparttextbox% + \advance\pgf@y by-.5\pgflinewidth% + } + + \saveddimen\radius{% + % + % Caculate ``height radius'' + % + \pgf@ya=.5\ht\pgfnodeparttextbox% + \advance\pgf@ya by.5\dp\pgfnodeparttextbox% + \advance\pgf@ya by.5\ht\pgfnodepartoutputbox% + \advance\pgf@ya by.5\dp\pgfnodepartoutputbox% + \advance\pgf@ya by.5\pgflinewidth% + \setlength\pgf@yb{\pgfshapeinnerysep}% + \advance\pgf@ya by2\pgf@yb% + % + % Caculate ``width radius'' + % + \pgf@xa=.5\wd\pgfnodeparttextbox% + \ifdim\pgf@xa<.5\wd\pgfnodepartoutputbox% + \pgf@xa=.5\wd\pgfnodepartoutputbox% + \fi% + \setlength\pgf@xb{\pgfshapeinnerxsep}% + \advance\pgf@xa by\pgf@xb% + % + % Calculate length of radius vector: + % + \pgf@process{\pgfpointnormalised{\pgfpoint{\pgf@xa}{\pgf@ya}}}% + \ifdim\pgf@x>\pgf@y% + \c@pgf@counta=\pgf@x% + \ifnum\c@pgf@counta=0\relax% + \else% + \divide\c@pgf@counta by 255\relax% + \pgf@xa=16\pgf@xa\relax% + \divide\pgf@xa by\c@pgf@counta% + \pgf@xa=16\pgf@xa\relax% + \fi% + \else% + \c@pgf@counta=\pgf@y% + \ifnum\c@pgf@counta=0\relax% + \else% + \divide\c@pgf@counta by 255\relax% + \pgf@ya=16\pgf@ya\relax% + \divide\pgf@ya by\c@pgf@counta% + \pgf@xa=16\pgf@ya\relax% + \fi% + \fi% + \pgf@x=\pgf@xa% + % + % If necessary, adjust radius so that the size requirements are + % met: + % + \setlength{\pgf@xb}{\pgfshapeminwidth}% + \setlength{\pgf@yb}{\pgfshapeminheight}% + \ifdim\pgf@x<.5\pgf@xb% + \pgf@x=.5\pgf@xb% + \fi% + \ifdim\pgf@x<.5\pgf@yb% + \pgf@x=.5\pgf@yb% + \fi% + % + % Now, add larger of outer sepearations. + % + \setlength{\pgf@xb}{\pgfshapeouterxsep}% + \setlength{\pgf@yb}{\pgfshapeouterysep}% + \ifdim\pgf@xb<\pgf@yb% + \advance\pgf@x by\pgf@yb% + \else% + \advance\pgf@x by\pgf@xb% + \fi% + } + + % + % Anchors + % + \inheritanchorborder[from=circle] + \inheritanchor[from=circle]{north} + \inheritanchor[from=circle]{north west} + \inheritanchor[from=circle]{north east} + \inheritanchor[from=circle]{center} + \inheritanchor[from=circle]{west} + \inheritanchor[from=circle]{east} + \inheritanchor[from=circle]{mid} + \inheritanchor[from=circle]{mid west} + \inheritanchor[from=circle]{mid east} + \inheritanchor[from=circle]{base} + \inheritanchor[from=circle]{base west} + \inheritanchor[from=circle]{base east} + \inheritanchor[from=circle]{south} + \inheritanchor[from=circle]{south west} + \inheritanchor[from=circle]{south east} + \anchor{output}{\outputanchor} + + % + % Background path + % + \inheritbackgroundpath[from=circle] + \beforebackgroundpath{ + \@tempdima=\radius% + \setlength{\pgf@xb}{\pgfshapeouterxsep}% + \setlength{\pgf@yb}{\pgfshapeouterysep}% + \ifdim\pgf@xb<\pgf@yb% + \advance\@tempdima by-\pgf@yb% + \else% + \advance\@tempdima by-\pgf@xb% + \fi% + \advance\@tempdima by-.5\pgflinewidth% + \pgfsetarrows{-}% + \pgfpathmoveto{\pgfpointadd{\centerpoint}{\pgfpoint{-\@tempdima}{0pt}}}% + \pgfpathlineto{\pgfpointadd{\centerpoint}{\pgfpoint{\@tempdima}{0pt}}}% + \pgfusepath{stroke}% + } +} + + + + +\endinput |