summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/circuitikz/pgfcirclabel.sty
blob: 436bd9416663049b3ac3611514a12cddcea63940 (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
% Copyright 2007-2009 by Massimo Redaelli
%
% 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/LICENSE for more details.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Bipole label positioning

%% Options
\tikzset{label/.style = { l=#1 } }
\tikzset{l/.code = { 
	\pgfkeys{/tikz/circuitikz/bipole/label/name=#1}
	\ctikzsetvalof{bipole/label/unit}{}
	\ifpgf@circ@siunitx 
		\pgf@circ@handleSI{#1}
		\ifpgf@circ@siunitx@res 
			\edef\pgf@temp{\pgf@circ@handleSI@val}
			\pgfkeyslet{/tikz/circuitikz/bipole/label/name}{\pgf@temp}
			\edef\pgf@temp{\pgf@circ@handleSI@unit}
			\pgfkeyslet{/tikz/circuitikz/bipole/label/unit}{\pgf@temp}
		\else
		\fi
	\else
	\fi
}}

\tikzset{label above/.code = { 
	l=#1, 
	\circuitikzbasekey/bipole/label/position=90 }
}
\tikzset{l^/.style = { 
	l=#1,
	\circuitikzbasekey/bipole/label/position=90 } 
}

\tikzset{label below/.code = { 
	l=#1,
	\circuitikzbasekey/bipole/label/position=-90 } 
}
\tikzset{l_/.style = { 
	l=#1,
	\circuitikzbasekey/bipole/label/position=-90 } 
}

%% Output routing
%% #1 - node name

\def\pgf@circ@drawlabel{
	\pgfextra{
		\def\pgf@circ@temp{\ctikzvalof{bipole/label/position}}
		\edef\pgf@circ@ffffff{\pgf@circ@direction}
		\def\pgfcircmathresult{\expandafter\pgf@circ@stripdecimals\pgf@circ@ffffff\pgf@nil}

		\ifnum\pgfcircmathresult >4 \ifnum\pgfcircmathresult <86
			\ifnum\pgf@circ@temp>0
				\def\pgf@circ@dir{south east} \else \def\pgf@circ@dir{north west}
			\fi
		\fi\fi
		\ifnum\pgfcircmathresult >85 \ifnum\pgfcircmathresult <95
			\ifnum\pgf@circ@temp>0
				\def\pgf@circ@dir{east} \else \def\pgf@circ@dir{west}
			\fi
		\fi\fi
		\ifnum\pgfcircmathresult >94 \ifnum\pgfcircmathresult <176
			\ifnum\pgf@circ@temp>0
				\def\pgf@circ@dir{north east} \else \def\pgf@circ@dir{south west}
			\fi
		\fi\fi
		\ifnum\pgfcircmathresult >175 \ifnum\pgfcircmathresult <185
			\ifnum\pgf@circ@temp>0
				\def\pgf@circ@dir{north} \else \def\pgf@circ@dir{south}
			\fi
		\fi\fi
		\ifnum\pgfcircmathresult >184 \ifnum\pgfcircmathresult <256
			\ifnum\pgf@circ@temp>0
				\def\pgf@circ@dir{north west}\else \def\pgf@circ@dir{south east}
			\fi
		\fi\fi
		\ifnum\pgfcircmathresult >265 \ifnum\pgfcircmathresult <275
			\ifnum\pgf@circ@temp>0
				\def\pgf@circ@dir{west} \else \def\pgf@circ@dir{east}
			\fi
		\fi\fi
		\ifnum\pgfcircmathresult >284 \ifnum\pgfcircmathresult <356
			\ifnum\pgf@circ@temp>0
				\def\pgf@circ@dir{south west} \else \def\pgf@circ@dir{north east}
			\fi
		\fi\fi
		\ifnum\pgfcircmathresult <5
			\ifnum\pgf@circ@temp>0
				\def\pgf@circ@dir{south} \else \def\pgf@circ@dir{north}
			\fi
		\fi
		\ifnum\pgfcircmathresult >355
			\ifnum\pgf@circ@temp>0
				\def\pgf@circ@dir{south} \else \def\pgf@circ@dir{north}
			\fi
		\fi
	}
	node [anchor=\pgf@circ@dir] at (\ctikzvalof{bipole/name}.\pgf@circ@temp) { 
 		\pgf@circ@finallabel{}
	}
}

\endinput