PSTricks: what do you think about using [mnode=anArbitraryCommandName]?

Denis Girou Denis.Girou at idris.fr
Tue Jul 29 21:07:16 CEST 1997


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

>>>>> "Christophe.Broult" == Christophe Broult <broult at info.unicaen.fr> writes:

    Christophe.Broult> I have some trouble to draw lines between nodes using my own node
    Christophe.Broult> formats. 

    Christophe.Broult> If I draw some lines between the nodes using a command like the one
    Christophe.Broult> I've inserted in the example above, the lines ends are inside the
    Christophe.Broult> box and not outside the enclosing box. I think it's due to the fact
    Christophe.Broult> the \psshadowbox command is enclosing the \rnodes commands and not the
    Christophe.Broult> reversed.

  Yes, in this case the content of the nodes are only the text so their width
and height is compute ignoring the special box which will be put around later.
So, node connections are not compute correctly.

  A simple solution is to change globally the nodesep parameter before the
psmatrix environment. You must compute it value adding the linewidth (0.8pt by 
default) and the framesep width (3pt by default). It's easy and work well for
simple cases, but is not very satisfaying: you must compute the value by hand,
effect is not perfect (for instance, if you use a shadowed box, there is no
more complete equality between left and right side), you can't use both two
personal node types, etc.

\documentclass{article}

\usepackage{pst-node}

\makeatletter
\newcommand{\mnode at MyNodeType}{%
\psshadowbox[linecolor=red]{\rnode at iii\Rnode at ii{\psm at thenode}}}
\makeatother

\begin{document}

\begin{psmatrix}[mnode=MyNodeType]
  [name=A] AAAA & [name=B] BBBB
\end{psmatrix}
\ncline{A}{B}

\vspace{1cm}
\psset{nodesep=3.8pt}
\begin{psmatrix}[mnode=MyNodeType]
  [name=A] AAAA & [name=B] BBBB
\end{psmatrix}
\ncline{A}{B}

\makeatletter
\renewcommand{\mnode at MyNodeType}{%
\psshadowbox[linecolor=cyan,framesep=1]{\rnode at iii\Rnode at ii{\psm at thenode}}}
\makeatother

\vspace{1cm}
\psset{nodesep=1.03}
\begin{psmatrix}[mnode=MyNodeType]
  [name=A] AAAA & [name=B] BBBB
\end{psmatrix}
\ncline{A}{B}

\end{document}

    Christophe.Broult> I've tried to replace
    Christophe.Broult>    \psshadowbox[linecolor=red]{\rnode at iii\Rnode at ii{\psm at thenode}}}

    Christophe.Broult> with

    Christophe.Broult>    \rnode at iii\Rnode at ii{\psshadowbox[linecolor=red]{\psm at thenode}}}

    Christophe.Broult> but without success.

  Yes, it cannot work this way. I think a generic solution can't be very
simple. I cannot guarantee that there is not an easier one, but here is what
I can propose:

\documentclass{article}

\usepackage[dvips]{pstcol}
\usepackage{pst-node}

\definecolor{Pink}{rgb}{1.,0.75,0.8}

\makeatletter

% To define personal nodes for the psmatrix environment
% Denis Girou <Denis.Girou at idris.fr> - Jul. 29, 1997
\def\MatrixNodeDefinition#1#2{%
% #1=type of node name, #2=macro to apply to the node contents
% Ex: \MatrixNodeDefinition{MyNodeType}{\psframebox[linecolor=red]}
\expandafter\def\csname mnode@#1\endcsname{%
\rnode{NodeTemp}{#2{\rnode at iii\Rnode at ii{\psm at thenode}}}
\unskip%
% Redefinition of temporary name to the "official" ones
% Implicit name node (like for {1,2} which is M-1-1-2)
\SameNode{\psm at thenode}{NodeTemp}%
% Explicit name node (given by the name= parameter)
\ifx\pst at NodeName\relax\else\SameNode{\pst at NodeName}{NodeTemp}\fi}}

% Modification of \psset at name to keep the name of the node in a macro
\let\pst at NodeName\relax
\def\psset at name#1{\edef\pst at NodeName{#1}\pst at getnode{#1}\psk at name}

% To give an alias name to a previous defined one
% Denis Girou <Denis.Girou at idris.fr> - May 15, 1997
% \SameNode{B}{A} define a node B equivalent to the predefined node A
% Useful to special connections for trees and special node types for psmatrix
\def\SameNode#1#2{%
\pst at getnode{#1}\pst at tempa
\pst at getnode@{#2}\pst at tempb
\pst at Verb{\pst at nodedict \pst at tempa \pst at tempb def end}}
% From \pst at getnode, but to return the name of node without the first /
% Definition is different for psmatrix environments and for trees
\def\pst at getnode@#1#2{%
\pst at expandafter\pst@@getnode@{#1},,\@nil#2}
\def\pst@@getnode@#1,#2,#3\@nil#4{%
\ifx\@empty#3\@empty
\edef#4{N@\pst at zapspace#1 \@empty\space}%
\else
\pst at cntg=#1\relax
\pst at cnth=#2\relax
% Node definition for trees
%\edef#4{N at M-\ifnum\psmatrixcnt=\z@ 1\else\the\psmatrixcnt\fi
%-\the\pst at cntg-\the\pst at cnth\space}%
% Node definition for psmatrix environments from \psmatrix at ii
\edef#4{N at M-\the\psmatrixcnt-\the\psrow-\the\pscol}%
\fi}

\makeatother

\begin{document}

\Huge

\begin{psmatrix}
  [name=A] \psshadowbox[framesep=0.5,linecolor=red,shadowcolor=Pink]{AAAA} &
    [name=B] \psshadowbox[framesep=0.5,linecolor=red,shadowcolor=Pink]{BBBBBBBB}
\end{psmatrix}
\ncline{A}{B}

\MatrixNodeDefinition%
{MyNodeTypeA}{\psshadowbox[framesep=0.5,linecolor=red,shadowcolor=Pink]}

\vspace{1cm}
\begin{psmatrix}[mnode=MyNodeTypeA]
  [name=A] AAAA & [name=B] BBBBBBBB
\end{psmatrix}
\ncline{A}{B}

\vspace{1cm}
\begin{psmatrix}[mnode=MyNodeTypeA]
  AAAA & BBBBBBBB
\end{psmatrix}
\ncline{1,1}{1,2}

\MatrixNodeDefinition{MyNodeTypeB}{\psdblframebox[framesep=1,linecolor=green]}

\vspace{2cm}
\begin{psmatrix}[mnode=MyNodeTypeA]
  [name=A] A & [name=B] B                   & [name=C,mnode=MyNodeTypeB] C \\
             & [name=D,mnode=MyNodeTypeB] D & [name=E] E
\end{psmatrix}
\psset{arrows=->}
\nccircle{A}{1.5}
\ncangle[angle=90,armB=0.8]{A}{C}
\ncline{C}{D}
\ncline{D}{E}
\ncbar[angleA=-90,armB=1]{A}{E}

\end{document}

D.G.

-----------------------------------------------------------------------------
To [un]subscribe to this list, send mail to pstricks-request at mail.tug.org
Leave the subject line blank and in the body put the line
[un]subscribe <email-address>
For help, put the word "help" in the message body.
To obtain current archive, put the words "get current" in the message body.
-----------------------------------------------------------------------------



More information about the PSTricks mailing list