Circuitikz – Drawing a MOSFET Bodydiode Dashed in Circuitikz

circuitikz

I need to draw multiple stages of current in a circuit, and it involves MOSFETs having current through it's channel or trhough it's body diode. I want the FET drawn with solid lines, and the body diode with dashed lines when current goes through the channel, and vice versa.

I know I could do it drawing separately the MOSFET and the diode, but I think that would take more time. Is there a way to make the tag bodydiode have it's own line style?

To be clear, I want something like this:

enter image description here

However, the image above was made with separate components. I want it with this kind of component:

enter image description here

which is made with

\documentclass[12pt]{report}
\usepackage{tikz}
\usepackage{circuitikz}

\begin{document}

\begin{circuitikz}
\draw (0,0) node (mosfet1) [nigfete,anchor=D,bodydiode] {$Q_1$};
\end{circuitikz}

\end{document}

Best Answer

(update September 9, 2022) I have added the option for styling the body diodes for the next release 1.5.4. You can have a preview here: https://github.com/circuitikz/circuitikz/pull/651.

For versions < 1.5.4, you can use the following code to patch the body diode drawing code:

\documentclass[border=10pt]{standalone}
\usepackage[siunitx, RPvoltages]{circuitikz}
\usepackage{etoolbox}
\def\bodydiodehook{\relax}
\tikzset{bodydiode hook/.store in=\bodydiodehook}
\patchcmd{\drawbodydiode}
    {\pgfscope}{\bodydiodehook\pgfscope}
    {}{\fail}
\begin{document}
\begin{tikzpicture}[]
    \draw (0,0) node (mosfet1) [nigfete,anchor=D,bodydiode] {$Q_1$};
    \draw[densely dashed]  (2,0) node (mosfet1) [nigfete,anchor=D,bodydiode] {$Q_2$};
    \draw (4,0) node (mosfet1) [nigfete,anchor=D,bodydiode] {$Q_A$};
    \draw (0,-2) node (mosfet1) [nigfete,anchor=D,bodydiode, bodydiode hook={\pgfsetdash{{1pt}{1pt}}{0pt}}] {$Q_3$};
    \draw[densely dashed]  (2,-2) node (mosfet1) [nigfete,anchor=D,bodydiode, bodydiode hook={\pgfsetdash{}{0pt}}] {$Q_4$};
    \draw (4,-2) node (mosfet1) [nigfete,anchor=D,bodydiode] {$Q_B$};
    \path (5,0);% for the bounding box
\end{tikzpicture}
\end{document}

enter image description here