I'm trying to create a a new shape (for nodes) based on the \pgfdeclareshape command.
The shape I'd like to define is supposed to represent a register (aka a D-flip-flop) like the ones used in digital architectural schematics. That is, a mere box to which a small '>' symbol has been added near to the lower left corner, just a little above (indicating the clock input). I'd also like to make it possible to define some new anchors on the borders. Like the so-called "D" input and "Q" output, some "R" reset input, etc, everything being optionally displayed or not (and if yes, possibly with a text label) depending on parameters passed at node definition time. Ideally, the size of the '>' symbol, along with the font size of the text labels of all inputs and outputs, would be automatically scaled to the size of the node. For instance these sizes would be proportional to the minimum width or minimum height of the node, the '>' symbol being placed at a specific amount of the height of the main rectangle, like .2 times (20%).
Let's say I'd like the fully-featured new shape to look like that (except the four small horizontal lines that would not be part of the shape itself):
I've tried to imitate the examples I've found in the TikZ/PGF manual (§101 of version 3.0.1) and on the web, like the document example which inherits from the rectangle predefined shape. Alas I can't get my code to work. When I try to define the coordinates of the left down edge of the small '>', using for instance \pgf@xd=\pgf@xa, I get a pdflatex error.
Does anyone have a clue to how to create this shape?
Thanks in advance!
Karim
PS: Below is my sample code. I've indicated with a comment the line that makes pdflatex crash. When I remove it, I can at least get a simple... rectangle. Yes, I know everything is far from over ;)
\documentclass{standalone} \usepackage{tikz} \begin{document} \makeatletter \pgfdeclareshape{register}{ \inheritsavedanchors[from=rectangle] \inheritanchorborder[from=rectangle] \inheritanchor[from=rectangle]{center} \inheritanchor[from=rectangle]{north} \inheritanchor[from=rectangle]{south} \inheritanchor[from=rectangle]{west} \inheritanchor[from=rectangle]{east} \backgroundpath{ % store lower right in xa/ya and upper right in xb/yb \southwest \pgf@xa=\pgf@x \pgf@ya=\pgf@y \northeast \pgf@xb=\pgf@x \pgf@yb=\pgf@y % compute starting point of the '>' \pgf@xc=\pgf@xa \pgf@yc=\pgf@ya \advance\pgf@yc by -5pt % this should be a parameter % construct main path \pgfpathmoveto{\pgfpoint{\pgf@xa}{\pgf@ya}} \pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@ya}} \pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@yb}} \pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@yb}} \pgfpathclose \pgf@xd=\pgf@xa } } \makeatother \begin{tikzpicture} \node[draw,shape=register,inner sep=2ex] (x) {D}; \end{tikzpicture} \end{document} 
\newdimen\pgf@xd, or\newlength\pgf@xdand\setlength{\pgf@xd}{\pgf@xa}instead of\\pgf@xd=\pgf@xa