Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I haven't found any example of using TikZ for drawing Harel's statecharts notation. There are numerous examples of finite-state automata, but that cannot be applied for statecharts for two reasons: no hierarchy and no orthogonality. Can anyone suggest me please what is the best way to draw something as simple as this:

(A) --> (B(C) | C(D)),

where there are two top-level states: A and B|C (state with two orthogonal regions B and C, divided by a dashed line in the middle of state); B has a nasted state C, whereas C has a nested state D; interlevel connections should be possible, i.e. a directed connection between A and C.

Edited: here's the picture

enter image description here

share|improve this question
1  
Welcome to TeX.sx! –  lockstep Oct 18 '12 at 14:02
    
I could not see exactly what you are asking for. Could you put a picture that shows what you want? can be done in any editor. But I think you can not add the sample directly into the post, then let it anywhere on the internet and bring the link to us. =) –  tecepe Oct 18 '12 at 14:06
    
Welcome to LaTeX! As new user without image posting privileges simply include the image as normal and remove the ! in front of it to turn it into a link. A moderator or another user with edit privileges can then reinsert the ! to turn it into an image again until you get more rep points. –  percusse Oct 18 '12 at 14:07
add comment

1 Answer

up vote 3 down vote accepted

Code

\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{fit,arrows,calc}

\begin{document}

\begin{tikzpicture}
[   round/.style={rounded corners=1.5mm,minimum width=1cm,inner sep=2mm,above right,draw,align=left,text width=7mm}
]
    \node[round] (D) at (0,0) {D};
    \node[round] (E) at (2,0) {E};
    \node[above right,inner sep=2mm] (B) at (0,1) {B};
    \node[above right,inner sep=2mm] (C) at (2,1) {C};
    \node[round,fit=(B)(C)(D)(E)] (BC) {};
        \draw[densely dashed] (BC.north) -- (BC.south);
    \node[round] (A) at (2.5,2.5) {A};
    \draw[-latex] (A) to[out=180, in=90] (D);
    \draw[-latex] ($(BC.north east)+(-0.3,-0.3)$) coordinate (temp) to[out=180,in=90] (E);
        \fill (temp) circle (0.05);
\end{tikzpicture}

\end{document}

Output

enter image description here

share|improve this answer
    
wow, thats looks very nice. –  Thomas Oct 18 '12 at 16:10
    
Thanks, the fit library is very nice for such things. –  Tom Bombadil Oct 18 '12 at 16:12
    
Tom, thank you very much! Looks very nice indeed:)Would you be so kind to explain me how the semantic relationship between the orthogonal states and their substates is expressed, e.g. between B and D. I can clearly see the realtionship between BC and substates defined using fit library, but not the former. –  Vitaly Oct 18 '12 at 16:21
    
I used absolute positions, so B is placed at (0,1) and D is placed at (0,0). So B is simply put (manually) above D. You can also have a look at the positioning library for relative positioning, for e.g. \node[above right,inner sep=2mm,above of=1cm of D] (B) {B};. –  Tom Bombadil Oct 18 '12 at 16:27
    
Ok, thank you for your help:) –  Vitaly Oct 18 '12 at 16:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.