1

I would like to add a filled background to the H timing character, which otherwise does not have one (it is just a line). I don't want to use the D or U characters which do have a background fill, because they also add lines at both top and bottom - I would like a line only on top. This is how far I got with the MWE below:

test1.png

In the metachar Y, I'm trying to add a H, then a background node (but \timing doesn't define a background layer), then use B (back) character to re-draw a H on "top" again, but that doesn't work - as it can be seen, the fills are still in front, and are not quite aligned with the transition lines.

How could I get an equivalent to a properly "filled" H character?

An additional question is - how could I get the \timing diagram as a "fitting node" (with width and height), so I could align it center in the master node? anchor=center doesn't make any difference (probably because either the named node tgraph1 doesn't have a size, or it just refers to the start of the diagram)

The MWE:

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{fit}
\usepackage{tikz-timing}

% "The modifiers ‘@’ and ‘$’ allow the user to include macros."
\tikztimingmetachar{Y}{H@{\begin{pgfonlayer}{background}}N[rectangle,fill=gray,anchor=north east,minimum width=\xunit,minimum height=\yunit,draw=none,on background layer]{}@{\end{pgfonlayer}}BH}
% \tikzset{timing/u/.style={draw=none}} \tikztimingmetachar{Y}{U{}BH} % doesn't look good
% \tikzset{timing/h/.style={draw=red}} % nope

% %http://tex.stackexchange.com/questions/47704/how-to-establish-node-anchor-like-points-on-a-tikz-rectangle-path
\makeatletter
\tikzset{ %
  fitting node/.style={
    inner sep=0pt,
    fill=none,
    draw=none,
    reset transform,
    fit={(\pgf@pathminx,\pgf@pathminy) (\pgf@pathmaxx,\pgf@pathmaxy)}
  },
  reset transform/.code={\pgftransformreset},
}
\makeatother


\begin{document}

\begin{tikzpicture}

\node[draw,minimum width=5cm,minimum height=2.5cm] (master) at (0,0) {};

\timing[very thick,
  name=tgraph1,
  fill=black,
  %timing/h/.style={fill=black},%{,cycle},
  %fitting node, % crashes w/ "! Dimension too large."
  anchor=center,
  timing/yunit=1cm,
]
    at (master.center)
  { LLL YYL HHH HHL };

\end{tikzpicture}

\end{document}

1 Answer 1

2

Well, still don't know about the node sizing and position, hope someone will help with that - but I did get somewhere in respect to background fill, by poking around in kpsewhich tikz-timing.sty. Basically, there are some macros handling transitions in there, and for some reason, only the \tikztimingdef{HL} will accept a fill parameter - and it seems to be working properly, but only as long as your timing sequence starts with an L and ends with an L. So, eventually, I end up with this:

test1a.png

... which is what I wanted in respect to background fill; unfortunately that will change all behavior of H characters, not just per single timing diagram. Here is the MWE (as a bit of trivia, used this for terminology - Proper meaning (and origin) of PCM? - Stack Overflow):

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{fit}
\usepackage{tikz-timing}

% to have the H character filled:
% (( note - if { LL LH HL H 0.9H 0.1L}:
% must split last H to 0.9H 0.1 (so to
% end on L, without drawing beyond range)
% else the fill of H is not good. ))
\tikztimingdef{HL}{
  -- ++(\slope,-\height)
  [fill=gray] \tikztiminguse{HH}{#1-\slope}
}

\begin{document}

\begin{tikzpicture}

\node[draw,minimum width=5cm,minimum height=2.5cm] (master) at (0,0) {};

\timing[very thick,
  name=tgraph1,
  fill=black,
  %timing/h/.style={fill=black},%{,cycle},
  %fitting node, % crashes w/ "! Dimension too large."
  anchor=center,
  timing/yunit=1cm,
]
    at (master.center)
  { LLL HHL HHH HHL };

\end{tikzpicture}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .