PSTricks: user defined and predefined nodes behave differently

Christophe Broult broult at info.unicaen.fr
Wed Jul 30 16:33:14 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.
-----------------------------------------------------------------------------


Hi,

First of all PSTricks is a great package and I'd like to say ``thank
you'' to this package creators and contributors and in particular to
Denis Girou for his answers to my questions.

Here's another question.

When I define new node types using the macro \MatrixNodeDefinition,
and if I put some connecting commands like \ncline inside the
\psmatrix, the result is incorrect. The following example shows the
problem.

\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

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

\newcommand{\example}[1]{%
  \vspace{1cm}
  \begin{psmatrix}[mnode=#1]  
    [name=A] AAAA\\[0pt]
    [name=B] BBBBBBBB
  \end{psmatrix}
  \ncline{A}{B}                    % OUTSIDE psmatrix environment
  \vspace{1cm}
  \begin{psmatrix}[mnode=#1]  
    [name=A] AAAA\\[0pt]
    [name=B] BBBBBBBB
    \ncline{A}{B}                  % INSIDE psmatrix environment
  \end{psmatrix}
  \par}

\example{MyNodeTypeA}
\example{circle}

\end{document}

Thank you for your help,

Chris

-- 

////////////////////////////////////////////////////////////////////////
//                    Christophe Broult
//
// CNET Caen DSV/APM             | GREYC - CNRS-UPRESA 6072
// Centre National d'Etude des   | Groupe de Recherche en Informatique,
// des Telecom                   | Image, Instrumentation de Caen
// 42, rue des Coutures          | Universite Caen
// BP 6243                       | Esplanade de la Paix
// 14066 Caen cedex              | 14032 Caen Cedex
// Voice: 02 31 75 93 38         | Voice: 02 31 56 59 43
// Fax:   02 31 75 09 44         | Fax:   02 31 56 58 14
////////////////////////////////////////////////////////////////////////

     "C makes it easy to shoot yourself in the foot.  C++ makes it
      harder, but when you do, it blows away your whole leg."

                               -- Bjarne Stroustrup on C++


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