[Tex/LaTex] How to get access to the size parameters of a TikZ node

tikz-pgf

The following is a refined form of the problem that I posted more than 18 hours ago.

I am new to Tikz. However, even with the little knowledge I have of TikZ, I do appreciate its superiority over the other graphics packages that I have used previously.

I would like to create a TikZ node style that can produce the diagram shown below. I have drawn it using Xfig. However, I would like to draw it in a more flexible way using TikZ. The following constraints pertain to the diagram:

  1. The arcs on the left and the right sides of the rectangular structure are
    semi-circles — each has a radius that is half the height of the
    underlying rectangle(s).
  2. The two triangles inside the structure are similar.
  3. Each triangle is an isosceles triangle whose apex lies on the center-line
    that is parallel to the top and bottom edges of the rectangular structure.
  4. The dimensions of the triangles are fixed fractions of the height of the
    rectangular structure.
  5. The base of the filled triangle is on the left edge of the (imaginary) inner
    rectangle; and that of the second triangle is on the base right
    edge of the (imaginary) inner rectangle.

The only parameters that I should be free to alter are the positions of the anchors, the height and the width of the rectangular structure. I need to know
how I can access the height and width parameters and use them in the calculation
of the other parameters of the structure.

Could some experienced user of TikZ and PGF come to my aid.

Thanks.

enter image description here

Best Answer

Here is one possibility with not-exactly-failproof node construction. The triangles are also accesible with (<nodename>-leftri) and (<nodename>-rightri). The possible failure reason would be rotating the node. It's possible to include that but it's unnecessarily complicated at this stage and I don't know if you ever need it.

\documentclass[tikz]{standalone}
\usetikzlibrary{shapes.geometric}

\begin{document}

\begin{tikzpicture}[mynode/.style args={#1 and #2}{
draw,
minimum height=#1,
minimum width=#2,
rounded corners=0.5*#1,
append after command={
\pgfextra{%                 
    \begin{pgfinterruptpath}
    \node[isosceles triangle,
          isosceles triangle stretches,
          draw=black,inner sep=0,
          anchor=west,
          minimum width=0.5*#1,
          minimum height=0.2*#1,
          fill=black] 
          (\tikzlastnode-leftri) at ([xshift=0.5*#1]\tikzlastnode.west) {};
    \node[isosceles triangle,
          isosceles triangle stretches,
          draw=black,inner sep=0,
          anchor=west,
          minimum width=0.5*#1,
          minimum height=0.2*#1,
          isosceles triangle apex angle=90]
          (\tikzlastnode-rightri) at ([xshift=-0.5*#1]\tikzlastnode.east) {};
\end{pgfinterruptpath}
        }   
    }
}
]

\node[mynode=1cm and 4cm] (a) {};
\node[mynode=3cm and 8cm] (b) at (0,3) {};
\draw (a-leftri) -- (b-rightri);
\end{tikzpicture}

\end{document}

enter image description here

Related Question