diff options
author | Norbert Preining <norbert@preining.info> | 2020-07-07 03:01:19 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2020-07-07 03:01:19 +0000 |
commit | ef87f13c4503a2aa4a9098cbf33e0bfcad19008e (patch) | |
tree | 3ffb99adbe8054f2bd6d04f982ea2a8e07a6bb62 /graphics/pgf/contrib | |
parent | 2caa59ac79d64858cdff8486b3fecc9859111e38 (diff) |
CTAN sync 202007070301
Diffstat (limited to 'graphics/pgf/contrib')
-rw-r--r-- | graphics/pgf/contrib/circuitikz/README.md | 8 | ||||
-rw-r--r-- | graphics/pgf/contrib/circuitikz/doc/changelog.tex | 34 | ||||
-rw-r--r-- | graphics/pgf/contrib/circuitikz/doc/circuitikz-context.pdf | bin | 17750 -> 17352 bytes | |||
-rw-r--r-- | graphics/pgf/contrib/circuitikz/doc/circuitikzmanual.pdf | bin | 1003704 -> 1017702 bytes | |||
-rw-r--r-- | graphics/pgf/contrib/circuitikz/doc/circuitikzmanual.tex | 624 | ||||
-rw-r--r-- | graphics/pgf/contrib/circuitikz/doc/ctikzmanutils.sty | 7 | ||||
-rw-r--r-- | graphics/pgf/contrib/circuitikz/tex/circuitikz.sty | 4 | ||||
-rw-r--r-- | graphics/pgf/contrib/circuitikz/tex/pgfcirc.defines.tex | 905 | ||||
-rw-r--r-- | graphics/pgf/contrib/circuitikz/tex/pgfcirccurrent.tex | 49 | ||||
-rw-r--r-- | graphics/pgf/contrib/circuitikz/tex/pgfcircflow.tex | 73 | ||||
-rw-r--r-- | graphics/pgf/contrib/circuitikz/tex/pgfcircpath.tex | 138 | ||||
-rw-r--r-- | graphics/pgf/contrib/circuitikz/tex/pgfcircvoltage.tex | 216 | ||||
-rw-r--r-- | graphics/pgf/contrib/circuitikz/tex/t-circuitikz.tex | 4 |
13 files changed, 1217 insertions, 845 deletions
diff --git a/graphics/pgf/contrib/circuitikz/README.md b/graphics/pgf/contrib/circuitikz/README.md index 26b73ef946..18614930e0 100644 --- a/graphics/pgf/contrib/circuitikz/README.md +++ b/graphics/pgf/contrib/circuitikz/README.md @@ -74,7 +74,13 @@ also the questions tagged `circuitikz` on https://tex.stackexchange.com/ are of * Romano Giannetti (romano.giannetti@gmail.com) ------------- -Copyright 2007-19 by Massimo Redaelli +Copyright 2018-2020 by Romano Giannetti + +Copyright 2015-2020 by Stefan Lindner + +Copyright 2013-2020 by Stefan Erhardt + +Copyright 2007-2020 by Massimo Redaelli This file may be distributed and/or modified diff --git a/graphics/pgf/contrib/circuitikz/doc/changelog.tex b/graphics/pgf/contrib/circuitikz/doc/changelog.tex index 80bc730a3e..a9e9200ee1 100644 --- a/graphics/pgf/contrib/circuitikz/doc/changelog.tex +++ b/graphics/pgf/contrib/circuitikz/doc/changelog.tex @@ -5,6 +5,40 @@ full list of changes. \begin{itemize} \item + Version 1.2.1 (2020-07-06) + + Several changes, both internal and user-visible. These are quite + risky, although they \emph{should} be backeard-compatible. + + From the user point of view: + + \begin{itemize} + \tightlist + \item + there is now a new style of voltages (``raised American'') + \item + a powerful mechanism for customize voltages, current and flows has + been added. + \end{itemize} + + The internal changes are basically the re-implementation of the macros + that draw the path elements (\texttt{to{[}...{]}}), which have been + completely rewritten. Please be sure to read the possible + incompatibilities in the manual (section 1.9). + + \begin{itemize} + \tightlist + \item + Added access to voltages, currents and flows anchors + \item + Added ``raised american'' voltage style + \item + Rewrite of the path generation macros + \item + Several small bugs fixed (no one ever used some + ``f\^{}\textgreater{}'' options\ldots{}) + \end{itemize} +\item Version 1.2.0 (2020-06-21) In this release, the big change is the rewriting of the voltages diff --git a/graphics/pgf/contrib/circuitikz/doc/circuitikz-context.pdf b/graphics/pgf/contrib/circuitikz/doc/circuitikz-context.pdf Binary files differindex 11d0fef2f0..9853c5f419 100644 --- a/graphics/pgf/contrib/circuitikz/doc/circuitikz-context.pdf +++ b/graphics/pgf/contrib/circuitikz/doc/circuitikz-context.pdf diff --git a/graphics/pgf/contrib/circuitikz/doc/circuitikzmanual.pdf b/graphics/pgf/contrib/circuitikz/doc/circuitikzmanual.pdf Binary files differindex 1547fdaa57..d4b9b8b763 100644 --- a/graphics/pgf/contrib/circuitikz/doc/circuitikzmanual.pdf +++ b/graphics/pgf/contrib/circuitikz/doc/circuitikzmanual.pdf diff --git a/graphics/pgf/contrib/circuitikz/doc/circuitikzmanual.tex b/graphics/pgf/contrib/circuitikz/doc/circuitikzmanual.tex index 9ecca9a39a..300ee04f20 100644 --- a/graphics/pgf/contrib/circuitikz/doc/circuitikzmanual.tex +++ b/graphics/pgf/contrib/circuitikz/doc/circuitikzmanual.tex @@ -141,23 +141,23 @@ \draw (C.pin 20) -- ++(0,-8) node[ground](GND){}; \draw (C.pin 7) to[D, fill=blue] ++(0,-1) -- ++(0.5,0) to[R] ++(2,0) coordinate(a1) to[short, -*] - node[above left, blue]{Massimo A. Redaelli} - node[below left,]{\email{m.redaelli@gmail.com}} + node[above left, blue, pos=1]{Massimo A. Redaelli} + node[below left, pos=1]{\email{m.redaelli@gmail.com}} (a1-|GND); \draw (C.pin 5) to[D, fill=red] ++(0,-3)-- ++(0.5,0) to[R] ++(2,0) coordinate(a2) to[short, -*] - node[above left, blue]{Stefan Lindner} - node[below left,]{\email{stefan.lindner@fau.de}} + node[above left, blue, pos=1]{Stefan Lindner} + node[below left, pos=1]{\email{stefan.lindner@fau.de}} (a2-|GND); \draw (C.pin 3) to[D, fill=green] ++(0,-5)-- ++(0.5,0) to[R] ++(2,0) coordinate(a3) to[short, -*] - node[above left, blue]{Stefan Erhardt} - node[below left,]{\email{stefan.erhardt@fau.de}} + node[above left, blue, pos=1]{Stefan Erhardt} + node[below left, pos=1]{\email{stefan.erhardt@fau.de}} (a3-|GND); \draw (C.pin 1) to[D, fill=yellow] ++(0,-7)-- ++(0.5,0) to[R] ++(2,0) coordinate(a4) to[short, -*] - node[above left, blue]{Romano Giannetti} - node[below left,]{\email{romano.giannetti@gmail.com}} + node[above left, blue, pos=1]{Romano Giannetti} + node[below left, pos=1]{\email{romano.giannetti@gmail.com}} (a4-|GND); \end{circuitikz} \par\bigskip\vfill} @@ -273,13 +273,21 @@ Nevertheless, \href{https://tex.stackexchange.com/a/529159/38080}{Schrödinger' \end{circuitikz} \end{LTXexample} -They \texttt{use fpu reciprocal} key seems to have no side effects, but given that it is patching an internal interface of \TikZ{} it can break any time, so it is advisable to use it only if and when needed. +The \texttt{use fpu reciprocal} key seems to have no side effects, but given that it is patching an internal interface of \TikZ{} it can break any time, so it is advisable to use it only if and when needed. \subsection{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 After v1.2.1: \textbf{Important:} the routine that implement the \texttt{to[...]} component positioning has been rewritten. That should enhance the line joins in path, and it's safer, but it can potentially change behavior. + + One of the changes is that the previous routine did the wrong thing if you used \texttt{(node) to[...]} (you should use an anchor or a coordinate, not a node there --- like \texttt{(node.anchor) to[...]}). + + The other one was that in the structure \texttt{... to[...] node[pos=\emph{something}] (coord)} the value of \texttt{pos} was completely wrong (even if you don't use \texttt{pos} explicitly, remeber it's \texttt{pos=0.5} by default). + + Additionally, the old code disrupted the \TikZ{} path-fill mechanism, so that you could get away with using the \texttt{fill} option on paths and having just the components to be filled, not the path. That was incorrect, although sometime it was handy. + \item After v1.2.0: voltage arrows, symbols and label positions are calculated with a rewritten routine. There should be little change, \emph{unless} you touched internal values\dots \item After v1.1.3: during the 1.1.0 --- 1.1.2 version, the inverted Schmitt buffer in IEEE style ports was called \texttt{inv schmitt} (with an additional space). The correct name is \texttt{invschmitt port} (the same as the legacy american port). \item After v1.1.2: the position of \texttt{american} voltages for the \texttt{open} bipoles (you can revert to old behavior, see section~\ref{sec:sub-voltage-position}). @@ -315,7 +323,12 @@ The easiest way to contact the authors is via the official Github repository: \u \subsection{Package options} \label{sec:package-options} -\noindent Circuit people are very opinionated about their symbols. In order to meet the individual gusto you can set a bunch of package options. The standard options are what the authors like, for example you get this: +Circuit people are very opinionated about their symbols. In order to meet the individual gusto you can set a bunch of package options. + +There are arguably way too much options in \Circuitikz, as you can see in the following list. Since version \texttt{1.0}, it is recommended to just use the basic ones --- voltage directions (you \textbf{should} specify one of them), \texttt{siunitx}, the global style (\texttt{american} or \texttt{european}) and use styles (see~\ref{sec:styling}) for the remaining options. + +The standard options are what the authors like, for example you get this: + \begin{LTXexample}[varwidth=true] \begin{circuitikz} \draw (0,0) to[R=2<\ohm>, i=?, v=84<\volt>] (2,0) -- @@ -5347,9 +5360,9 @@ Long names/styles for the bipoles can be used: \subsection{Labels and Annotations} \label{sec:labels-and-annotations} -Since Version 0.7, beside the original label (l) option, there is a new option to place a second label, called annotation (a) at each bipole. Up to now this is a beta-test and there can be problems. For example, up to now this option is not compatible with the concurrent use of voltage labels. +Since Version 0.7, beside the original label (\texttt{l}) option, there is a new option to place a second label, called annotation (\texttt{a}) at each bipole. -The position of (a) and (l) labels can be adjusted with \_ and \^, respectively. +The position of annotations and labels can be adjusted with \verb|_| and \verb|^|. \begin{LTXexample}[varwidth=true] \begin{circuitikz} @@ -5364,7 +5377,7 @@ The position of (a) and (l) labels can be adjusted with \_ and \^, respectively. \end{LTXexample} \textbf{Caveat:} notice that the way in which \texttt{circuitikz} processes the options, there will be problems if the label (or annotation, voltage, or current) contains one of the characters $=$ (equal) or $,$ (comma), giving unexpected errors and wrong output. -These two characters must be protected to the option parser using an \verb|\mbox| command, or redefining the characters with a \TeX\ \verb|\def|: +These two characters must be protected from the option parser using an \verb|\mbox| command, or redefining the characters with a \TeX\ \verb|\def|: \begin{LTXexample}[varwidth=true] \def\eq{=} @@ -5513,9 +5526,54 @@ as shown in the following examples. This manual has been typeset with the option \texttt{\chosenvoltoption}. +\subsubsection{Common properties of voltages and currents} +\label{sec:common-vif-pos} + +Currents, voltages and flows (see later) are positioned along, or across, the part of the wires that connect the inner component to the rest of the circuit. So, changing the length of the connection (the coordinates that embrace the \texttt{to[...]} command) will change the position of the components. + +\begin{LTXexample}[varwidth=true] +\begin{circuitikz} + \draw (-1,1) to[R, v=$v$, i=$i$, f>^=$f$] (1,1); + \draw (-2,0) to[R, v=$v$, i=$i$, f>^=$f$] (2,0); +\end{circuitikz} +\end{LTXexample} + +However, you can override the properties \texttt{voltage/distance from node} (default \texttt{0.5}: how distant from the initial and final points of the path the arrow starts and ends or the plus and minus symbols are drawn) and \texttt{voltage/bump b} (how high the bump of the arrow is --- how curved it is, default \texttt{1.5}), and also \texttt{voltage/european label distance} (how distant from the normal position the voltage label will be, default \texttt{1.4}) on a per-component basis, in order to fine-tune the voltages: + +\begin{LTXexample}[varwidth=true] +\tikz \draw (0,0) to[R, v=1<\volt>] (2,0); \par +\ctikzset{voltage/distance from node=.1} +\ctikzset{voltage/bump b=2.5} +\tikz \draw (0,0) to[R, v=1<\volt>] (2,0); +\end{LTXexample} + +The same concept as \texttt{distance from node} applies to the key \texttt{current/distance} for the position of the current's arrow: + +\begin{LTXexample}[varwidth=true] +\tikz \draw (0,0) to[C, i=$\imath$] (2,0); \par +\ctikzset{current/distance = .2} +\tikz \draw (0,0) to[C, i=$\imath$] (2,0); +\end{LTXexample} + +You can change globally these parameters by defining a component-specific key; you have to use the internal name of the component (in the component list, is the \texttt{nodename} without the terminal ``\texttt{shape}'' part): + +\begin{LTXexample}[varwidth=true] +\tikz \draw (0,0) to[R, v=1<\volt>] (1.5,0) + to[C, v=2<\volt>] (3,0); \par +\ctikzset{bipoles/capacitor/voltage/distance from node/.initial=.7} +\tikz \draw (0,0) to[R, v=1<\volt>] (1.5,0) + to[C, v=2<\volt>] (3,0); \par +\end{LTXexample} + +Note the \texttt{.initial}; you have to create such key the first time you use it. These kind of adjustments are not guaranteed to work in future upgrades, though; if you have to create a key you are somehow touching the internal structure of the package; it's much safer to create a style. + +One common request is to change the style of the arrows (both head and line) of these elements. Voltages, currents and flows are part of the same path of the component, so this is not possible in simple way; you have to drawn your own with \TikZ{} commands using the facilities explained in section~\ref{sec:vif-anchors}. + \subsection{Currents}\label{sec:currents} -Inline (along the wire) currents are selected with \verb|i_>|, \verb|i^<|, \verb|i>_|, \verb|i>^|, and various simplification; the default position and direction is obtained with the key \verb|i=...|. +Inline (along the wire) currents are selected with \verb|i_>|, \verb|i^<|, \verb|i>_|, \verb|i>^|, and various combination; the default position and direction is obtained with the simple key \verb|i=...|. + +Basically, \verb|^| and \verb|_| control if the label is above or below the line (above and below \textbf{do} depend on the direction of the component path), and \verb|<| and \verb|>| the direction of the arrow; swapping them (from for example from \verb|i^>| to \verb|i>^|) will switch the side of the component where the symbol is drawn. See the following examples: \begin{LTXexample}[varwidth=true] @@ -5566,31 +5624,16 @@ Inline (along the wire) currents are selected with \verb|i_>|, \verb|i^<|, \verb \end{circuitikz} \end{LTXexample} -Also: +Also notice that the direction of the path is important: \begin{LTXexample}[varwidth=true] \begin{circuitikz} + \draw (2,1) to[R, i<=$i_1$] (0,1); \draw (0,0) to[R, i<=$i_1$] (2,0); \end{circuitikz} \end{LTXexample} -\begin{LTXexample}[varwidth=true] -\begin{circuitikz} - \draw (0,0) to[R, i>=$i_1$] (2,0); -\end{circuitikz} -\end{LTXexample} - -\begin{LTXexample}[varwidth=true] -\begin{circuitikz} - \draw (0,0) to[R, i^=$i_1$] (2,0); -\end{circuitikz} -\end{LTXexample} - -\begin{LTXexample}[varwidth=true] -\begin{circuitikz} - \draw (0,0) to[R, i_=$i_1$] (2,0); -\end{circuitikz} -\end{LTXexample} +Default directions can change if the component is active or passive,\footnote{This, in hindsight, has been a bad feature --- and I'm partly responsible for it. But removing it would create \emph{too small} variations in circuits, so it stays.} following the chosen global voltage direction strategy (see section~\ref{curr-and-volt}). \begin{LTXexample}[varwidth=true] \begin{circuitikz} @@ -5599,8 +5642,8 @@ Also: \end{LTXexample} \begin{LTXexample}[varwidth=true] -\begin{circuitikz} - \draw (0,0) to[V<=10V, i_=$i_1$] (2,0); +\begin{circuitikz}[voltage dir=EF] + \draw (0,0) to[V=10V, i_=$i_1$] (2,0); \end{circuitikz} \end{LTXexample} @@ -5616,22 +5659,27 @@ Also: \end{circuitikz} \end{LTXexample} +Current generators with the direct label (the one obtained by, for example, \texttt{I = something}) will treat it as a current: + \begin{LTXexample}[varwidth=true] -\begin{circuitikz}[american] - \draw (0,0) to[dcisource=1A, i_=$i_1$] (2,0); +\begin{circuitikz} + \draw (0,0) to[I=$a_1$] (2,0); \end{circuitikz} \end{LTXexample} +If you use the option \texttt{americancurrent} or using the style \texttt{[american currents]} +you can changhe the style of current generators. + \begin{LTXexample}[varwidth=true] -\begin{circuitikz}[american] - \draw (0,0) to[dcisource=1A,invert, i_=$i_1$] (2,0); +\begin{circuitikz}[american currents] + \draw (0,0) to[I=$a_1$] (2,0); \end{circuitikz} \end{LTXexample} + \subsection{Flows}\label{flows} -As an alternative for the current arrows, you can also use the following flows. They can also be used to indicate thermal or power flows. The syntax is pretty the same as for currents. -\textit{This is a new beta feature since version 0.8.3; therefore, please provide bug reports or hints to optimize this feature regarding placement and appearance! This means that the appearance may change in the future!} +As an alternative for the current arrows, you can also use the following ``flows''. They can also be used to indicate thermal or power flows. The syntax is pretty the same as for currents. \begin{LTXexample}[varwidth=true] \begin{circuitikz} @@ -5676,9 +5724,13 @@ As an alternative for the current arrows, you can also use the following flows. \end{LTXexample} \subsection{Voltages} -See introduction note at Currents and Voltages (chapter \ref{curr-and-volt}, page \pageref{curr-and-volt}) for the direction of the voltage and currents. +See the introduction at Currents and Voltages (section~\ref{curr-and-volt}, page \pageref{curr-and-volt}) for the default direction of the voltage and currents. + +Voltages come in four different styles: European (with curved or straight arrows) and American (with signs that can stay near the wire or raised at the label level). + +Direction and position of the symbols are controlled in the same way as for the currents (see section~\ref{sec:currents}) with the \verb|_^<>| symbols. -\subsubsection{European style} The default, with arrows. Use option \texttt{europeanvoltage} or style \verb![european voltages]!, or setting (even locally) \texttt{voltage=european}. +\subsubsection{European style} The default, with curved arrows. Use option \texttt{europeanvoltage} or style \verb![european voltages]!, or setting (even locally) \texttt{voltage=european}. \begin{LTXexample}[varwidth=true] \begin{circuitikz}[european voltages] @@ -5704,49 +5756,71 @@ See introduction note at Currents and Voltages (chapter \ref{curr-and-volt}, pag \end{circuitikz} \end{LTXexample} +The default direction for active elements can change, depending on the global \texttt{voltage dir} setting, so be careful. + \begin{LTXexample}[varwidth=true] \begin{circuitikz} - \draw (0,0) to[V=10V, i_=$i_1$] (2,0); + \draw (0,0) to[I=1A, v_=$u_1$] (2,0); \end{circuitikz} \end{LTXexample} \begin{LTXexample}[varwidth=true] \begin{circuitikz} - \draw (0,0) to[V<=10V, i_=$i_1$] (2,0); + \draw (0,0) to[I<=1A, v_=$u_1$] (2,0); \end{circuitikz} \end{LTXexample} \begin{LTXexample}[varwidth=true] \begin{circuitikz} - \draw (0,0) to[I=1A, v_=$u_1$] (2,0); + \draw (0,0) to[I=$~$,l=1A, v_=$u_1$] (2,0); \end{circuitikz} \end{LTXexample} \begin{LTXexample}[varwidth=true] \begin{circuitikz} - \draw (0,0) to[I<=1A, v_=$u_1$] (2,0); + \draw (0,0) to[I,l=1A, v_=$u_1$] (2,0); \end{circuitikz} \end{LTXexample} +Moreover, for historical reasons, voltage generators have differently looking arrows (they are straight even in curved European style). \begin{LTXexample}[varwidth=true] \begin{circuitikz} - \draw (0,0) to[I=$~$,l=1A, v_=$u_1$] (2,0); + \draw (0,0) to[battery,l_=1V, v=$u_1$, i=$i_1$] (2,0); \end{circuitikz} \end{LTXexample} \begin{LTXexample}[varwidth=true] \begin{circuitikz} - \draw (0,0) to[I,l=1A, v_=$u_1$] (2,0); + \draw (0,0) to[V=10V, i_=$i_1$] (2,0); \end{circuitikz} \end{LTXexample} +You can change this last thing by forcing ``off'' the status of ``voltage generator'' of the component; but now the normal (passive) rule will apply, so, again, be careful. + \begin{LTXexample}[varwidth=true] \begin{circuitikz} - \draw (0,0) to[battery,l_=1V, v=$u_1$, i=$i_1$] (2,0); + \draw (0,0) to[battery, bipole/is voltage=false, + v>=$u_1$,] (2,0); +\end{circuitikz} +\end{LTXexample} + +As for the currents, the direct label of voltage sources is passed as a voltage: + +\begin{LTXexample}[varwidth=true] +\begin{circuitikz} + \draw (0,0) to[cV=$k\cdot a_1$] (2,0); \end{circuitikz} \end{LTXexample} -\subsubsection{Straight European style} Using straight arrows. Use option \texttt{straightvoltages} or style \verb![straight voltages]!, or setting (even locally) \texttt{voltage=straight}. Notice that this is an only lightly tested option, so use with care. +The following results from using the option \texttt{americanvoltage} or the style \texttt{[american voltages]}. + +\begin{LTXexample}[varwidth=true] +\begin{circuitikz}[american voltages] + \draw (0,0) to[V=$a_1$] (2,0); +\end{circuitikz} +\end{LTXexample} + +\subsubsection{Straight European style} Using straight arrows. Use option \texttt{straightvoltages} or style \verb![straight voltages]!, or setting (even locally) \texttt{voltage=straight}. \begin{LTXexample}[varwidth=true] \begin{circuitikz}[straight voltages] @@ -5772,89 +5846,115 @@ See introduction note at Currents and Voltages (chapter \ref{curr-and-volt}, pag \end{circuitikz} \end{LTXexample} +Again, voltage generators are treated differently: + \begin{LTXexample}[varwidth=true] \begin{circuitikz}[straight voltages] - \draw (0,0) to[V=10V, i_=$i_1$] (2,0); + \draw (0,0) to[V=10V, i_=$i_1$] (3,0); \end{circuitikz} \end{LTXexample} \begin{LTXexample}[varwidth=true] \begin{circuitikz}[straight voltages] - \draw (0,0) to[V<=10V, i_=$i_1$] (2,0); + \draw (0,0) to[I, v=10V, i_=$i_1$] (3,0); \end{circuitikz} \end{LTXexample} +And you can override that with \texttt{bipole/is voltage} keeping into account that the default direction will be the one of passive components: + \begin{LTXexample}[varwidth=true] \begin{circuitikz}[straight voltages] - \draw (0,0) to[I=1A, v_=$u_1$] (2,0); + \draw (0,0) to[V=10V, bipole/is voltage=false, + i_=$i_1$] (3,0); \end{circuitikz} \end{LTXexample} +\subsubsection{American style} +Use option \texttt{americanvoltage} or set \verb![american voltages]! or use the option \texttt{voltage=american}. + \begin{LTXexample}[varwidth=true] -\begin{circuitikz}[straight voltages] - \draw (0,0) to[I<=1A, v_=$u_1$] (2,0); +\begin{circuitikz}[american voltages] + \draw (0,0) to[R, v^>=$v_1$] (2,0); \end{circuitikz} \end{LTXexample} \begin{LTXexample}[varwidth=true] -\begin{circuitikz}[straight voltages] - \draw (0,0) to[I=$~$,l=1A, v_=$u_1$] (2,0); +\begin{circuitikz}[american voltages] + \draw (0,0) to[R, v^<=$v_1$] (2,0); \end{circuitikz} \end{LTXexample} \begin{LTXexample}[varwidth=true] -\begin{circuitikz}[straight voltages] - \draw (0,0) to[I,l=1A, v_=$u_1$] (2,0); +\begin{circuitikz}[american voltages] + \draw (0,0) to[R, v_>=$v_1$] (2,0); \end{circuitikz} \end{LTXexample} \begin{LTXexample}[varwidth=true] -\begin{circuitikz}[straight voltages] - \draw (0,0) to[battery,l_=1V, v=$u_1$, i=$i_1$] (2,0); +\begin{circuitikz}[american voltages] + \draw (0,0) to[R, v_<=$v_1$] (2,0); +\end{circuitikz} +\end{LTXexample} + +\begin{LTXexample}[varwidth=true] +\begin{circuitikz}[american] + \draw (0,0) to[I=1A, v_=$u_1$] (2,0); \end{circuitikz} \end{LTXexample} +\begin{LTXexample}[varwidth=true] +\begin{circuitikz}[american] + \draw (0,0) to[I<=1A, v_=$i_1$] (2,0); +\end{circuitikz} +\end{LTXexample} -\subsubsection{American style} -Use option \texttt{americanvoltage} or set \verb![american voltages]! or use the option \texttt{voltage=american}. + +\subsubsection{Raised American style} + +Since version \texttt{1.2.1}, ``raised'' American voltages are available; to use them, set the style \verb![raised voltages]! or use the option \texttt{voltage=raised}. +This is a version of the American-style voltage where the signs are raised to the level of the label. +The label is centered between the two signs, and the position of the signs is calculated supposing that the label itself will be pretty simple; if you have very big labels you will need to adjust the position with \texttt{voltage shift} and/or the \texttt{voltage/distance from node} properties (see section~\ref{sec:common-vif-pos}). \begin{LTXexample}[varwidth=true] -\begin{circuitikz}[american voltages] +\begin{circuitikz}[raised voltages] \draw (0,0) to[R, v^>=$v_1$] (2,0); \end{circuitikz} \end{LTXexample} \begin{LTXexample}[varwidth=true] -\begin{circuitikz}[american voltages] +\begin{circuitikz}[raised voltages] \draw (0,0) to[R, v^<=$v_1$] (2,0); \end{circuitikz} \end{LTXexample} \begin{LTXexample}[varwidth=true] -\begin{circuitikz}[american voltages] +\begin{circuitikz}[raised voltages] \draw (0,0) to[R, v_>=$v_1$] (2,0); \end{circuitikz} \end{LTXexample} \begin{LTXexample}[varwidth=true] -\begin{circuitikz}[american voltages] +\begin{circuitikz}[raised voltages] \draw (0,0) to[R, v_<=$v_1$] (2,0); \end{circuitikz} \end{LTXexample} \begin{LTXexample}[varwidth=true] \begin{circuitikz}[american] + \ctikzset{voltage=raised} \draw (0,0) to[I=1A, v_=$u_1$] (2,0); \end{circuitikz} \end{LTXexample} \begin{LTXexample}[varwidth=true] -\begin{circuitikz}[american] +\begin{circuitikz}[raised voltages] \draw (0,0) to[I<=1A, v_=$i_1$] (2,0); \end{circuitikz} \end{LTXexample} -\subsubsection{Voltage position}\label{sec:sub-voltage-position} It is possible to move away the arrows and the plus or minus signs with the key \texttt{voltages shift} (default value is \texttt{0}, which gives the standard position): +\subsubsection{Voltage position}\label{sec:sub-voltage-position} + +It is possible to move the arrows and the plus or minus signs away form the component with the key \texttt{voltages shift} (default value is \texttt{0}, which gives the standard position): \begin{LTXexample}[varwidth=true] \begin{circuitikz}[] @@ -5862,7 +5962,7 @@ Use option \texttt{americanvoltage} or set \verb![american voltages]! or use the \draw (0,-1) to[R, v=$v_1$, i=$i_1$, voltage shift=0.5] (2,-1); \draw (0,-2) to[R, v=$v_1$, i=$i_1$, - voltage shift=1.0, ] (2,-2); + voltage shift=1.0] (2,-2); \end{circuitikz} \end{LTXexample} @@ -5872,12 +5972,24 @@ Use option \texttt{americanvoltage} or set \verb![american voltages]! or use the \end{circuitikz} \end{LTXexample} +Negative values do work as expected: + +\begin{LTXexample}[varwidth=true] +\begin{circuitikz}[raised voltages] + \draw (0,1.5) to[R, v^=$v_1$, i=$i_1$] ++(2,0); + \draw (0,0) to[R, v^=$v_1$, i=$i_1$, + voltage shift=-1.0] ++(2,0); +\end{circuitikz} +\end{LTXexample} + You can fine-tune the position of the \texttt{+} and \texttt{-} symbols and the label in independent way using \texttt{voltage/shift} (default \texttt{0.0} for the former and \texttt{voltage/american label distance} (the distance of the label form the lines of the symbols, default \texttt{1.4}) for the latter. \begin{LTXexample}[varwidth=true] \begin{circuitikz}[american voltages] - \ctikzset{voltage/american label distance=0.2, voltage/shift=2} - \draw (0,0) to[R, v=$v_1$, i=$i_1$] (2,0); + \draw (0,1) to[R, v=$v_1$, i=$i_1$] ++(2,0); + % normally 1.4, make it tighter + \ctikzset{voltage/american label distance=0.5} + \draw (0,0) to[R, v=$v_1$, i=$i_1$] ++(2,0); \end{circuitikz} \end{LTXexample} @@ -5949,32 +6061,6 @@ This could be especially useful if you define a style, to use like this: \end{LTXexample} -\subsection{Global properties of voltages and currents} - -\begin{LTXexample}[varwidth=true] -\tikz \draw (0,0) to[R, v=1<\volt>] (2,0); \par -\ctikzset{voltage/distance from node=.1} -\tikz \draw (0,0) to[R, v=1<\volt>] (2,0); -\end{LTXexample} - -\begin{LTXexample}[varwidth=true] -\tikz \draw (0,0) to[C, i=$\imath$] (2,0); \par -\ctikzset{current/distance = .2} -\tikz \draw (0,0) to[C, i=$\imath$] (2,0); -\end{LTXexample} - -However, you can override the properties \texttt{voltage/distance from node} (how distant from the initial and final points of the path the arrow starts and ends, default \texttt{0.5}) and \texttt{voltage/bump b} (how high the bump of the arrow is --- how curved it is, default \texttt{1.5}), and also \texttt{voltage/european label distance} (how distant from the ``bump'' the voltage label will be, default \texttt{1.4}) on a per-component basis, in order to fine-tune the voltages: - - -\begin{LTXexample}[varwidth=true] -\tikz \draw (0,0) to[R, v=1<\volt>] (1.5,0) - to[C, v=2<\volt>] (3,0); \par -\ctikzset{bipoles/capacitor/voltage/distance from node/.initial=.7} -\tikz \draw (0,0) to[R, v=1<\volt>] (1.5,0) - to[C, v=2<\volt>] (3,0); \par -\end{LTXexample} - -Note the \texttt{.initial}; you have to create such key the first time you use it. \subsection{Changing the style of labels and text ornaments} @@ -5987,7 +6073,7 @@ For example, you can make all annotations small by using: \ctikzset{bipole annotation style/.style={font=\small}} \end{lstlisting} -And the change (override) the setting in one specific bipole using: +And/or change (override) the setting in one specific bipole using: \begin{lstlisting}[numbers=none] ...to[bipole annotation style={color=red}, R, a={Red note}]... @@ -6017,141 +6103,231 @@ The available styles and commands are \texttt{bipole label style}, \texttt{bipol \end{circuitikz} \end{LTXexample} -\subsection{Labels in special components} - -For some components label, current and voltage behave as one would expect: +\subsection{Accessing labels text nodes} -\begin{LTXexample}[varwidth=true] -\begin{circuitikz} - \draw (0,0) to[I=$a_1$] (2,0); -\end{circuitikz} -\end{LTXexample} +Since 0.9.5, you can access all the labels nodes\footnote{The access to \texttt{label}s and \texttt{annotation}s was present before, but not documented.} using special node names. So, if you use \texttt{name} to give a name to the bipole node, you can access also the following nodes: \texttt{namelabel} (notice: no space nor any other symbol between \texttt{name} and \texttt{label}!), \texttt{nameannotation}, \texttt{namevoltage}, \texttt{namecurrent} and \texttt{nameflow}. Notice that the node names are available only if the bipole has an anchor or an annotation, of course. -\begin{LTXexample}[varwidth=true] -\begin{circuitikz} - \draw (0,0) to[I, i=$a_1$] (2,0); +\begin{LTXexample}[varwidth=true, + pos=t, basicstyle=\small\ttfamily + ] +\newcommand{\marknode}[2][45]{% + \node[circle, draw, red, inner sep=1pt, + pin={[red, font=\tiny]#1:#2}] at (#2.center) {}; +} +\begin{circuitikz}[ american] + \draw (0,0) to [R=L1, a=A1, name=L1] ++(3,0) + to [R, l2_=L2 and 2L, a^=A2, name=L2] ++(3,0); + \marknode{L1} \marknode{L1label} \marknode[0]{L1annotation} + \marknode{L2} \marknode[0]{L2label} \marknode{L2annotation} + \draw[blue] (L2label.south west) rectangle (L2label.north east); + \draw (6.1,0) to [R=R1, v=V1, i=I1, f>^=F1, name=R1] ++(3,0) + to [R, v<=V2, i^=I2, f>^=F2, name=R2] ++(3,0); + \marknode[0]{R1voltage} \marknode[0]{R2voltage} \marknode[90]{R1current} + \marknode[90]{R2current} \marknode{R1flow} \marknode{R2flow} \end{circuitikz} \end{LTXexample} +\subsection{Advanced voltages, currents and flows}\label{sec:vif-anchors} -\begin{LTXexample}[varwidth=true] -\begin{circuitikz} - \draw (0,0) to[cI=$k\cdot a_1$] (2,0); -\end{circuitikz} -\end{LTXexample} +Since version \texttt{1.2.1}, it is possible to access the anchors of the ``ornaments'' --- voltage, current and flows, together with some additional information that makes it possible to personalize them. +Normally, voltages and flow and currents are drawn into the path of the bipoles, so that it is not possible, for example, to change the line type or color of the arrows, or the type of arrows\footnote{in regular voltages, the arrows are not real \TikZ{} arrows, but the auxiliary arrow shapes of \Circuitikz{}}. Access to the anchors allows to do all this things, and more. +For example, you can do something like this: -\begin{LTXexample}[varwidth=true] -\begin{circuitikz} - \draw (0,0) to[sI=$a_1$] (2,0); +\begin{LTXexample}[varwidth=true, basicstyle=\small\ttfamily] +\begin{circuitikz}[] + \draw (0,1) to[R, v=$v$] ++(3,0); + \draw (0,0) to[R, v, name=R, voltage/bump b=3] ++(3,0); + \draw [thin, red, -{Stealth[width=8pt]}, ] + (R-Vfrom) .. controls (R-Vcont1) and (R-Vcont2).. (R-Vto) + node [black, pos=0.5, fill=white]{v}; \end{circuitikz} \end{LTXexample} -\begin{LTXexample}[varwidth=true] -\begin{circuitikz} - \draw (0,0) to[csI=$k\cdot a_1$] (2,0); +Or, for example, to have a different voltage style; normally you would define a macro: + +\begin{LTXexample}[varwidth=true, basicstyle=\small\ttfamily] +\begin{circuitikz}[voltage shift=0.5] + \def\eurVPM#1#2{% node, label + \draw [thin, -{Stealth[width=8pt]}, shorten >=5pt, + shorten <=5pt] (#1-Vfrom) node[font=\tiny]{$-$} + .. controls (#1-Vcont1) and (#1-Vcont2).. + (#1-Vto) node[font=\tiny]{$+$} + node[pos=0.5,anchor=\ctikzgetanchor{#1}{Vlab}]{#2};} + \draw (0,0) to[R=R1, name=R1, v, i=$i$] ++(3,0) + to[R, l_=R2, v^, name=R2] ++(0,-3); + \eurVPM{R1}{$v_1$} \eurVPM{R2}{$v_2$} \end{circuitikz} \end{LTXexample} -The following results from using the option \texttt{americancurrent} or using the style \texttt{[american currents]}. +\subsubsection{Activating the anchors} -\begin{LTXexample}[varwidth=true] -\begin{circuitikz}[american currents] - \draw (0,0) to[I=$a_1$] (2,0); -\end{circuitikz} -\end{LTXexample} +You will have access to the anchors for voltages, currents and flows when, in the bipole, you have both a \texttt{v}, \texttt{i}, \texttt{f} specification (one or more of them) \textbf{and} a \texttt{name} key, to give the bipole a name. Otherwise, the anchors and the associated functions are not defined. +To suppress the normal output of the \texttt{v}, \texttt{i}, \texttt{f} keys, you can use such keys without any argument, like in the previous example; notice that the \verb|_| and \verb|^| modifiers work as expected. -\begin{LTXexample}[varwidth=true] -\begin{circuitikz}[american currents] - \draw (0,0) to[I, i=$a_1$] (2,0); -\end{circuitikz} -\end{LTXexample} +The following line of resistors has been drawn with the following commands; it is used to show the name of the available anchors. +\begin{lstlisting} + \draw (0,0) to[R=R1, v=$v$, name=R1] ++(4,0) + to[R, l_=R2, i=$i$, name=R2] ++(4,0) + to[R=R3, f=$f$, name=R3] ++(4,0); +\end{lstlisting} -\begin{LTXexample}[varwidth=true] -\begin{circuitikz}[american currents] - \draw (0,0) to[cI=$k\cdot a_1$] (2,0); +\begin{circuitikz}[] + \draw (0,0) to[R=R1, v=$v$, name=R1] ++(4,0) to[R, l_=R2, i=$i$, name=R2] ++(4,0) to[R=R3, f=$f$, name=R3] ++(4,0); + \path + (R1-Vto) \showcoord(R1-Vto)<-135:0.2> + (R1-Vfrom) \showcoord(R1-Vfrom)<-45:0.2> + (R1-Vcont1) \showcoord(R1-Vcont1)<-45:0.2> + (R1-Vcont2) \showcoord(R1-Vcont2)<-135:0.2> + (R1-Vlab) \showcoord(R1-Vlab)<-90:0.5> + (R2-Ito) \showcoord(R2-Ito)<45:0.3> + (R2-Ifrom) \showcoord(R2-Ifrom)<135:0.3> + (R2-Ipos) \showcoord(R2-Ipos)<-90:0.3> + (R3-Fto) \showcoord(R3-Fto)<45:0.3> + (R3-Ffrom) \showcoord(R3-Ffrom)<135:0.3> + (R3-Fpos) \showcoord(R3-Fpos)<-90:0.4> + ; \end{circuitikz} -\end{LTXexample} +The meaning of the anchors is the following: +\begin{itemize} +\item + \texttt{Vfrom} and \texttt{Vto} are the main points where the voltage information is given: start and end point of the arrow, or position of the $+$ or $-$ sign. This is the same for the \texttt{Ffrom} or \texttt{Fto} anchors for flows; for inline currents, the corresponding \texttt{Ifrom} and \texttt{Ito} mark the wire segment where the arrowhead is positioned (at the specified \texttt{current/distance} fraction. The direction of the arrow is available using the auxiliary macro \verb|\ctikzgetdirection| (see below). +\item + \texttt{Vcont1} and \texttt{Vcont2} are the control points for the curved arrow (see the examples above); in the case of straight arrows or american-style voltages, they are set at the midpoint between \texttt{Vfrom} and \texttt{Vto}. +\item + \texttt{Vlab} is where the text label for the voltage is normally positioned. The anchor used for such label is available using the auxiliary macro \verb|\ctikzgetanchor| (see below) +\item + \texttt{Ipos} and \texttt{Fpos} are the position for the arrowhead or the small flow arrow (which is a \texttt{currarrow} or \texttt{flowarrow} node normally) is positioned, respectively. The label is then added to the correct side of it using the anchor available via \verb|\ctikzgetanchor|.\footnote{In this case, the exact position of the label is not available if you do not position the element, for this there is no \texttt{Flab} or \texttt{Ilab} coordinate; you have to use the \texttt{Fpos} and \texttt{Ipos} coordinate with the corresponding \texttt{Ilab} and \texttt{Flab} anchors.} +\end{itemize} -\begin{LTXexample}[varwidth=true] -\begin{circuitikz}[american currents] - \draw (0,0) to[sI=$a_1$] (2,0); -\end{circuitikz} -\end{LTXexample} +Changing the options of the elements, will change the anchors acoordingly: -\begin{LTXexample}[varwidth=true] -\begin{circuitikz}[american currents] - \draw (0,0) to[csI=$k\cdot a_1$] (2,0); +\begin{lstlisting} + \ctikzset{current/distance=0.2} + \draw (0,0) to[R=R1, v>=$v$, name=R1] ++(4,0) + to[R, l_=R2, i<_=$i$, name=R2] ++(4,0) + to[R, l_=R3, f<_=$f$, name=R3] ++(4,0); +\end{lstlisting} + +\begin{circuitikz}[] + \ctikzset{current/distance=0.2} + \draw (0,0) to[R=R1, v>=$v$, name=R1] ++(4,0) to[R, l_=R2, i<_=$i$, name=R2] ++(4,0) to[R, l_=R3, f<_=$f$, name=R3] ++(4,0); + \path + (R1-Vto) \showcoord(R1-Vto)<-45:0.2> + (R1-Vfrom) \showcoord(R1-Vfrom)<-135:0.2> + (R1-Vcont1) \showcoord(R1-Vcont1)<-135:0.2> + (R1-Vcont2) \showcoord(R1-Vcont2)<-45:0.2> + (R1-Vlab) \showcoord(R1-Vlab)<-90:0.5> + (R2-Ito) \showcoord(R2-Ito)<135:0.3> + (R2-Ifrom) \showcoord(R2-Ifrom)<45:0.3> + (R2-Ipos) \showcoord(R2-Ipos)<90:0.3> + (R3-Fto) \showcoord(R3-Fto)<90:0.4> + (R3-Ffrom) \showcoord(R3-Ffrom)<80:0.4> + (R3-Fpos) \showcoord(R3-Fpos)<-90:0.4> + ; \end{circuitikz} -\end{LTXexample} -The same holds for voltage sources: +Obviously, the anchors follow the voltage style you choose: -\begin{LTXexample}[varwidth=true] -\begin{circuitikz} - \draw (0,0) to[V=$a_1$] (2,0); -\end{circuitikz} -\end{LTXexample} +\begin{lstlisting} + \draw (0,0) to[R=R1, v=$v$, name=R1, voltage=straight] ++(4,0) + to[R=R2, v=$v$, name=R2, voltage=american] ++(4,0) + to[R=R3, v=$v$, name=R3, voltage=raised] ++(4,0); +\end{lstlisting} -\begin{LTXexample}[varwidth=true] -\begin{circuitikz} - \draw (0,0) to[V, v=$a_1$] (2,0); +\begin{circuitikz}[] + \ctikzset{current/distance=0.2} + \draw (0,0) to[R=R1, v=$v$, name=R1, voltage=straight] ++(4,0) + to[R=R2, v=$v$, name=R2, voltage=american] ++(4,0) + to[R=R3, v=$v$, name=R3, voltage=raised] ++(4,0); + \foreach \i in {1, 2, 3} { + \path + (R\i-Vto) \showcoord(R\i-Vto)<-90:0.4> + (R\i-Vfrom) \showcoord(R\i-Vfrom)<-90:0.4> + (R\i-Vcont1) \showcoord(R\i-Vcont1)<135:0.6> + (R\i-Vcont2) \showcoord(R\i-Vcont2)<45:0.6> + (R\i-Vlab) \showcoord(R\i-Vlab)<-90:0.6> + ; + } \end{circuitikz} -\end{LTXexample} +Notice the postion of the control points, as well as the fact that the anchor available with \verb|\ctikzgetanchor| is applied to \texttt{Vfrom} and \texttt{Vto} symbols, too. -\begin{LTXexample}[varwidth=true] -\begin{circuitikz} - \draw (0,0) to[cV=$k\cdot a_1$] (2,0); -\end{circuitikz} -\end{LTXexample} +Finally, as ever, generators are treated differently, but you have all your anchors too. +\begin{lstlisting} + \ctikzset{american} + \draw (0,0) to[V=$v$, name=G1, voltage=european] ++(4,0) + to[V=$v$, v=$v$, name=G2, voltage=american] ++(4,0) + to[battery2, v=$v$, name=G3, voltage=raised] ++(4,0); +\end{lstlisting} -\begin{LTXexample}[varwidth=true] -\begin{circuitikz} - \draw (0,0) to[sV=$a_1$] (2,0); +\begin{circuitikz}[] + \ctikzset{american} + \draw (0,0) to[V=$v$, name=G1, voltage=european] ++(4,0) + to[V=$v$, v=$v$, name=G2, voltage=american] ++(4,0) + to[battery2, v=$v$, name=G3, voltage=raised] ++(4,0); + \foreach \i in {1, 2, 3} { + \path + (G\i-Vto) \showcoord(G\i-Vto)<-60:0.1> + (G\i-Vfrom) \showcoord(G\i-Vfrom)<-120:0.1> + (G\i-Vlab) \showcoord(G\i-Vlab)<90:0.3> + ; + } \end{circuitikz} -\end{LTXexample} -\begin{LTXexample}[varwidth=true] -\begin{circuitikz} - \draw (0,0) to[csV=$k\cdot a_1$] (2,0); -\end{circuitikz} -\end{LTXexample} +\subsubsection{Auxiliary information} -The following results from using the option \texttt{americanvoltage} or the style \texttt{[american voltages]}. +When the anchors are activated, there are additional macros that you can use: +\begin{itemize} + \item \texttt{\textbackslash ctikzgetanchor\{\emph{<name>}\}\{\emph{<anchor>}\}}: \emph{name} is the name of the bipole, and \emph{anchor} can be \texttt{Vlab}, \texttt{Fpos} or \texttt{Ipos}. This macro expands to the normal anchor position (something like \texttt{north}, \texttt{south west}). Notice that if you have not activated the corresponding anchor, the content of this macro is not specified. It could be equivalent to \verb|\relax| (basically, empty) or contains the anchor of a bipole with the same name from another drawing --- it's a global macro like the coordinates. + \item \texttt{\textbackslash ctikzgetdirection\{\emph{<name>}\}}: a number which is the direction of the \emph{name}d bipole. +\end{itemize} -\begin{LTXexample}[varwidth=true] -\begin{circuitikz}[american voltages] - \draw (0,0) to[V=$a_1$] (2,0); -\end{circuitikz} -\end{LTXexample} +For example, you could like the voltage label oriented with the bipole: -\begin{LTXexample}[varwidth=true] -\begin{circuitikz}[american voltages] - \draw (0,0) to[V, v=$a_1$] (2,0); +\begin{LTXexample}[varwidth=true, basicstyle=\small\ttfamily] +\begin{circuitikz}[] + \def\myvv#1#2{% + \draw [thin, blue, ->,] + (#1-Vfrom) .. controls (#1-Vcont1) and (#1-Vcont2).. (#1-Vto) + node [pos=0.5, below, + rotate=\ctikzgetdirection{#1}] at (#1-Vlab) {#2}; } + \draw (0,0) to[R, v, name=A] ++(3,0); + \draw (0,0) to[R, v, name=B] ++(3,3); + \myvv{A}{$v_A$}\myvv{B}{$v_B$} \end{circuitikz} \end{LTXexample} +Or you could use the anchor to substitute the flow with a fancy one and still position automatically the label; suppose you have the following definition in your preamble (see \TikZ{} manual, ``Path decorations''): -\begin{LTXexample}[varwidth=true] -\begin{circuitikz}[american voltages] - \draw (0,0) to[cV=$k v_e$] (2,0); -\end{circuitikz} -\end{LTXexample} - +\begin{lstlisting} +% requires \usetikzlibrary{decorations, decorations.pathmorphing} +\tikzset{% +lray/.style={decorate, decoration={ + snake, amplitude=2pt,pre length=1pt,post length=2pt, segment length=5pt,}, + -Triangle, +}} +\end{lstlisting} +\tikzset{% +lray/.style={decorate, decoration={ + snake, amplitude=2pt,pre length=1pt,post length=2pt, segment length=5pt, }, + -Triangle, +}} -\begin{LTXexample}[varwidth=true] -\begin{circuitikz}[american voltages] - \draw (0,0) to[sV=$a_1$] (2,0); -\end{circuitikz} -\end{LTXexample} +You can then define a kind of ``power flow'' style: -\begin{LTXexample}[varwidth=true] -\begin{circuitikz}[american voltages] - \draw (0,0) to[csV=$k v_e$] (2,0); +\begin{LTXexample}[varwidth=true, basicstyle=\small\ttfamily] +\begin{circuitikz}[] + \newcommand\myff[3][blue]{% [opt: color] node label + \draw [lray, #1, ] (#2-Ffrom) -- (#2-Fto) + node [anchor=\ctikzgetanchor{#2}{Flab}, inner sep=4pt] + at (#2-Fpos) {#3};} + \draw (0,1) to[R, f, name=A] ++(3,0); + \draw (0,0) to[R, f_<, name=B] ++(3,0); + \myff{A}{$P_A$}\myff[red]{B}{$P_B$} \end{circuitikz} \end{LTXexample} @@ -6195,30 +6371,6 @@ If the option {\ttfamily siunitx} is active (and \emph{not} in \ConTeXt), then t \end{circuitikz} \end{LTXexample} -\subsection{Accessing labels text nodes} - -Since 0.9.5, you can access all the labels nodes\footnote{The access to \texttt{label}s and \texttt{annotation}s was present before, but not documented.} using special node names. So, if you use \texttt{name} to give a name to the bipole node, you can access also the following nodes: \texttt{namelabel} (notice: no space nor any other symbol between \texttt{name} and \texttt{label}!), \texttt{nameannotation}, \texttt{namevoltage}, \texttt{namecurrent} and \texttt{nameflow}. - -\begin{LTXexample}[varwidth=true, - pos=t, basicstyle=\small\ttfamily - ] -\newcommand{\marknode}[2][45]{% - \node[circle, draw, red, inner sep=1pt, - pin={[red, font=\tiny]#1:#2}] at (#2.center) {}; -} -\begin{circuitikz}[ american] - \draw (0,0) to [R=L1, a=A1, name=L1] ++(3,0) - to [R, l2_=L2 and 2L, a^=A2, name=L2] ++(3,0); - \marknode{L1} \marknode{L1label} \marknode[0]{L1annotation} - \marknode{L2} \marknode[0]{L2label} \marknode{L2annotation} - \draw[blue] (L2label.south west) rectangle (L2label.north east); - \draw (6.1,0) to [R=R1, v=V1, i=I1, f>^=F1, name=R1] ++(3,0) - to [R, v<=V2, i^=I2, f>^=F2, name=R2] ++(3,0); - \marknode[0]{R1voltage} \marknode[0]{R2voltage} \marknode[90]{R1current} - \marknode[90]{R2current} \marknode{R1flow} \marknode{R2flow} -\end{circuitikz} -\end{LTXexample} - \section{Using bipoles in circuits} @@ -6354,7 +6506,7 @@ There are several predefined shorthand as the above; in the following pages you \end{circuitikz} \end{LTXexample} -\subsubsection{Transparent poles} +\subsubsection{Transparent poles}\label{sec:transparent-poles} ``Open-poles'' terminals (\texttt{ocirc}, \texttt{odiamondpole}, and \texttt{osquarepole}) are normally filled with the background color at full opacity. This is because, for simplicity of operation, the nodes are placed \emph{after} the wires are drawn and have to ``white-out'' the underlying lines. @@ -6363,14 +6515,16 @@ Anyway, \emph{if you know what you are doing}, you can change it with the key \t \begin{LTXexample}[pos=t, basicstyle=\small\ttfamily] \begin{circuitikz}[scale=3, transform shape] \fill[cyan] (0,0) rectangle (4.1,-0.6); - \tikzset{halfwhite/.style={fill opacity=0.5, fill=white, open poles opacity=0.5}} + \tikzset{open poles opacity=0.5} % automatic positioning when opacity is not 1.0 creates artifacts - \draw[halfwhite] (0,0) to[generic, -o] ++(2,0) --++(0,-0.5); + % note that opacity must go on the draw command for path-style components + \draw[fill opacity=0.5] (0,0) to[generic, fill=white, -o] ++(2,0) --++(0,-0.5); % you have to use manual positioning - \draw[halfwhite] (2.2,0) -- ++(0.5,0) node[ocirc, anchor=180]{}; - \draw[halfwhite] (3,0) node[ocirc](B){} (B.0) --++(0.5,0) (B.-90) --++(0,-0.5); + \draw (2.2,0) -- ++(0.5,0) node[ocirc, anchor=180, fill opacity=0.5]{}; + \draw (3,0) node[ocirc, fill opacity=0.5](B){} (B.0) --++(0.5,0) (B.-90) --++(0,-0.5); % maybe really useful only for terminals going out of the circuit... - \draw (3.6,0) -- ++(0.2,0) node[ocirc, halfwhite, anchor=180]{}; + % notice that in node commands you can specify the opacity directly + \draw (3.6,0) -- ++(0.2,0) node[ocirc, fill=white, fill opacity=0.5, anchor=180]{}; \end{circuitikz} \end{LTXexample} @@ -6457,9 +6611,17 @@ To correct the line ending, there are support shapes to fill the missing rectang \end{tikzpicture} \end{LTXexample} - \section{Colors} +Color support in \Circuitikz{} is quite limited. You will have no problem if: +\begin{enumerate} + \item You stick to use styles (see~\ref{sec:styling-fillcolor}) for filling your components, or using a direct \texttt{fill=...} option directly; + \item when coloring whole circuits, use the option \texttt{color=...} in your global picture options or in the \verb|\draw| command (not just the color name as a shorthand); + \item forget about transparency. +\end{enumerate} + +Nevertheless, if you really need to do strange things with colors you can read on; you can do almost everything but there are several glitches to take into account. + \subsection{Shape colors} The color of the components is stored in the key \verb!\circuitikzbasekey/color!. Circui\TikZ\ tries to follow the color set in \TikZ, although sometimes it fails. If you change color in the picture, please do not use just the color name as a style, like \verb![red]!, but rather assign the style \verb![color=red]!. @@ -6583,20 +6745,23 @@ A workaround is shown in port \texttt{3}: ;\end{circuitikz} \end{LTXexample} -Notice also that the connection point are always filled, although the color \emph{tries} to follow the color of the filling of the component: +Notice also that the connection point are always filled, although the color \emph{tries} to follow the color of the filling of the component (but look at section~\ref{sec:transparent-poles}). Moreover, if you want to pass fill transparency down to path-style components, you \emph{have} to put it into the options of the \verb|\draw| command. \begin{LTXexample}[varwidth=true, pos=t] \begin{circuitikz} \fill[cyan] (0,3.0) rectangle (7,7); - \draw [fill=yellow, ] (4,4) to [D,o-o] ++(0,2) to[D*, fill=yellow] ++(2,0) - to[D*] ++(0,-2) to[D, fill=red, o-o] ++(-2,0); - \draw (1,4) node[ocirc]{} -- ++(1,0) node[ocirc]{}; - \draw (1,4.5) to[short, o-o] ++(1,0) to[short, -o] ++(1,0); - \draw[fill=yellow] (1,5) to[short, o-o] ++(1,0) to[short, -o] ++(1,0); + \draw [fill opacity=0.5] (1,6.5) to[generic, fill=white,o-o] ++(2,0); \draw (1,5.5) to[short, fill=red, o-o] ++(1,0) to[short, -o] ++(1,0); + \draw[fill=yellow] (1,5) to[short, o-o] ++(1,0) to[short, -o] ++(1,0); + \draw (1,4.5) to[short, o-o] ++(1,0) to[short, -o] ++(1,0); + \draw (1,4) node[ocirc]{} -- ++(1,0) node[ocirc]{}; + \draw [thick, color=green!50!black] (4,4) to [D,o-o,fill=yellow] ++(0,2) to[D*, fill=yellow] + ++(2,0) to[D*,fill=yellow] ++(0,-2) to[D, fill=red, o-o] ++(-2,0); \end{circuitikz} \end{LTXexample} +As you can see, the ``black'' components (as \texttt{D*}) follow the color of the line, not the fill. + \section{FAQ} \noindent Q: When using \verb!\tikzexternalize! I get the following error: @@ -7197,3 +7362,4 @@ Here a series of example, contributed by several people, is shown with their cod \printindex \end{document} +% vim: set fdm=marker fmr=%<<<,%>>>: diff --git a/graphics/pgf/contrib/circuitikz/doc/ctikzmanutils.sty b/graphics/pgf/contrib/circuitikz/doc/ctikzmanutils.sty index 38bf7716fc..f402c9fa73 100644 --- a/graphics/pgf/contrib/circuitikz/doc/ctikzmanutils.sty +++ b/graphics/pgf/contrib/circuitikz/doc/ctikzmanutils.sty @@ -17,7 +17,7 @@ \RequirePackage{showexpl} \RequirePackage{ragged2e} % for some example we need them... -\usetikzlibrary{calc,fit} +\usetikzlibrary{calc,fit, decorations, decorations.pathmorphing} \RequirePackage{upgreek} % % The following trick is used to silence showexpl a bit, so that the @@ -135,6 +135,11 @@ [blue, inner sep=0.5pt, font=\small, pin distance=#3\pgf@circ@Rlen, pin edge={blue, }% ]#2:#1}](#1){}} + \def\showcoordwc[#1](#2)<#3:#4>{% + node[circle, #1, draw, inner sep=1pt,pin={% + [#1, inner sep=0.5pt, font=\small, + pin distance=#4\pgf@circ@Rlen, pin edge={#1, }% + ]#3:#2}](#2){}} \makeatother % show anchors of a node component: % optional: options of the circuitikz environment diff --git a/graphics/pgf/contrib/circuitikz/tex/circuitikz.sty b/graphics/pgf/contrib/circuitikz/tex/circuitikz.sty index 5f72a46277..c1e8d1808c 100644 --- a/graphics/pgf/contrib/circuitikz/tex/circuitikz.sty +++ b/graphics/pgf/contrib/circuitikz/tex/circuitikz.sty @@ -12,8 +12,8 @@ \NeedsTeXFormat{LaTeX2e} -\def\pgfcircversion{1.2.0} -\def\pgfcircversiondate{2020/06/21} +\def\pgfcircversion{1.2.1} +\def\pgfcircversiondate{2020/07/06} \ProvidesPackage{circuitikz}% [\pgfcircversiondate{} The CircuiTikz circuit drawing package version \pgfcircversion] diff --git a/graphics/pgf/contrib/circuitikz/tex/pgfcirc.defines.tex b/graphics/pgf/contrib/circuitikz/tex/pgfcirc.defines.tex index af70e82d75..e3686e4d94 100644 --- a/graphics/pgf/contrib/circuitikz/tex/pgfcirc.defines.tex +++ b/graphics/pgf/contrib/circuitikz/tex/pgfcirc.defines.tex @@ -9,9 +9,10 @@ % 2. under the GNU Public License. % % See the files gpl-3.0_license.txt and lppl-1-3c_license.txt for more details. - % -%% Key managements +% This file has folding marks for vim (See last line). +% +%% Key managements%<<<1 \long\def\pgf@circ@comment#1{} @@ -24,15 +25,17 @@ \def\ctikzvalof#1{\pgfkeysvalueof{\circuitikzbasekey/#1}} \def\ctikzsetvalof#1#2{\pgfkeyssetvalue{\circuitikzbasekey/#1}{#2}} -%% Temporary Counters +\pgfkeys{\circuitikzbasekey/.search also={/tikz}} +%%>>> +%% Temporary Counters and dimensions%<<<1 +%% Temporary Counters \newcount\pgf@circ@count@a \newcount\pgf@circ@count@b \newcount\pgf@circ@count@c %%%%%%%%%%%% %% Dimensions - -% coordinates +% coordinate \newdimen\pgf@circ@res@up \newdimen\pgf@circ@res@down \newdimen\pgf@circ@res@zero @@ -41,10 +44,19 @@ \newdimen\pgf@circ@res@other \newdimen\pgf@circ@res@step \newdimen\pgf@circ@res@temp +% Base len for all circuitikz +\newdimen\pgf@circ@Rlen +% scaled length for internal use in scalable shapes +\newdimen\pgf@circ@scaled@Rlen +\ctikzset{bipoles/length/.code={\pgf@circ@Rlen = #1\pgf@circ@scaled@Rlen=\pgf@circ@Rlen}} +\pgf@circ@Rlen = 1.4cm +% by default scale is 1.0 +\pgf@circ@scaled@Rlen=\pgf@circ@Rlen % inital thickness \newdimen \pgfstartlinewidth +%%>>> -% arrow tips, ported over old arrows library (deprecated) +% arrow tips, ported over old arrows library (deprecated)%<<<1 % see https://tex.stackexchange.com/questions/234084/latex-arrow-tip-with-arrows-meta-library % this was the original definition of latex' tips, renamed to avoid clashes % @@ -76,6 +88,9 @@ } \pgfarrowsdeclarereversed{latexslim reversed}{latexslim reversed}{latexslim}{latexslim} +%%>>> + +%% Macros to do things depending on the class%<<<1 \def\pgf@circ@setifdefinedfill#1#2{% % if \ctikzclass is defined and \ctikzclass/fill is defined and is not none: @@ -150,8 +165,9 @@ } % use \pgf@circ@setlinewidth{none}{\pgflinewidth} if there is no legacy case \ctikzset{none/thickness/.initial=1.0} % do not touch +%%>>> -%% font changes compatible with plain/LaTeX/ConTeXt +%% font changes compatible with plain/LaTeX/ConTeXt%<<<1 %% thanks to Henri Menke https://github.com/circuitikz/circuitikz/issues/285#issuecomment-537224605 \ifpgfutil@format@is@latex @@ -203,8 +219,10 @@ {{}}% #1 is \relax, so consider empty {\expandafter{#1}}% otherwise, leave the key after one more expansion }% -% -% text position (added with ieeestd logic ports. Maybe to be extended to other components, +%>>> + +% text position in some component.%<<<1 +% (added with ieeestd logic ports. Maybe to be extended to other components, % like amplifiers) % \newif\ifpgf@circ@center@text\pgf@circ@center@texttrue @@ -215,8 +233,9 @@ \ctikzset{component text/center/.code={\pgf@circ@center@texttrue}}% \ctikzset{component text/left/.code={\pgf@circ@center@textfalse}}% \ctikzset{left text distance/.initial=0.3em}% +%>>> -% voltage options +% voltage direction options%<<<1 \newif\ifpgf@circ@siunitx \newif\ifpgf@circuit@compat @@ -229,54 +248,109 @@ \ctikzset{voltage dir/noold/.code={\pgf@circ@oldvoltagedirectionfalse\pgf@circ@fixbatteriesfalse}} \ctikzset{voltage dir/RP/.code={\pgf@circ@oldvoltagedirectiontrue\pgf@circ@fixbatteriestrue}} \ctikzset{voltage dir/EF/.code={\pgf@circ@oldvoltagedirectionfalse\pgf@circ@fixbatteriestrue}} -\tikzset{voltage dir/.style={circuitikz/voltage dir=#1}} +\tikzset{voltage dir/.style={circuitikz/voltage dir=#1}}% +%>>> -% Option ">" for twoports -\newif\ifpgf@circuit@inputarrow -\ctikzset{>/.add code={}{\pgf@circuit@inputarrowtrue}} -\ctikzset{inputarrow/.is choice} -\ctikzset{inputarrow/true/.code={\pgf@circuit@inputarrowtrue}} -\ctikzset{inputarrow/false/.code={\pgf@circuit@inputarrowfalse}} +% bipole definitions for path component and text decorations%%<<<1 +% +% Option "t=*" for nodes +\pgfkeys{/tikz/t/.add code={}{\ctikzset{text=#1}}} +% +\ctikzset{bipole/.is family} +\ctikzset{bipole/kind/.initial=} +\ctikzset{bipole/name/.initial=} +\newif\ifpgf@circuit@bipole@isvoltage +\ctikzset{bipole/is voltage/.is if=pgf@circuit@bipole@isvoltage} +\newif\ifpgf@circuit@bipole@voltageoutsideofsymbol +\ctikzset{bipole/is voltageoutsideofsymbol/.is if=pgf@circuit@bipole@voltageoutsideofsymbol} +\newif\ifpgf@circuit@bipole@strokedsymbol +\ctikzset{bipole/is strokedsymbol/.is if=pgf@circuit@bipole@strokedsymbol} +\newif\ifpgf@circuit@bipole@iscurrent +\ctikzset{bipole/is current/.is if=pgf@circuit@bipole@iscurrent} -% Option "boxed" for nodes and twoports -\newif\ifpgf@circuit@boxed -\pgfkeys{/tikz/boxed/.add code={}{\pgf@circuit@boxedtrue}} -\ctikzset{boxed/.add code={}{\pgf@circuit@boxedtrue}} -\pgfkeys{/tikz/box/.add code={}{\pgf@circuit@boxedtrue}} -\ctikzset{box/.add code={}{\pgf@circuit@boxedtrue}} +\ctikzset{bipole/voltage/.is family} +\newif\ifpgf@circuit@bipole@voltage@backward +\ctikzset{bipole/voltage/direction/.is choice} +\ctikzset{bipole/voltage/direction/forward/.code={\pgf@circuit@bipole@voltage@backwardfalse}} +\ctikzset{bipole/voltage/direction/backward/.code={\pgf@circuit@bipole@voltage@backwardtrue}} +\newif\ifpgf@circuit@bipole@voltage@below +\ctikzset{bipole/voltage/position/.is choice} +\ctikzset{bipole/voltage/position/above/.code={\pgf@circuit@bipole@voltage@belowfalse}} +\ctikzset{bipole/voltage/position/below/.code={\pgf@circuit@bipole@voltage@belowtrue}} -% Option "dashed" for nodes and twoports -\newif\ifpgf@circuit@dashed -\pgfkeys{/tikz/dashed/.add code={}{\pgf@circuit@dashedtrue}} -\ctikzset{dashed/.add code={}{\pgf@circuit@dashedtrue}} +\ctikzset{bipole/voltage/label/unit/.initial=} +\ctikzset{bipole/voltage/label/name/.initial=} -% Option "t=*" for nodes -\pgfkeys{/tikz/t/.add code={}{\ctikzset{text=#1}}} +\ctikzset{bipole/current/.is family} +\newif\ifpgf@circuit@bipole@current@backward +\ctikzset{bipole/current/direction/.is choice} +\ctikzset{bipole/current/direction/forward/.code={\pgf@circuit@bipole@current@backwardfalse}} +\ctikzset{bipole/current/direction/backward/.code={\pgf@circuit@bipole@current@backwardtrue}} +\newif\ifpgf@circuit@bipole@current@before +\ctikzset{bipole/current/x position/.is choice} +\ctikzset{bipole/current/x position/after/.code={\pgf@circuit@bipole@current@beforefalse}} +\ctikzset{bipole/current/x position/before/.code={\pgf@circuit@bipole@current@beforetrue}} +\newif\ifpgf@circuit@bipole@current@below +\ctikzset{bipole/current/y position/.is choice} +\ctikzset{bipole/current/y position/above/.code={\pgf@circuit@bipole@current@belowfalse}} +\ctikzset{bipole/current/y position/below/.code={\pgf@circuit@bipole@current@belowtrue}} +\ctikzset{bipole/current/label/unit/.initial=} +\ctikzset{bipole/current/label/name/.initial=} -\ctikzset{current arrow scale/.initial=16} +\ctikzset{bipole/flow/.is family} +\newif\ifpgf@circuit@bipole@flow@backward +\ctikzset{bipole/flow/direction/.is choice} +\ctikzset{bipole/flow/direction/forward/.code={\pgf@circuit@bipole@flow@backwardfalse}} +\ctikzset{bipole/flow/direction/backward/.code={\pgf@circuit@bipole@flow@backwardtrue}} +\newif\ifpgf@circuit@bipole@flow@before +\ctikzset{bipole/flow/x position/.is choice} +\ctikzset{bipole/flow/x position/after/.code={\pgf@circuit@bipole@flow@beforefalse}} +\ctikzset{bipole/flow/x position/before/.code={\pgf@circuit@bipole@flow@beforetrue}} +\newif\ifpgf@circuit@bipole@flow@below +\ctikzset{bipole/flow/y position/.is choice} +\ctikzset{bipole/flow/y position/above/.code={\pgf@circuit@bipole@flow@belowfalse}} +\ctikzset{bipole/flow/y position/below/.code={\pgf@circuit@bipole@flow@belowtrue}} +\ctikzset{bipole/flow/label/unit/.initial=} +\ctikzset{bipole/flow/label/name/.initial=} +\ctikzset{flow/distance/.initial = .5} +\ctikzset{flow/offset/.initial = .2}%distance between flow-arrow and conductor -\ctikzset{bipoles/.is family} +\ctikzset{bipole/label/.is family} +\ctikzset{bipole/label/position/.initial=90} +\ctikzset{bipole/label/unit/.initial=} +\ctikzset{bipole/label/name/.initial=} +\ctikzset{bipole/annotation/.is family} +\ctikzset{bipole/annotation/position/.initial=-90} +\ctikzset{bipole/annotation/unit/.initial=} +\ctikzset{bipole/annotation/name/.initial=} + +\newif\ifpgf@circ@siunitx +\newif\ifpgf@circ@siunitx@res + +\ctikzset{label/align/.is choice} +\ctikzset{label/align/straight/.code={\ctikzsetvalof{label/align}{straight}}} +\ctikzset{label/align/rotate/.code={\ctikzsetvalof{label/align}{rotate}}} +\ctikzset{label/align/smart/.code={\ctikzsetvalof{label/align}{smart}}} +%%>>> + +% traditional styles %<<<1 +% +\ctikzset{thickness/.initial=2} +\ctikzset{color/.initial=black} +\pgfkeys{/tikz/color/.add code={}{\ctikzset{color={#1}}}} \ctikzset{bipoles/border margin/.initial=1.1} \ctikzset{bipoles/thickness/.initial=2} \ctikzset{tripoles/thickness/.initial=2} \ctikzset{quadpoles/thickness/.initial=2} \ctikzset{nodes width/.initial=.04} +%%>>> -% Base len for all circuitikz -\newdimen\pgf@circ@Rlen -% scaled length for internal use in scalable shapes -\newdimen\pgf@circ@scaled@Rlen -\ctikzset{bipoles/length/.code={\pgf@circ@Rlen = #1\pgf@circ@scaled@Rlen=\pgf@circ@Rlen}} -\pgf@circ@Rlen = 1.4cm -% by default scale is 1.0 -\pgf@circ@scaled@Rlen=\pgf@circ@Rlen +% Styles definitions and macros%<<<1 %%%%%%%%%%%%%%%%%%%%%%%%%%%% %% main style definitions %%%%%%%%%%%%%%%%%%%%%%%%%%%% - - % load a style file: search ctikzstyle-NAME.tex in path \def\ctikzloadstyle#1{% \pgfutil@InputIfFileExists{ctikzstyle-#1}{}{% @@ -395,8 +469,15 @@ \ctikzset{displays/scale/.initial=1.0} \ctikzset{displays/fill/.initial=none} \ctikzset{displays/thickness/.initial=none} +% +% general styles +% +\tikzset{european/.style = {european currents, european voltages, european resistors, european inductors, european ports, european gas filled surge arrester set}} +\tikzset{american/.style = {american currents, american voltages, american resistors, american inductors, american ports, american gas filled surge arrester set}} +\tikzset{cute/.style = {european currents, european voltages, american resistors, cute inductors, american ports}} +%%>>> -% grounds and power supplies +% grounds and power supplies%<<<1 \ctikzset{monopoles/.is family} \ctikzset{monopoles/ground/width/.initial=.25} @@ -423,24 +504,28 @@ \ctikzset{monopoles/bareantenna/width/.initial=.25} \ctikzset{monopoles/bareantenna/label/xanchor/.initial=1} \ctikzset{monopoles/bareantenna/label/yanchor/.initial=0.5} -\ctikzset{monopoles/waves/width/.initial=0.5} +\ctikzset{monopoles/waves/width/.initial=0.5}% +%>>> -% microstrips +% microstrips %<<<1 \ctikzset{bipoles/mstline/height/.initial=0.3} \ctikzset{bipoles/mstline/width/.initial=1.2} \pgfkeys{/tikz/mstlinelen/.add code={}{\ctikzset{bipoles/mstline/width=#1}}} \ctikzset{monopoles/msport/width/.initial=.5} \ctikzset{monopoles/msrstub/height/.initial=1.0} -\ctikzset{monopoles/msrstub/width/.initial=0.6} +\ctikzset{monopoles/msrstub/width/.initial=0.6}% +%>>> -% microphone and loudspeaker +% microphone and loudspeaker%<<<1 \ctikzset{bipoles/loudspeaker/height/.initial=.8} \ctikzset{bipoles/loudspeaker/depth/.initial=.3} \ctikzset{bipoles/loudspeaker/width/.initial=.8} \ctikzset{bipoles/mic/height/.initial=1.2} \ctikzset{bipoles/mic/depth/.initial=.1} -\ctikzset{bipoles/mic/width/.initial=.8} +\ctikzset{bipoles/mic/width/.initial=.8}% +%>>> +% resistors%<<<1 % Zig Zag resistors \ctikzset{resistors/zigs/.initial=3} \ctikzset{resistors/width/.code={% @@ -501,8 +586,19 @@ \ctikzset{bipoles/tgeneric/height/.initial=.70} \ctikzset{bipoles/tgeneric/width/.initial=.80} \ctikzset{bipoles/ageneric/width/.initial=.80} +\ctikzset{bipoles/memristor/height/.initial=.30} +\ctikzset{bipoles/memristor/wave height/.initial=.5} +\ctikzset{bipoles/memristor/width/.initial=.80} -%% Capacitors +\newif\ifpgf@circuit@europeanresistor +\ctikzset{resistor/.is choice} +\ctikzset{resistor/american/.code = \pgf@circuit@europeanresistorfalse } +\ctikzset{resistor/european/.code = \pgf@circuit@europeanresistortrue } +\tikzset{american resistors/.style = {\circuitikzbasekey/resistor = american}} +\tikzset{european resistors/.style = {\circuitikzbasekey/resistor = european}} +%%>>> + +%% Capacitors%<<<1 \ctikzset{bipoles/capacitor/height/.initial=.6} \ctikzset{bipoles/capacitor/width/.initial=.2} \ctikzset{bipoles/ecapacitor/height/.initial=.5} @@ -519,9 +615,10 @@ \ctikzset{bipoles/vcapacitor/width/.initial=.5} \ctikzset{bipoles/vcapacitor/capacitor width/.initial=.4} \ctikzset{bipoles/piezoelectric/height/.initial=.7} -\ctikzset{bipoles/piezoelectric/width/.initial=.5} +\ctikzset{bipoles/piezoelectric/width/.initial=.5}% +%>>> -% Inductors +% Inductors%<<<1 \ctikzset{inductors/coils/.code={% \ctikzset{bipoles/cuteinductor/coils=#1}% \ctikzset{bipoles/cutechoke/coils=#1}% @@ -578,8 +675,20 @@ \ctikzset{bipoles/tfullgeneric/width/.initial=.80} \ctikzset{bipoles/fullgeneric/height/.initial=.30} \ctikzset{bipoles/fullgeneric/width/.initial=.80} +\ctikzset{inductor/.is choice} +\ctikzset{inductor/cute/.code={\ctikzsetvalof{inductor}{cute}}} +\ctikzset{inductor/european/.code={\ctikzsetvalof{inductor}{european}}} +\ctikzset{inductor/american/.code={\ctikzsetvalof{inductor}{american}}} + +\tikzset{american inductors/.style = {\circuitikzbasekey/inductor = american}} +\tikzset{european inductors/.style = {\circuitikzbasekey/inductor = european}} +\tikzset{cute inductors/.style = {\circuitikzbasekey/inductor = cute}} +\tikzset{american ports/.style = {\circuitikzbasekey/logic ports = american}} +\tikzset{european ports/.style = {\circuitikzbasekey/logic ports = european}} -% Sources +%%>>> + +% Sources%<<<1 \ctikzset{bipoles/esource/height/.initial=.60} \ctikzset{bipoles/esource/width/.initial=.60} @@ -632,7 +741,12 @@ \ctikzset{bipoles/battery1/width/.initial=.3} \ctikzset{bipoles/battery2/height/.initial=.6} \ctikzset{bipoles/battery2/width/.initial=.3} +% noise sources +\ctikzset{bipoles/noise sources/fillcolor/.initial=gray!50} +%%>>> + +% "oo" style transformers and power grid diagrams%<<<1 % % % ootransformer \ctikzset{bipoles/oosourcetrans/height/.initial=.6} \ctikzset{bipoles/oosourcetrans/width/.initial=.6} @@ -671,9 +785,10 @@ \pgfkeys{tikz/tert/.is choice} \pgfkeys{tikz/tert/delta/.add code={}{\pgf@circ@tert@deltatrue}} \pgfkeys{tikz/tert/wye/.add code={}{\pgf@circ@tert@wyetrue}} -\pgfkeys{tikz/tert/zig/.add code={}{\pgf@circ@tert@zigtrue}} +\pgfkeys{tikz/tert/zig/.add code={}{\pgf@circ@tert@zigtrue}}% +%>>> -% diodes +% diodes%<<<1 \ctikzset{bipoles/diode/height/.initial=.50} \ctikzset{bipoles/diode/width/.initial=.40} @@ -683,8 +798,52 @@ \ctikzset{bipoles/bidirectionaldiode/diode width right/.initial=.3} \ctikzset{bipoles/varcap/height/.initial=.50} \ctikzset{bipoles/varcap/width/.initial=.45} +\ctikzset{tripoles/thyristor/height/.initial=1.10} +\ctikzset{tripoles/thyristor/height 2/.initial=.5} +\ctikzset{tripoles/thyristor/width/.initial=1.0} +\ctikzset{tripoles/thyristor/diode height/.initial=.5} +\ctikzset{tripoles/thyristor/diode width left/.initial=.4} +\ctikzset{tripoles/thyristor/diode width right/.initial=.3} + +\ctikzset{tripoles/triac/height/.initial=1.1} +\ctikzset{tripoles/triac/width/.initial=1} +\ctikzset{tripoles/triac/diode width left/.initial=.3} +\ctikzset{tripoles/triac/diode width right/.initial=.3} +% +% Flipping arrows in LED and photodiodes +% +\newif\ifpgf@led@fliparrows +\newif\ifpgf@pd@fliparrows +\pgf@led@fliparrowsfalse +\pgf@pd@fliparrowsfalse +% +% by default the arrows start (LED) and go (PD) to the anode. +% +\ctikzset{led arrows from anode/.code=\pgf@led@fliparrowsfalse} +\ctikzset{pd arrows to anode/.code=\pgf@pd@fliparrowsfalse} +% +% but they can start form the cathode (LED) or go to it (PD) +% +\ctikzset{led arrows from cathode/.code=\pgf@led@fliparrowstrue} +\ctikzset{pd arrows to cathode/.code=\pgf@pd@fliparrowstrue} -% switches +\newif\ifpgf@circuit@strokediode +\newif\ifpgf@circuit@fulldiode +\pgf@circuit@strokediodefalse +\pgf@circuit@fulldiodefalse + +\ctikzset{diode/.is choice} +\ctikzset{diode/empty/.code = \pgf@circuit@fulldiodefalse\pgf@circuit@strokediodefalse}%default +\ctikzset{diode/full/.code = \pgf@circuit@fulldiodetrue } +\ctikzset{diode/stroke/.code = \pgf@circuit@strokediodetrue} + +\tikzset{full diodes/.style = { \circuitikzbasekey/diode = full}} +\tikzset{empty diodes/.style = { \circuitikzbasekey/diode = empty}} +\tikzset{stroke diodes/.style = { \circuitikzbasekey/diode = stroke}} + +%%>>> + +% switches%<<<1 \ctikzset{bipoles/spst/height/.initial=.35} \ctikzset{bipoles/spst/width/.initial=.35} @@ -695,12 +854,30 @@ \ctikzset{bipoles/ncs/height/.initial=.35} \ctikzset{bipoles/ncs/width/.initial=.35} \ctikzset{bipoles/ncs/depth/.initial=.2} +\ctikzset{bipoles/pushbutton/height/.initial=.5} +\ctikzset{bipoles/pushbutton/height 2/.initial=.2} +\ctikzset{bipoles/pushbutton/width/.initial=.50} %%% reed switch \ctikzset{bipoles/reed/height/.initial=.4} \ctikzset{bipoles/reed/width/.initial=.8}% 0.35 in nos \ctikzset{bipoles/reed/depth/.initial=.4} +%% Cute switches +\ctikzset{bipoles/cuteswitch/shape/.initial={ocirc}} +\ctikzset{bipoles/cuteswitch/height/.initial=.6} +\ctikzset{bipoles/cuteswitch/height 2/.initial=.2} +\ctikzset{bipoles/cuteswitch/width/.initial=.50} +\ctikzset{bipoles/cuteswitch/thickness/.initial=1} -% misc +\ctikzset{tripoles/spdt/width/.initial=.85} +\ctikzset{tripoles/spdt/height/.initial=.45} +\ctikzset{tripoles/spdt/margin/.initial=.45} + +\ctikzset{tripoles/toggleswitch/height/.initial=.8} +\ctikzset{tripoles/toggleswitch/height 2/.initial=.0} +\ctikzset{tripoles/toggleswitch/width/.initial=.80} +%%>>> + +% arresters, fuses, lamps, etc%<<<1 \ctikzset{bipoles/european gas filled surge arrester/height/.initial=.30} \ctikzset{bipoles/european gas filled surge arrester/width/.initial=.80} @@ -715,9 +892,31 @@ \ctikzset{bipoles/fuse/width/.initial=.50} \ctikzset{bipoles/afuse/height/.initial=.20} \ctikzset{bipoles/afuse/width/.initial=.50} -\ctikzset{bipoles/memristor/height/.initial=.30} -\ctikzset{bipoles/memristor/wave height/.initial=.5} -\ctikzset{bipoles/memristor/width/.initial=.80} +\ctikzset{bipoles/lamp/height/.initial=.60} +\ctikzset{bipoles/lamp/width/.initial=.60} +\ctikzset{bipoles/bulb/height/.initial=.8} +\ctikzset{bipoles/bulb/width/.initial=.8} +\ctikzset{bipoles/tline/height/.initial=.3} +\ctikzset{bipoles/tline/width/.initial=.8} +\ctikzset{bipoles/squid/height/.initial=.60} +\ctikzset{bipoles/squid/width/.initial=.60} +\ctikzset{bipoles/barrier/height/.initial=.60} +\ctikzset{bipoles/barrier/width/.initial=.60} +\ctikzset{bipoles/openbarrier/gap/.initial=0.5} +\ctikzset{bipoles/thermocouple/height/.initial=.250} +\ctikzset{bipoles/thermocouple/height 2/.initial=.60} +\ctikzset{bipoles/thermocouple/width/.initial=.140} +\newif\ifpgf@circuit@europeangfsurgearrester +\ctikzset{gas filled surge arrester choice/.is choice} +\ctikzset{gas filled surge arrester choice/european/.code= {\pgf@circuit@europeangfsurgearrestertrue}} +\ctikzset{gas filled surge arrester choice/american/.code= {\pgf@circuit@europeangfsurgearresterfalse}} + +\tikzset{american gas filled surge arrester set/.style = {\circuitikzbasekey/gas filled surge arrester choice=american}} +\tikzset{european gas filled surge arrester set/.style = {\circuitikzbasekey/gas filled surge arrester choice=european}} +%%>>> + +% wires (open, shorts, ...)%<<<1 + \ctikzset{bipoles/open/height/.initial=.3} %necessary for curly voltages \ctikzset{bipoles/open/width/.initial=.3} %necessary for curly voltages \ctikzset{bipoles/open/voltage/straight label distance/.initial=0} @@ -728,7 +927,11 @@ \ctikzset{bipoles/multiwire/height/.initial=0.4} \ctikzset{bipoles/multiwire/width/.initial=0.2} \ctikzset{bipoles/multiwire/spacing/.initial=0.05} +% crossing wires +\ctikzset{bipoles/crossing/size/.initial=.2} +%%>>> +% Instruments %<<<1 \ctikzset{bipoles/ammeter/height/.initial=.60} \ctikzset{bipoles/ammeter/width/.initial=.60} \ctikzset{bipoles/ohmmeter/height/.initial=.60} @@ -759,30 +962,9 @@ \ctikzset{straight instruments/.add code={}{\pgf@circuit@straightinstrumentstrue}} \pgfkeys{/tikz/rotated instruments/.add code={}{\pgf@circuit@straightinstrumentsfalse}} \ctikzset{rotated instruments/.add code={}{\pgf@circuit@straightinstrumentsfalse}} +%%>>> - -\ctikzset{bipoles/buffer/height/.initial=1} -\ctikzset{bipoles/buffer/width/.initial=1} -\ctikzset{bipoles/not port/width/.initial=1} -\ctikzset{bipoles/not port/height/.initial=.8} -\ctikzset{bipoles/not port/circle width/.initial=.15} -\ctikzset{bipoles/lamp/height/.initial=.60} -\ctikzset{bipoles/lamp/width/.initial=.60} -\ctikzset{bipoles/bulb/height/.initial=.8} -\ctikzset{bipoles/bulb/width/.initial=.8} -\ctikzset{bipoles/tline/height/.initial=.3} -\ctikzset{bipoles/tline/width/.initial=.8} -\ctikzset{bipoles/squid/height/.initial=.60} -\ctikzset{bipoles/squid/width/.initial=.60} -\ctikzset{bipoles/barrier/height/.initial=.60} -\ctikzset{bipoles/barrier/width/.initial=.60} -\ctikzset{bipoles/openbarrier/gap/.initial=0.5} -\ctikzset{bipoles/thermocouple/height/.initial=.250} -\ctikzset{bipoles/thermocouple/height 2/.initial=.60} -\ctikzset{bipoles/thermocouple/width/.initial=.140} -\ctikzset{bipoles/pushbutton/height/.initial=.5} -\ctikzset{bipoles/pushbutton/height 2/.initial=.2} -\ctikzset{bipoles/pushbutton/width/.initial=.50} +% blocks (twoports and so)%<<<1 \ctikzset{bipoles/twoport/width/.initial=.7} \ctikzset{bipoles/twoport/height/.initial=.7} @@ -805,11 +987,16 @@ \ctikzset{bipoles/phaseshifter/width/.initial=.7} \ctikzset{bipoles/vphaseshifter/width/.initial=.7} \ctikzset{bipoles/detector/width/.initial=.7} +\ctikzset{tripoles/mixer/width/.initial=0.7} +\ctikzset{tripoles/adder/width/.initial=0.7} +\ctikzset{tripoles/circulator/width/.initial=.7} +\ctikzset{tripoles/oscillator/width/.initial=.7} -% crossing wires -\ctikzset{bipoles/crossing/size/.initial=.2} +\ctikzset{tripoles/wilkinson/height/.initial=1.3} +\ctikzset{tripoles/wilkinson/width/.initial=1.3} +%%>>> -% Transistors starts here +% Transistors %<<<1 \newif\ifpgf@circuit@trans@depletiontype \pgf@circuit@trans@depletiontypefalse @@ -1203,10 +1390,44 @@ \ctikzset{tripoles/bjt/pnp/curr direction/.initial=-1} %% transistors stop here +%%>>> + +% Electronic tubes: diodetube, triode, tetrode and pentode%<<<1 +\ctikzset{tubes/width/.initial=1} % relative width +\ctikzset{tubes/height/.initial=1.4} % relative height +\ctikzset{tubes/tube radius/.initial=0.40} % radius of tube circle +\ctikzset{tubes/anode distance/.initial=0.40} % distance from center +\ctikzset{tubes/anode width/.initial=0.40} % width of an anode/plate +\ctikzset{tubes/grid protrusion/.initial=0.25} % distance from center +\ctikzset{tubes/grid dashes/.initial=5} % number of grid dashes +\ctikzset{tubes/grid separation/.initial=0.2} % separation between grids +\ctikzset{tubes/grid shift/.initial=0.0} % y shift grids from center +\ctikzset{tubes/cathode distance/.initial=0.40} % distance from grid +\ctikzset{tubes/cathode width/.initial=0.40} % width of an cathode +\ctikzset{tubes/cathode corners/.initial=0.06} % corners of the cathode wire +\ctikzset{tubes/cathode right extend/.initial=0.075} % extension at the right side +\ctikzset{tubes/filament distance/.initial=0.1} % distance from cathode +\ctikzset{tubes/filament angle/.initial=15} % Angle from centerpoint + +\newif\ifpgf@circuit@tubes@filament\pgf@circuit@tubes@filamentfalse +\pgfkeys{/tikz/filament/.add code={}{\pgf@circuit@tubes@filamenttrue}} +\ctikzset{tubes/filament/.add code={}{\pgf@circuit@tubes@filamenttrue}} +\newif\ifpgf@circuit@tubes@nocathode\pgf@circuit@tubes@nocathodefalse +\pgfkeys{/tikz/nocathode/.add code={}{\pgf@circuit@tubes@nocathodetrue}} +\ctikzset{tubes/nocathode/.add code={}{\pgf@circuit@tubes@nocathodetrue}} +\newif\ifpgf@circuit@tubes@fullcathode\pgf@circuit@tubes@fullcathodefalse +\pgfkeys{/tikz/fullcathode/.add code={}{\pgf@circuit@tubes@fullcathodetrue}} +\ctikzset{tubes/fullcathode/.add code={}{\pgf@circuit@tubes@fullcathodetrue}}% +%>>> -%% Logic ports +%% Logic ports%<<<1 %% beware that the third option is in IEEE ports in pgfcircmultipoles.tex +% switches for logic gates +% +\pgfkeys{/tikz/number inputs/.initial=0} +\pgfkeys{/tikz/number inputs/.default=0} + \newif\ifpgf@circuit@europeanlogicport \ctikzset{logic ports/.is choice} \ctikzset{logic ports/european/.code= {\pgf@circuit@europeanlogicporttrue @@ -1296,6 +1517,12 @@ \tikzset{all leads/.code={\pgfcirc@draw@output@leadstrue\pgfcirc@draw@input@leadstrue}} \tikzset{no leads/.code={\pgfcirc@draw@output@leadsfalse\pgfcirc@draw@input@leadsfalse}} +% old, legacy keys that should be killed over +\ctikzset{bipoles/buffer/height/.initial=1} +\ctikzset{bipoles/buffer/width/.initial=1} +\ctikzset{bipoles/not port/width/.initial=1} +\ctikzset{bipoles/not port/height/.initial=.8} +\ctikzset{bipoles/not port/circle width/.initial=.15} \ctikzset{tripoles/american and port/width/.initial=1.1} \ctikzset{tripoles/american and port/height/.initial=.8} @@ -1429,10 +1656,9 @@ \ctikzset{tripoles/american xnor port/bbb/.initial=.4} \ctikzset{tripoles/american xnor port/ccc/.initial=.5} \ctikzset{tripoles/american xnor port/ddd/.initial=.0} -% switches for logic gates -% -\pgfkeys{/tikz/number inputs/.initial=0} -\pgfkeys{/tikz/number inputs/.default=0} +%%>>> + +% flip flops and muxdemxes%<<<1 %% flip-flop specific keys (most others are the same as chips) @@ -1455,7 +1681,10 @@ \ctikzset{multipoles/muxdemux/NR/.initial=1} \ctikzset{multipoles/muxdemux/NB/.initial=3} \ctikzset{multipoles/muxdemux/NT/.initial=0} -\ctikzset{multipoles/muxdemux/square pins/.initial=0} +\ctikzset{multipoles/muxdemux/square pins/.initial=0}% +%>>> + +% Amplifiers%<<<1 % % switches for op amps % changing input polarity @@ -1576,42 +1805,9 @@ \tikzset{amp minus/.code={\ctikzsetvalof{amplifiers/minus}{#1}}} \def\pgf@circ@ampli@plus{\ctikzvalof{amplifiers/plus}} \def\pgf@circ@ampli@minus{\ctikzvalof{amplifiers/minus}} +%%>>> -\ctikzset{tripoles/thyristor/height/.initial=1.10} -\ctikzset{tripoles/thyristor/height 2/.initial=.5} -\ctikzset{tripoles/thyristor/width/.initial=1.0} -\ctikzset{tripoles/thyristor/diode height/.initial=.5} -\ctikzset{tripoles/thyristor/diode width left/.initial=.4} -\ctikzset{tripoles/thyristor/diode width right/.initial=.3} - -\ctikzset{tripoles/triac/height/.initial=1.1} -\ctikzset{tripoles/triac/width/.initial=1} -\ctikzset{tripoles/triac/diode width left/.initial=.3} -\ctikzset{tripoles/triac/diode width right/.initial=.3} - -%% Cute switches -\ctikzset{bipoles/cuteswitch/shape/.initial={ocirc}} -\ctikzset{bipoles/cuteswitch/height/.initial=.6} -\ctikzset{bipoles/cuteswitch/height 2/.initial=.2} -\ctikzset{bipoles/cuteswitch/width/.initial=.50} -\ctikzset{bipoles/cuteswitch/thickness/.initial=1} - -\ctikzset{tripoles/spdt/width/.initial=.85} -\ctikzset{tripoles/spdt/height/.initial=.45} -\ctikzset{tripoles/spdt/margin/.initial=.45} - -\ctikzset{tripoles/toggleswitch/height/.initial=.8} -\ctikzset{tripoles/toggleswitch/height 2/.initial=.0} -\ctikzset{tripoles/toggleswitch/width/.initial=.80} - -\ctikzset{tripoles/mixer/width/.initial=0.7} -\ctikzset{tripoles/adder/width/.initial=0.7} -\ctikzset{tripoles/circulator/width/.initial=.7} -\ctikzset{tripoles/oscillator/width/.initial=.7} - - -\ctikzset{tripoles/wilkinson/height/.initial=1.3} -\ctikzset{tripoles/wilkinson/width/.initial=1.3} +% Transformers%<<<1 \ctikzset{quadpoles/transformer/inner/.initial=0.4} \ctikzset{quadpoles/transformer/width/.initial=1.5} @@ -1654,9 +1850,105 @@ \ctikzset{quadpoles/gyrator/width=0.6}% }% } +%%>>> + +% seven segment displays by RGtti%<<<1 +\newif\ifpgf@circ@sevenseg@dot +\newif\ifpgf@circ@sevenseg@box +\def\pgf@circ@sevenseg@dotstate{empty} +\ctikzset{seven seg/.is family} +\ctikzset{seven seg/dot/.is choice} +% none means no dot, not space for it. Empty means no dot, but space +\ctikzset{seven seg/dot/none/.code={\pgf@circ@sevenseg@dotfalse}} +\ctikzset{seven seg/dot/empty/.code={\pgf@circ@sevenseg@dottrue\def\pgf@circ@sevenseg@dotstate{empty}}} +\ctikzset{seven seg/dot/off/.code={\pgf@circ@sevenseg@dottrue\def\pgf@circ@sevenseg@dotstate{off}}} +\ctikzset{seven seg/dot/on/.code={\pgf@circ@sevenseg@dottrue\def\pgf@circ@sevenseg@dotstate{on}}} % -% multipoles +\ctikzset{seven seg/width/.initial=0.4}% relative to \pgf@circ@Rlen +\ctikzset{seven seg/thickness/.initial=4pt}% segment thickness +\ctikzset{seven seg/segment sep/.initial=0.2pt}% gap between segments +\ctikzset{seven seg/box sep/.initial=1pt}% external box gap +\ctikzset{seven seg/color on/.initial=red}% color for segment "on" +\ctikzset{seven seg/color off/.initial=gray!20!white} % ...and "off" +\ctikzset{seven seg/box/.is choice} +\ctikzset{seven seg/box/off/.code={\pgf@circ@sevenseg@boxfalse}} +\ctikzset{seven seg/box/on/.code={\pgf@circ@sevenseg@boxtrue}} + +\ctikzset{seven seg/bits/.initial=0000000} + +\ctikzset{seven seg/value/.code={% + \edef\@@tmp{#1}% + \edef\@@n{0} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1111110}\fi + \edef\@@n{1} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=0110000}\fi + \edef\@@n{2} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1101101}\fi + \edef\@@n{3} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1111001}\fi + \edef\@@n{4} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=0110011}\fi + \edef\@@n{5} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1011011}\fi + \edef\@@n{6} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1011111}\fi + \edef\@@n{7} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1110000}\fi + \edef\@@n{8} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1111111}\fi + \edef\@@n{9} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1111011}\fi + \edef\@@n{10}\ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1110111}\fi + \edef\@@n{11}\ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=0011111}\fi + \edef\@@n{12}\ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1001110}\fi + \edef\@@n{13}\ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=0111101}\fi + \edef\@@n{14}\ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1001111}\fi + \edef\@@n{15}\ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1000111}\fi + \edef\@@n{A} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1110111}\fi + \edef\@@n{B} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=0011111}\fi + \edef\@@n{C} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1001110}\fi + \edef\@@n{D} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=0111101}\fi + \edef\@@n{E} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1001111}\fi + \edef\@@n{F} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1000111}\fi + \edef\@@n{a} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1110111}\fi + \edef\@@n{b} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=0011111}\fi + \edef\@@n{c} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1001110}\fi + \edef\@@n{d} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=0111101}\fi + \edef\@@n{e} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1001111}\fi + \edef\@@n{f} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1000111}\fi + \edef\@@n{-} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=0000001}\fi +}} + +\tikzset{% + seven segment val/.style args={#1dot#2box#3}{% + shape=bare7seg, + /tikz/circuitikz/seven seg/value=#1, + /tikz/circuitikz/seven seg/dot=#2, + /tikz/circuitikz/seven seg/box=#3, + }, + seven segment bits/.style args={#1dot#2box#3}{% + shape=bare7seg, + /tikz/circuitikz/seven seg/bits=#1, + /tikz/circuitikz/seven seg/dot=#2, + /tikz/circuitikz/seven seg/box=#3, + }, +} +%%>>> + +% Options for twoports and blocks%<<<1 + +% Option ">" for twoports +\newif\ifpgf@circuit@inputarrow +\ctikzset{>/.add code={}{\pgf@circuit@inputarrowtrue}} +\ctikzset{inputarrow/.is choice} +\ctikzset{inputarrow/true/.code={\pgf@circuit@inputarrowtrue}} +\ctikzset{inputarrow/false/.code={\pgf@circuit@inputarrowfalse}} + +% Option "boxed" for nodes and twoports +\newif\ifpgf@circuit@boxed +\pgfkeys{/tikz/boxed/.add code={}{\pgf@circuit@boxedtrue}} +\ctikzset{boxed/.add code={}{\pgf@circuit@boxedtrue}} +\pgfkeys{/tikz/box/.add code={}{\pgf@circuit@boxedtrue}} +\ctikzset{box/.add code={}{\pgf@circuit@boxedtrue}} + +% Option "dashed" for nodes and twoports +\newif\ifpgf@circuit@dashed +\pgfkeys{/tikz/dashed/.add code={}{\pgf@circuit@dashedtrue}} +\ctikzset{dashed/.add code={}{\pgf@circuit@dashedtrue}}% +%>>> + +% Chips and Rotary switches (multipoles) %<<<1 % \ctikzset{multipoles/thickness/.initial=2} \ctikzset{multipoles/font/.initial=\pgf@circ@font@tiny} @@ -1738,8 +2030,9 @@ rotary switch ->/.default={5 in 60 wiper 20}, rotary switch <->/.default={5 in 60 wiper 20}, } +%%>>> -% %Mechanical section +% %Mechanical section%<<<1 \ctikzset{/tikz/circuitikz/tripoles/elmech/height/.initial=.8} \ctikzset{/tikz/circuitikz/tripoles/elmech/width/.initial=.6} \ctikzset{bipoles/spring/height/.initial=.5} @@ -1753,142 +2046,56 @@ \ctikzset{bipoles/damper/height/.initial=.35} \ctikzset{bipoles/damper/length/.initial=.3} \ctikzset{bipoles/damper/width/.initial=.4} +%%>>> +% powerelectronic blocks%<<<1 +\ctikzset{bipoles/sacdc/width/.initial=.7} +\ctikzset{bipoles/sdcac/width/.initial=.7} +\ctikzset{bipoles/tacdc/width/.initial=.7} +\ctikzset{bipoles/tdcac/width/.initial=.7} +\ctikzset{quadpoles/gridnode/width/.initial=.7} %not sure if quadpole? +%>>> -\ctikzset{bipole/.is family} -\ctikzset{bipole/kind/.initial=} -\ctikzset{bipole/name/.initial=} -\newif\ifpgf@circuit@bipole@isvoltage -\ctikzset{bipole/is voltage/.is if=pgf@circuit@bipole@isvoltage} -\newif\ifpgf@circuit@bipole@voltageoutsideofsymbol -\ctikzset{bipole/is voltageoutsideofsymbol/.is if=pgf@circuit@bipole@voltageoutsideofsymbol} -\newif\ifpgf@circuit@bipole@strokedsymbol -\ctikzset{bipole/is strokedsymbol/.is if=pgf@circuit@bipole@strokedsymbol} -\newif\ifpgf@circuit@bipole@iscurrent -\ctikzset{bipole/is current/.is if=pgf@circuit@bipole@iscurrent} - -\ctikzset{bipole/voltage/.is family} -\newif\ifpgf@circuit@bipole@voltage@backward -\ctikzset{bipole/voltage/direction/.is choice} -\ctikzset{bipole/voltage/direction/forward/.code={\pgf@circuit@bipole@voltage@backwardfalse}} -\ctikzset{bipole/voltage/direction/backward/.code={\pgf@circuit@bipole@voltage@backwardtrue}} -\newif\ifpgf@circuit@bipole@voltage@below -\ctikzset{bipole/voltage/position/.is choice} -\ctikzset{bipole/voltage/position/above/.code={\pgf@circuit@bipole@voltage@belowfalse}} -\ctikzset{bipole/voltage/position/below/.code={\pgf@circuit@bipole@voltage@belowtrue}} - -\ctikzset{bipole/voltage/label/unit/.initial=} -\ctikzset{bipole/voltage/label/name/.initial=} - -\ctikzset{bipole/current/.is family} -\newif\ifpgf@circuit@bipole@current@backward -\ctikzset{bipole/current/direction/.is choice} -\ctikzset{bipole/current/direction/forward/.code={\pgf@circuit@bipole@current@backwardfalse}} -\ctikzset{bipole/current/direction/backward/.code={\pgf@circuit@bipole@current@backwardtrue}} -\newif\ifpgf@circuit@bipole@current@before -\ctikzset{bipole/current/x position/.is choice} -\ctikzset{bipole/current/x position/after/.code={\pgf@circuit@bipole@current@beforefalse}} -\ctikzset{bipole/current/x position/before/.code={\pgf@circuit@bipole@current@beforetrue}} -\newif\ifpgf@circuit@bipole@current@below -\ctikzset{bipole/current/y position/.is choice} -\ctikzset{bipole/current/y position/above/.code={\pgf@circuit@bipole@current@belowfalse}} -\ctikzset{bipole/current/y position/below/.code={\pgf@circuit@bipole@current@belowtrue}} -\ctikzset{bipole/current/label/unit/.initial=} -\ctikzset{bipole/current/label/name/.initial=} - -\ctikzset{bipole/flow/.is family} -\newif\ifpgf@circuit@bipole@flow@backward -\ctikzset{bipole/flow/direction/.is choice} -\ctikzset{bipole/flow/direction/forward/.code={\pgf@circuit@bipole@flow@backwardfalse}} -\ctikzset{bipole/flow/direction/backward/.code={\pgf@circuit@bipole@flow@backwardtrue}} -\newif\ifpgf@circuit@bipole@flow@before -\ctikzset{bipole/flow/x position/.is choice} -\ctikzset{bipole/flow/x position/after/.code={\pgf@circuit@bipole@flow@beforefalse}} -\ctikzset{bipole/flow/x position/before/.code={\pgf@circuit@bipole@flow@beforetrue}} -\newif\ifpgf@circuit@bipole@flow@below -\ctikzset{bipole/flow/y position/.is choice} -\ctikzset{bipole/flow/y position/above/.code={\pgf@circuit@bipole@flow@belowfalse}} -\ctikzset{bipole/flow/y position/below/.code={\pgf@circuit@bipole@flow@belowtrue}} -\ctikzset{bipole/flow/label/unit/.initial=} -\ctikzset{bipole/flow/label/name/.initial=} -\ctikzset{flow/distance/.initial = .5} -\ctikzset{flow/offset/.initial = .2}%distance between flow-arrow and conductor - -\ctikzset{bipole/label/.is family} -\ctikzset{bipole/label/position/.initial=90} -\ctikzset{bipole/label/unit/.initial=} -\ctikzset{bipole/label/name/.initial=} -\ctikzset{bipole/annotation/.is family} -\ctikzset{bipole/annotation/position/.initial=-90} -\ctikzset{bipole/annotation/unit/.initial=} -\ctikzset{bipole/annotation/name/.initial=} - -\newif\ifpgf@circuit@europeanresistor -\ctikzset{resistor/.is choice} -\ctikzset{resistor/american/.code = \pgf@circuit@europeanresistorfalse } -\ctikzset{resistor/european/.code = \pgf@circuit@europeanresistortrue } - -\ctikzset{inductor/.is choice} -\ctikzset{inductor/cute/.code={\ctikzsetvalof{inductor}{cute}}} -\ctikzset{inductor/european/.code={\ctikzsetvalof{inductor}{european}}} -\ctikzset{inductor/american/.code={\ctikzsetvalof{inductor}{american}}} - -% -% Flipping arrows in LED and photodiodes -% -\newif\ifpgf@led@fliparrows -\newif\ifpgf@pd@fliparrows -\pgf@led@fliparrowsfalse -\pgf@pd@fliparrowsfalse -% -% by default the arrows start (LED) and go (PD) to the anode. -% -\ctikzset{led arrows from anode/.code=\pgf@led@fliparrowsfalse} -\ctikzset{pd arrows to anode/.code=\pgf@pd@fliparrowsfalse} -% -% but they can start form the cathode (LED) or go to it (PD) -% -\ctikzset{led arrows from cathode/.code=\pgf@led@fliparrowstrue} -\ctikzset{pd arrows to cathode/.code=\pgf@pd@fliparrowstrue} - -\newif\ifpgf@circuit@strokediode -\newif\ifpgf@circuit@fulldiode -\pgf@circuit@strokediodefalse -\pgf@circuit@fulldiodefalse - -\ctikzset{diode/.is choice} -\ctikzset{diode/empty/.code = \pgf@circuit@fulldiodefalse\pgf@circuit@strokediodefalse}%default -\ctikzset{diode/full/.code = \pgf@circuit@fulldiodetrue } -\ctikzset{diode/stroke/.code = \pgf@circuit@strokediodetrue} - -\tikzset{full diodes/.style = { \circuitikzbasekey/diode = full}} -\tikzset{empty diodes/.style = { \circuitikzbasekey/diode = empty}} -\tikzset{stroke diodes/.style = { \circuitikzbasekey/diode = stroke}} - -\ctikzset{thickness/.initial=2} -\ctikzset{color/.initial=black} -\pgfkeys{/tikz/color/.add code={}{\ctikzset{color={#1}}}} - -\newif\ifpgf@circ@siunitx -\newif\ifpgf@circ@siunitx@res - -% -% voltage and current options +% voltage and current options%<<<1 % +\ctikzset{current arrow scale/.initial=16} +\ctikzset{current/distance/.initial = .5} \newif\ifpgf@circuit@europeancurrent \newif\ifpgf@circuit@europeanvoltage \newif\ifpgf@circuit@bipole@voltage@straight +\newif\ifpgf@circuit@bipole@voltage@raised \ctikzset{voltage/.is choice} % % straight is expected to be a subset of european, so disable it in american style % -\ctikzset{voltage/american/.code = {\pgf@circuit@europeanvoltagefalse\pgf@circuit@bipole@voltage@straightfalse}} -\ctikzset{voltage/european/.code = {\pgf@circuit@europeanvoltagetrue\pgf@circuit@bipole@voltage@straightfalse}} -\ctikzset{voltage/straight/.code = {\pgf@circuit@europeanvoltagetrue\pgf@circuit@bipole@voltage@straighttrue}} -\ctikzset{voltage/curved/.code = {\pgf@circuit@europeanvoltagetrue\pgf@circuit@bipole@voltage@straightfalse}} - +\ctikzset{voltage/american/.code = {% + \pgf@circuit@europeanvoltagefalse + \pgf@circuit@bipole@voltage@straightfalse + \pgf@circuit@bipole@voltage@raisedfalse +}} +\ctikzset{voltage/raised/.code = {% + \pgf@circuit@europeanvoltagefalse + \pgf@circuit@bipole@voltage@straightfalse + \pgf@circuit@bipole@voltage@raisedtrue +}} +\ctikzset{voltage/european/.code = {% + \pgf@circuit@europeanvoltagetrue + \pgf@circuit@bipole@voltage@straightfalse + \pgf@circuit@bipole@voltage@raisedfalse +}} +\ctikzset{voltage/straight/.code = {% + \pgf@circuit@europeanvoltagetrue + \pgf@circuit@bipole@voltage@straighttrue + \pgf@circuit@bipole@voltage@raisedfalse +}} +\ctikzset{voltage/curved/.code = {% + \pgf@circuit@europeanvoltagetrue + \pgf@circuit@bipole@voltage@straightfalse + \pgf@circuit@bipole@voltage@raisedfalse +}} +% are these used? \ctikzset{current/.is choice} \ctikzset{current/american/.code = \pgf@circuit@europeancurrentfalse} \ctikzset{current/european/.code = \pgf@circuit@europeancurrenttrue} @@ -1903,9 +2110,17 @@ % above. I hope it is ok --- would be a mess otherwise % \ctikzset{voltage/shift/.initial=0.0} % shift form the cable of voltage symbols -\ctikzset{voltage shift/.style={voltage/shift=#1}} +\ctikzset{voltage shift/.style={\circuitikzbasekey/voltage/shift=#1}} \tikzset{voltage shift/.style={\circuitikzbasekey/voltage/shift=#1}} - +% +% keys for exporting voltage, current, flow anchors +% +\newif\ifpgfcirc@has@v\pgfcirc@has@vfalse +\newif\ifpgfcirc@has@f\pgfcirc@has@ffalse +\newif\ifpgfcirc@has@i\pgfcirc@has@ifalse +\def\ctikzgetanchor#1#2{\csname pgfcirc@#1-#2-anchor\endcsname} +\def\ctikzgetdirection#1{\csname pgfcirc@#1-direction\endcsname} +% % shaping the +/- sign, see pgfcircvoltage.tex \ctikzset{voltage/american font/.initial={}} \ctikzset{voltage/american plus/.initial={$+$}} @@ -1938,13 +2153,29 @@ \ctikzset{voltage/european label distance/.initial=1.4} \ctikzset{voltage/straight label distance/.initial=1.4} \ctikzset{voltage/american label distance/.initial=1.4} +% american open voltage adjusting +% +\newif\ifpgf@adjust@open@voltage\pgf@adjust@open@voltagetrue +\ctikzset{american open voltage/.is choice} +\ctikzset{american open voltage/center/.code={\pgf@adjust@open@voltagetrue}} +\ctikzset{american open voltage/legacy/.code={\pgf@adjust@open@voltagefalse}} +% +% voltage and current styles % +\tikzset{american currents/.style = {\circuitikzbasekey/current = american}} +\tikzset{european currents/.style = {\circuitikzbasekey/current = european}} +\tikzset{american voltages/.style = {\circuitikzbasekey/voltage = american}} +\tikzset{european voltages/.style = {\circuitikzbasekey/voltage = european}} +\tikzset{straight voltages/.style = {\circuitikzbasekey/voltage = straight}} +\tikzset{raised voltages/.style = {\circuitikzbasekey/voltage = raised}} +%%>>> + +% special cases for voltage positions%<<<1 % the KIND is the node name without SHAPE % See the definition above for meaning % if bipoles/KIND/voltage/straight label distance is not defined, it uses the height % if bipoles/KIND/voltage/additional shift is not defined, it is 0 (extra distance) % -% special cases for voltage positions \ctikzset{bipoles/generic/voltage/distance from node/.initial=0.4} \ctikzset{bipoles/generic/voltage/bump b/.initial=2} % @@ -1992,169 +2223,7 @@ \ctikzset{bipoles/battery/voltage/bump a/.initial=1.4} \ctikzset{bipoles/vsourceAM/voltage/american label distance/.initial=1.2} \ctikzset{bipoles/cvsourceAM/voltage/american label distance/.initial=1.2} -% -% american open voltage adjusting -% -\newif\ifpgf@adjust@open@voltage\pgf@adjust@open@voltagetrue -\ctikzset{american open voltage/.is choice} -\ctikzset{american open voltage/center/.code={\pgf@adjust@open@voltagetrue}} -\ctikzset{american open voltage/legacy/.code={\pgf@adjust@open@voltagefalse}} -% -% currents -% -\ctikzset{current/distance/.initial = .5} - -% -% voltage and current styles -% - -\tikzset{american currents/.style = {\circuitikzbasekey/current = american}} -\tikzset{european currents/.style = {\circuitikzbasekey/current = european}} -\tikzset{american voltages/.style = {\circuitikzbasekey/voltage = american}} -\tikzset{european voltages/.style = {\circuitikzbasekey/voltage = european}} -\tikzset{straight voltages/.style = {\circuitikzbasekey/voltage = straight}} -\tikzset{american resistors/.style = {\circuitikzbasekey/resistor = american}} -\tikzset{european resistors/.style = {\circuitikzbasekey/resistor = european}} - -\newif\ifpgf@circuit@europeangfsurgearrester -\ctikzset{gas filled surge arrester choice/.is choice} -\ctikzset{gas filled surge arrester choice/european/.code= {\pgf@circuit@europeangfsurgearrestertrue}} -\ctikzset{gas filled surge arrester choice/american/.code= {\pgf@circuit@europeangfsurgearresterfalse}} - -\tikzset{american gas filled surge arrester set/.style = {\circuitikzbasekey/gas filled surge arrester choice=american}} -\tikzset{european gas filled surge arrester set/.style = {\circuitikzbasekey/gas filled surge arrester choice=european}} -\tikzset{american inductors/.style = {\circuitikzbasekey/inductor = american}} -\tikzset{european inductors/.style = {\circuitikzbasekey/inductor = european}} -\tikzset{cute inductors/.style = {\circuitikzbasekey/inductor = cute}} -\tikzset{american ports/.style = {\circuitikzbasekey/logic ports = american}} -\tikzset{european ports/.style = {\circuitikzbasekey/logic ports = european}} - -% -% general styles -% - -\tikzset{european/.style = {european currents, european voltages, european resistors, european inductors, european ports, european gas filled surge arrester set}} -\tikzset{american/.style = {american currents, american voltages, american resistors, american inductors, american ports, american gas filled surge arrester set}} -\tikzset{cute/.style = {european currents, european voltages, american resistors, cute inductors, american ports}} - - -% noise sources -\ctikzset{bipoles/noise sources/fillcolor/.initial=gray!50} - -\ctikzset{label/align/.is choice} -\ctikzset{label/align/straight/.code={\ctikzsetvalof{label/align}{straight}}} -\ctikzset{label/align/rotate/.code={\ctikzsetvalof{label/align}{rotate}}} -\ctikzset{label/align/smart/.code={\ctikzsetvalof{label/align}{smart}}} - -% seven segment displays by RGtti - -\newif\ifpgf@circ@sevenseg@dot -\newif\ifpgf@circ@sevenseg@box -\def\pgf@circ@sevenseg@dotstate{empty} -\ctikzset{seven seg/.is family} -\ctikzset{seven seg/dot/.is choice} -% none means no dot, not space for it. Empty means no dot, but space -\ctikzset{seven seg/dot/none/.code={\pgf@circ@sevenseg@dotfalse}} -\ctikzset{seven seg/dot/empty/.code={\pgf@circ@sevenseg@dottrue\def\pgf@circ@sevenseg@dotstate{empty}}} -\ctikzset{seven seg/dot/off/.code={\pgf@circ@sevenseg@dottrue\def\pgf@circ@sevenseg@dotstate{off}}} -\ctikzset{seven seg/dot/on/.code={\pgf@circ@sevenseg@dottrue\def\pgf@circ@sevenseg@dotstate{on}}} -% -\ctikzset{seven seg/width/.initial=0.4}% relative to \pgf@circ@Rlen -\ctikzset{seven seg/thickness/.initial=4pt}% segment thickness -\ctikzset{seven seg/segment sep/.initial=0.2pt}% gap between segments -\ctikzset{seven seg/box sep/.initial=1pt}% external box gap -\ctikzset{seven seg/color on/.initial=red}% color for segment "on" -\ctikzset{seven seg/color off/.initial=gray!20!white} % ...and "off" -\ctikzset{seven seg/box/.is choice} -\ctikzset{seven seg/box/off/.code={\pgf@circ@sevenseg@boxfalse}} -\ctikzset{seven seg/box/on/.code={\pgf@circ@sevenseg@boxtrue}} - -\ctikzset{seven seg/bits/.initial=0000000} - -\ctikzset{seven seg/value/.code={% - \edef\@@tmp{#1}% - \edef\@@n{0} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1111110}\fi - \edef\@@n{1} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=0110000}\fi - \edef\@@n{2} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1101101}\fi - \edef\@@n{3} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1111001}\fi - \edef\@@n{4} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=0110011}\fi - \edef\@@n{5} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1011011}\fi - \edef\@@n{6} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1011111}\fi - \edef\@@n{7} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1110000}\fi - \edef\@@n{8} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1111111}\fi - \edef\@@n{9} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1111011}\fi - \edef\@@n{10}\ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1110111}\fi - \edef\@@n{11}\ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=0011111}\fi - \edef\@@n{12}\ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1001110}\fi - \edef\@@n{13}\ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=0111101}\fi - \edef\@@n{14}\ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1001111}\fi - \edef\@@n{15}\ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1000111}\fi - \edef\@@n{A} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1110111}\fi - \edef\@@n{B} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=0011111}\fi - \edef\@@n{C} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1001110}\fi - \edef\@@n{D} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=0111101}\fi - \edef\@@n{E} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1001111}\fi - \edef\@@n{F} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1000111}\fi - \edef\@@n{a} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1110111}\fi - \edef\@@n{b} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=0011111}\fi - \edef\@@n{c} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1001110}\fi - \edef\@@n{d} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=0111101}\fi - \edef\@@n{e} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1001111}\fi - \edef\@@n{f} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=1000111}\fi - \edef\@@n{-} \ifx\@@tmp\@@n\relax\ctikzset{seven seg/bits=0000001}\fi -}} - -\tikzset{% - seven segment val/.style args={#1dot#2box#3}{% - shape=bare7seg, - /tikz/circuitikz/seven seg/value=#1, - /tikz/circuitikz/seven seg/dot=#2, - /tikz/circuitikz/seven seg/box=#3, - }, - seven segment bits/.style args={#1dot#2box#3}{% - shape=bare7seg, - /tikz/circuitikz/seven seg/bits=#1, - /tikz/circuitikz/seven seg/dot=#2, - /tikz/circuitikz/seven seg/box=#3, - }, -} - - -%%%%%%%%%% new -\pgfkeys{\circuitikzbasekey/.search also={/tikz}} - -% Electronic tubes: diodetube, triode, tetrode and pentode -\ctikzset{tubes/width/.initial=1} % relative width -\ctikzset{tubes/height/.initial=1.4} % relative height -\ctikzset{tubes/tube radius/.initial=0.40} % radius of tube circle -\ctikzset{tubes/anode distance/.initial=0.40} % distance from center -\ctikzset{tubes/anode width/.initial=0.40} % width of an anode/plate -\ctikzset{tubes/grid protrusion/.initial=0.25} % distance from center -\ctikzset{tubes/grid dashes/.initial=5} % number of grid dashes -\ctikzset{tubes/grid separation/.initial=0.2} % separation between grids -\ctikzset{tubes/grid shift/.initial=0.0} % y shift grids from center -\ctikzset{tubes/cathode distance/.initial=0.40} % distance from grid -\ctikzset{tubes/cathode width/.initial=0.40} % width of an cathode -\ctikzset{tubes/cathode corners/.initial=0.06} % corners of the cathode wire -\ctikzset{tubes/cathode right extend/.initial=0.075} % extension at the right side -\ctikzset{tubes/filament distance/.initial=0.1} % distance from cathode -\ctikzset{tubes/filament angle/.initial=15} % Angle from centerpoint - -\newif\ifpgf@circuit@tubes@filament\pgf@circuit@tubes@filamentfalse -\pgfkeys{/tikz/filament/.add code={}{\pgf@circuit@tubes@filamenttrue}} -\ctikzset{tubes/filament/.add code={}{\pgf@circuit@tubes@filamenttrue}} -\newif\ifpgf@circuit@tubes@nocathode\pgf@circuit@tubes@nocathodefalse -\pgfkeys{/tikz/nocathode/.add code={}{\pgf@circuit@tubes@nocathodetrue}} -\ctikzset{tubes/nocathode/.add code={}{\pgf@circuit@tubes@nocathodetrue}} -\newif\ifpgf@circuit@tubes@fullcathode\pgf@circuit@tubes@fullcathodefalse -\pgfkeys{/tikz/fullcathode/.add code={}{\pgf@circuit@tubes@fullcathodetrue}} -\ctikzset{tubes/fullcathode/.add code={}{\pgf@circuit@tubes@fullcathodetrue}} - -% powerelectronic blocks -\ctikzset{bipoles/sacdc/width/.initial=.7} -\ctikzset{bipoles/sdcac/width/.initial=.7} -\ctikzset{bipoles/tacdc/width/.initial=.7} -\ctikzset{bipoles/tdcac/width/.initial=.7} -\ctikzset{quadpoles/gridnode/width/.initial=.7} %not sure if quadpole? +%%>>> \endinput +% vim: set fdm=marker fmr=%<<<,%>>>: diff --git a/graphics/pgf/contrib/circuitikz/tex/pgfcirccurrent.tex b/graphics/pgf/contrib/circuitikz/tex/pgfcirccurrent.tex index b8cf055590..a6b0d039b7 100644 --- a/graphics/pgf/contrib/circuitikz/tex/pgfcirccurrent.tex +++ b/graphics/pgf/contrib/circuitikz/tex/pgfcirccurrent.tex @@ -88,6 +88,7 @@ } \ctikzset{i/.code = { + \pgfcirc@has@itrue \pgfkeys{\circuitikzbasekey/bipole/current/direction = forward, \circuitikzbasekey/bipole/current/x position = after, \circuitikzbasekey/bipole/current/y position = above } @@ -131,8 +132,8 @@ %% Output routine \def\pgf@circ@drawcurrent{ \pgfextra{ - \edef\pgf@circ@ffffff{\pgf@circ@direction} - \def\pgfcircmathresult{\expandafter\pgf@circ@stripdecimals\pgf@circ@ffffff\pgf@nil} + \edef\pgf@circ@rounded@dir{\pgf@circ@direction} + \def\pgfcircmathresult{\expandafter\pgf@circ@stripdecimals\pgf@circ@rounded@dir\pgf@nil} \ifnum\pgfcircmathresult >4 \ifnum\pgfcircmathresult <86 \ifpgf@circuit@bipole@current@below @@ -178,36 +179,50 @@ \ifpgf@circuit@bipole@current@below \def\pgf@circ@dir{north}\else\def\pgf@circ@dir{south} \fi - \fi + \fi + % export anchor position (if not needed, is always the same macro) + \expandafter\xdef\csname pgfcirc@\pgfcirc@a@prefix-Ilab-anchor\endcsname{\pgf@circ@dir} - \ifpgf@circuit@bipole@current@below - \def\pgf@circ@bipole@current@label@where{-90} - \else - \def\pgf@circ@bipole@current@label@where{+90} - \fi + \ifpgf@circuit@bipole@current@below + \def\pgf@circ@bipole@current@label@where{-90} + \else + \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%draw current at a short at middle of the line - (\tikztostart)--(\tikztotarget) + coordinate (\pgfcirc@a@prefix-Ifrom) at (\tikztostart) + coordinate (\pgfcirc@a@prefix-Ito) at (\tikztotarget) \else% normal bipole or source \ifpgf@circuit@bipole@current@before - (\tikztostart)--(anchorstartnode) + coordinate (\pgfcirc@a@prefix-Ifrom) at (\tikztostart) + coordinate (\pgfcirc@a@prefix-Ito) at (anchorstartnode) \else - (anchorendnode)--(\tikztotarget) + coordinate (\pgfcirc@a@prefix-Ifrom) at (anchorendnode) + coordinate (\pgfcirc@a@prefix-Ito) at (\tikztotarget) \fi \fi \ifpgf@circuit@bipole@current@backward \pgfextra{ - \pgfmathsubtract{\pgf@circ@ffffff}{180} - \edef\pgf@circ@ffffff{\expandafter\pgf@circ@stripdecimals\pgfmathresult\pgf@nil} + \pgfmathsubtract{\pgf@circ@rounded@dir}{180} + \edef\pgf@circ@rounded@dir{\expandafter\pgf@circ@stripdecimals\pgfmathresult\pgf@nil} } \fi - coordinate[currarrow,pos=\ctikzvalof{current/distance},rotate=\pgf@circ@ffffff, - anchor=center](Iarrow) - (Iarrow.\pgf@circ@bipole@current@label@where) + coordinate (\pgfcirc@a@prefix-Ipos) at ($(\pgfcirc@a@prefix-Ifrom)! \ctikzvalof{current/distance} !(\pgfcirc@a@prefix-Ito)$) + % if the current label is not empty (in which case we have already all the anchors) + \pgf@circ@ifkeyempty{bipole/current/label/name}\else + % put the arrow node + node[currarrow, rotate=\pgf@circ@rounded@dir, anchor=center](Iarrow) at (\pgfcirc@a@prefix-Ipos) {} + % put the label node[anchor=\pgf@circ@dir, \circuitikzbasekey/bipole current style] - (\ctikzvalof{bipole/name}current){\pgf@circ@finallabels{current/label}} + (\ctikzvalof{bipole/name}current) + at (Iarrow.\pgf@circ@bipole@current@label@where){\pgf@circ@finallabels{current/label}} + \fi % end ifempty + \ifpgf@circuit@bipole@current@backward + \pgfcirc@swap@coordinates{\pgfcirc@a@prefix-Ifrom}{\pgfcirc@a@prefix-Ito} + \fi } \endinput diff --git a/graphics/pgf/contrib/circuitikz/tex/pgfcircflow.tex b/graphics/pgf/contrib/circuitikz/tex/pgfcircflow.tex index b7bb8b9767..f2adc0d8ef 100644 --- a/graphics/pgf/contrib/circuitikz/tex/pgfcircflow.tex +++ b/graphics/pgf/contrib/circuitikz/tex/pgfcircflow.tex @@ -13,6 +13,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% flow handling + %% styles \ctikzset{bipole flow style/.style={}} \tikzset{bipole flow style/.code={ @@ -27,7 +28,7 @@ f = #1, \circuitikzbasekey/bipole/flow/direction = forward, \circuitikzbasekey/bipole/flow/x position = after, - \circuitikzbasekey/bipole/curflowrent/y position = above + \circuitikzbasekey/bipole/flow/y position = above } } @@ -93,6 +94,7 @@ \ctikzset{f^/.style = { f = #1, \circuitikzbasekey/bipole/flow/y position = above } } \ctikzset{f/.code = { + \pgfcirc@has@ftrue \pgfkeys{\circuitikzbasekey/bipole/flow/direction = forward, \circuitikzbasekey/bipole/flow/x position = after, \circuitikzbasekey/bipole/flow/y position = above } @@ -113,10 +115,11 @@ } %% Output routine + \def\pgf@circ@drawflow{ \pgfextra{ - \edef\pgf@circ@ffffff{\pgf@circ@direction} - \def\pgfcircmathresult{\expandafter\pgf@circ@stripdecimals\pgf@circ@ffffff\pgf@nil} + \edef\pgf@circ@rounded@dir{\pgf@circ@direction} + \def\pgfcircmathresult{\expandafter\pgf@circ@stripdecimals\pgf@circ@rounded@dir\pgf@nil} \ifnum\pgfcircmathresult >4 \ifnum\pgfcircmathresult <86 \ifpgf@circuit@bipole@flow@below @@ -169,38 +172,62 @@ \else \def\pgf@circ@bipole@flow@label@where{+90} \fi + % export anchor position (if not needed, is always the same macro) + \expandafter\xdef\csname pgfcirc@\pgfcirc@a@prefix-Flab-anchor\endcsname{\pgf@circ@dir} } \pgfextra{\def\pgf@temp{short}\edef\pgf@circ@temp{\ctikzvalof{bipole/kind}}} - \ifx\pgf@circ@temp\pgf@temp%draw flow at a short at middle of the line - (\tikztostart)--(\tikztotarget) + \ifx\pgf@circ@temp\pgf@temp%draw current at a short at middle of the line + coordinate (pgfcirc@Ffrom@flat) at (\tikztostart) + coordinate (pgfcirc@Fto@flat) at (\tikztotarget) \else% normal bipole or source \ifpgf@circuit@bipole@flow@before - (\tikztostart)--(anchorstartnode) + coordinate (pgfcirc@Ffrom@flat) at (\tikztostart) + coordinate (pgfcirc@Fto@flat) at (anchorstartnode) \else - (anchorendnode)--(\tikztotarget) + coordinate (pgfcirc@Ffrom@flat) at (anchorendnode) + coordinate (pgfcirc@Fto@flat) at (\tikztotarget) \fi \fi \pgfextra{ + \newdimen{\absfshift} + \def\flow@offset{\ctikzvalof{flow/offset}\pgf@circ@Rlen} + \absfshift=\flow@offset \ifpgf@circuit@bipole@flow@backward - \ifpgf@circuit@bipole@flow@below - \def\flow@offset{\ctikzvalof{flow/offset}\pgf@circ@Rlen} - \else - \def\flow@offset{-\ctikzvalof{flow/offset}\pgf@circ@Rlen} - \fi - \pgfmathsubtract{\pgf@circ@ffffff}{180} - \edef\pgf@circ@ffffff{\expandafter\pgf@circ@stripdecimals\pgfmathresult\pgf@nil} - \else - \ifpgf@circuit@bipole@flow@below - \def\flow@offset{-\ctikzvalof{flow/offset}\pgf@circ@Rlen} - \else - \def\flow@offset{\ctikzvalof{flow/offset}\pgf@circ@Rlen} - \fi + \pgfmathsubtract{\pgf@circ@rounded@dir}{180} + \edef\pgf@circ@rounded@dir{\expandafter\pgf@circ@stripdecimals\pgfmathresult\pgf@nil} \fi } - coordinate[flowarrow,pos=\ctikzvalof{flow/distance},rotate=\pgf@circ@ffffff,yshift=\flow@offset, anchor=center](Farrowpos) - (Farrowpos.\pgf@circ@bipole@flow@label@where) node[anchor=\pgf@circ@dir, \circuitikzbasekey/bipole flow style] - (\ctikzvalof{bipole/name}flow){\pgf@circ@finallabels{flow/label}} + \ifpgf@circuit@bipole@flow@below + coordinate (pgfcirc@Ffrom@up) at ($(pgfcirc@Ffrom@flat) ! \absfshift !-90: (pgfcirc@Fto@flat)$) + coordinate (pgfcirc@Fto@up) at ($(pgfcirc@Fto@flat) ! \absfshift !90: (pgfcirc@Ffrom@flat)$) + \else + coordinate (pgfcirc@Ffrom@up) at ($(pgfcirc@Ffrom@flat) ! \absfshift !90: (pgfcirc@Fto@flat)$) + coordinate (pgfcirc@Fto@up) at ($(pgfcirc@Fto@flat) ! \absfshift !-90: (pgfcirc@Ffrom@flat)$) + \fi + coordinate (\pgfcirc@a@prefix-Fpos) at ($(pgfcirc@Ffrom@up) ! \ctikzvalof{flow/distance} !(pgfcirc@Fto@up)$) + \pgfextra{ + \absfshift=0.25\pgf@circ@Rlen% This is half size of the "flowarrow" shape! + } + coordinate (\pgfcirc@a@prefix-Ffrom) at ($(\pgfcirc@a@prefix-Fpos)!\absfshift!(pgfcirc@Ffrom@up)$) + coordinate (\pgfcirc@a@prefix-Fto) at ($(\pgfcirc@a@prefix-Fpos)!\absfshift!(pgfcirc@Fto@up) $) + % + % coordinate (\pgfcirc@a@prefix-Fpos) at + % ([yshift=\flow@offset]$(\pgfcirc@a@prefix-Ffrom)! \ctikzvalof{flow/distance} !(\pgfcirc@a@prefix-Fto)$) + % if the flow label is not empty (in which case we have already all the anchors) + \pgf@circ@ifkeyempty{bipole/flow/label/name}\else + % the flow arrow is really a node "flowarrow", not a real arrow + node[flowarrow, rotate=\pgf@circ@rounded@dir, anchor=center](Farrowpos) at (\pgfcirc@a@prefix-Fpos) {} + + node[anchor=\pgf@circ@dir, \circuitikzbasekey/bipole flow style] + (\ctikzvalof{bipole/name}flow) at (Farrowpos.\pgf@circ@bipole@flow@label@where) {\pgf@circ@finallabels{flow/label}} + \fi + + % adjust from and to before exporting --- it's much more simple like this then rework the algorithm above + \ifpgf@circuit@bipole@flow@backward + \pgfcirc@swap@coordinates{\pgfcirc@a@prefix-Ffrom}{\pgfcirc@a@prefix-Fto} + \fi + } \endinput diff --git a/graphics/pgf/contrib/circuitikz/tex/pgfcircpath.tex b/graphics/pgf/contrib/circuitikz/tex/pgfcircpath.tex index e6ba47b7ab..695deaea63 100644 --- a/graphics/pgf/contrib/circuitikz/tex/pgfcircpath.tex +++ b/graphics/pgf/contrib/circuitikz/tex/pgfcircpath.tex @@ -13,6 +13,13 @@ \def\pgf@circ@direction{0.0} +% swap two coordinates +\def\pgfcirc@swap@coordinates#1#2{% + coordinate (tmp) at (#1) + coordinate (#1) at (#2) + coordinate (#2) at (tmp) +} + % Names \ctikzset{name/.style = { n=#1 } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@@@ \ctikzset{n/.code = { @@ -52,22 +59,6 @@ } } -%% Helper function for path-function to ensure using anchors between nodes -\def\set@explicit@center@anchor#1{ - \pgfutil@ifundefined{pgf@sh@ns@#1} - { - %This coordinate is no node(but a relative position or a coordinate), no further handling needed - }{ - \pgfutil@in@.{#1} - \ifpgfutil@in@ - % Anchor is used, do nothing! - \else% - \let\tikz@moveto@waiting=\relax - \pgfpathmoveto{\tikz@last@position}%force movement, because tikz@moveto@waiting - \edef#1{#1.center}%ensure using center anchor - \fi -} -} %% Generic bipole path \def\pgf@circ@bipole@path#1#2{ @@ -111,80 +102,79 @@ % #4: this will be filled by the argument of the to-path % \pgfextra{ - \set@explicit@center@anchor{\tikztostart} - \set@explicit@center@anchor{\tikztotarget} - \pgfsyssoftpath@getcurrentpath{\myp@th}%% save current path to extend after calculation of correct start/end coordinates \ctikzset{bipole/kind = #3} \edef\pgf@temp{\ctikzvalof{bipole/name}} \def\pgf@circ@temp{} \ifx\pgf@temp\pgf@circ@temp % if it has not a name \pgfmathrandominteger{\pgf@circ@rand}{1000}{9999} \ctikzset{bipole/name = #3\pgf@circ@rand} % create it (re-usage should not create problem, but...) + \edef\pgfcirc@a@prefix{pgfcirc}% do not pollute the namespace for nothing + \else + \edef\pgfcirc@a@prefix{\ctikzvalof{bipole/name}}% for exporting v-i-f anchors \fi } - - (\tikztostart) coordinate (\ctikzvalof{bipole/name}start)%necessary to get correct coordinates in the case of relative start/end or constructions like ((node1)-|(node2)) - (\tikztotarget) coordinate (\ctikzvalof{bipole/name}end) + % save start and stop values + % notice that we DO NOT MOVE the path position at all! + coordinate (\ctikzvalof{bipole/name}start) at (\tikztostart) + coordinate (\ctikzvalof{bipole/name}end) at (\tikztotarget) \pgfextra{ + % find the direction (angle) of the path \pgfmathanglebetweenpoints{\pgfpointanchor{\ctikzvalof{bipole/name}start}{center}} - {\pgfpointanchor{\ctikzvalof{bipole/name}end}{center}} - % DO NOT ROUND HERE! pgfcirclabel.tex will do that when needed - % \pgfmathround{\pgfmathresult} - \edef\pgf@circ@direction{\pgfmathresult}%Calculate direction(angle) of path - % \typeout{DIRECTION:\pgf@circ@direction} - \pgfsyssoftpath@setcurrentpath{\myp@th} + {\pgfpointanchor{\ctikzvalof{bipole/name}end}{center}} + \edef\pgf@circ@direction{\pgfmathresult} + \expandafter\xdef\csname pgfcirc@\pgfcirc@a@prefix-direction\endcsname{\pgf@circ@direction} } - \pgfextra{\def\pgf@temp{open}\def\pgf@circ@temp{#3}} - \ifx\pgf@temp\pgf@circ@temp % if it is an open + % position the component in the middle of the path. We DO NOT MOVE the current position! + node[#3#1, rotate=\pgf@circ@direction, yscale=\ctikzvalof{mirror value}, + xscale=\ctikzvalof{invert value}] (\ctikzvalof{bipole/name}) + at ($(\tikztostart) ! .5 ! (\tikztotarget)$) {#2} + % set start and end labels + \ifpgf@circuit@bipole@inverted + \ifcsname pgf@anchor@#3#1@pathstart\endcsname%if special path-anchors are defined, use them! + coordinate (anchorstartnode) at (\ctikzvalof{bipole/name}.pathend) + coordinate (anchorendnode) at (\ctikzvalof{bipole/name}.pathstart) \else - --($(\ctikzvalof{bipole/name}start) ! .5\pgflinewidth ! (\ctikzvalof{bipole/name}end)$) %ugly workaround to get correct linejoins(node breaks path?) - \fi - ($(\tikztostart) ! .5 ! (\tikztotarget)$)%%positio of middle node - node[#3#1, rotate=\pgf@circ@direction, yscale=\ctikzvalof{mirror value}, xscale=\ctikzvalof{invert value}] - (\ctikzvalof{bipole/name}) {#2} - \ifpgf@circuit@bipole@inverted - \ifcsname pgf@anchor@#3#1@pathstart\endcsname%if special path-anchors are defined, use them! - coordinate (anchorstartnode) at (\ctikzvalof{bipole/name}.pathend) - coordinate (anchorendnode) at (\ctikzvalof{bipole/name}.pathstart) - \else - coordinate (anchorstartnode) at (\ctikzvalof{bipole/name}.right) - coordinate (anchorendnode) at (\ctikzvalof{bipole/name}.left) - \fi - \else - \ifcsname pgf@anchor@#3#1@pathstart\endcsname%if special path-anchors are defined, use them! - coordinate (anchorstartnode) at (\ctikzvalof{bipole/name}.pathstart) - coordinate (anchorendnode) at (\ctikzvalof{bipole/name}.pathend) - \else - coordinate (anchorstartnode) at (\ctikzvalof{bipole/name}.left) - coordinate (anchorendnode) at (\ctikzvalof{bipole/name}.right) - \fi + coordinate (anchorstartnode) at (\ctikzvalof{bipole/name}.right) + coordinate (anchorendnode) at (\ctikzvalof{bipole/name}.left) \fi - \pgfextra{\def\pgf@temp{open}\def\pgf@circ@temp{#3}} - \ifx\pgf@temp\pgf@circ@temp % if it is an open \else - (\ctikzvalof{bipole/name}start.center) -- (anchorstartnode) - (anchorendnode) -- (\ctikzvalof{bipole/name}end.center) - \fi - - \drawpoles - \pgf@circ@ifkeyempty{bipole/label/name}\else\pgf@circ@drawlabels{label}\fi - \pgf@circ@ifkeyempty{bipole/annotation/name}\else\pgf@circ@drawlabels{annotation}\fi - \pgf@circ@ifkeyempty{bipole/voltage/label/name}\else\pgf@circ@drawvoltage\fi - \pgf@circ@ifkeyempty{bipole/current/label/name}\else\pgf@circ@drawcurrent\fi - \pgf@circ@ifkeyempty{bipole/flow/label/name}\else\pgf@circ@drawflow\fi - \pgfextra{\def\pgf@temp{open}\def\pgf@circ@temp{#3}} - \ifx\pgf@temp\pgf@circ@temp % if it is an open - (\ctikzvalof{bipole/name}end)%Move to end of path + \ifcsname pgf@anchor@#3#1@pathstart\endcsname%if special path-anchors are defined, use them! + coordinate (anchorstartnode) at (\ctikzvalof{bipole/name}.pathstart) + coordinate (anchorendnode) at (\ctikzvalof{bipole/name}.pathend) \else - ($(\ctikzvalof{bipole/name}end) ! .5\pgflinewidth ! (\ctikzvalof{bipole/name}start)$) -- (\ctikzvalof{bipole/name}end)%ugly workaround to get correct linejoins(node breaks path?) - %tikztostart and tikztotarget could not be used, because it would break if target coordinate is something like (node1-|node2) - + coordinate (anchorstartnode) at (\ctikzvalof{bipole/name}.left) + coordinate (anchorendnode) at (\ctikzvalof{bipole/name}.right) \fi - % reset - \pgfextra{ - \pgfcircresetpath - } - \tikztonodes%draw pending nodes an path + \fi + % draw the leads unless it's an open circuit + % stop at the component + \pgfextra{\def\pgf@temp{open}\def\pgf@circ@temp{#3}} + \ifx\pgf@temp\pgf@circ@temp % if it is an open do nothing + \else + % it is important to start the path with -- to have correct line joins! + -- (\tikztostart) -- (anchorstartnode) + \fi + % Add all the "ornaments": labels, annotations, voltages, currents and flows + \drawpoles + \pgf@circ@ifkeyempty{bipole/label/name}\else\pgf@circ@drawlabels{label}\fi + \pgf@circ@ifkeyempty{bipole/annotation/name}\else\pgf@circ@drawlabels{annotation}\fi + \ifpgfcirc@has@v\pgf@circ@drawvoltage\fi + % \pgf@circ@ifkeyempty{bipole/current/label/name}\else\pgf@circ@drawcurrent\fi + \ifpgfcirc@has@i\pgf@circ@drawcurrent\fi + % \pgf@circ@ifkeyempty{bipole/flow/label/name}\else\pgf@circ@drawflow\fi + \ifpgfcirc@has@f\pgf@circ@drawflow\fi + % finish the path from the component to the final target + % you never know --- re-set \pgf@temp to detect open + \pgfextra{\def\pgf@temp{open}\def\pgf@circ@temp{#3}} + \ifx\pgf@temp\pgf@circ@temp % if it is an open do nothing + (\tikztotarget) + \else + (anchorendnode) -- (\tikztotarget) + \fi + % reset internal circuit keys + \pgfextra{\pgfcircresetpath} + %draw pending nodes an path + \tikztonodes } %%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/graphics/pgf/contrib/circuitikz/tex/pgfcircvoltage.tex b/graphics/pgf/contrib/circuitikz/tex/pgfcircvoltage.tex index 00fa692b0f..032a66f29c 100644 --- a/graphics/pgf/contrib/circuitikz/tex/pgfcircvoltage.tex +++ b/graphics/pgf/contrib/circuitikz/tex/pgfcircvoltage.tex @@ -58,6 +58,7 @@ % Default position varies whether the component is a voltage source % or not \ctikzset{v/.code = { + \pgfcirc@has@vtrue \ifpgf@circuit@bipole@isvoltage \pgfkeys{\circuitikzbasekey/bipole/voltage/position=above, \circuitikzbasekey/bipole/voltage/direction=forward} @@ -174,6 +175,10 @@ \def\pgf@circ@bipole@voltage@label@anchor{center} \fi \fi + \ifpgf@circuit@bipole@voltage@raised + \def\pgf@circ@bipole@voltage@label@anchor{center} + \pgfmathsetlength{\absvshift}{\absvshift+height{"Q"}} % with the current font. + \fi } % %\pgf@circ@Rlen/\ctikzvalof{current arrow scale} is equal to the length of the currarrow %absolute move, minimum space is length of arrowhead @@ -193,28 +198,33 @@ coordinate (pgfcirc@bottom) at (\ctikzvalof{bipole/name}.-90) coordinate (pgfcirc@Vto1) at ($(pgfcirc@mid)+(pgfcirc@bottom)-(pgfcirc@Vfrom@flat)$) coordinate (pgfcirc@Vfrom1) at ($(pgfcirc@mid)+(pgfcirc@bottom)-(pgfcirc@Vto@flat)$) - coordinate (pgfcirc@Vto) at ($(pgfcirc@Vto1) ! \absvshift!90 : (pgfcirc@Vfrom1)$) - coordinate (pgfcirc@Vfrom) at ($(pgfcirc@Vfrom1) ! \absvshift!-90 : (pgfcirc@Vto1)$) - coordinate (pgfcirc@Vlab) at ($(pgfcirc@Vto)!0.5!(pgfcirc@Vfrom) $) - coordinate (pgfcirc@Vdir) at (pgfcirc@Vto) + coordinate (\pgfcirc@a@prefix-Vto) at ($(pgfcirc@Vto1) ! \absvshift!90 : (pgfcirc@Vfrom1)$) + coordinate (\pgfcirc@a@prefix-Vfrom) at ($(pgfcirc@Vfrom1) ! \absvshift!-90 : (pgfcirc@Vto1)$) + coordinate (\pgfcirc@a@prefix-Vlab) at ($(\pgfcirc@a@prefix-Vto)!0.5!(\pgfcirc@a@prefix-Vfrom) $) + coordinate (pgfcirc@Vdir) at (\pgfcirc@a@prefix-Vto) \else - coordinate (pgfcirc@Vto) at ($(pgfcirc@Vto@flat) ! \absvshift!90 : (anchorendnode)$) - coordinate (pgfcirc@Vfrom) at ($(pgfcirc@Vfrom@flat) ! \absvshift!-90 : (anchorstartnode)$) + coordinate (\pgfcirc@a@prefix-Vto) at ($(pgfcirc@Vto@flat) ! \absvshift!90 : (anchorendnode)$) + coordinate (\pgfcirc@a@prefix-Vfrom) at ($(pgfcirc@Vfrom@flat) ! \absvshift!-90 : (anchorstartnode)$) coordinate (pgfcirc@Vcont1t) at ($(\ctikzvalof{bipole/name}.center) ! \bumpb ! (\ctikzvalof{bipole/name}.-110)$) coordinate (pgfcirc@Vcont2t) at ($(\ctikzvalof{bipole/name}.center) ! \bumpb ! (\ctikzvalof{bipole/name}.-70)$) - coordinate (pgfcirc@Vcont1) at ($(pgfcirc@Vcont1t) ! -\absvshift!90 : (pgfcirc@Vcont2t)$) - coordinate (pgfcirc@Vcont2) at ($(pgfcirc@Vcont2t) ! -\absvshift!-90 : (pgfcirc@Vcont1t)$) - coordinate (pgfcirc@Vlab) at ($(pgfcirc@Vcont2)!0.5!(pgfcirc@Vcont1)$) - coordinate (pgfcirc@Vdir) at (pgfcirc@Vcont2) + coordinate (\pgfcirc@a@prefix-Vcont1) at ($(pgfcirc@Vcont1t) ! -\absvshift!90 : (pgfcirc@Vcont2t)$) + coordinate (\pgfcirc@a@prefix-Vcont2) at ($(pgfcirc@Vcont2t) ! -\absvshift!-90 : (pgfcirc@Vcont1t)$) + coordinate (\pgfcirc@a@prefix-Vlab) at ($(\pgfcirc@a@prefix-Vcont2)!0.5!(\pgfcirc@a@prefix-Vcont1)$) + coordinate (pgfcirc@Vdir) at (\pgfcirc@a@prefix-Vcont2) \fi - \else % we are here in case of american here + \else % we are in case of american here - coordinate (pgfcirc@Vto) at ($(pgfcirc@Vto@flat) ! \absvshift!90 : (anchorendnode)$) - coordinate (pgfcirc@Vfrom) at ($(pgfcirc@Vfrom@flat) ! \absvshift!-90 : (anchorstartnode)$) + coordinate (\pgfcirc@a@prefix-Vto) at ($(pgfcirc@Vto@flat) ! \absvshift!90 : (anchorendnode)$) + coordinate (\pgfcirc@a@prefix-Vfrom) at ($(pgfcirc@Vfrom@flat) ! \absvshift!-90 : (anchorstartnode)$) coordinate (pgfcirc@bottom) at (\ctikzvalof{bipole/name}.-90) coordinate (pgfcirc@Vdir0) at ($(pgfcirc@mid)+(pgfcirc@bottom)-(pgfcirc@Vfrom@flat)$) - coordinate (pgfcirc@Vlab) at ($(pgfcirc@bottom) ! \absvshift!-90 : (pgfcirc@Vdir0)$) - coordinate (pgfcirc@Vdir) at ($(pgfcirc@mid)+(pgfcirc@Vlab)-(pgfcirc@Vfrom@flat)$) + coordinate (\pgfcirc@a@prefix-Vlab) at ($(pgfcirc@bottom) ! \absvshift!-90 : (pgfcirc@Vdir0)$) + coordinate (pgfcirc@Vdir) at ($(pgfcirc@mid)+(\pgfcirc@a@prefix-Vlab)-(pgfcirc@Vfrom@flat)$) + \ifpgf@circuit@bipole@voltage@raised + % move the from and to up to the level of Vlab + coordinate (\pgfcirc@a@prefix-Vto) at ($(\pgfcirc@a@prefix-Vlab)+(pgfcirc@Vto@flat)-(pgfcirc@mid)$) + coordinate (\pgfcirc@a@prefix-Vfrom) at ($(\pgfcirc@a@prefix-Vlab)+(pgfcirc@Vfrom@flat)-(pgfcirc@mid)$) + \fi \fi \else \ifpgf@circuit@europeanvoltage @@ -224,102 +234,113 @@ coordinate (pgfcirc@Vto1) at ($(pgfcirc@mid)+(pgfcirc@top)-(pgfcirc@Vfrom@flat)$) coordinate (pgfcirc@Vfrom1) at ($(pgfcirc@mid)+(pgfcirc@top)-(pgfcirc@Vto@flat)$) % add the extra distance - coordinate (pgfcirc@Vto) at ($(pgfcirc@Vto1) ! \absvshift!-90 : (pgfcirc@Vfrom1)$) - coordinate (pgfcirc@Vfrom) at ($(pgfcirc@Vfrom1) ! \absvshift!90 : (pgfcirc@Vto1)$) - coordinate (pgfcirc@Vlab) at ($(pgfcirc@Vto)!0.5!(pgfcirc@Vfrom) $) + coordinate (\pgfcirc@a@prefix-Vto) at ($(pgfcirc@Vto1) ! \absvshift!-90 : (pgfcirc@Vfrom1)$) + coordinate (\pgfcirc@a@prefix-Vfrom) at ($(pgfcirc@Vfrom1) ! \absvshift!90 : (pgfcirc@Vto1)$) + coordinate (\pgfcirc@a@prefix-Vlab) at ($(\pgfcirc@a@prefix-Vto)!0.5!(\pgfcirc@a@prefix-Vfrom) $) % direction line to shift the label later - coordinate (pgfcirc@Vdir) at (pgfcirc@Vto) + coordinate (pgfcirc@Vdir) at (\pgfcirc@a@prefix-Vto) \else % european voltages here - coordinate (pgfcirc@Vto) at ($(pgfcirc@Vto@flat) ! -\absvshift!90 : (anchorendnode)$) - coordinate (pgfcirc@Vfrom) at ($(pgfcirc@Vfrom@flat) ! -\absvshift!-90 : (anchorstartnode)$) + coordinate (\pgfcirc@a@prefix-Vto) at ($(pgfcirc@Vto@flat) ! -\absvshift!90 : (anchorendnode)$) + coordinate (\pgfcirc@a@prefix-Vfrom) at ($(pgfcirc@Vfrom@flat) ! -\absvshift!-90 : (anchorstartnode)$) % identify the two control points for the "arc" of the voltage coordinate (pgfcirc@Vcont1t) at ($(\ctikzvalof{bipole/name}.center) ! \bumpb ! (\ctikzvalof{bipole/name}.110)$) coordinate (pgfcirc@Vcont2t) at ($(\ctikzvalof{bipole/name}.center) ! \bumpb ! (\ctikzvalof{bipole/name}.70)$) % and shift them a bit - coordinate (pgfcirc@Vcont1) at ($(pgfcirc@Vcont1t) ! \absvshift!90 : (pgfcirc@Vcont2t)$) - coordinate (pgfcirc@Vcont2) at ($(pgfcirc@Vcont2t) ! \absvshift!-90 : (pgfcirc@Vcont1t)$) - coordinate (pgfcirc@Vlab) at ($(pgfcirc@Vcont2)!0.5!(pgfcirc@Vcont1)$) + coordinate (\pgfcirc@a@prefix-Vcont1) at ($(pgfcirc@Vcont1t) ! \absvshift!90 : (pgfcirc@Vcont2t)$) + coordinate (\pgfcirc@a@prefix-Vcont2) at ($(pgfcirc@Vcont2t) ! \absvshift!-90 : (pgfcirc@Vcont1t)$) + coordinate (\pgfcirc@a@prefix-Vlab) at ($(\pgfcirc@a@prefix-Vcont2)!0.5!(\pgfcirc@a@prefix-Vcont1)$) % direction line to shift the label later - coordinate (pgfcirc@Vdir) at (pgfcirc@Vcont2) + coordinate (pgfcirc@Vdir) at (\pgfcirc@a@prefix-Vcont2) \fi \else % we are in case of american here - coordinate (pgfcirc@Vto) at ($(pgfcirc@Vto@flat) ! \absvshift!-90 : (anchorendnode)$) - coordinate (pgfcirc@Vfrom) at ($(pgfcirc@Vfrom@flat) ! \absvshift!90 : (anchorstartnode)$) + coordinate (\pgfcirc@a@prefix-Vto) at ($(pgfcirc@Vto@flat) ! \absvshift!-90 : (anchorendnode)$) + coordinate (\pgfcirc@a@prefix-Vfrom) at ($(pgfcirc@Vfrom@flat) ! \absvshift!90 : (anchorstartnode)$) coordinate (pgfcirc@top) at (\ctikzvalof{bipole/name}.90) % move parallel to the component line coordinate (pgfcirc@Vdir0) at ($(pgfcirc@mid)+(pgfcirc@top)-(pgfcirc@Vfrom@flat)$) % and add the extra distance - coordinate (pgfcirc@Vlab) at ($(pgfcirc@top) ! \absvshift!90 : (pgfcirc@Vdir0)$) - coordinate (pgfcirc@Vdir) at ($(pgfcirc@mid)+(pgfcirc@Vlab)-(pgfcirc@Vfrom@flat)$) + coordinate (\pgfcirc@a@prefix-Vlab) at ($(pgfcirc@top) ! \absvshift!90 : (pgfcirc@Vdir0)$) + coordinate (pgfcirc@Vdir) at ($(pgfcirc@mid)+(\pgfcirc@a@prefix-Vlab)-(pgfcirc@Vfrom@flat)$) + \ifpgf@circuit@bipole@voltage@raised + % move the from and to up to the level of Vlab + coordinate (\pgfcirc@a@prefix-Vto) at ($(\pgfcirc@a@prefix-Vlab)+(pgfcirc@Vto@flat)-(pgfcirc@mid)$) + coordinate (\pgfcirc@a@prefix-Vfrom) at ($(\pgfcirc@a@prefix-Vlab)+(pgfcirc@Vfrom@flat)-(pgfcirc@mid)$) + \fi \fi \fi \ifx\@@kind\@@open - coordinate (pgfcirc@Vto) at (pgfcirc@Vto@flat) - coordinate (pgfcirc@Vfrom) at (pgfcirc@Vfrom@flat) + coordinate (\pgfcirc@a@prefix-Vto) at (pgfcirc@Vto@flat) + coordinate (\pgfcirc@a@prefix-Vfrom) at (pgfcirc@Vfrom@flat) \fi \ifpgf@circ@debugv node [ocirc, fill=red] at (anchorstartnode) {} node [ocirc, fill=blue] at (anchorendnode) {} - node [ocirc, fill=green] at (pgfcirc@Vto) {} - node [ocirc, fill=yellow] at (pgfcirc@Vfrom) {} + node [ocirc, fill=green] at (\pgfcirc@a@prefix-Vto) {} + node [ocirc, fill=yellow] at (\pgfcirc@a@prefix-Vfrom) {} node [odiamondpole, fill=green!50!black] at (pgfcirc@Vto@flat) {} node [odiamondpole, fill=orange] at (pgfcirc@Vfrom@flat) {} \ifpgf@circuit@europeanvoltage \ifpgf@circuit@bipole@voltage@straight \else - node [osquarepole, fill=red] at (pgfcirc@Vcont1) {} - node [osquarepole, fill=blue] at (pgfcirc@Vcont2) {} + node [osquarepole, fill=red] at (\pgfcirc@a@prefix-Vcont1) {} + node [osquarepole, fill=blue] at (\pgfcirc@a@prefix-Vcont2) {} \fi \fi \fi + % + % Now we draw the voltage things (only if not empty --- in which case we have been + % called just to set the anchors) + % + \pgf@circ@ifkeyempty{bipole/voltage/label/name}\else \ifpgf@circuit@europeanvoltage \ifpgf@circuit@bipole@voltage@straight \ifpgf@circuit@bipole@voltage@backward - (pgfcirc@Vto) --(pgfcirc@Vfrom) node[currarrow, sloped, allow upside down, pos=1,anchor=tip] {} + (\pgfcirc@a@prefix-Vto) --(\pgfcirc@a@prefix-Vfrom) node[currarrow, sloped, allow upside down, pos=1,anchor=tip] {} \else - (pgfcirc@Vfrom) --(pgfcirc@Vto) node[currarrow, sloped, allow upside down, pos=1,anchor=tip] {} + (\pgfcirc@a@prefix-Vfrom) --(\pgfcirc@a@prefix-Vto) node[currarrow, sloped, allow upside down, pos=1,anchor=tip] {} \fi \else \ifpgf@circuit@bipole@voltage@backward - (pgfcirc@Vto) .. controls (pgfcirc@Vcont2) and (pgfcirc@Vcont1) .. + (\pgfcirc@a@prefix-Vto) .. controls (\pgfcirc@a@prefix-Vcont2) and (\pgfcirc@a@prefix-Vcont1) .. node[currarrow, sloped, allow upside down, pos=1, anchor=tip] {} - (pgfcirc@Vfrom) + (\pgfcirc@a@prefix-Vfrom) \else - (pgfcirc@Vfrom) .. controls (pgfcirc@Vcont1) and (pgfcirc@Vcont2) .. + (\pgfcirc@a@prefix-Vfrom) .. controls (\pgfcirc@a@prefix-Vcont1) and (\pgfcirc@a@prefix-Vcont2) .. node[currarrow, sloped, allow upside down, pos=1, anchor=tip] {} - (pgfcirc@Vto) + (\pgfcirc@a@prefix-Vto) \fi \fi \else % american \ifpgf@circuit@bipole@voltage@backward \ifpgf@circ@oldvoltagedirection - (pgfcirc@Vfrom) node[inner sep=0, node font=\pgf@circ@avfont, + (\pgfcirc@a@prefix-Vfrom) node[inner sep=0, node font=\pgf@circ@avfont, anchor=\pgf@circ@bipole@voltage@label@anchor]{\pgf@circ@avplus} - (pgfcirc@Vto) node[inner sep=0, node font=\pgf@circ@avfont, + (\pgfcirc@a@prefix-Vto) node[inner sep=0, node font=\pgf@circ@avfont, anchor=\pgf@circ@bipole@voltage@label@anchor]{\pgf@circ@avminus} \else - (pgfcirc@Vfrom) node[inner sep=0, node font=\pgf@circ@avfont, + (\pgfcirc@a@prefix-Vfrom) node[inner sep=0, node font=\pgf@circ@avfont, anchor=\pgf@circ@bipole@voltage@label@anchor]{\pgf@circ@avminus} - (pgfcirc@Vto) node[inner sep=0, node font=\pgf@circ@avfont, + (\pgfcirc@a@prefix-Vto) node[inner sep=0, node font=\pgf@circ@avfont, anchor=\pgf@circ@bipole@voltage@label@anchor]{\pgf@circ@avplus} \fi \else \ifpgf@circ@oldvoltagedirection - (pgfcirc@Vfrom) node[inner sep=0, node font=\pgf@circ@avfont, + (\pgfcirc@a@prefix-Vfrom) node[inner sep=0, node font=\pgf@circ@avfont, anchor=\pgf@circ@bipole@voltage@label@anchor]{\pgf@circ@avminus} - (pgfcirc@Vto) node[inner sep=0, node font=\pgf@circ@avfont, + (\pgfcirc@a@prefix-Vto) node[inner sep=0, node font=\pgf@circ@avfont, anchor=\pgf@circ@bipole@voltage@label@anchor]{\pgf@circ@avplus} \else - (pgfcirc@Vfrom) node[inner sep=0, node font=\pgf@circ@avfont, + (\pgfcirc@a@prefix-Vfrom) node[inner sep=0, node font=\pgf@circ@avfont, anchor=\pgf@circ@bipole@voltage@label@anchor]{\pgf@circ@avplus} - (pgfcirc@Vto) node[inner sep=0, node font=\pgf@circ@avfont, + (\pgfcirc@a@prefix-Vto) node[inner sep=0, node font=\pgf@circ@avfont, anchor=\pgf@circ@bipole@voltage@label@anchor]{\pgf@circ@avminus} \fi \fi \fi + \fi % Closing the ...ifempty } %% Output routine for voltage sources @@ -351,21 +372,22 @@ \ifpgf@circuit@bipole@voltage@below coordinate (pgfcirc@Vfrom0) at ($(\ctikzvalof{bipole/name}.center) ! \bumpaplus ! (\ctikzvalof{bipole/name}.-120)$) coordinate (pgfcirc@Vto0) at ($(\ctikzvalof{bipole/name}.center) ! \bumpaplus ! (\ctikzvalof{bipole/name}.-60)$) - coordinate (pgfcirc@Vfrom) at ($ (pgfcirc@Vfrom0) ! \addvshift! -90: (pgfcirc@Vto0) $) - coordinate (pgfcirc@Vto) at ($ (pgfcirc@Vto0) ! \addvshift! 90: (pgfcirc@Vfrom0) $) + coordinate (\pgfcirc@a@prefix-Vfrom) at ($ (pgfcirc@Vfrom0) ! \addvshift! -90: (pgfcirc@Vto0) $) + coordinate (\pgfcirc@a@prefix-Vto) at ($ (pgfcirc@Vto0) ! \addvshift! 90: (pgfcirc@Vfrom0) $) \else coordinate (pgfcirc@Vfrom0) at ($ (\ctikzvalof{bipole/name}.center) ! \bumpaplus ! (\ctikzvalof{bipole/name}.120)$) coordinate (pgfcirc@Vto0) at ($ (\ctikzvalof{bipole/name}.center) ! \bumpaplus ! (\ctikzvalof{bipole/name}.60)$) - coordinate (pgfcirc@Vfrom) at ($ (pgfcirc@Vfrom0) ! \addvshift! 90: (pgfcirc@Vto0) $) - coordinate (pgfcirc@Vto) at ($ (pgfcirc@Vto0) ! \addvshift! -90: (pgfcirc@Vfrom0) $) + coordinate (\pgfcirc@a@prefix-Vfrom) at ($ (pgfcirc@Vfrom0) ! \addvshift! 90: (pgfcirc@Vto0) $) + coordinate (\pgfcirc@a@prefix-Vto) at ($ (pgfcirc@Vto0) ! \addvshift! -90: (pgfcirc@Vfrom0) $) \fi - coordinate (pgfcirc@Vlab) at ($(pgfcirc@Vto)!0.5!(pgfcirc@Vfrom) $) - coordinate (pgfcirc@Vdir) at (pgfcirc@Vto) + coordinate (\pgfcirc@a@prefix-Vlab) at ($(\pgfcirc@a@prefix-Vto)!0.5!(\pgfcirc@a@prefix-Vfrom) $) + coordinate (pgfcirc@Vdir) at (\pgfcirc@a@prefix-Vto) + \pgf@circ@ifkeyempty{bipole/voltage/label/name}\else \ifpgf@circuit@europeanvoltage \ifpgf@circuit@bipole@voltage@backward - (pgfcirc@Vto) -- node[currarrow, sloped, allow upside down, pos=1, anchor=tip] {} (pgfcirc@Vfrom) + (\pgfcirc@a@prefix-Vto) -- node[currarrow, sloped, allow upside down, pos=1, anchor=tip] {} (\pgfcirc@a@prefix-Vfrom) \else - (pgfcirc@Vfrom) -- node[currarrow, sloped, allow upside down, pos=1, anchor=tip] {} (pgfcirc@Vto) + (\pgfcirc@a@prefix-Vfrom) -- node[currarrow, sloped, allow upside down, pos=1, anchor=tip] {} (\pgfcirc@a@prefix-Vto) \fi \else% american voltage \ifpgf@circuit@bipole@voltageoutsideofsymbol @@ -373,23 +395,24 @@ \ifpgf@circ@fixbatteries \ifpgf@circuit@bipole@voltage@backward - (pgfcirc@Vfrom) node[node font=\pgf@circ@avfont] {\pgf@circ@avplus} - (pgfcirc@Vto) node[node font=\pgf@circ@avfont] {\pgf@circ@avminus} + (\pgfcirc@a@prefix-Vfrom) node[node font=\pgf@circ@avfont] {\pgf@circ@avplus} + (\pgfcirc@a@prefix-Vto) node[node font=\pgf@circ@avfont] {\pgf@circ@avminus} \else - (pgfcirc@Vfrom) node[node font=\pgf@circ@avfont] {\pgf@circ@avminus} - (pgfcirc@Vto) node[node font=\pgf@circ@avfont] {\pgf@circ@avplus} + (\pgfcirc@a@prefix-Vfrom) node[node font=\pgf@circ@avfont] {\pgf@circ@avminus} + (\pgfcirc@a@prefix-Vto) node[node font=\pgf@circ@avfont] {\pgf@circ@avplus} \fi \else \ifpgf@circuit@bipole@voltage@backward - (pgfcirc@Vfrom) node[node font=\pgf@circ@avfont] {\pgf@circ@avminus} - (pgfcirc@Vto) node[node font=\pgf@circ@avfont] {\pgf@circ@avplus} + (\pgfcirc@a@prefix-Vfrom) node[node font=\pgf@circ@avfont] {\pgf@circ@avminus} + (\pgfcirc@a@prefix-Vto) node[node font=\pgf@circ@avfont] {\pgf@circ@avplus} \else - (pgfcirc@Vfrom) node[node font=\pgf@circ@avfont] {\pgf@circ@avplus} - (pgfcirc@Vto) node[node font=\pgf@circ@avfont] {\pgf@circ@avminus} + (\pgfcirc@a@prefix-Vfrom) node[node font=\pgf@circ@avfont] {\pgf@circ@avplus} + (\pgfcirc@a@prefix-Vto) node[node font=\pgf@circ@avfont] {\pgf@circ@avminus} \fi \fi \fi \fi + \fi % closes ...ifempty } %% Output routine @@ -397,8 +420,21 @@ %% %% locally used dimensions \newdimen{\pgfcirc@labelshift} +\newif\ifpgfcirc@v@curved % helper if --- true only if voltages are curved \def\pgf@circ@drawvoltage{% node name - \pgfextra{ %WARNING: indentation is probably wrong + \pgfextra{% + % set the helper if...curved + \ifpgf@circuit@europeanvoltage + \ifpgf@circuit@bipole@voltage@straight + \pgfcirc@v@curvedfalse + \else + \pgfcirc@v@curvedtrue + \fi + \else + \pgfcirc@v@curvedfalse + \fi + % \typeout{V routine called with prefix: \pgfcirc@a@prefix} + % Label anchors WARNING: indentation is probably wrong \edef\pgfcircmathresult{\expandafter\pgf@circ@stripdecimals\pgf@circ@direction\pgf@nil} \ifnum\pgfcircmathresult >4 \ifnum\pgfcircmathresult <86 \ifpgf@circuit@bipole@voltage@below @@ -457,13 +493,15 @@ \fi \fi\fi + % export anchor position (if not needed, is always the same macro) + \expandafter\xdef\csname pgfcirc@\pgfcirc@a@prefix-Vlab-anchor\endcsname{\pgf@circ@bipole@voltage@label@anchor} % this must be set *before* changing for mirroring and inverting; in that case % the xscale/yscale parameters take it into account - \ifpgf@circuit@bipole@voltage@below - \def\pgf@circ@bipole@voltage@label@where{-90} - \else - \def\pgf@circ@bipole@voltage@label@where{90} - \fi + \ifpgf@circuit@bipole@voltage@below + \def\pgf@circ@bipole@voltage@label@where{-90} + \else + \def\pgf@circ@bipole@voltage@label@where{90} + \fi % magic to counteract the scale and yscale effects (there should be a better way...) \ifnum \ctikzvalof{mirror value}=-1 @@ -507,7 +545,12 @@ % check for american \edef\pgf@temp{/tikz/circuitikz/bipoles/\ctikzvalof{bipole/kind}/voltage/american label distance} \pgfkeysifdefined{\pgf@temp}{% - \edef\labeldist{\ctikzvalof{bipoles/\ctikzvalof{bipole/kind}/voltage/american label distance}}% + \ifpgf@circuit@bipole@voltage@raised + % do not apply the shift if we are using raised american style + \edef\labeldist{1.4}% default value + \else + \edef\labeldist{\ctikzvalof{bipoles/\ctikzvalof{bipole/kind}/voltage/american label distance}}% + \fi % \typeout{AL:ADJUSTED\space for\space \ctikzvalof{bipole/kind} \space at \space \aldist} }{\edef\labeldist{\ctikzvalof{voltage/american label distance}}} \ifpgf@circ@debugv\edef\whichtypeshift{AME}\fi @@ -534,6 +577,9 @@ \ifpgf@circuit@bipole@isvoltage \pgf@circ@drawvoltagegenerator + % add fake cont1 and cont2 anchors for export + coordinate (\pgfcirc@a@prefix-Vcont1) at ($(\pgfcirc@a@prefix-Vfrom) !0.5! (\pgfcirc@a@prefix-Vto)$) + coordinate (\pgfcirc@a@prefix-Vcont2) at ($(\pgfcirc@a@prefix-Vfrom) !0.5! (\pgfcirc@a@prefix-Vto)$) \else \pgf@circ@drawvoltagegeneric \fi @@ -544,26 +590,40 @@ % \pgf@circ@debugvtrue} % move a bit if requested - coordinate (pgfcirc@Vlab) at ($(pgfcirc@Vlab) ! \pgfcirc@labelshift ! \pgf@circ@bipole@voltage@label@where :(pgfcirc@Vdir)$) + coordinate (\pgfcirc@a@prefix-Vlab) at ($(\pgfcirc@a@prefix-Vlab) ! \pgfcirc@labelshift ! \pgf@circ@bipole@voltage@label@where :(pgfcirc@Vdir)$) % check for the case of american AND open \ifpgf@circuit@europeanvoltage \else \ifx\@@kind\@@open % override pgfcirc@Vlab - coordinate (pgfcirc@Vlab) at ($(pgfcirc@Vfrom@flat)!0.5!(pgfcirc@Vto@flat)$)\fi + coordinate (\pgfcirc@a@prefix-Vlab) at ($(pgfcirc@Vfrom@flat)!0.5!(pgfcirc@Vto@flat)$)\fi \fi \ifpgf@circ@debugv - node [odiamondpole, color=blue] at (pgfcirc@Vlab) {} + node [odiamondpole, color=blue] at (\pgfcirc@a@prefix-Vlab) {} node [odiamondpole, color=red] at (pgfcirc@Vdir) {} node [overlay, red, font=\tiny, anchor=south east, align=right] at(pgfcirc@Vdir) {\whichtypeshift:\the\pgfcirc@labelshift\\ DIR:\pgf@circ@bipole@voltage@label@where} \fi - node [anchor=\pgf@circ@bipole@voltage@label@anchor, inner sep=2pt, - \circuitikzbasekey/bipole voltage style](\ctikzvalof{bipole/name}voltage) - at (pgfcirc@Vlab) {\pgf@circ@finallabels{voltage/label}} + % put the node only if it's not empty + \pgf@circ@ifkeyempty{bipole/voltage/label/name}\else + node [anchor=\pgf@circ@bipole@voltage@label@anchor, inner sep=2pt, + \circuitikzbasekey/bipole voltage style](\ctikzvalof{bipole/name}voltage) + at (\pgfcirc@a@prefix-Vlab) {\pgf@circ@finallabels{voltage/label}} + \fi + + \ifpgfcirc@v@curved\else + % fake Vcont1 and Vcont2 for when they are exported --- in the middle of Vto and Vfrom + coordinate (\pgfcirc@a@prefix-Vcont1) at ($(\pgfcirc@a@prefix-Vfrom) !0.5! (\pgfcirc@a@prefix-Vto)$) + coordinate (\pgfcirc@a@prefix-Vcont2) at ($(\pgfcirc@a@prefix-Vfrom) !0.5! (\pgfcirc@a@prefix-Vto)$) + \fi + % revert from and to (and c1 - c2) if needed (simpler than rework the positioning above...) + \ifpgf@circuit@bipole@voltage@backward + \pgfcirc@swap@coordinates{\pgfcirc@a@prefix-Vfrom}{\pgfcirc@a@prefix-Vto} + \pgfcirc@swap@coordinates{\pgfcirc@a@prefix-Vcont1}{\pgfcirc@a@prefix-Vcont2} + \fi }%end drawvoltages \endinput diff --git a/graphics/pgf/contrib/circuitikz/tex/t-circuitikz.tex b/graphics/pgf/contrib/circuitikz/tex/t-circuitikz.tex index 9d588ae13a..06210be341 100644 --- a/graphics/pgf/contrib/circuitikz/tex/t-circuitikz.tex +++ b/graphics/pgf/contrib/circuitikz/tex/t-circuitikz.tex @@ -10,8 +10,8 @@ % % See the files gpl-3.0_license.txt and lppl-1-3c_license.txt for more details. -\def\pgfcircversion{1.2.0} -\def\pgfcircversiondate{2020/06/21} +\def\pgfcircversion{1.2.1} +\def\pgfcircversiondate{2020/07/06} \writestatus{loading}{\pgfcircversiondate{} The CircuiTikz circuit drawing package version \pgfcircversion} \usemodule[tikz] |