draft of draft of UML package for pstricks

Denis Girou Denis.Girou at idris.fr
Fri Mar 27 18:28:23 CET 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.
-----------------------------------------------------------------------------

>>>>> "Maurice.Diamantini" == Maurice DIAMANTINI <diam at ensta.fr> writes:

    Maurice.Diamantini> In fact, this is not realy a "project", just the wish to try to do some 
    Maurice.Diamantini> schematics (the UML diagramms) with pstricks.

    Maurice.Diamantini> .......................................................
    Maurice.Diamantini> Moreever, I think such a package is far more general than UML,
    Maurice.Diamantini> it could be usefull for any electric  schematic, organigramms
    Maurice.Diamantini> and other diagramms.
  
  Now that `fancyvrb' is released, I'm back to waiting messages...

  First thank for your work and ideas. It is a good starting point, and as you 
say, outside UML (that I will certainly never used myself!) it can be useful
in many more areas.

  As I recently discuss with one of you who use ER-diagrams, there is no
general solution withou usage of an external software. The field of "automatic 
graph layout" is very large but has been studied by a lot of people and there
are many theoritical publications but also powerful software available.
They use high level representation of graphs (defining nodes, connections and
attributes of them) and applied sophisticated layout algorithms to generate
the graphs, optimizing nodes placement, minimizing the number of crossings,
etc. As far as I know, there is no one which generate PSTricks code today,
but this way is praticable.

  A rather complete bibliography (but frozen in 1994) is on:

/anonymous at wilma.cs.brown.edu:/pub/papers/compgeo/gdbiblio.ps.Z


    Maurice.Diamantini> 3 - putting new arrows
    Maurice.Diamantini> ---------------------

    Maurice.Diamantini> Starting from Denis examples on how create new arrow type
    Maurice.Diamantini> for pstricks, I have not yet found a mean to 
    Maurice.Diamantini> create new arrow type without putting postscript in the 
    Maurice.Diamantini> "\psas@<newArrowString>" command (except for the fonte 
    Maurice.Diamantini> caracters), 

    Maurice.Diamantini> \@namedef{psas at arrowName}{### XXXXX ###}

  This point is not very clear for me. We will discuss precisely of it later.

    Maurice.Diamantini> Default options is for putting an icon as an arrow on the start of 
    Maurice.Diamantini> the connector, but one can put it on the middle of a segment if 
    Maurice.Diamantini> one like (this feature is better than an true pstricks arrow).

  It can be done for \nc... types connector as I show for \psline, \psbezier
some months ago, but it is rather heavy and must be done separately for each
type of connection.

  Other points:

    - I don't understand why you use boxes for Classes. Which advantages
comparing to macros as usage is less straightforward?

    - pst-key.sty is on  contrib/misc/pst-key.sty

    - outside manual \rput, psmatrix (tabular) environment and trees, another
possibility is also to implement moves is the "pic" way. Sebastian show an
example in LGC for electrical circuit drawing. Here is a simplify example,
because here requirements are less importants than in his case (objects have
their size, orientation of objects is known). The difference with the manual
\rput approach is that it allow to think by relative moves, which can be
easier. But here, it is just to give the idea!

\documentclass{article}

\usepackage{pst-uml}

\makeatletter

% For debugging (to debug, set PstDebug=1)
\def\psset at PstDebug#1{\pst at getint{#1}\psk at PstDebug}

\setkeys{psset}{PstDebug=0}

% From Maurice Diamantini <diam at ensta.fr> (from the `pst-uml' package)
% --------------------------------------------------------------------

\newsavebox{\Classi}\savebox{\Classi}{%
\umlClass{Classe1}{%
  umlClassWidth = 0 \\
 (par d\'efaut) \\\hline
 Attribut2 Tres tres longue ligne \\ \hline 
 Attribut3 \\ \hline %
 M\'ethode1%
}}

\psset{umlClassWidth=4cm}
\newsavebox{\Classii}\savebox{\Classii}{%
\umlClass{Classe2}{%
 Defaut = 4cm \\ \hline
 Attribut2 \\ \hline %
 M\'ethode1\\
 M\'ethode2%
}}

\newsavebox{\Classiii}\savebox{\Classiii}{%
\umlClass[umlClassWidth=2.7]{Classe3}{%
 Defaut = 4cm \\
 umlClassWidth = 2.7 \\ \hline 
 Methode1 \\
 Methode2}}

% Classe4 doit retrouver la nouvelle valeur par d\'efaut de 4cm
\newsavebox{\Classiv}\savebox{\Classiv}{%
\umlClass{Classe4}{%
 Defaut = 4cm \\
 MonAttribut2 \\ \hline 
 Methode1}}

% Classe5 : largeur automatique et titre seul
\newsavebox{\Classv}\savebox{\Classv}{%
\umlClass[umlClassWidth=0]{Classe5}{}}

% Inspired by an idea of Sebastian Rahtz <s.rahtz at elsevier.co.uk>
% (LGC, example 4-10-10)
% ----------------------------------------------------------

% Direction is: 0 right, 1 left, 2 up, 3 down
\def\Pst at Direction{-1}

% Default position (down left, as PSTricks default)
\def\Pst at PosX{0}
\def\Pst at PosY{0}

% Show position
\def\ShowPosition{%
\typeout{%
\ifcase\Pst at Direction Direction: right, now at
        \or Direction: left, \space now at
        \or Direction: up, \space\space\space now at
        \or Direction: down, \space now at
        \else At
\fi
(\Pst at PosX,\Pst at PosY)}}

% Set position
\def\SetX#1{%
\edef\Pst at PosX{#1}%
\ifnum\psk at PstDebug=\@ne\ShowPosition\fi}

\def\SetY#1{%
\edef\Pst at PosY{#1}
\ifnum\psk at PstDebug=\@ne\ShowPosition\fi}

% Moves
\def\Down#1{%
\edef\Pst at Direction{3}%
\pst at dima=\Pst at PosY pt
\advance\pst at dima by -#1 pt
\pst at dimtonum{\pst at dima}{\Pst@@CurY}
\edef\Pst at PosY{\Pst@@CurY}%
\ifnum\psk at PstDebug=\@ne\ShowPosition\fi}

\def\Up#1{%
\edef\Pst at Direction{2}%
\pst at dima=\Pst at PosY pt
\advance\pst at dima by #1 pt
\pst at dimtonum{\pst at dima}{\Pst@@CurY}
\edef\Pst at PosY{\Pst@@CurY}%
\ifnum\psk at PstDebug=\@ne\ShowPosition\fi}

\def\Left#1{%
\edef\Pst at Direction{1}%
\pst at dima=\Pst at PosX pt
\advance\pst at dima by -#1 pt
\pst at dimtonum{\pst at dima}{\Pst@@CurX}
\edef\Pst at PosX{\Pst@@CurX}%
\ifnum\psk at PstDebug=\@ne\ShowPosition\fi}

\def\Right#1{%
\edef\Pst at Direction{0}%
\pst at dima=\Pst at PosX pt
\advance\pst at dima by #1 pt
\pst at dimtonum{\pst at dima}{\Pst@@CurX}
\edef\Pst at PosX{\Pst@@CurX}%
\ifnum\psk at PstDebug=\@ne\ShowPosition\fi}

% Put an object at current coordinates and assign a node of specified name to it
\def\NodePut{%
\@ifnextchar[\@NodePut{\@NodePut[]}}
\def\@NodePut[#1]#2#3{{%
\setkeys{psset}{#1}%
\rput(\Pst at PosX,\Pst at PosY){\rnode{#2}{#3}}}}

\makeatother

\textheight=25cm
\topmargin=-3cm

\pagestyle{empty}

\begin{document}

\psset{PstDebug=1}

\psframebox[framesep=0]{%
\begin{pspicture}(-2.7,-1)(11,8.8)
  \SetY{7.5}
  \NodePut{Class1}{\usebox{\Classi}}
  \Right{6}
  \NodePut{Actor1}{\umlActor{Actor 1}}
  \Right{3}
  \Down{3.5}
  \NodePut{Class2}{\usebox{\Classii}}
  \Left{7}
  \Down{4}
  \NodePut{Class4}{\usebox{\Classiv}}
  % Connections
  \psset{arrows=->,arrowscale=2}
  \ncline{Class1}{Actor1}
  \ncSE{Class1}{Class2}
  \ncSHS{Class2}{Class4}\naput{ncSHS}
\end{pspicture}
}

\psframebox[framesep=0]{%
\begin{pspicture}(-0.7,-0.7)(9,6.3)
  \SetY{1}
  \NodePut{Actor1}{\umlActor{Actor 1}}
  \Up{4}
  \Right{3}
  \NodePut{Actor2}{\umlActor[linecolor=red]{Actor 2}}
  \Right{5}
  \NodePut{Actor3}{\umlActor[xunit=2,yunit=0.7,linecolor=green]{Actor 3}}
  \Left{2}
  \Down{4}
  \NodePut{Actor4}{\umlActor[yunit=1.5,linecolor=cyan]{Actor 4}}
  % Connections
  \psset{arrows=->,arrowscale=2}
  \ncNHN{Actor1}{Actor2}
  \ncline{Actor2}{Actor3}
  \ncSXE[arm=1]{Actor3}{Actor4}
\end{pspicture}
}

\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