% Copyright 2007-2009 by Massimo Redaelli
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.
%
% See the file doc/LICENSE for more details.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%  Other shapes


%% Nothing

\pgfdeclareshape{emptyshape}{
	\savedanchor{\northeast}{%
		\pgf@x=.5\wd\pgfnodeparttextbox%
		\pgf@y=.5\ht\pgfnodeparttextbox%
   }
	\anchor{north}{
		\northeast
		\pgf@x=0cm
	}
	\anchor{east}{%
		\northeast
		\pgf@y=0cm
   }
	\anchor{south}{%
		\northeast
		\pgf@y=-\pgf@y
		\pgf@x=0cm
   }
	\anchor{west}{
		\northeast
		\pgf@y=0cm
		\pgf@x=-\pgf@x
	}
	\anchor{text}{%
		\pgfpointorigin
   }
	\anchor{center}{
		\pgfpointorigin
	}
}

%% Full terminal

\pgfdeclareshape{circ}{
	\anchor{center}{
		\pgfpointorigin
	}
	\anchorborder{
		\pgf@circ@res@left=\pgf@x
		\pgf@circ@res@up=\pgf@y
		\pgfpointborderellipse{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}
}{\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/nodes width}*\pgfkeysvalueof{/tikz/circuitikz/bipoles/length}}{\pgfkeysvalueof{/tikz/circuitikz/nodes width}*\pgfkeysvalueof{/tikz/circuitikz/bipoles/length}}}		
	}
	\behindforegroundpath{		
		
		\pgfscope
			\pgfpathcircle{\pgfpointorigin}{\pgfkeysvalueof{/tikz/circuitikz/nodes width}*\pgfkeysvalueof{/tikz/circuitikz/bipoles/length}}
			\pgfsetcolor{\pgfkeysvalueof{/tikz/circuitikz/color}}
			\pgfusepath{draw,fill}		
		\endpgfscope

		}
}

%% Empty terminal

\pgfdeclareshape{ocirc}{
	\anchor{center}{
		\pgfpointorigin
	}
	\anchorborder{
		\pgf@circ@res@left=\pgf@x
		\pgf@circ@res@up=\pgf@y
		\pgfpointborderellipse{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}
}{\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/nodes width}*\pgfkeysvalueof{/tikz/circuitikz/bipoles/length}}{\pgfkeysvalueof{/tikz/circuitikz/nodes width}*\pgfkeysvalueof{/tikz/circuitikz/bipoles/length}}}		
	}

	\behindforegroundpath{		
		
		\pgfscope
			\pgfpathcircle{\pgfpointorigin}{\pgfkeysvalueof{/tikz/circuitikz/nodes width}*\pgfkeysvalueof{/tikz/circuitikz/bipoles/length}}
			\pgfsetcolor{\pgfkeysvalueof{/tikz/circuitikz/color}}
			\pgfsetfillcolor{white}
			\pgfusepath{draw,fill}		
		\endpgfscope

		}
}

%% Diamond terminal

\pgfdeclareshape{diamondpole}{
	\anchor{center}{
		\pgfpointorigin
	}
	\anchorborder{
		\pgf@circ@res@left=\pgf@x
		\pgf@circ@res@up=\pgf@y
	}
	\behindforegroundpath{		
		\pgfscope
			\pgfmathsetlength{\pgf@circ@res@temp}{\pgfkeysvalueof{/tikz/circuitikz/nodes width}*\pgfkeysvalueof{/tikz/circuitikz/bipoles/length}}
			\pgftransformrotate{45}
			\pgfpathrectanglecorners
			{\pgfpoint{\pgf@circ@res@left-\pgf@circ@res@temp}{\pgf@circ@res@up+\pgf@circ@res@temp}}
			{\pgfpoint{\pgf@circ@res@left+\pgf@circ@res@temp}{\pgf@circ@res@up-\pgf@circ@res@temp}}
			\pgfsetcolor{\pgfkeysvalueof{/tikz/circuitikz/color}}
			\pgfusepath{draw,fill}		
		\endpgfscope
		}
}

%% Current arrow

\pgfdeclareshape{currarrow}{
	\anchor{center}{
		\pgfpointorigin
	}
	\behindforegroundpath{		
		
		\pgfscope
			\pgf@circ@res@step = \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
			\divide \pgf@circ@res@step by 16

			\pgfpathmoveto{\pgfpoint{-.7\pgf@circ@res@step}{0pt}}
			\pgfpathlineto{\pgfpoint{-.7\pgf@circ@res@step}{-.8\pgf@circ@res@step}}
			\pgfpathlineto{\pgfpoint{1\pgf@circ@res@step}{0pt}}
			\pgfpathlineto{\pgfpoint{-.7\pgf@circ@res@step}{.8\pgf@circ@res@step}}
			\pgfpathlineto{\pgfpoint{-.7\pgf@circ@res@step}{0pt}}			
			\pgfsetcolor{\pgfkeysvalueof{/tikz/circuitikz/color}}
			\pgfusepath{draw,fill}

		\endpgfscope
	}

}

%% Current arrow

\pgfdeclareshape{inputarrow}{
	\savedanchor{\tip}{
		\pgfpointorigin
	}
	\anchor{center}{
		\tip
	}
	\anchor{tip}{
		\tip
	}
	\behindforegroundpath{		
		
		\pgfscope
			\pgf@circ@res@step = \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
			\divide \pgf@circ@res@step by 16

			\pgfpathmoveto{\pgfpoint{-1.7\pgf@circ@res@step}{0pt}}
			\pgfpathlineto{\pgfpoint{-1.7\pgf@circ@res@step}{-.8\pgf@circ@res@step}}
			\pgfpathlineto{\pgfpoint{0pt}{0pt}}
			\pgfpathlineto{\pgfpoint{-1.7\pgf@circ@res@step}{.8\pgf@circ@res@step}}
			\pgfpathlineto{\pgfpoint{-1.7\pgf@circ@res@step}{0pt}}			
			\pgfsetcolor{\pgfkeysvalueof{/tikz/circuitikz/color}}
			\pgfusepath{fill}

		\endpgfscope
	}

}


%% box

\pgfdeclareshape{box}{
	\anchor{center}{
		\pgfpointorigin
	}
	\behindforegroundpath{		
		
		\pgfscope
			\pgf@circ@res@step = \ctikzvalof{bipoles/twoport/width}\pgf@circ@Rlen
			\pgf@circ@res@step = 0.5\pgf@circ@res@step
			\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
			\pgfpathrectanglecorners{\pgfpoint{-\pgf@circ@res@step}{\pgf@circ@res@step}}{\pgfpoint{\pgf@circ@res@step}{-\pgf@circ@res@step}}
			\pgfusepath{draw}
		\endpgfscope
	}

}

\endinput
