Skip to content

Commit

Permalink
current label now independent of regular label at current sources; co…
Browse files Browse the repository at this point in the history
…de cleanup at current label drawing
  • Loading branch information
sistlind committed Apr 22, 2017
1 parent ad8c384 commit 6524f22
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 72 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The major changes among the different circuitikz versions are listed here. See <
- Reworked arrows at spst-switches
- Fixed direction of controlled american voltage source
- "v<=" and "i<=" do not rotate the sources anymore(see them as "counting direction indication", this can be different then the shape orientation); Use the option "invert" to change the direction of the source/apperance of the shape.
- current label "i=" can now be used independent of the regular label "l=" at current sources

* Version 0.8.1 (2017-03-25)
- Fixed unwanted line through components if target coordinate is a name of a node
Expand Down
3 changes: 2 additions & 1 deletion doc/circuitikzmanual.tex
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ \subsection{Loading the package}

\subsection{Requirements}
\begin{itemize}
\item \texttt{tikz}, version $\ge 2$;
\item \texttt{tikz}, version $\ge 3$;
\item \texttt{xstring}, not older than 2009/03/13;
\item \texttt{siunitx}, if using \texttt{siunitx} option.
\end{itemize}
Expand All @@ -147,6 +147,7 @@ \section{Incompabilities between version}
Here, we will provide a list of incompabilitys between different version of circuitikz. We will try to hold this list short, but sometimes it is easier to break with old syntax than including a lot of switches and compatibility layers.
You can check the used version at your local installation using the macro \verb!\pgfcircversion{}!.
\begin{itemize}
\item Since v0.8.2: voltage and current label directions(v<= / i<=) do NOT change the orientation of the drawn source shape anymore. Use the "invert" option to rotate the shape of the source. Furthermore, from this version on, the current label(i=) at current sources can be used independent of the regular label(l=).
\item Since v0.7?: The label behaviour at mirrored bipoles has changes, this fixes the voltage drawing, but perhaps you have to adjust your label positions.
\item Since v0.5.1: The parts pfet,pigfete,pigfetebulk and pigfetd are now mirrored by default. Please adjust your yscale-option to correct this.
\item Since v0.5: New voltage counting direction, here exists an option to use the old behaviour
Expand Down
2 changes: 1 addition & 1 deletion tex/circuitikz.sty
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
\ProvidesPackage{circuitikz}%
[\pgfcircversiondate{} The CircuiTikz circuit drawing package version \pgfcircversion]

%% Version 2.0 of pgf/TikZ is required
%% Version 3.0 of pgf/TikZ is required
\RequirePackage{tikz}
\usetikzlibrary{calc}
\usepgflibrary{arrows}
Expand Down
89 changes: 19 additions & 70 deletions tex/pgfcirccurrent.tex
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
%% Current handling

%% Options


\ctikzset{i^>/.style = {
i = #1,
\circuitikzbasekey/bipole/current/direction = forward,
Expand Down Expand Up @@ -78,12 +76,7 @@
}

\ctikzset{i/.code = {
% \ifpgf@circuit@bipole@iscurrent
% \pgfkeys{\circuitikzbasekey/bipole/current/position=above}
% \else
% \pgfkeys{\circuitikzbasekey/bipole/current/position=below}
% \fi
\pgfkeys{\circuitikzbasekey/bipole/current/direction = forward,
\pgfkeys{\circuitikzbasekey/bipole/current/direction = forward,
\circuitikzbasekey/bipole/current/x position = after,
\circuitikzbasekey/bipole/current/y position = above }
\pgfkeys{/tikz/circuitikz/bipole/current/label/name=#1}
Expand Down Expand Up @@ -124,38 +117,7 @@
\ctikzset{i>/.style = {i = #1, \circuitikzbasekey/bipole/current/direction = forward } }
\ctikzset{i^/.style = { i= #1, \circuitikzbasekey/bipole/current/y position = above } }


\def\pgf@circ@drawnormalcurrent{
\ifpgf@circuit@bipole@current@before
\ifpgf@circuit@bipole@current@backward
{ (anchorstartnode) --
node [currarrow, pos=\ctikzvalof{current/distance}, sloped, allow upside down] (Iarrow) {}
(\tikztostart)
}
\else
{ (\tikztostart) --
node [currarrow, pos=\ctikzvalof{current/distance}, sloped, allow upside down] (Iarrow) {}
(anchorstartnode)
}
\fi
\else
\ifpgf@circuit@bipole@current@backward
{ (\tikztotarget) --
node [currarrow, pos=\ctikzvalof{current/distance}, sloped, allow upside down] (Iarrow) {}
(anchorendnode)
}
\else
{ (anchorendnode) --
node [currarrow, pos=\ctikzvalof{current/distance}, sloped, allow upside down] (Iarrow) {}
(\tikztotarget)
}
\fi
\fi
}

%% Output routine
%% #1 - node name

\def\pgf@circ@drawcurrent{
\pgfextra{
\edef\pgf@circ@ffffff{\pgf@circ@direction}
Expand Down Expand Up @@ -213,44 +175,31 @@
\def\pgf@circ@bipole@current@label@where{+90}
\fi
}


\pgfextra{ \def\pgf@temp{short} \edef\pgf@circ@temp{\ctikzvalof{bipole/kind}} }

\ifx\pgf@circ@temp\pgf@temp % caso di corrente (centrata) su un corto
\pgfextra{\def\pgf@temp{short}\edef\pgf@circ@temp{\ctikzvalof{bipole/kind}}}
\ifx\pgf@circ@temp\pgf@temp%draw current at a short at middle of the line
\ifpgf@circuit@bipole@current@backward
{ (\tikztotarget) --
node [currarrow, pos=\ctikzvalof{current/distance}, sloped, allow upside down] (Iarrow) {}
(\tikztostart) }
(\tikztotarget)--(\tikztostart)
\else
{ (\tikztostart) --
node [currarrow, pos=\ctikzvalof{current/distance}, sloped, allow upside down] (Iarrow) {}
(\tikztotarget) }
(\tikztostart)--(\tikztotarget)
\fi

\else % altri bipoli - e quindi tra nodo e target

\ifpgf@circuit@bipole@iscurrent
\ifpgf@circuit@europeancurrent
\pgf@circ@drawnormalcurrent
\else
\else% normal bipole or source
\ifpgf@circuit@bipole@current@before
\ifpgf@circuit@bipole@current@backward
(anchorstartnode)--(\tikztostart)
\else
(\tikztostart)--(anchorstartnode)
\fi
\else
\pgf@circ@drawnormalcurrent
\ifpgf@circuit@bipole@current@backward
(\tikztotarget)--(anchorendnode)
\else
(anchorendnode)--(\tikztotarget)
\fi
\fi
\fi

\ifpgf@circuit@bipole@iscurrent
node [anchor=\pgf@circ@dir] at (\ctikzvalof{bipole/name}.\pgf@circ@bipole@current@label@where)
{ \pgf@circ@finallabels{current/label} }
\else
(Iarrow.\pgf@circ@bipole@current@label@where) node [anchor=\pgf@circ@dir]
{ \pgf@circ@finallabels{current/label} }
\fi

coordinate[currarrow,pos=\ctikzvalof{current/distance},sloped,allow upside down](Iarrow)
(Iarrow.\pgf@circ@bipole@current@label@where) node[anchor=\pgf@circ@dir]{\pgf@circ@finallabels{current/label}}
}

\endinput



\endinput

0 comments on commit 6524f22

Please sign in to comment.