I want to make a node which will be a SPDT switch symbol, which looks like this:

So, I thought, I could start by deriving a custom shape from a rectangular node, whose size will be set by minimum width/height; then I could add small circular nodes at south west, north west and east, and draw a connector line with arrow from the eastto the north west node. I would like the added nodes to be addressable (so I can use them later for connector lines); and I would also like to have a parameter for controlling the small circular nodes' size.
I tried reading:
- Can a shape be composed out of "subshapes" in TikZ?
- How to draw saturation symbol inside a node in TikZ
- pgfdeclareshape with variable dimensions using pgfkeys
... and so I tried to cook up an example, but I get stuck at this point:

The X and the rectangular border are added just for debug; it starts fine (I can draw a circle path, and also add a circular node at the same position, at south west), but then the problem is - it seems I cannot calculate the height of the master node properly for the north west "small" node.
What would be the right way to solve this? Also, the MWE below works for above=of positioning, but crashes for right=of positioning - any way to fix that?
Here is my MWE so far:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
% https://tex.stackexchange.com/questions/18400/can-a-shape-be-composed-out-of-subshapes-in-tikz
% https://tex.stackexchange.com/questions/65469/how-to-draw-saturation-symbol-inside-a-node-in-tikz
% https://tex.stackexchange.com/questions/73877/pgfdeclareshape-with-variable-dimensions-using-pgfkeys
\makeatletter
\pgfkeys{/tikz/spdtcircsize/.initial = 0.15cm}
\pgfdeclareshape{spdt}{
%\savedanchor\centerpoint{
% \pgf@x = .5\wd\pgfnodeparttextbox
% \pgf@y = .5\ht\pgfnodeparttextbox
%}
%\anchor{center}{\centerpoint}
\inheritsavedanchors[from={rectangle}]
\inheritbackgroundpath[from={rectangle}]
\inheritanchorborder[from={rectangle}]
\foreach \x in {center,north east,north west,north,south,south east,south west}{
\inheritanchor[from={rectangle}]{\x}
}
\saveddimen\circsize{\pgf@x=\pgfkeysvalueof{/tikz/spdtcircsize}}
% \savedanchor{\center}{%
% \pgfpointorigin}
% \anchor{center}{\center}
%%
% \backgroundpath{
\foregroundpath{
% \centerpoint
% \pgfkeys{/pgf/minimum size = \circsize}
% \pgfset{inner sep=1pt}
%%
\southwest
\pgfpathcircle{\southwest}{\circsize}
% \pgfusepath{draw}
{
\pgfkeys{/pgf/minimum size = \circsize}
\pgftransformshift{\southwest}
\pgfnode{circle}{center}{}{\tikz@fig@name-c1}{\pgfusepath{draw}}
}
%\pgfpathmoveto{\pgfpoint{0}{-\pgf@ya}}
\pgfpointdiff{\northeast}{\southwest}
\pgf@xa=\pgf@x \pgf@ya=\pgf@y
% \pgfpathmoveto{\pgfpointadd{\southwest}{\pgfpoint{0}{-1.0\pgf@ya}}}
\pgfpathcircle{\pgfpointadd{\southwest}{\pgfpoint{0}{-1.0\pgf@ya}}}{\circsize}
% \pgfnode{circle}{center}{}{\tikz@fig@name-c2}{}
}
}
\makeatother
\begin{document}
\begin{tikzpicture}
\node[draw] (n1) at (1,0) {Testing};
% right= of causes ! Package PGF Math Error: Unknown function `west' (in 'west').
\node[spdt,draw,minimum width=20pt,minimum height=20pt] (n2) [above=10pt of n1] {X};
\end{tikzpicture}
\end{document}


east,westanchors to the foreach. – percusse Apr 22 '14 at 22:51:)). That fixes theright=ofissue, but I still don't know how to use the height provided by\pgfpointdiffproperly... Cheers! – sdaau Apr 22 '14 at 22:56\pgfnodepartextboxare simply artefacts of copypasting of snippets... Cheers! – sdaau Apr 24 '14 at 04:16