summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/metapost/metauml/metauml_paths.mp
blob: cb307f8df001697e0423700fef14317814c8f11c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
% MetaUML, a MetaPost library for typesetting exquisite UML diagrams.
% Copyright (C) 2005 Ovidiu Gheorghies
%
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License
% as published by the Free Software Foundation; either version 2
% of the License, or (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

if known _metauml_paths_mp: 
  expandafter endinput 
fi;
_metauml_paths_mp:=1;

def pathDirect(expr pA,pB) =
  pA--pB
enddef;

vardef pathManhattanX(expr pA,pB) =
  pA--(xpart(pB), ypart(pA))--pB
enddef;

vardef rpathManhattanX(expr pA,pB) =
  pB--(xpart(pB), ypart(pA))--pA
enddef;

vardef pathManhattanY(expr pA,pB) =
  pA--(xpart(pA), ypart(pB))--pB
enddef;

vardef rpathManhattanY(expr pA,pB) =
  pB--(xpart(pA), ypart(pB))--pA
enddef;

vardef pathStepX(expr pA,pB, deltax) =
  pA--(pA+(deltax, 0))--(((xpart pA)+deltax), ypart(pB))--pB
enddef;

vardef rpathStepX(expr pA,pB, deltax) =
  pB--(((xpart pA)+deltax), ypart(pB))--(pA+(deltax, 0))--pA
enddef;

vardef pathStepY(expr pA,pB, deltay) =
  pA--(pA+(0, deltay))--(xpart(pB), ((ypart pA)+deltay))--pB
enddef;

vardef rpathStepY(expr pA,pB, deltay) =
  pB--(xpart(pB), ((ypart pA)+deltay))--(pA+(0, deltay))--pA
enddef;

vardef pathHorizontal(expr pA, untilX) =
  pA--(untilX,ypart(pA))
enddef;

vardef rpathHorizontal(expr pA, untilX) =
  (untilX,ypart(pA))--pA
enddef;

vardef pathVertical(expr pA, untilY) =
  pA--(xpart(pA), untilY)
enddef;

vardef rpathVertical(expr pA, untilY) =
  (xpart(pA), untilY)--pA
enddef;

% Cuts path thePath so that it won't intersect the objects
% objectA and objectB. The border of the objects is obtained
% by invoking the method "_border".
% 
vardef pathCut(suffix objectA, objectB)(expr thePath)=
  save timeA, timeB;
  
  timeA = xpart (thePath intersectiontimes objectBorder(objectA));
  timeB = xpart (thePath intersectiontimes objectBorder(objectB));

  subpath (timeA, timeB) of thePath
enddef;