summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pgf/libraries/pgflibraryshapes.multipart.code.tex
blob: 2299d9520c80f52e26bd2305a004e91b05501d38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
% Copyright 2006 by Till Tantau
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.
%
% See the file doc/generic/pgf/licenses/LICENSE for more details.

\ProvidesFileRCS[v\pgfversion] $Header: /cvsroot/pgf/pgf/generic/pgf/libraries/pgflibraryshapes.multipart.code.tex,v 1.1 2007/06/08 11:24:59 tantau Exp $

\newbox\pgfnodepartlowerbox

%
% A circle that is split in the middle into an upper and a lower part.
%
% This node consists of two parts: The upper (main) part is shown in
% the upper half of the circle. The second part is the (optional)
% lower part.
%
% Parts: text, lower

\pgfdeclareshape{circle split}
{
  %
  % Node parts
  %
  \nodeparts{text,lower}

  %
  % Anchors
  %
  \savedanchor\centerpoint{%
    \pgf@x=.5\wd\pgfnodeparttextbox%
    \pgfmathsetlength{\pgf@y}{\pgfshapeinnerysep}%
    \pgf@y=-\pgf@y%
    \advance\pgf@y by-\dp\pgfnodeparttextbox%
    \advance\pgf@y by-.5\pgflinewidth%
  }%
  \savedanchor\loweranchor{%
    \pgf@x=-.5\wd\pgfnodepartlowerbox%
    \advance\pgf@x by.5\wd\pgfnodeparttextbox%
    \pgfmathsetlength{\pgf@y}{\pgfshapeinnerysep}%
    \pgf@y=-2\pgf@y%
    \advance\pgf@y by-\ht\pgfnodepartlowerbox%
    \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\pgfnodepartlowerbox%
    \advance\pgf@ya by.5\dp\pgfnodepartlowerbox%
    \advance\pgf@ya by.5\pgflinewidth%
    \pgfmathsetlength\pgf@yb{\pgfshapeinnerysep}%
    \advance\pgf@ya by2\pgf@yb%
    % 
    % Caculate ``width radius''
    % 
    \pgf@xa=.5\wd\pgfnodeparttextbox%
    \ifdim\pgf@xa<.5\wd\pgfnodepartlowerbox%
      \pgf@xa=.5\wd\pgfnodepartlowerbox%
    \fi%
    \pgfmathsetlength\pgf@xb{\pgfshapeinnerxsep}%
    \advance\pgf@xa by\pgf@xb%
    % 
    % Calculate length of radius vector:
    % 
    \pgf@process{\pgfpointnormalised{\pgfqpoint{\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: 
    % 
    \pgfmathsetlength{\pgf@xb}{\pgfshapeminwidth}%  
    \pgfmathsetlength{\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.
    % 
    \pgfmathsetlength{\pgf@xb}{\pgfshapeouterxsep}%  
    \pgfmathsetlength{\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{lower}{\loweranchor}

  %
  % Background path
  %
  \inheritbackgroundpath[from=circle]
  \beforebackgroundpath{
    \pgfutil@tempdima=\radius%
    \pgfmathsetlength{\pgf@xb}{\pgfshapeouterxsep}%  
    \pgfmathsetlength{\pgf@yb}{\pgfshapeouterysep}%  
    \ifdim\pgf@xb<\pgf@yb%
      \advance\pgfutil@tempdima by-\pgf@yb%
    \else%
      \advance\pgfutil@tempdima by-\pgf@xb%
    \fi%
    \advance\pgfutil@tempdima by-.5\pgflinewidth%  
    \pgfsetshortenstart{0pt}%
    \pgfsetshortenend{0pt}%
    \pgfsetarrows{-}%  
    \pgfpathmoveto{\pgfpointadd{\centerpoint}{\pgfqpoint{-1\pgfutil@tempdima}{0pt}}}%
    \pgfpathlineto{\pgfpointadd{\centerpoint}{\pgfqpoint{\pgfutil@tempdima}{0pt}}}%
    \pgfusepath{stroke}%
  }
}



\endinput