node connectors

Denis Girou Denis.Girou at idris.fr
Sat May 8 22:26:27 CEST 1999


-----------------------------------------------------------------------------
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.
-----------------------------------------------------------------------------

>>>>> "Jason.Levy" == J Levy <jlevy at zeus.UWaterloo.ca> writes:

    Jason.Levy> Is there any way to prevent the node connectors
    Jason.Levy> (ncdiagg, ncangle, etc...)
    Jason.Levy> from appearing on TOP of the text in my node?

    Jason.Levy> ie. I would like to move the node connector to the 
    Jason.Levy> background so it doesn't block out what I'm writing
    Jason.Levy> in my node.

  Jason Levy send me today an example to illustrate the problem he has,
and this time I could clearly understand what he said.

  Unfortunately, it was a "good" question, that is too say a "bad" one,
with clearly no direct and really satisfactory answer. I can only think to an
indirect solution, using a side effect. It is totally outside the scope and
the power of PSTricks to be aware of the characteristics and the positions of
all the objects of a drawing, and to react according to them to draw
connections. Generally speaking, it is a common and difficult problem, which
has a lot of research works (for instance for representation of graphs,
to minimize the number of crosses in connections of numberous vertices).

  For the general case, the only hope is to have a program in a high level
language with special algorithms to manage this problem, and to generate the
PSTricks code by this program accordingly. Such applications already exist
(look for instance to Angela! and FSA - I put the Web links on the PSTricks
main page some months ago), but I have not check what they do in this area.

  Nevertheless, and even if specialized tools can offer a more general and
powerful solution, if you have only cases of a limited size, you can be enough
happy with an indirect solution, using a side effect (one of the most general:
doing two times the same thing, but the second one with a side effect).

  The original code send by Jason Levy was (with very minor changes from me),
which clearly show the problem:

\documentclass{article}

\usepackage{pstcol,pst-node}

\pagestyle{empty}

\begin{document}

\begin{pspicture}(15,5)

\rput(3.7,3.8){\psframe(0,-0.4)(2.7,0.4)}
\rput(5.05,3.8){good}
\rput(6.4,3.8){\pnode{A}}

\rput(7.5,2.7){\psframe(0,-0.4)(2.7,0.4)}
\rput(8.9,2.7){bad}
\rput(10.2,2.7){\pnode{B}}

\rput(12.5,1){\pnode{C}}
\rput(12.5,1){\psframe(0,-0.4)(2.7,0.4)}
\rput(13.8,1){nice}

\ncline{A}{C}
\ncline{B}{C}

\end{pspicture}

\end{document}

  But the following code do the same and mask the ugly part of the crossed
line:

\documentclass{article}

\usepackage{pstcol,pst-node}

\pagestyle{empty}

\newcommand{\FrameBox}[1]{%
\psframebox[framesep=0.2,fillstyle=solid,fillcolor=white]{\makebox[2.5\psxunit]{#1}}}

\newcommand{\Nodes}{%
\rput(5,-5){%
  \begin{psmatrix}
    [name=Good,href=1]\FrameBox{good} \\
      & [name=Bad,href=1]\FrameBox{bad} \\
      &   & [name=Nice,href=-1]\FrameBox{nice}
  \end{psmatrix}}}

\begin{document}

\Nodes
% Node connections
\ncline{Good}{Nice}
\ncline{Bad}{Nice}
% To erase the unwanted parts of line connections...
\Nodes

\end{document}

  The idea is easy to understand.

  P.S. In any case, always try to avoid to put explicit coordinates for each
element of your drawing: if there are more than few elements, it become very 
difficult to read, to maintain and nearly impossible to adapt later to other
circumstances. Nevertheless, I see such things very often (sometimes one or two
full pages of code lines, each beginning with \rput(.,.){...}). As far as you
can, use high level constructions as the "psmatrix" environment (which is very
powerful), use your own macros as \FrameBox here to build your own internal
elements as logical objects, etc.

      Even if, for a certain reason, you have cases where you can't use
confortably the "psmatrix" environment, at least define your own objects,
as for instance:

\documentclass{article}

\usepackage{pstcol,pst-node}

\pagestyle{empty}

\newcommand{\FrameBoxNode}[3]{%
\Rnode[href=#3]{#1}{%
\psframebox[framesep=0.2,fillstyle=solid,fillcolor=white]{\makebox[2.5\psxunit]{#2}}}}

\newcommand{\Nodes}{%
\rput(3.7,3.6){\FrameBoxNode{A}{good}{1}}
\rput(7.5,2.5){\FrameBoxNode{B}{bad}{1}}
\rput(12.5,1){\FrameBoxNode{C}{nice}{-1}}}

\begin{document}

\begin{pspicture}(15,5)
\Nodes
% Node connections
\ncline{A}{C}
\ncline{B}{C}
% To erase the unwanted parts of line connections...
\Nodes
\end{pspicture}

\end{document}

  P.P.S. Such questions, not obvious and of general interest, would have
a good place in a PSTricks FAQ, if ever some day a courageous person would
like to build one... (not me!)

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