[pst-tree] Framing parts of a tree

Denis Girou Denis.Girou at idris.fr
Wed Sep 30 23:35:50 CEST 1998


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

  To frame subtrees, I give here last week a solution based on a modification
of the effect of the showbbox parameter. This solution seems rather powerful
but is a pure hack and has the inconvenience to require to reset carefully 
showbbox to false in various places.

  But today I have a clean and standard solution to frame subtrees, based on
two new macros \pstreeframe and \pstreecurve, which accept the various framing 
parameters.

  For that, I study again the Beta 0.94 version of `pst-tree' that Timothy
never released. In fact, Sebastian and me introduced the main part of this
Beta version in PSTricks 97 when there was something new comparing to the old
`pst-beta' material, but we did not do it for the tree macros. Timothy began
in 1994 to rewrite all the code of `pst-tree', in a largely new way and with
complete changes in the internal macros. Unfortunately he stopped in the
middle of the road and this version is impossible to use (many problems,
incompatibilities with the external interface of the 0.93 version,
etc.) And he introduce also at this time new ideas and new functionnalities.

  Specially, he introduce a new part to allow framing of subtrees. After a
long work, I succeed to have the 2/3 of it working with the current `pst-tree'
version, changing all the required internals and solving a lot of problems.

  I put these macros on a pst-trex.file (temporarily on
http://www.tug.org/applications/PSTricks/Temporary/pst-trex.tex )
- "x" for eXtensions.

  I give here my test file. As I understand now nearly all this code, you can
report problems if you found some.

D.G.

\documentclass{article}

\usepackage{pstcol}
\usepackage{pst-tree}
\input{pst-trex}                % Extensions to `pst-tree'

\pagestyle{empty}

\setlength{\parindent}{0pt}
\setlength{\oddsidemargin}{0cm}
\setlength{\evensidemargin}{0cm}
\setlength{\textwidth}{19cm}

\begin{document}

\psset{radius=0.3}

\pstreeframe{\pstree{\TC}{\TC}}
\hspace{1cm}
\pstreeframe[framesep=0]{\pstree{\TC}{\TC}}
\hspace{1cm}
\pstreecurve{\pstree{\TC}{\TC}}
\hspace{1cm}
\pstreecurve[framesep=0]{\pstree{\TC}{\TC}}
\hspace{1cm}
\pstreecurve[framesep=-0.1]{\pstree{\TC}{\TC}}
\hspace{1cm}
\pstreecurve[showpoints=true,dotsize=0.3]{\pstree{\TC}{\TC \TC}}
\hspace{1cm}
\pstreecurve{\pstree{\TC}{\TC \TC \TC}}

\vspace{2cm}
\pstree[treemode=L]{\TC}{\pstree{\TC}{\TC*}}
\hspace{1cm}
\pstree[treemode=L]{\TC}{\pstreeframe{\pstree{\TC}{\TC*}}}
\hspace{1cm}
\pstree[treemode=L]{\TC}{\pstreecurve{\pstree{\TC}{\TC*}}}

\vspace{1cm}
\pstree[treemode=R]{\TC}{\pstree{\TC}{\TC*}}
\hspace{1cm}
\pstree[treemode=R]{\TC}{\pstreeframe{\pstree{\TC}{\TC*}}}
\hspace{1cm}
\pstree[treemode=R]{\TC}{\pstreecurve{\pstree{\TC}{\TC*}}}

\vspace{1cm}
\pstree[treemode=U]{\TC}{\pstree{\TC}{\TC*}}
\hspace{1cm}
\pstree[treemode=U]{\TC}{\pstreeframe{\pstree{\TC}{\TC*}}}
\hspace{1cm}
\pstree[treemode=U]{\TC}{\pstreecurve{\pstree{\TC}{\TC*}}}
\hspace{1cm}
\pstree[treemode=D]{\TC}{\pstree{\TC}{\TC*}}
\hspace{1cm}
\pstree[treemode=D]{\TC}{\pstreeframe{\pstree{\TC}{\TC*}}}
\hspace{1cm}
\pstree[treemode=D]{\TC}{\pstreecurve{\pstree{\TC}{\TC*}}}

\vspace{1cm}
{\psset{framesep=0}
\pstreeframe[linecolor=green]{%
  \pstree[treemode=L]{\TC}
         {\TC
          \pstreeframe{%
            \pstree{\TC}
                   {\TC \TC
                    \pstreeframe[linecolor=red]{%
                      \pstree{\TC}
                             {\TC \TC \TC \TC}}}}}}
}
\hspace{1cm}
\pstreeframe[linecolor=green]{%
  \pstree{\TC}
         {\TC
          \pstreecurve[framesep=0]{%
            \pstree[treemode=R]{\TC}
                   {\TC \TC
                    \pstreeframe[linecolor=red]{%
                      \pstree{\TC}
                             {\TC \TC \TC \TC}}}}}}

\vspace{1cm}
\pstreecurve[linecolor=green]{%
  \pstree{\TC}
         {\TC
          \pstreecurve[linewidth=1mm,linestyle=dashed]{%
            \pstree{\TC}
                   {\TC \TC
                    \pstreecurve[linecolor=red,linestyle=dotted]{%
                      \pstree{\TC}
                             {\TC \TC \TC \TC}}}}}}
\hspace{1cm}
\pstreecurve[linecolor=green,curvature=0.3 0.1 0]{%
  \pstree[treemode=R]{\TC}
         {\TC
          \pstreecurve[curvature=0 0.1 0]{%
            \pstree{\TC}
                   {\TC \TC
                    \pstreecurve[linecolor=red,curvature=1 0.1 -1]{%
                      \pstree{\TC}
                             {\TC \TC \TC \TC}}}}}}

\vspace{1cm}
{\psset{framesep=0}
\pstreeframe*[linecolor=green]{%
  \pstree[thistreesep=2]{\TC}
         {\TC
          \pstreeframe*[linecolor=yellow]{%
            \pstree{\TC}
                   {\TC
                    \pstreeframe*[linecolor=red]{%
                      \pstree{\TC}
                             {\TC \TC}}}}}}
\hspace{1cm}
\pstreecurve*[linecolor=green]{%
  \pstree{\TC}
         {\TC
          \pstreecurve*[linecolor=yellow]{%
            \pstree{\TC}
                   {\TC \TC
                    \pstreecurve*[linecolor=red]{%
                      \pstree{\TC}
                             {\TC \TC \TC \TC}}}}}}
}

\vspace{2cm}
\pstreeframe[linecolor=green]{%
  \pstree[treefit=loose]{\TC}
         {\TC
          \pstreeframe{%
            \pstree{\TC}
                   {\TC \TC
                    \pstreeframe[linecolor=red]{%
                      \pstree{\TC}
                             {\TC \TC \TC \TC}}}}}}
\hspace{1cm}
\pstreecurve[linecolor=green]{%
  \begin{psTree}{\TC}
     \TC
     \pstreecurve[framesep=0,linewidth=1mm]{%
       \begin{psTree}{\TC}
         \TC \TC
         \pstreecurve[linecolor=red]{%
           \begin{psTree}{\TC}
             \TC \TC \TC \TC
           \end{psTree}}
       \end{psTree}}
  \end{psTree}}

\pstreeframe[linecolor=green]{%
  \pstree[levelsep=1]{\TC}
         {\skiplevel{\TC}
          \pstree{\TC}
                 {\TC
                  \begin{skiplevels}{2}
                    \pstreeframe{%
                      \pstree{\TC}
                             {\TC \TC}}
                      \TC
                  \end{skiplevels}
                  \pstree{\TC}
                         {\TC \TC}}}}

\vspace{1cm}
\pstreeframe[linecolor=green]{%
  \pstree[treemode=L,levelsep=1]{\TC}
         {\skiplevel{\TC}
          \pstreeframe[linecolor=red]{%
            \pstree{\TC}
                   {\TC
                    \begin{skiplevels}{2}
                      \pstreeframe{%
                        \pstree{\TC}
                               {\TC \TC}}
                        \TC
                    \end{skiplevels}
                    \pstree{\TC}
                           {\TC \TC}}}}}
\hspace{1cm}
\pstreeframe[linecolor=green]{%
  \pstree[treemode=R,levelsep=1]{\TC}
         {\skiplevel{\TC}
          \pstreeframe[linecolor=red]{%
            \pstree{\TC}
                   {\TC
                    \begin{skiplevels}{2}
                      \pstreecurve[framesep=0]{%
                        \pstree{\TC}
                              {\TC \TC}}
                        \TC
                    \end{skiplevels}
                    \pstree{\TC}
                           {\TC \TC}}}}}

\definecolor{LemonChiffon}{rgb}{1.,0.98,0.8}
\definecolor{PaleGreen}   {rgb}{0.88,1,0.88}
\definecolor{Pink}        {rgb}{1.,0.75,0.8}
\definecolor{Thistle}     {rgb}{0.85,0.75,0.85}

\renewcommand{\psedge}[2]{\ncangle[angleA=90,angleB=-90]{#2}{#1}}
\newcommand{\Node}[2]{\Tr{\psshadowbox[fillstyle=solid,#1]{#2}}}
%
\psset{levelsep=4,armB=1.5}
%
\rotateleft{%
  \pstreeframe[framesep=0.8,framearc=0.2]{%
    \footnotesize
    \pstree{\Node{fillcolor=white}{\LARGE Tree}}
           {\pstreeframe[framesep=0.3,framearc=0.4]{%
              \pstree{\Node{fillcolor=Thistle}{AAAAAAA}}
                     {\Node{fillcolor=Thistle}{AAAA}
                      \Node{fillcolor=Thistle}{AA}}}
            \pstreeframe[framesep=0.3,fillstyle=solid,fillcolor=yellow]{%
              \pstree{\Node{fillcolor=LemonChiffon}{BBB}}
                     {\Node{fillcolor=LemonChiffon}{BBBB}
                      \Node{fillcolor=LemonChiffon}{BBBBBBB}
                      \pstree{\Node{fillcolor=LemonChiffon}{BBB}}
                             {\Node{fillcolor=LemonChiffon}{BBBB}
                              \Node{fillcolor=LemonChiffon}{B}
                              \Node{fillcolor=LemonChiffon}{BBB}}
                      \Node{fillcolor=LemonChiffon}{BBB}}}
            \pstreeframe[framesep=0.3,framearc=0.3,linecolor=red,
                         doubleline=true]{%
              \pstree{\Node{fillcolor=Pink}{CCCC}}
                     {\Node{fillcolor=Pink}{CC}
                      \Node{fillcolor=Pink}{C}
                      \Node{fillcolor=Pink}{CCCCC}
                      \Node{fillcolor=Pink}{CCC}}}}}}

\end{document}

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