naput nbput +180

Denis Girou Denis.Girou at idris.fr
Wed Oct 11 20:38:48 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> Le probleme que je rencontre est le suivant: Si l'orientation d'une
    Matthieu.Paindavoine> connection entre deux noeuds est dans le cadre 90-270 degres, tout ce que je
    Matthieu.Paindavoine> mets avec naput et nbput "a les jambes en l'air". 
    Matthieu.Paindavoine> Je souhaiterais savoir s'il est possible de 
    Matthieu.Paindavoine> 1- Determiner l'angle de naput et nbput (avec nrot=:U)
    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}

    Matthieu.Paindavoine> Existe t il une fonction qui permette de realiser cette operation?

[
  The question was about the orientation of the labels in the two quadrants
for an angle of 90-270 degrees. This can be easily shown on a simple example:

\documentclass[a4paper]{article}

\usepackage{pst-node}

\begin{document}

\begin{pspicture}(-3,-3)(3,3)\psgrid[subgriddiv=0,griddots=5]
  \pcline(0,0)(2.5,2.5)\naput[nrot=:U]{above}\nbput[nrot=:U]{below}
  \pcline(0,0)(-2.5,2.5)\naput[nrot=:U]{above}\nbput[nrot=:U]{below}
  \pcline(0,0)(-2.5,-2.5)\naput[nrot=:U]{above}\nbput[nrot=:U]{below}
\end{pspicture}

\end{document}

  This is the expected behaviour, but it can be called no user-friendly as
some labels are not in the "natural" orientation to read them easily.
And the question was about a method to automatically reverse the orientation
of the labels when they are not in the "natural" one.
]

  As this question is of general interest, I follow my answer on the list.

    Matthieu.Paindavoine> 	naput[nrot=:U]{above} ==> nbput[nrot=:U+180]{above}
    Matthieu.Paindavoine> 	nbput[nrot=:U]{below} ==> naput[nrot=:U+180]{below}

  First, a minor remark: if you make the change by hand, simply use in this
case:
        \naput[nrot=:U]{above} ==> \nbput[nrot=:D]{above}
        \nbput[nrot=:U]{below} ==> \naput[nrot=:D]{below}

  But I do not think that there is a simple solution to this question.
I am even not sure that there is a complicated one... This is a global
limitation of PSTricks: you can transfer "informations" (in the general
meaning) from TeX to PostScript, but obviously you can't transfer any result
from PostScript to TeX, as such result will be only known when the PostScript
interpreter will execute the code, after the end of the compilation (as the
VTeX/GeX system include all the part of a PostScript interpreter needed by
PSTricks, it can probably handle such situations, but this is a special case
with in any case no portable code).

  As nodes can be defined in various ways, and for instance as an operation
on other nodes previously defined, you can't know their coordinates in the TeX
code, so you can't automatically decide in it if you must execute
\naput[nrot=:U] or \nbput[nrot=:D]. And deciding in the PostScript code that
you must not execute the code itself but another one is far more complex in
such cases...

  So, in the general case, I think that you must do the changes by hand after
seeing the original result. Nevertheless, there are some simple situations
where this can be done easily. You have just to compare in the PostScript
InitNC macro the values of the horizontal coordinates and to decide to
exchange or not the coordinates of the two nodes according to the result.
This solve basic situations, but this is also easy to see that this create
immediate side effects when the situation is not symmetric for the two nodes
(usage of arrows, parameter values such angleA different than angleB, etc.).


\documentclass[a4paper]{article}

\usepackage{pst-node}

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

\newcommand{\Test}{%
\begin{pspicture}(-3,-3)(3,3)\psgrid
  \pcline(0,0)(2.5,2.5)\naput[nrot=:U]{above}\nbput[nrot=:U]{below}
  \pcline(0,0)(-2.5,2.5)\naput[nrot=:U]{above}\nbput[nrot=:U]{below}
  \pcline{->}(0,0)(-2.5,-2.5)\naput[nrot=:U]{above}\nbput[nrot=:U]{below}
\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}}
  \naput[nrot=:U]{above}\nbput[nrot=:U]{below}
\end{pspicture}}

\pagestyle{empty}

\begin{document}

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

\Test

\makeatletter

\pst at def{InitNC}<{%
/b ED
/a ED
/NodeSepTypeB ED
/NodeSepTypeA ED
/NodeSepB ED
/NodeSepA ED
/OffsetB ED
/OffsetA ED
tx at NodeDict a known
tx at NodeDict b known
and dup {/NodeA a load def
         /NodeB b load def
         NodeA GetCenter
         /yA ED
         /xA ED
         NodeB GetCenter
         /yB ED
         /xB ED
% D.G. modification begin - Oct. 11, 2000
         xB xA lt {/xATemp xA     def /yATemp yA     def
                   /xA     xB     def /yA     yB     def
                   /xB     xATemp def /yB     yATemp def} if
% D.G. modification end
         } if}>

\makeatother

\vspace{1cm}
\Test

\end{document}


D.G.

-----------------------------------------------------------------------------
The list interface (subscription, information, access to the archives) is on:
http://www.tug.org/cgi-bin/lwgate/pstricks
Otherway to unsubscribe, send mail to pstricks-request at mail.tug.org
with a blank subject and in body the line unsubscribe <email-address>
-----------------------------------------------------------------------------



More information about the PSTricks mailing list