diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/circuitikz/pgfcirclabel.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/circuitikz/pgfcirclabel.sty | 123 |
1 files changed, 70 insertions, 53 deletions
diff --git a/Master/texmf-dist/tex/latex/circuitikz/pgfcirclabel.sty b/Master/texmf-dist/tex/latex/circuitikz/pgfcirclabel.sty index 8ce4a72d9a3..120fa7f8cb3 100644 --- a/Master/texmf-dist/tex/latex/circuitikz/pgfcirclabel.sty +++ b/Master/texmf-dist/tex/latex/circuitikz/pgfcirclabel.sty @@ -46,69 +46,86 @@ \circuitikzbasekey/bipole/label/position=-90 } } + + +\def\pgf@circ@drawlabel{ + \pgfextra{ + \edef\pgf@temp{\ctikzvalof{label/align}} + \def\pgf@circ@temp{straight} + } + \ifx\pgf@temp\pgf@circ@temp %straight + \pgf@circ@drawreglabel + \else + \pgfextra{\def\pgf@circ@temp{rotate}} + \ifx\pgf@temp\pgf@circ@temp %rotate + \pgf@circ@drawrotlabel + \else % smart + \pgf@circ@drawsmartlabel + \fi + \fi +} + +\def\pgf@circ@drawsmartlabel{ + \pgfextra{ + %\pgfmathadd{\pgf@circ@direction}{360} + \pgfmathmod{\pgf@circ@direction}{90} + \edef\pgfcircmathresult{\expandafter\pgf@circ@stripdecimals\pgfmathresult\pgf@nil} + } + \ifnum \pgfcircmathresult > 20 + \ifnum \pgfcircmathresult < 70 % NON quasi retto + \pgf@circ@drawrotlabel + \else + \pgf@circ@drawreglabel + \fi + \else + \pgf@circ@drawreglabel + \fi +} + %% Output routing %% #1 - node name -\def\pgf@circ@drawlabel{ +\def\pgf@circ@drawrotlabel{ \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} + % calcolo rotazione label + \def\pgf@circ@temp{\ctikzvalof{bipole/label/position}} %%% àncora label + \edef\pgfcirclabrot{\pgf@circ@direction} % primo e quarto quadrante + \edef\pgfcircmathresult{\expandafter\pgf@circ@stripdecimals\pgf@circ@direction\pgf@nil} + \ifnum \pgfcircmathresult > 90 \ifnum \pgfcircmathresult < 270 % terzo e secondo + \pgfmathsubtract{\pgf@circ@direction}{180} + \edef\pgfcirclabrot{\expandafter\pgf@circ@stripdecimals\pgfmathresult\pgf@nil} + \pgfmathadd{\pgf@circ@temp}{180} %%% + \edef\pgf@circ@temp{\expandafter\pgf@circ@stripdecimals\pgfmathresult\pgf@nil} %%% + \fi\fi - \ifnum \ctikzvalof{mirror value}=-1 - \pgfmathadd{\pgfcircmathresult}{+180} - \def\pgfcircmathresult{\expandafter\pgf@circ@stripdecimals\pgfmathresult\pgf@nil} + \ifnum \ctikzvalof{mirror value} = -1 + \pgfmathadd{\pgf@circ@temp}{180} + \edef\pgf@circ@temp{\expandafter\pgf@circ@stripdecimals\pgfmathresult\pgf@nil} \fi + } + coordinate (labelcoor) at ($(\ctikzvalof{bipole/name})!2!(\ctikzvalof{bipole/name}.north)$) + (labelcoor) node [transform shape, rotate=\pgfcirclabrot] {\pgf@circ@finallabel{}} +} + +\def\pgf@circ@drawreglabel{ + \pgfextra{ + \pgfmathsubtract{\pgf@circ@direction}{90} + \edef\pgf@circ@labanc{\expandafter\pgf@circ@stripdecimals\pgfmathresult\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 + \edef\pgf@circ@temp{\ctikzvalof{bipole/label/position}} %%% àncora label + \ifnum \pgf@circ@temp < 0 + \pgfmathadd{\pgf@circ@labanc}{180} + \edef\pgf@circ@labanc{\expandafter\pgf@circ@stripdecimals\pgfmathresult\pgf@nil} \fi - \ifnum\pgfcircmathresult >355 - \ifnum\pgf@circ@temp>0 - \def\pgf@circ@dir{south} \else \def\pgf@circ@dir{north} - \fi + + \ifnum \ctikzvalof{mirror value} = -1 + \pgfmathadd{\pgf@circ@labanc}{180} + \edef\pgf@circ@labanc{\expandafter\pgf@circ@stripdecimals\pgfmathresult\pgf@nil} \fi } - node [anchor=\pgf@circ@dir] at (\ctikzvalof{bipole/name}.\pgf@circ@temp) { - \pgf@circ@finallabel{} - } + node [ anchor = \pgf@circ@labanc] + at (\ctikzvalof{bipole/name}.\pgf@circ@temp) {\pgf@circ@finallabel{}} } + \endinput |