[Tex/LaTex] SCR (aka thyristor) symbol in TikZ circuit

circuitssymbolstikz-circuit-libtikz-pgf

I want to use the SCR symbol in a circuit drawn with TikZ library circuit. I'm able to write a tikzpicture similar to the image below but I don't know how to draw a TikZ circuit symbol (with anchors and so on).

Is there any manual that has guidelines to follow in creating symbols or at least indicating the minimum requirements it should have? I haven't found too much on the pgfmanual.

Note that I don't want a solution involving CircuiTikZ. The library circuit of TikZ is based on CircuiTikZ but the two of them are pretty much incompatibles and cannot be used (without some efforts) in the same document.

Here some picture of an SCR symbol, but I think that the best solution is to use the diode symbol (that is already present in the circuit tikzlibrary):

SCR

Edit:
Looking at the comments I think that my exposition of the problem was the best possible. Sorry for that, I'll try to explain better in the following lines.

First of all, I'm looking for a symbol in the circuit TikZ sense. This means that I'm not looking for a simple tikz image but for something that I could use in a tikzpicture like

\documentclass[tikz]{standalone}
\usetikzlibrary{circuits.ee.IEC}
\begin{document}
\begin{tikzpicture}[circuit ee IEC]
\draw(0,1)to [diode] (2,1)to[inductor] (4,1);
\draw(0,2)to [thyristor] (2,2)to[inductor] (4,2);
\end{tikzpicture}
\end{document}

Note that in the image are displayed two diode, not a diode and a thyristor.

example

I also need to have the right anchors. This is an example of the zener diode anchors.

\documentclass[tikz]{standalone}
\usetikzlibrary{circuits.ee.IEC}
\tikzset{shape example/.style= {  
  color=black!30,
  draw,
  fill=yellow!30,
  line width=.5cm,
  inner xsep=2.5cm,
  inner ysep=0.5cm}
}
\begin{document}
\begin{tikzpicture}
\node[
  name=s,
  shape=breakdown diode IEC,
  shape example,
  minimum width=6cm,
  minimum height=4cm] {};
\foreach\anchor/\placement in {
  center/above,
  30/above right,
  north/above, 
  south/below, 
  east/left, 
  west/right,
  north east/above, 
  south east/below, 
  south west/below, 
  north west/above,
  input/left,
  output/right}
\draw [shift=(s.\anchor)] 
  plot [mark=x] coordinates{(0,0)} 
  node [\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{document}

zener

In my case, obv the shape should be different from a diode and a zener, but it should also have another anchor: instead of s.input I should have s.input1 and s.input2. Even if it would better to have the three anchors named s.anode,s.cathode and s.gate.

Any answer that cover this requirements is appreciated but if you could also give me some reference, like where did you find the definition of these symbols or what are the preferred steps in defining a new circuit symbol will be appreciated (in this way I don't need to ask again an help for each new circuit symbol).

Best Answer

OK, I learned a very nice trick from Torbjørn T.: pics that behave like nodes. Most likely I am reinventing something, but anyway here comes a thyristor pic whose elements you can access from outside, but you can also reference the whole thing.

\documentclass[tikz,border=3.14mm]{standalone}
\makeatletter % https://tex.stackexchange.com/a/241737/121799
\tikzset{pics/named scope code/.style={code={\tikz@fig@mustbenamed%
  \begin{scope}[local bounding box/.expanded=\tikz@fig@name]#1\end{scope}%
}}}
\makeatother
\tikzset{pics/.cd,
  pic thyristor/.style={named scope code={
  \begin{scope}[line join=round,font=\sffamily,line width=1.5pt]
    \draw (0,0) coordinate(-Anode) node[above]{Anode}-- ++(1.5,0) 
    -- ++(0,0.5) -- ++ (0.5,-0.5) coordinate(tip) 
    -- ++(-0.5,-0.5) -- ++(0,0.5);
    \draw (tip) -- ++ (0,0.5) -- ++ (0,-1) coordinate[pos=0.75] (branch);
    \draw (tip) -- ++ (1.5,0) coordinate(-Cathode) node[above]{Cathode};
    \draw (branch) -- ++(0.25,-0.25) -- ++ (0,-0.25) coordinate(-Gate)
    node[below]{Gate};
   \end{scope}
  }}
}
\begin{document}
\begin{tikzpicture}
\pic (thyr1) at (0,0) {pic thyristor};
\draw[blue,latex-latex] (thyr1-Anode) to[out=-90,in=180] (thyr1-Gate);
\pic (thyr2) at (7,0) {pic thyristor};
\draw[ultra thick,red,-latex] (thyr1) -- (thyr2);
\end{tikzpicture}
\end{document}

enter image description here

I added illustrations of how you may use it.

ADDENDUM: I went a little bit along the path outlined and paved by @percusse, and also shamelessly stole from his code. So here is what I have at the moment. In do not think it is particularly pretty but may potentially serve as a starting point. What I did is to look up the definitions in pgflibraryshapes.gates.ee.IEC.code.tex and slightly modified them. But I confess that I do not really know what I am doing, so there is certainly a lot of room for improvement.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{circuits.ee.IEC}
\makeatletter
\pgfdeclareshape{thyristor}
{ \inheritsavedanchors[from=rectangle ee]
  \inheritanchor[from=rectangle ee]{center}
  \inheritanchor[from=rectangle ee]{north}
  \inheritanchor[from=rectangle ee]{south}
  \inheritanchor[from=rectangle ee]{east}
  \inheritanchor[from=rectangle ee]{west}
  \inheritanchor[from=rectangle ee]{north east}
  \inheritanchor[from=rectangle ee]{north west}
  \inheritanchor[from=rectangle ee]{south east}
  \inheritanchor[from=rectangle ee]{south west}
  \inheritanchor[from=rectangle ee]{input}
  \inheritanchor[from=rectangle ee]{output}
  \inheritanchorborder[from=rectangle ee]

  \savedanchor\gatepoint{%
    \pgfmathsetlength\pgf@xa{\pgfkeysvalueof{/pgf/outer xsep}}%
    \pgf@x=4.8\pgf@xa%
    \pgfmathsetlength\pgf@ya{\pgfkeysvalueof{/pgf/outer ysep}}%
    \pgfmathsetlength\pgf@yb{\pgfkeysvalueof{/pgf/minimum height}}%
    \pgf@y=-3.2\pgf@ya%
    \advance\pgf@y by-.5\pgf@yb%
  }
  \anchor{gate}{\gatepoint}

  \backgroundpath{
    \pgf@process{\pgfpointadd{\southwest}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}}
    \pgf@xa=\pgf@x \pgf@ya=\pgf@y
    \pgf@process{\pgfpointadd{\northeast}{\pgfpointscale{-1}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}}}
    \pgf@xb=\pgf@x \pgf@yb=\pgf@y
    \pgf@xc=.5\pgf@xa \advance\pgf@xc by.5\pgf@xb
    \pgf@yc=.5\pgf@ya
    \advance\pgf@yc by .5\pgf@yb
    % Triangle:
    \pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@ya}}
    \pgfpathlineto{\pgfqpoint{\pgf@xc}{\pgf@yc}}
    \pgfpathlineto{\pgfqpoint{\pgf@xa}{\pgf@yb}}
    \pgfpathclose
  }


  \beforebackgroundpath{
    {
      \pgf@process{\pgfpointadd{\southwest}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}}
      \pgf@xa=\pgf@x \pgf@ya=\pgf@y
      \pgf@process{\pgfpointadd{\northeast}{\pgfpointscale{-1}{\pgfpoint{\pgfkeysvalueof{/pgf/outer xsep}}{\pgfkeysvalueof{/pgf/outer ysep}}}}}
      \pgf@xb=\pgf@x \pgf@yb=\pgf@y
      \pgf@yc=.5\pgf@ya
      \advance\pgf@yc by.5\pgf@yb
      \pgfpathmoveto{\pgfpointorigin} %
      \pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgf@yc}}
      \pgfusepathqstroke
      \pgf@xc=.5\pgf@xa
      \advance\pgf@xc by.5\pgf@xb
      \pgftransformshift{\pgfqpoint{\pgf@xc}{\pgf@yc}}  
      \pgf@yc=.5\pgf@yb
      \advance\pgf@yc by-.5\pgf@ya
      \pgftransformscale{\pgf@sys@tonumber{\pgf@yc}} 
      % the following is from @percusses answer
      \pgfpathmoveto{\pgfqpoint{0pt}{0pt}}%
      \pgfpathlineto{\pgfqpoint{0pt}{-1pt}}%
      \pgfpathlineto{\pgfqpoint{0pt}{1pt}}%
      \pgfpathmoveto{\pgfpoint{0pt}{-0.5pt}}%
      \pgfpathlineto{\pgfpoint{0.6pt}{-0.9pt}}%
      \pgfpathlineto{\pgfpoint{0.6pt}{-1.4pt}}%      
      \pgfusepathqstroke%     
    }
  }
}
\pgfkeys{
  /pgf/thyristor/before background/.initial=,
}

\makeatother
\tikzset{
  thyristor IEC graphic/.style={circuit symbol size=width 3 height 2,
    shape=thyristor,
    transform shape,draw
    }}
\tikzset{
  circuit declare symbol = thyristor
    }
\tikzset{
  circuit ee IEC/.append style=
  {set thyristor graphic              = thyristor IEC graphic}}

\begin{document}
\begin{tikzpicture}[circuit ee IEC]
\draw(0,1)to [diode] (2,1)to[inductor] (4,1);
\draw(0,2)to [thyristor] (2,2)to[inductor] (4,2);
\end{tikzpicture}
\tikzset{shape example/.style= {  
  color=black!30,
  draw,
  fill=yellow!30,
  line width=.5cm,
  inner xsep=2.5cm,
  inner ysep=0.5cm}
}
\begin{tikzpicture}
\node[
  name=s,
  shape=thyristor,
  shape example,
  minimum width=6cm,
  minimum height=4cm] {};
\foreach\anchor/\placement in {gate/below,
  center/above,
  30/above right,
  north/above, 
  south/below, 
  east/left, 
  west/right,
  north east/above, 
  south east/below, 
  south west/below, 
  north west/above,
  input/left,
  output/right}
\draw [shift=(s.\anchor)] 
  plot [mark=x] coordinates{(0,0)} 
  node [\placement] {\scriptsize\texttt{(s.\anchor)}};
\end{tikzpicture}
\end{document}

enter image description here

UPDATE: After digging through some of the libraries, I believe to understand things slightly better now. Notice that I did not adjust the border to also go around the gate.

Related Question