[pstricks] [Nodes] \ncdiagg connection with a negative value for armA
Denis Girou
Denis.Girou at idris.fr
Fri Apr 27 21:29:20 CEST 2001
Denis Roegel <Denis.Roegel at loria.fr> recently point me on the fact that
the example of pages 41-42 of the so-called Beta documentation (betadoc2.ps
on CTAN and http://tex.loria.fr/tex/graph-pack/pstricks/pst-doc2.ps.gz
on the LaTeX Navigator), which use the \ncdiagg macro for connections
with a _negative_ value for the armA parameter, actually doesn't work.
This point concern the `pst-node' package but is mainly useful for the
`pst-tree' one, allowing to align corners of edges for horirontal trees
when leaves have their content centered (see the result of this effect
at the top of the page 42).
Historical reason of this problem is the following (people non interested
by History can skip this paragraph...): PSTricks 97 was built by Sebastian
Rahtz and myself with all the material we had when Timothy van Zandt stop his
work in 1994, that is to say the 0.93a version, the Beta files of 1994
(pst-beta.tex, pst-beta.bug, psn-beta.pro), all of them publicly released
by Timothy in 1993 and 1994, but also some files of the pre-version 0.94,
never publicly diffused by Timothy but which he sent to Sebastian and me
to generate the article of the TUG conference in 1994. Using these three
sources, we tried each time to use the most recent when there were several
rewrittings of the same files. We dit it for everything expect for `pst-tree'
which Timothy would like to largely rewrite for 0.94 version but did it only
at 75 %, so which could not replace the one included in the Beta material.
For nodes, there were three different versions: 0.93a, Beta, pre-0.94, each
time with huge rewrittings. What we integrated in PST 97 come logically from
the last one, which had important changes comparing to the Beta one.
But the special management of negative values for the arms of the connections
only existed in the Beta version, which was used by Timothy to generate the
Beta documentation, and was not integrated in the pre-0.94 version. So, this
is the reason of the discrepancy of the behaviour of \ncdiagg today...
As this is an interesting effect for trees (you could verify that the
misalignment of the corners is rather inesthetic for such trees), I will
restore the old behaviour by a patch in the file pst-node.pro.
Here is my test file:
\documentclass[a4paper]{article}
\usepackage{pst-tree}
\newcommand{\Test}{%
\pstree[treemode=R,levelsep=4]
{\TC*}
{\Tr{aa}
\Tr{bbbb}
\Tr{cccccccccc}
\Tr{d}}
\vspace{3mm}}
\newcommand{\TestsArms}{%
\renewcommand{\psedge}[2]{\ncdiagg{##2}{##1}}
\Test
\hfill
\renewcommand{\psedge}[2]{\ncdiagg[armA=0]{##2}{##1}}
\Test
\renewcommand{\psedge}[2]{\ncdiagg[armA=1]{##2}{##1}}
\Test
\hfill
\renewcommand{\psedge}[2]{\ncdiagg[armA=-1]{##2}{##1}}
\Test
\renewcommand{\psedge}[2]{\ncdiagg[armA=-2]{##2}{##1}}
\Test
\renewcommand{\psedge}[2]{\ncdiag[armA=-1]{##2}{##1}}
\Test
\hfill
\renewcommand{\psedge}[2]{\ncdiag[armB=-1]{##2}{##1}}
\Test
\renewcommand{\psedge}[2]{\ncdiag[armB=-2]{##2}{##1}}
\Test
\hfill
\renewcommand{\psedge}[2]{\ncdiag[arm=-1]{##2}{##1}}
\Test
\renewcommand{\psedge}[2]{\ncdiag[armB=2]{##2}{##1}}
\Test
\hfill
\renewcommand{\psedge}[2]{\ncdiag[arm=1]{##2}{##1}}
\Test
}
\begin{document}
\psset{angleA=180,nodesep=0.1}
\TestsArms
\clearpage
\makeatletter
\pst at def{NCDiagg}<%
% Modification of GetArmA to manage the case of armA < 0
% as in Beta material released in 1994 after the 0.93a version
/GetArmA {
ArmTypeA 0 eq
% D.G. modification begin - Apr. 23, 2001
% { /xA2 ArmA AngleA cos mul xA1 add def
% /yA2 ArmA AngleA sin mul yA1 add def }
{ /xA2 ArmA abs AngleA cos mul
ArmA 0 lt { xA OffsetA AngleA AddOffset} { xA1 } ifelse
add def
/yA2 ArmA abs AngleA sin mul yA1 add def }
% D.G. modification end
{ ArmTypeA 1 eq {{exch}} {{}} ifelse
/Do ED
ArmA AngleA XYPos OffsetA AngleA AddOffset yA add
/yA2 ED
xA add
/xA2 ED} ifelse } def
%
% Modification of GetArmB to manage the case of armB < 0
% as in Beta material released in 1994 after the 0.93a version
/GetArmB {
ArmTypeB 0 eq
% D.G. modification begin - Apr. 23, 2001
% { /xB2 ArmB AngleB cos mul xB1 add def
% /yB2 ArmB AngleB sin mul yB1 add def }
{ /xB2 ArmB abs AngleB cos mul
ArmB 0 lt { xB OffsetB AngleB AddOffset} { xB1 } ifelse
add def
/yB2 ArmB abs AngleB sin mul yB1 add def }
% D.G. modification end
{ ArmTypeB 1 eq {{exch}} {{}} ifelse
/Do ED
ArmB AngleB XYPos OffsetB AngleB AddOffset yB add
/yB2 ED xB add
/xB2 ED} ifelse } def
%
GetEdgeA GetArmA yB yA2 sub xB xA2 sub Atan 180 add
/AngleB ED
GetEdgeB mark xB1 yB1 xA2 yA2 ArmA 0 ne { xA1 yA1 } if
tx at Dict begin false Line end
/LPutVar [ xB1 yB1 xA2 yA2 xA1 yA1 ] cvx def
/LPutPos { LPutLines } def
/HPutPos { HPutLines } def
/VPutPos { VPutLines } def>
\makeatother
\TestsArms
\end{document}
D.G.
More information about the PSTricks
mailing list