[pstricks] Another node connection needed

Herbert Voss Herbert.Voss at fu-berlin.de
Tue Jul 3 16:48:20 CEST 2007


Boris Veytsman wrote:
> I think I need another type of node connection.  It is like ncbar (or
> ncbarr in pstricks-add), but has 5 segments.
>
> 1.  Two segments armA and armB go from nodes A and B with angles
>     angleA and angleB correspondingly.
>
> 2.  The ends are connected by \ncbar with arm armC and angle angleC.
>
> Here is an example with angleA=0, angleB=-180, angleC=90:
>
>      -----------
>      |         |
>   A---         -----B
>
>   
\listfiles
\documentclass{article}
\usepackage{pst-node, pst-xkey}
\SpecialCoor

\makeatletter
\newdimen\psk at armC
\define at key[psset]{}{armC}{\pst at getlength{#1}\psk at armC}
\define at key[psset]{}{angleC}{\pst at getangle{#1}\psk at angleC}
\psset{armC=0.5cm,angleC=0}
%
\def\ncBar{\pst at object{ncBar}}
\def\ncBar at i{\check at arrow{\ncBar at ii}}
\def\ncBar at ii#1#2{%
  \begin at OpenObj
  \pnode(! tx at NodeDict begin
    /N@#1 load GetCenter % xA yA on stack
    \psk at armA\space \psk at angleA\space sin mul add \pst at number\psyunit
div exch
    \psk at armA\space \psk at angleA\space cos mul add \pst at number\psxunit
div exch
    end pstack){N at de@A}%
  \pnode(! tx at NodeDict begin
    /N@#2 load GetCenter % xB yB on stack
    \psk at armB\space \psk at angleB\space sin mul add \pst at number\psyunit
div exch
    \psk at armB\space \psk at angleB\space cos mul add \pst at number\psxunit
div exch
    end ){N at de@B}
  \ncline[nodesepB=0,arrows=\psk at arrowA-]{#1}{N at de@A}%
  \pcbar[angleA=\psk at angleC,armA=\psk at armC pt,arrows=-](N at de@A)(N at de@B)%
  \ncline[nodesepA=0,arrows=-\psk at arrowB]{N at de@B}{#2}
  \end at OpenObj%
}
\makeatother

\begin{document}

\begin{pspicture}[showgrid=true](5,5)
\pnode(1,1){A}\pnode(4,4){B}
\ncBar[arm=1cm,angleA=45,angleC=90,armC=1cm,arrowscale=2]{|->}{A}{B}
\end{pspicture}

\begin{pspicture}(5,5)
\pnode(1,3){A}\pnode(5,3){B}\psdot[linecolor=red](A)\psdot[linecolor=red](B)
\ncBar[angleA=0,angleB=180,angleC=90,armC=1cm,armB=1cm]{A}{B}
\rnode{A}{NodeA}\hspace{4cm}\ovalnode{B}{NodeB}
\ncBar[angleA=0,armA=1cm,angleB=180,armB=1.5cm,angleC=90,armC=1.5cm,linestyle=dashed]{A}{B}
\end{pspicture}

\end{document}


Herbert



More information about the PSTricks mailing list