Zeichnen eines Parallelogramms in einem Flussdiagramm mit der psmatrix-Umgebung

Zeichnen eines Parallelogramms in einem Flussdiagramm mit der psmatrix-Umgebung

Ich versuche, Flussdiagramme zu zeichnen, und habe mir einige Pakete angesehen. Da ich mich damit besser auskenne, pstrickshabe ich es ausgewählt, und da ich die Beispiele überprüft habe, versuche ich, es mit der psmatrixUmgebung zu zeichnen.

Unser Lehrer hat uns gesagt, dass die „Initialisierungen“ in einem Parallelogramm geschrieben werden sollten, und als ich versuchte, dies in mein Flussdiagramm zu zeichnen, hatte ich keine Ahnung, welche Syntax ich für ein Parallelogramm verwenden sollte!

Gibt es dafür einen speziellen Befehl?

Muss ich \psdiaboxeinen bestimmten Winkel verwenden, um ein Parallelgramm zu erhalten? Wenn ja, wie muss ich den Winkel definieren?

Hier ist ein Beispiel dessen, was ich zu zeichnen versuche, wobei ich das rote Kästchen – „Initialisierung“ – als Parallelogramm statt als Rechteck haben möchte.

Bildbeschreibung hier eingeben

‎\documentclass{article}‎
‎\usepackage{pstricks}‎
‎\usepackage{pst-node}‎
‎\usepackage{pst-blur}‎
‎\definecolor{Pink}{rgb}{1.,0.75,0.8}‎
‎\pagestyle{empty}‎
‎\begin{document}‎


‎\vspace{0.5cm}‎
‎\small‎‎‎
  ‎\psset{shadowcolor=black!70,blur=true}‎
  ‎\begin{psmatrix}[rowsep=0.4,colsep=0.5]‎
    ‎\psovalbox{Begin} \\‎
    ‎\psframebox[‎,fillstyle=solid,fillcolor=red‎]{Initialisations} \\‎
    ‎\psdiabox{Special} &‎
       ‎\psframebox[shadow=true]{Call to SP1} & \psframebox[shadow=true]{Call to SP2} \\‎
    ‎\psframebox{Action 1} \\‎
    ~‎\\‎
    ‎\psframebox{Action 2} \\‎
    ‎\psovalbox{End}‎
    % ‎Links‎
    ‎\ncline{->}{1,1}{2,1}‎
    ‎\ncline{->}{2,1}{3,1}‎
    ‎\ncline{->}{3,1}{4,1}<{\textcolor{red}{No}}‎
    ‎\ncline{->}{4,1}{6,1}‎
    ‎\ncline{->}{6,1}{7,1}‎
    ‎\ncline{->}{3,1}{3,2}^{\textcolor{red}{Yes}}‎
    ‎\ncline{->}{3,2}{3,3}‎
    ‎\ncbar[angleA=-90,armB=0,nodesepB=0.25]{->}{3,3}{4,1}‎
  \end{document}

Antwort1

\documentclass{article}
\usepackage{pstricks}
\usepackage{pst-node,pst-3d}
\usepackage{pst-blur}
\definecolor{Pink}{rgb}{1.,0.75,0.8}

\makeatletter
\newsavebox\TBox
\newcommand\psParaBox[2][]{{
  \psset{framesep=5pt,gangle=60,#1}%
  \sbox\TBox{\psTilt{\psk@gangle}{\psframebox{\phantom{ #2}}}}%
  \usebox\TBox%  
  \rput(-0.5\wd\TBox,\dimexpr 0.5\ht\TBox-0.5ex\relax){ #2}}}
\makeatother

\pagestyle{empty}
\begin{document}

  \psset{shadowcolor=black!70,blur}
  \begin{psmatrix}[rowsep=0.4,colsep=0.5]
    \psovalbox{Begin} \\
    \psParaBox[fillstyle=solid,fillcolor=red!40]{Initialisations} \\
    \psdiabox{Special} &
       \psframebox[shadow=true]{Call to SP1} & \psframebox[shadow=true]{Call to SP2} \\
    \psframebox{Action 1} \\
    ~\\
    \psframebox{Action 2} \\
    \psovalbox{End}
    % Links
    \ncline{->}{1,1}{2,1}
    \ncline{->}{2,1}{3,1}
    \ncline{->}{3,1}{4,1}<{\textcolor{red}{No}}
    \ncline{->}{4,1}{6,1}
    \ncline{->}{6,1}{7,1}
    \ncline{->}{3,1}{3,2}^{\textcolor{red}{Yes}}
    \ncline{->}{3,2}{3,3}
    \ncbar[angleA=-90,armB=0,nodesepB=0.25]{->}{3,3}{4,1}
  \end{psmatrix}
\end{document}

Bildbeschreibung hier eingeben

Antwort2

Die folgende Definition \psparallelogram[<options>]{<stuff>}funktioniert genauso \psdiaboxund \psframeboxfunktioniert:

Bildbeschreibung hier eingeben

\documentclass{article}
\usepackage{pstricks}
\usepackage{pst-node}
\usepackage{pst-blur}
\definecolor{Pink}{rgb}{1.,0.75,0.8}

% ================================
% Source: http://tug.org/pipermail/pstricks/2009/006766.html

\makeatletter
\newdimen\psparallelogramsep
\def\psset@parallelogramsep#1{\pssetlength\psparallelogramsep{#1}}
\psset@parallelogramsep{3mm}
\def\psparallelogrambox{\pst@object{psparallelogrambox}}
\def\psparallelogrambox@i{\pst@makebox\psparallelogrambox@ii}
\def\psparallelogrambox@ii{%
    \begingroup
    \pst@useboxpar
    \pst@dima=\pslinewidth
    \advance\pst@dima by \psframesep
    \pst@dimc=\wd\pst@hbox\advance\pst@dimc by \pst@dima
    \pst@dimb=\dp\pst@hbox\advance\pst@dimb by \pst@dima
    \pst@dimd=\ht\pst@hbox\advance\pst@dimd by \pst@dima
    \setbox\pst@hbox=\hbox{%
        \ifpsboxsep\kern\pst@dima\fi
        \begin@ClosedObj
        \addto@pscode{%
            \psk@cornersize
            \pst@number\pst@dima neg
            \pst@number\pst@dimb neg
            \pst@number\pst@dimc
            \pst@number\pst@dimd .5
            \pst@number\psparallelogramsep
            \tx@Parallelogram}%
            \def\pst@linetype{2}%
            \showpointsfalse
        \end@ClosedObj
        \box\pst@hbox
        \ifpsboxsep\kern\pst@dima\fi%
    }%
    \ifpsboxsep\dp\pst@hbox=\pst@dimb\ht\pst@hbox=\pst@dimd\fi
    \leavevmode\box\pst@hbox
    \endgroup%
}

% From the Frame and Rect PostScript macros
\pst@def{Parallelogram}<{%
/ParallelogramA {
x1 pgs sub y1 moveto
x1 y2 lineto
x2 pgs add y2 lineto
x2 y1 lineto
x1 pgs sub y1 lineto
closepath} def
%
/pgs ED
CLW mul
/a ED
3 -1 roll
2 copy gt { exch } if
a sub
/y2 ED
a add
/y1 ED
2 copy gt { exch } if
a sub
/x2 ED
a add
/x1 ED
1 index 0 eq {pop pop ParallelogramA } { OvalFrame } ifelse}>
\makeatother

\def\pspbox[#1]#2{\makebox[#1]{\psparallelogrambox{#2}}}

% ================================


\pagestyle{empty}
\begin{document}


\vspace{0.5cm}
\small
  \psset{shadowcolor=black!70,blur=true}
  \begin{psmatrix}[rowsep=0.4,colsep=0.5]
    \psovalbox{Begin} \\
    %\psframebox[fillstyle=solid,fillcolor=red]{Initialisations} \\
    \psparallelogrambox[fillstyle=solid,fillcolor=red]{Initialisations} \\
    \psdiabox{Special} &
       \psframebox[shadow=true]{Call to SP1} & \psframebox[shadow=true]{Call to SP2} \\
    \psframebox{Action 1} \\
    ~\\
    \psframebox{Action 2} \\
    \psovalbox{End}
    % Links
    \ncline{->}{1,1}{2,1}
    \ncline{->}{2,1}{3,1}
    \ncline{->}{3,1}{4,1}<{\textcolor{red}{No}}
    \ncline{->}{4,1}{6,1}
    \ncline{->}{6,1}{7,1}
    \ncline{->}{3,1}{3,2}^{\textcolor{red}{Yes}}
    \ncline{->}{3,2}{3,3}
    \ncbar[angleA=-90,armB=0,nodesepB=0.25]{->}{3,3}{4,1}
  \end{psmatrix}
\end{document}

Die Quelle für das Parallelogramm stammt aus dem PStricks-Mailingeintrag aufParallelogramm in Bäumen.

verwandte Informationen