# naput nbput +180

Denis Girou Denis.Girou at idris.fr
Fri Oct 13 22:31:52 CEST 2000

-----------------------------------------------------------------------------
This is the PSTricks mailing list, devoted to discussions about computational
graphics in (La)TeX using the PSTricks package from Timothy van Zandt.
For help using this mailing list, see instructions at the end of message.
-----------------------------------------------------------------------------

>>>>> "Matthieu.Paindavoine" == MPAINDAV  <MPAINDAV at arinc.com> writes:

Matthieu.Paindavoine> ma question concerne le placement des labels en fonction de l'orientation
Matthieu.Paindavoine> des connections.
Matthieu.Paindavoine> ...
Matthieu.Paindavoine> 2- En fonction de l'angle, operer la transformation:
Matthieu.Paindavoine> naput[nrot=:U]{above} ==> nbput[nrot=:U+180]{above}
Matthieu.Paindavoine> nbput[nrot=:U]{below} ==> naput[nrot=:U+180]{below}

D.G.> ...
D.G.>   But I do not think that there is a simple solution to this question.
D.G.> I am even not sure that there is a complicated one... This is a global
D.G.> ...
D.G.> Nevertheless, there are some simple situations
D.G.> where this can be done easily. You have just to compare in the PostScript
D.G.> InitNC macro the values of the horizontal coordinates and to decide to
D.G.> exchange or not the coordinates of the two nodes according to the result.
D.G.> This solve basic situations, but this is also easy to see that this create
D.G.> immediate side effects when the situation is not symmetric for the two nodes
D.G.> (usage of arrows, parameter values such angleA different than angleB, etc.).

I study again this question this evening.

At the opposite of what I said on Wednesday (sorry...), there is clearly
a better and more powerful (and not very complicated...) solution than
the limited one that I gave at this time.

Nevertheless, I can't guarantee the code... As there are a lot of possible
usage of nodes and node connections, these changes can not work in all
situations, create bad side effects or break some functionalities. You must
test them in your real situations. But, at least, it work on the following
examples:

\documentclass[a4paper]{article}

\usepackage{pst-node}

\setlength{\textwidth}{14cm}
\setlength{\parindent}{-2cm}

\newcommand{\Labels}{%
\naput[nrot=:U]{above}
\ncput[nrot=:U]{on}
\nbput[nrot=:U]{below}}

\newcommand{\Test}{%
\begin{pspicture}(-3,-3)(3,3)\psgrid
\pcline(0,0)(2.5,2.5)\Labels
\pcline(0,0)(-2.5,2.5)\Labels
\pcline{->}(0,0)(-2.5,-2.5)\Labels
\end{pspicture}
\hfill
\begin{pspicture}(7,7)\psgrid
\cnodeput(4,6){A}{A}
\cnodeput(1,2){B}{B}
\cnodeput(6,1){C}{C}
\ncarc[arcangle=30]{A}{C}
\ncput{\pnode{D}}
\ncarc[arcangle=-30]{B}{C}
\ncput{\pnode{E}}
\nccurve[angleA=180]{D}{E}
\ncput{\rnode{F}{F}}
\Labels
\end{pspicture}}

\pagestyle{empty}

\begin{document}

\psset{arrowscale=3,subgriddiv=0,griddots=5}

\Test

\makeatletter

\def\psset@@nrot:#1\@nil{%
\psset@@rot#1\@nil
\edef\psk at rot{%
NAngle \ifx\psk at rot\@empty\else\psk at rot add \fi
% D.G. modification begin - Oct. 13, 2000
tx at NodeDict begin xB xA lt {180 add} if end
% D.G. modification end
}}

\def\naput at i{%
\pst at killglue
\pst at makebox{%
\naput at ii{%
% D.G. modification begin - Oct. 13, 2000
tx at NodeDict begin xB xA lt {NAngle 90 sub} {NAngle 90 add} ifelse end
}}}
% D.G. modification end

\def\nbput at i{%
\pst at killglue
\pst at makebox{%
\naput at ii{%
% D.G. modification begin - Oct. 13, 2000
%NAngle 90 sub
tx at NodeDict begin xB xA lt {NAngle 90 add} {NAngle 90 sub} ifelse end
% D.G. modification end
}}}

\makeatother

\vspace{1cm}
\Test

\end{document}

D.G.

-----------------------------------------------------------------------------